3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

unit: Use overlapped in/out buffers

Since aes_wrap & aes_unwrap advertise support for overlapped in/out
buffers, make sure that the unit test actually tests this as well.
valgrind will complain if the memory is overlapped and memcpy is used
instead of memmove.
This commit is contained in:
Denis Kenzior 2017-08-31 13:15:28 -05:00
parent 9da2d64980
commit da029bead8

View File

@ -351,18 +351,18 @@ static void aes_wrap_test(const void *data)
0xae, 0xf3, 0x4b, 0xd8, 0xfb, 0x5a, 0x7b, 0x82, 0xae, 0xf3, 0x4b, 0xd8, 0xfb, 0x5a, 0x7b, 0x82,
0x9d, 0x3e, 0x86, 0x23, 0x71, 0xd2, 0xcf, 0xe5, 0x9d, 0x3e, 0x86, 0x23, 0x71, 0xd2, 0xcf, 0xe5,
}; };
uint8_t out[24]; uint8_t buf[24];
memset(out, 0, 24); memcpy(buf, key_data, sizeof(key_data));
assert(aes_wrap(kek, buf, sizeof(key_data), buf));
assert(!memcmp(buf, ciphertext, sizeof(ciphertext)));
assert(aes_wrap(kek, key_data, sizeof(key_data), out)); buf[10] = 10;
assert(!memcmp(out, ciphertext, sizeof(ciphertext))); assert(!aes_unwrap(kek, buf, sizeof(ciphertext), buf));
out[10] = 10; memcpy(buf, ciphertext, sizeof(ciphertext));
assert(!aes_unwrap(kek, out, sizeof(ciphertext), out)); assert(aes_unwrap(kek, buf, sizeof(ciphertext), buf));
assert(!memcmp(buf, key_data, sizeof(key_data)));
assert(aes_unwrap(kek, ciphertext, sizeof(ciphertext), out));
assert(!memcmp(out, key_data, sizeof(key_data)));
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])