mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 11:42:46 +01:00
crypto: remove unneeded assignments in aes_unwrap
A is present in the specification but in practice B always contains A so drop A.
This commit is contained in:
parent
f659265000
commit
f66ae1e481
@ -125,7 +125,7 @@ bool cmac_aes(const void *key, size_t key_len,
|
|||||||
bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len,
|
bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len,
|
||||||
uint8_t *out)
|
uint8_t *out)
|
||||||
{
|
{
|
||||||
uint8_t a[8], b[16];
|
uint8_t b[16];
|
||||||
uint8_t *r;
|
uint8_t *r;
|
||||||
size_t n = (len - 8) >> 3;
|
size_t n = (len - 8) >> 3;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -136,7 +136,7 @@ bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Set up */
|
/* Set up */
|
||||||
memcpy(a, in, 8);
|
memcpy(b, in, 8);
|
||||||
memmove(out, in + 8, n * 8);
|
memmove(out, in + 8, n * 8);
|
||||||
|
|
||||||
/* Unwrap */
|
/* Unwrap */
|
||||||
@ -144,11 +144,9 @@ bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len,
|
|||||||
r = out + (n - 1) * 8;
|
r = out + (n - 1) * 8;
|
||||||
|
|
||||||
for (i = n; i >= 1; i--) {
|
for (i = n; i >= 1; i--) {
|
||||||
memcpy(b, a, 8);
|
|
||||||
memcpy(b + 8, r, 8);
|
memcpy(b + 8, r, 8);
|
||||||
b[7] ^= n * j + i;
|
b[7] ^= n * j + i;
|
||||||
l_cipher_decrypt(cipher, b, b, 16);
|
l_cipher_decrypt(cipher, b, b, 16);
|
||||||
memcpy(a, b, 8);
|
|
||||||
memcpy(r, b + 8, 8);
|
memcpy(r, b + 8, 8);
|
||||||
r -= 8;
|
r -= 8;
|
||||||
}
|
}
|
||||||
@ -158,7 +156,7 @@ bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len,
|
|||||||
|
|
||||||
/* Check IV */
|
/* Check IV */
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
if (a[i] != 0xA6)
|
if (b[i] != 0xA6)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user