⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig-8-9.c

📁 计算机网络第四版的实现源代码
💻 C
字号:
#define LENGTH 16			/* # bytes in data block or key */#define NROWS 4				/* number of rows in state */#define NCOLS 4				/* number of columns in state */#define ROUNDS 10			/* number of iterations */typedef unsigned char byte;		/* unsigned 8-bit integer */rijndael(byte plaintext[LENGTH], byte ciphertext[LENGTH], byte key[LENGTH]){  int r;				/* loop index */  byte state[NROWS][NCOLS];		/* current state */  struct {byte k[NROWS][NCOLS];} rk[ROUNDS + 1];	/* round keys */  expand_key(key, rk);	/* construct the round keys */  copy_plaintext_to_state(state, plaintext);	/* init current state */  xor_roundkey_into_state(state, rk[0]);	/* XOR key into state */  for (r = 1; r <= ROUNDS; r++) {        substitute(state);			/* apply S-box to each byte */        rotate_rows(state);			/* rotate row i by i bytes */        if (r < ROUNDS) mix_columns(state);	/* mix function */        xor_roundkey_into_state(state, rk[r]);	/* XOR key into state */  }  copy_state_to_ciphertext(ciphertext, state);	/* return result */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -