Lines Matching refs:w
68 def aes_add_round_key(state, w): argument
70 state[i] ^= w[i]
75 def aes_sb_sr_mc_ark(state, w, w_idx, temp): argument
82 temp[temp_idx] = aes_gf8_mul_2(x0) ^ aes_gf8_mul_3(x1) ^ x2 ^ x3 ^ w[w_idx]
83 temp[temp_idx + 1] = x0 ^ aes_gf8_mul_2(x1) ^ aes_gf8_mul_3(x2) ^ x3 ^ w[w_idx + 1]
84 temp[temp_idx + 2] = x0 ^ x1 ^ aes_gf8_mul_2(x2) ^ aes_gf8_mul_3(x3) ^ w[w_idx + 2]
85 temp[temp_idx + 3] = aes_gf8_mul_3(x0) ^ x1 ^ x2 ^ aes_gf8_mul_2(x3) ^ w[w_idx + 3]
94 def aes_sb_sr_ark(state, w, w_idx, temp): argument
101 temp[temp_idx] = x0 ^ w[w_idx]
102 temp[temp_idx + 1] = x1 ^ w[w_idx + 1]
103 temp[temp_idx + 2] = x2 ^ w[w_idx + 2]
104 temp[temp_idx + 3] = x3 ^ w[w_idx + 3]
113 def aes_state(state, w, temp, nr): argument
114 aes_add_round_key(state, w)
117 aes_sb_sr_mc_ark(state, w, w_idx, temp)
119 aes_sb_sr_ark(state, w, w_idx, temp)
124 def aes_key_expansion(key, w, temp, nk, nr): argument
126 w[i] = key[i]
132 t[0] = aes_s_box(w[w_idx + 1]) ^ aes_r_con(i // nk)
134 t[j] = aes_s_box(w[w_idx + (j + 1) % 4])
137 t[j] = aes_s_box(w[w_idx + j])
139 t = w
143 w[w_idx + j] = w[w_idx + j - 4 * nk] ^ t[t_idx + j]
164 self.w = bytearray(16 * (self.nr + 1))
169 aes_key_expansion(key, self.w, self.temp, self.nk, self.nr)
179 aes_state(self.state, self.w, self.temp, self.nr)