1 2 #define TEST_NAME "auth7" 3 #include "cmptest.h" 4 5 static unsigned char key[32]; 6 static unsigned char c[600]; 7 static unsigned char a[64]; 8 9 int 10 main(void) 11 { 12 size_t clen; 13 14 for (clen = 0; clen < sizeof c; ++clen) { 15 crypto_auth_keygen(key); 16 randombytes_buf(c, clen); 17 crypto_auth_hmacsha512(a, c, clen, key); 18 if (crypto_auth_hmacsha512_verify(a, c, clen, key) != 0) { 19 printf("fail %u\n", (unsigned int) clen); 20 return 100; 21 } 22 if (clen > 0) { 23 c[(size_t) rand() % clen] += 1 + (rand() % 255); 24 if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) { 25 printf("forgery %u\n", (unsigned int) clen); 26 return 100; 27 } 28 a[rand() % sizeof a] += 1 + (rand() % 255); 29 if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) { 30 printf("forgery %u\n", (unsigned int) clen); 31 return 100; 32 } 33 } 34 } 35 return 0; 36 } 37