Fix tests, use guard page instead of NULL because of Wasm

This commit is contained in:
Frank Denis
2019-02-09 20:47:24 +01:00
parent d47ded1867
commit 83a873ea1b
9 changed files with 38 additions and 37 deletions
+8 -6
View File
@@ -67,7 +67,7 @@ main(void)
printf("\n");
}
// Empty message tests: HMAC-SHA512
/* Empty message tests: HMAC-SHA512 */
memset(a2, 0, sizeof a2);
crypto_auth_hmacsha512_init(&st, key, sizeof key);
crypto_auth_hmacsha512_final(&st, a2);
@@ -80,11 +80,11 @@ main(void)
memset(a3, 0, sizeof a3);
crypto_auth_hmacsha512_init(&st, key, sizeof key);
crypto_auth_hmacsha512_update(&st, NULL, 0U);
crypto_auth_hmacsha512_update(&st, guard_page, 0U);
crypto_auth_hmacsha512_final(&st, a3);
assert(sodium_memcmp(a2, a3, sizeof a2) == 0);
// Empty message tests: HMAC-SHA512-256
/* Empty message tests: HMAC-SHA512-256 */
memset(a2, 0, sizeof a2);
crypto_auth_hmacsha512256_init(&st512_256, key, sizeof key);
crypto_auth_hmacsha512256_final(&st512_256, a2);
@@ -97,12 +97,12 @@ main(void)
memset(a3, 0, sizeof a3);
crypto_auth_hmacsha512256_init(&st512_256, key, sizeof key);
crypto_auth_hmacsha512256_update(&st512_256, NULL, 0U);
crypto_auth_hmacsha512256_update(&st512_256, guard_page, 0U);
crypto_auth_hmacsha512256_final(&st512_256, a3);
assert(sodium_memcmp(a2, a3, sizeof a2) == 0);
/* Empty message tests: HMAC-SHA256 */
// Empty message tests: HMAC-SHA256
memset(a2, 0, sizeof a2);
crypto_auth_hmacsha256_init(&st256, key, sizeof key);
crypto_auth_hmacsha256_final(&st256, a2);
@@ -115,10 +115,12 @@ main(void)
memset(a3, 0, sizeof a3);
crypto_auth_hmacsha256_init(&st256, key, sizeof key);
crypto_auth_hmacsha256_update(&st256, NULL, 0U);
crypto_auth_hmacsha256_update(&st256, guard_page, 0U);
crypto_auth_hmacsha256_final(&st256, a3);
assert(sodium_memcmp(a2, a3, sizeof a2) == 0);
/* --- */
assert(crypto_auth_bytes() > 0U);
assert(crypto_auth_keybytes() > 0U);
assert(strcmp(crypto_auth_primitive(), "hmacsha512256") == 0);