aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-10-10 15:55:19 (GMT)
committerJouni Malinen <j@w1.fi>2015-10-10 15:57:14 (GMT)
commit6f5b284b327ff938d919e42c57e6d2ad256893cf (patch)
treedb0203e32596956aa552e0ddaa285a25dbb28a86 /src/crypto
parent0d2a7bad0fb2c432520afb622a05b50749eaf8e8 (diff)
downloadhostap-6f5b284b327ff938d919e42c57e6d2ad256893cf.zip
hostap-6f5b284b327ff938d919e42c57e6d2ad256893cf.tar.gz
hostap-6f5b284b327ff938d919e42c57e6d2ad256893cf.tar.bz2
tests: Module test for hmac_sha256_kdf() maximum output length
Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/crypto_module_tests.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/crypto/crypto_module_tests.c b/src/crypto/crypto_module_tests.c
index 581005d..2d508c1 100644
--- a/src/crypto/crypto_module_tests.c
+++ b/src/crypto/crypto_module_tests.c
@@ -1503,6 +1503,7 @@ static int test_sha256(void)
const u8 *addr[2];
size_t len[2];
int errors = 0;
+ u8 *key;
for (i = 0; i < ARRAY_SIZE(tests); i++) {
wpa_printf(MSG_INFO, "SHA256 test case %d:", i + 1);
@@ -1573,6 +1574,29 @@ static int test_sha256(void)
hash, sizeof(hash));
/* TODO: add proper test case for this */
+ key = os_malloc(8161);
+ if (key) {
+ int res;
+
+ res = hmac_sha256_kdf((u8 *) "secret", 6, "label",
+ (u8 *) "seed", 4, key, 8160);
+ if (res) {
+ wpa_printf(MSG_INFO,
+ "Unexpected hmac_sha256_kdf(outlen=8160) failure");
+ errors++;
+ }
+
+ res = hmac_sha256_kdf((u8 *) "secret", 6, "label",
+ (u8 *) "seed", 4, key, 8161);
+ if (res == 0) {
+ wpa_printf(MSG_INFO,
+ "Unexpected hmac_sha256_kdf(outlen=8161) success");
+ errors++;
+ }
+
+ os_free(key);
+ }
+
if (!errors)
wpa_printf(MSG_INFO, "SHA256 test cases passed");
return errors;