diff --git a/.gitignore b/.gitignore index 8bc6f4e0..e1d66b58 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,7 @@ test/default/secretbox2 test/default/secretbox7 test/default/secretbox8 test/default/secretbox_easy +test/default/secretbox_easy2 test/default/shorthash test/default/sodium_core test/default/sodium_utils diff --git a/test/default/Makefile.am b/test/default/Makefile.am index bb8659fd..f637cec0 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -38,6 +38,7 @@ EXTRA_DIST = \ secretbox7.exp \ secretbox8.exp \ secretbox_easy.exp \ + secretbox_easy2.exp \ shorthash.exp \ sodium_core.exp \ sodium_utils.exp \ @@ -86,6 +87,7 @@ DISTCLEANFILES = \ secretbox7.res \ secretbox8.res \ secretbox_easy.res \ + secretbox_easy2.res \ shorthash.res \ sodium_core.res \ sodium_utils.res \ @@ -142,6 +144,7 @@ TESTS_TARGETS = \ secretbox7 \ secretbox8 \ secretbox_easy \ + secretbox_easy2 \ shorthash \ sodium_core \ sodium_utils \ @@ -268,6 +271,9 @@ secretbox8_LDADD = $(TESTS_LDADD) secretbox_easy_SOURCE = cmptest.h secretbox_easy.c secretbox_easy_LDADD = $(TESTS_LDADD) +secretbox_easy2_SOURCE = cmptest.h secretbox_easy2.c +secretbox_easy2_LDADD = $(TESTS_LDADD) + shorthash_SOURCE = cmptest.h shorthash.c shorthash_LDADD = $(TESTS_LDADD) diff --git a/test/default/secretbox_easy2.c b/test/default/secretbox_easy2.c new file mode 100644 index 00000000..62663a30 --- /dev/null +++ b/test/default/secretbox_easy2.c @@ -0,0 +1,27 @@ +#include +#include + +#define TEST_NAME "secretbox_easy2" +#include "cmptest.h" + +unsigned char m[10000]; +unsigned char m2[10000]; +unsigned char c[crypto_secretbox_MACBYTES + 10000]; +unsigned char nonce[crypto_secretbox_NONCEBYTES]; +unsigned char k[crypto_secretbox_KEYBYTES]; + +int main(void) +{ + unsigned long long mlen; + + randombytes_buf(k, sizeof k); + mlen = (unsigned long long) randombytes_uniform((uint32_t) sizeof m); + randombytes_buf(m, mlen); + randombytes_buf(nonce, sizeof nonce); + crypto_secretbox_easy(c, m, mlen, nonce, k); + crypto_secretbox_open_easy(m2, c, mlen + crypto_secretbox_MACBYTES, + nonce, k); + printf("%d\n", memcmp(m, m2, mlen)); + + return 0; +} diff --git a/test/default/secretbox_easy2.exp b/test/default/secretbox_easy2.exp new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/test/default/secretbox_easy2.exp @@ -0,0 +1 @@ +0