diff --git a/test/default/Makefile.am b/test/default/Makefile.am index 36b04329..c2477509 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -6,6 +6,8 @@ EXTRA_DIST = \ auth2.exp \ auth3.exp \ auth5.exp \ + auth6.exp \ + auth7.exp \ box.exp \ box2.exp \ box7.exp \ @@ -56,6 +58,8 @@ DISTCLEANFILES = \ auth2.res \ auth3.res \ auth5.res \ + auth6.res \ + auth7.res \ box.res \ box2.res \ box7.res \ @@ -114,6 +118,8 @@ TESTS_TARGETS = \ auth2 \ auth3 \ auth5 \ + auth6 \ + auth7 \ box \ box2 \ box7 \ @@ -178,6 +184,12 @@ auth3_LDADD = $(TESTS_LDADD) auth5_SOURCE = cmptest.h auth5.c windows/windows-quirks.h auth5_LDADD = $(TESTS_LDADD) +auth6_SOURCE = cmptest.h auth6.c windows/windows-quirks.h +auth6_LDADD = $(TESTS_LDADD) + +auth7_SOURCE = cmptest.h auth7.c windows/windows-quirks.h +auth7_LDADD = $(TESTS_LDADD) + box_SOURCE = cmptest.h box.c box_LDADD = $(TESTS_LDADD) diff --git a/test/default/auth6.c b/test/default/auth6.c new file mode 100644 index 00000000..5bf0500f --- /dev/null +++ b/test/default/auth6.c @@ -0,0 +1,21 @@ +#include + +#define TEST_NAME "auth6" +#include "cmptest.h" + +/* "Test Case 2" from RFC 4231 */ +unsigned char key[32] = "Jefe"; +unsigned char c[] = "what do ya want for nothing?"; + +unsigned char a[64]; + +int main(void) +{ + int i; + crypto_auth_hmacsha512(a,c,sizeof c - 1U,key); + for (i = 0;i < 64;++i) { + printf(",0x%02x",(unsigned int) a[i]); + if (i % 8 == 7) printf("\n"); + } + return 0; +} diff --git a/test/default/auth6.exp b/test/default/auth6.exp new file mode 100644 index 00000000..da0c5284 --- /dev/null +++ b/test/default/auth6.exp @@ -0,0 +1,8 @@ +,0x16,0x4b,0x7a,0x7b,0xfc,0xf8,0x19,0xe2 +,0xe3,0x95,0xfb,0xe7,0x3b,0x56,0xe0,0xa3 +,0x87,0xbd,0x64,0x22,0x2e,0x83,0x1f,0xd6 +,0x10,0x27,0x0c,0xd7,0xea,0x25,0x05,0x54 +,0x97,0x58,0xbf,0x75,0xc0,0x5a,0x99,0x4a +,0x6d,0x03,0x4f,0x65,0xf8,0xf0,0xe6,0xfd +,0xca,0xea,0xb1,0xa3,0x4d,0x4a,0x6b,0x4b +,0x63,0x6e,0x07,0x0a,0x38,0xbc,0xe7,0x37 diff --git a/test/default/auth7.c b/test/default/auth7.c new file mode 100644 index 00000000..be67312b --- /dev/null +++ b/test/default/auth7.c @@ -0,0 +1,37 @@ +#include +#include +#include "windows/windows-quirks.h" + +#define TEST_NAME "auth7" +#include "cmptest.h" + +unsigned char key[32]; +unsigned char c[10000]; +unsigned char a[64]; + +int main(void) +{ + int clen; + for (clen = 0;clen < 10000;++clen) { + randombytes(key,sizeof key); + randombytes(c,clen); + crypto_auth_hmacsha512(a,c,clen,key); + if (crypto_auth_hmacsha512_verify(a,c,clen,key) != 0) { + printf("fail %d\n",clen); + return 100; + } + if (clen > 0) { + c[rand() % clen] += 1 + (rand() % 255); + if (crypto_auth_hmacsha512_verify(a,c,clen,key) == 0) { + printf("forgery %d\n",clen); + return 100; + } + a[rand() % sizeof a] += 1 + (rand() % 255); + if (crypto_auth_hmacsha512_verify(a,c,clen,key) == 0) { + printf("forgery %d\n",clen); + return 100; + } + } + } + return 0; +} diff --git a/test/default/auth7.exp b/test/default/auth7.exp new file mode 100644 index 00000000..e69de29b