Lines Matching +full:2 +full:x
72 static inline u32 sm4_t_non_lin_sub(u32 x) in sm4_t_non_lin_sub() argument
76 out = (u32)sbox[x & 0xff]; in sm4_t_non_lin_sub()
77 out |= (u32)sbox[(x >> 8) & 0xff] << 8; in sm4_t_non_lin_sub()
78 out |= (u32)sbox[(x >> 16) & 0xff] << 16; in sm4_t_non_lin_sub()
79 out |= (u32)sbox[(x >> 24) & 0xff] << 24; in sm4_t_non_lin_sub()
84 static inline u32 sm4_key_lin_sub(u32 x) in sm4_key_lin_sub() argument
86 return x ^ rol32(x, 13) ^ rol32(x, 23); in sm4_key_lin_sub()
89 static inline u32 sm4_enc_lin_sub(u32 x) in sm4_enc_lin_sub() argument
91 return x ^ rol32(x, 2) ^ rol32(x, 10) ^ rol32(x, 18) ^ rol32(x, 24); in sm4_enc_lin_sub()
94 static inline u32 sm4_key_sub(u32 x) in sm4_key_sub() argument
96 return sm4_key_lin_sub(sm4_t_non_lin_sub(x)); in sm4_key_sub()
99 static inline u32 sm4_enc_sub(u32 x) in sm4_enc_sub() argument
101 return sm4_enc_lin_sub(sm4_t_non_lin_sub(x)); in sm4_enc_sub()
131 rk[2] = get_unaligned_be32(&key[2]) ^ fk[2]; in sm4_expandkey()
135 rk[0] ^= sm4_key_sub(rk[1] ^ rk[2] ^ rk[3] ^ ck[i + 0]); in sm4_expandkey()
136 rk[1] ^= sm4_key_sub(rk[2] ^ rk[3] ^ rk[0] ^ ck[i + 1]); in sm4_expandkey()
137 rk[2] ^= sm4_key_sub(rk[3] ^ rk[0] ^ rk[1] ^ ck[i + 2]); in sm4_expandkey()
138 rk[3] ^= sm4_key_sub(rk[0] ^ rk[1] ^ rk[2] ^ ck[i + 3]); in sm4_expandkey()
142 ctx->rkey_enc[i + 2] = rk[2]; in sm4_expandkey()
146 ctx->rkey_dec[31 - 2 - i] = rk[2]; in sm4_expandkey()
162 u32 x[4], i; in sm4_crypt_block() local
164 x[0] = get_unaligned_be32(in + 0 * 4); in sm4_crypt_block()
165 x[1] = get_unaligned_be32(in + 1 * 4); in sm4_crypt_block()
166 x[2] = get_unaligned_be32(in + 2 * 4); in sm4_crypt_block()
167 x[3] = get_unaligned_be32(in + 3 * 4); in sm4_crypt_block()
170 x[0] = sm4_round(x[0], x[1], x[2], x[3], rk[i + 0]); in sm4_crypt_block()
171 x[1] = sm4_round(x[1], x[2], x[3], x[0], rk[i + 1]); in sm4_crypt_block()
172 x[2] = sm4_round(x[2], x[3], x[0], x[1], rk[i + 2]); in sm4_crypt_block()
173 x[3] = sm4_round(x[3], x[0], x[1], x[2], rk[i + 3]); in sm4_crypt_block()
176 put_unaligned_be32(x[3 - 0], out + 0 * 4); in sm4_crypt_block()
177 put_unaligned_be32(x[3 - 1], out + 1 * 4); in sm4_crypt_block()
178 put_unaligned_be32(x[3 - 2], out + 2 * 4); in sm4_crypt_block()
179 put_unaligned_be32(x[3 - 3], out + 3 * 4); in sm4_crypt_block()