diff --git a/.gitignore b/.gitignore index 59777667..12220ced 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ test/default/box2 test/default/box7 test/default/box8 test/default/box_easy +test/default/box_easy2 test/default/core1 test/default/core2 test/default/core3 diff --git a/test/default/Makefile.am b/test/default/Makefile.am index f1ef77e6..db193f52 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -11,6 +11,7 @@ EXTRA_DIST = \ box7.exp \ box8.exp \ box_easy.exp \ + box_easy2.exp \ core1.exp \ core2.exp \ core3.exp \ @@ -57,6 +58,7 @@ DISTCLEANFILES = \ box7.res \ box8.res \ box_easy.res \ + box_easy2.res \ core1.res \ core2.res \ core3.res \ @@ -111,6 +113,7 @@ TESTS_TARGETS = \ box7 \ box8 \ box_easy \ + box_easy2 \ core1 \ core2 \ core3 \ @@ -181,6 +184,9 @@ box8_LDADD = $(TESTS_LDADD) box_easy_SOURCE = cmptest.h box_easy.c box_easy_LDADD = $(TESTS_LDADD) +box_easy2_SOURCE = cmptest.h box_easy2.c +box_easy2_LDADD = $(TESTS_LDADD) + core1_SOURCE = cmptest.h core1.c core1_LDADD = $(TESTS_LDADD) diff --git a/test/default/box_easy2.c b/test/default/box_easy2.c new file mode 100644 index 00000000..a2f1d139 --- /dev/null +++ b/test/default/box_easy2.c @@ -0,0 +1,31 @@ +#include +#include + +#define TEST_NAME "box_easy2" +#include "cmptest.h" + +unsigned char m[10000]; +unsigned char m2[10000]; +unsigned char c[crypto_box_MACBYTES + 10000]; +unsigned char nonce[crypto_box_NONCEBYTES]; +unsigned char alicepk[crypto_box_PUBLICKEYBYTES]; +unsigned char alicesk[crypto_box_SECRETKEYBYTES]; +unsigned char bobpk[crypto_box_PUBLICKEYBYTES]; +unsigned char bobsk[crypto_box_SECRETKEYBYTES]; + +int main(void) +{ + unsigned long long mlen; + + crypto_box_keypair(alicepk, alicesk); + crypto_box_keypair(bobpk, bobsk); + mlen = (unsigned long long) randombytes_uniform((uint32_t) sizeof m); + randombytes_buf(m, mlen); + randombytes_buf(nonce, sizeof nonce); + crypto_box_easy(c, m, mlen, nonce, bobpk, alicesk); + crypto_box_open_easy(m2, c, mlen + crypto_box_MACBYTES, + nonce, alicepk, bobsk); + printf("%d\n", memcmp(m, m2, mlen)); + + return 0; +} diff --git a/test/default/box_easy2.exp b/test/default/box_easy2.exp new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/test/default/box_easy2.exp @@ -0,0 +1 @@ +0