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