diff options
author | Андрей Мозжухин <amozzhuhin@yandex.ru> | 2018-01-03 15:43:56 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-01-29 12:50:13 -0500 |
commit | af09eba64f808946c6c901436e7dfabd17a11498 (patch) | |
tree | 69ae8dbb79cbea7643ff143d57de39a1f7046d95 /arch/arm/mach-tegra | |
parent | 1414e09b4f25f2ad5886f124024e10878feb75f0 (diff) | |
download | u-boot-af09eba64f808946c6c901436e7dfabd17a11498.tar.gz |
aes: Allow non-zero initialization vector
AES encryption in CBC mode, in most cases, must be used with random
initialization vector. Using the same key and initialization vector several
times is weak and must be avoided.
Added iv parameter to the aes_cbc_encrypt_blocks and aes_cbc_decrypt_blocks
functions for passing initialization vector.
Command 'aes' now also require the initialization vector parameter.
Signed-off-by: Andrey Mozzhuhin <amozzhuhin@yandex.ru>
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r-- | arch/arm/mach-tegra/tegra20/crypto.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/arm/mach-tegra/tegra20/crypto.c b/arch/arm/mach-tegra/tegra20/crypto.c index eae79217d4..58d6662f6d 100644 --- a/arch/arm/mach-tegra/tegra20/crypto.c +++ b/arch/arm/mach-tegra/tegra20/crypto.c @@ -50,6 +50,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst, u32 num_aes_blocks) { u8 tmp_data[AES_KEY_LENGTH]; + u8 iv[AES_KEY_LENGTH] = {0}; u8 left[AES_KEY_LENGTH]; u8 k1[AES_KEY_LENGTH]; u8 *cbc_chain_data; @@ -61,7 +62,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst, for (i = 0; i < AES_KEY_LENGTH; i++) tmp_data[i] = 0; - aes_cbc_encrypt_blocks(key_schedule, tmp_data, left, 1); + aes_cbc_encrypt_blocks(key_schedule, iv, tmp_data, left, 1); left_shift_vector(left, k1, sizeof(left)); @@ -102,6 +103,7 @@ static int encrypt_and_sign(u8 *key, enum security_op oper, u8 *src, { u32 num_aes_blocks; u8 key_schedule[AES_EXPAND_KEY_LENGTH]; + u8 iv[AES_KEY_LENGTH] = {0}; debug("encrypt_and_sign: length = %d\n", length); @@ -116,7 +118,8 @@ static int encrypt_and_sign(u8 *key, enum security_op oper, u8 *src, if (oper & SECURITY_ENCRYPT) { /* Perform this in place, resulting in src being encrypted. */ debug("encrypt_and_sign: begin encryption\n"); - aes_cbc_encrypt_blocks(key_schedule, src, src, num_aes_blocks); + aes_cbc_encrypt_blocks(key_schedule, iv, src, src, + num_aes_blocks); debug("encrypt_and_sign: end encryption\n"); } |