Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\crypto\aes.c Create Date:2022-07-28 06:43:55
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:aes_expandkey - Expands the AES key as described in FIPS-197*@ctx: The location where the computed key will be stored.*@in_key: The supplied key.*@key_len: The length of the supplied key.* Returns 0 on success

Proto:int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key, unsigned int key_len)

Type:int

Parameter:

TypeParameterName
struct crypto_aes_ctx *ctx
const u8 *in_key
unsigned intkey_len
188  kwords = key_len / sizeof(u32)
192  err = validate key length for AES algorithms
193  If err Then Return err
196  key_length = key_len
198  When i < kwords cycle key_enc[i] = get_unaligned_le32(in_key + i * sizeof(u32))
201  When i < 10 cycle
202  rki = key_enc + i * kwords
203  rko = rki + kwords
205  rko[0] = r32 - rotate a 32-bit value right*@word: value to rotate*@shift: bits to roll ^ rc ^ rki[0]
206  rko[1] = rko[0] ^ rki[1]
207  rko[2] = rko[1] ^ rki[2]
208  rko[3] = rko[2] ^ rki[3]
210  If key_len == AES_KEYSIZE_192 Then
211  If i >= 7 Then Break
213  rko[4] = rko[3] ^ rki[4]
214  rko[5] = rko[4] ^ rki[5]
215  Else if key_len == AES_KEYSIZE_256 Then
216  If i >= 6 Then Break
218  rko[4] = subw(rko[3]) ^ rki[4]
219  rko[5] = rko[4] ^ rki[5]
220  rko[6] = rko[5] ^ rki[6]
221  rko[7] = rko[6] ^ rki[7]
231  key_dec[0] = key_enc[key_len + 24]
232  key_dec[1] = key_enc[key_len + 25]
233  key_dec[2] = key_enc[key_len + 26]
234  key_dec[3] = key_enc[key_len + 27]
236  When j > 0 cycle
237  key_dec[i] = inv_mix_columns(key_enc[j])
238  key_dec[i + 1] = inv_mix_columns(key_enc[j + 1])
239  key_dec[i + 2] = inv_mix_columns(key_enc[j + 2])
240  key_dec[i + 3] = inv_mix_columns(key_enc[j + 3])
243  key_dec[i] = key_enc[0]
244  key_dec[i + 1] = key_enc[1]
245  key_dec[i + 2] = key_enc[2]
246  key_dec[i + 3] = key_enc[3]
248  Return 0