use crypto_*_keygen() in tests

This commit is contained in:
Frank Denis
2017-02-19 21:20:45 +01:00
parent 7e5d64834c
commit 8af252bf87
6 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ int main(void)
size_t clen;
for (clen = 0; clen < 1000; ++clen) {
randombytes_buf(key, sizeof key);
crypto_auth_keygen(key);
randombytes_buf(c, clen);
crypto_auth(a, c, clen, key);
if (crypto_auth_verify(a, c, clen, key) != 0) {
+1 -1
View File
@@ -11,7 +11,7 @@ int main(void)
size_t clen;
for (clen = 0; clen < sizeof c; ++clen) {
randombytes_buf(key, sizeof key);
crypto_auth_keygen(key);
randombytes_buf(c, clen);
crypto_auth_hmacsha512(a, c, clen, key);
if (crypto_auth_hmacsha512_verify(a, c, clen, key) != 0) {
+1 -1
View File
@@ -11,7 +11,7 @@ int main(void)
int clen;
for (clen = 0; clen < 1000; ++clen) {
randombytes_buf(key, sizeof key);
crypto_onetimeauth_keygen(key);
randombytes_buf(c, clen);
crypto_onetimeauth(a, c, clen, key);
if (crypto_onetimeauth_verify(a, c, clen, key) != 0) {
+1 -1
View File
@@ -15,7 +15,7 @@ int main(void)
for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;
++mlen) {
randombytes_buf(k, crypto_secretbox_KEYBYTES);
crypto_secretbox_keygen(k);
randombytes_buf(n, crypto_secretbox_NONCEBYTES);
randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen);
crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k);
+1 -1
View File
@@ -16,7 +16,7 @@ int main(void)
for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;
++mlen) {
randombytes_buf(k, crypto_secretbox_KEYBYTES);
crypto_secretbox_keygen(k);
randombytes_buf(n, crypto_secretbox_NONCEBYTES);
randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen);
crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k);
+1 -1
View File
@@ -20,7 +20,7 @@ int main(void)
nonce = (unsigned char *) sodium_malloc(crypto_secretbox_NONCEBYTES);
k = (unsigned char *) sodium_malloc(crypto_secretbox_KEYBYTES);
mac = (unsigned char *) sodium_malloc(crypto_secretbox_MACBYTES);
randombytes_buf(k, crypto_secretbox_KEYBYTES);
crypto_secretbox_keygen(k);
randombytes_buf(m, (unsigned long long) mlen);
randombytes_buf(nonce, crypto_secretbox_NONCEBYTES);
crypto_secretbox_easy(c, m, (unsigned long long) mlen, nonce, k);