2 #define TEST_NAME "keygen"
5 typedef struct KeygenTV_ {
6 void (*fn)(unsigned char *k);
13 static const KeygenTV tvs[] = {
14 { crypto_auth_keygen, crypto_auth_KEYBYTES },
15 { crypto_auth_hmacsha256_keygen, crypto_auth_hmacsha256_KEYBYTES },
16 { crypto_aead_aes256gcm_keygen, crypto_aead_aes256gcm_KEYBYTES },
17 { crypto_auth_hmacsha512_keygen, crypto_auth_hmacsha512_KEYBYTES },
18 { crypto_auth_hmacsha512256_keygen, crypto_auth_hmacsha512256_KEYBYTES },
19 { crypto_generichash_keygen, crypto_generichash_KEYBYTES },
20 { crypto_generichash_blake2b_keygen, crypto_generichash_blake2b_KEYBYTES },
21 { crypto_kdf_keygen, crypto_kdf_KEYBYTES },
22 { crypto_onetimeauth_keygen, crypto_onetimeauth_KEYBYTES },
23 { crypto_onetimeauth_poly1305_keygen, crypto_onetimeauth_poly1305_KEYBYTES },
24 { crypto_aead_chacha20poly1305_ietf_keygen, crypto_aead_chacha20poly1305_ietf_KEYBYTES },
25 { crypto_aead_chacha20poly1305_keygen, crypto_aead_chacha20poly1305_KEYBYTES },
26 { crypto_aead_chacha20poly1305_ietf_keygen, crypto_aead_chacha20poly1305_ietf_KEYBYTES },
27 { crypto_aead_xchacha20poly1305_ietf_keygen, crypto_aead_xchacha20poly1305_ietf_KEYBYTES },
28 { crypto_secretbox_xsalsa20poly1305_keygen, crypto_secretbox_xsalsa20poly1305_KEYBYTES },
29 { crypto_secretbox_keygen, crypto_secretbox_KEYBYTES },
30 { crypto_secretstream_xchacha20poly1305_keygen, crypto_secretstream_xchacha20poly1305_KEYBYTES },
31 { crypto_shorthash_keygen, crypto_shorthash_KEYBYTES },
32 { crypto_stream_keygen, crypto_stream_KEYBYTES },
33 { crypto_stream_chacha20_keygen, crypto_stream_chacha20_KEYBYTES },
34 { crypto_stream_chacha20_ietf_keygen, crypto_stream_chacha20_ietf_KEYBYTES },
35 { crypto_stream_salsa20_keygen, crypto_stream_salsa20_KEYBYTES },
36 { crypto_stream_xsalsa20_keygen, crypto_stream_xsalsa20_KEYBYTES }
43 for (i = 0; i < (sizeof tvs) / (sizeof tvs[0]); i++) {
45 key = (unsigned char *) sodium_malloc(tv->key_len);
46 key[tv->key_len - 1U] = 0;
47 for (j = 0; j < 10000; j++) {
49 if (key[tv->key_len - 1U] != 0) {
55 printf("Buffer underflow with test vector %u\n", (unsigned int) i);
58 printf("tv_keygen: ok\n");