Changes to update Tomato RAF.
[tomato.git] / release / src / router / dnscrypt / src / libnacl / tests / auth5.c
blob92d8fea3c65988306f06e858c6608ad27af06e5d
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "crypto_auth_hmacsha512256.h"
4 #include "randombytes.h"
5 #include "windows/windows-quirks.h"
7 unsigned char key[32];
8 unsigned char c[10000];
9 unsigned char a[32];
11 main()
13 int clen;
14 int i;
15 for (clen = 0;clen < 10000;++clen) {
16 randombytes(key,sizeof key);
17 randombytes(c,clen);
18 crypto_auth_hmacsha512256(a,c,clen,key);
19 if (crypto_auth_hmacsha512256_verify(a,c,clen,key) != 0) {
20 printf("fail %d\n",clen);
21 return 100;
23 if (clen > 0) {
24 c[random() % clen] += 1 + (random() % 255);
25 if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) {
26 printf("forgery %d\n",clen);
27 return 100;
29 a[random() % sizeof a] += 1 + (random() % 255);
30 if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) {
31 printf("forgery %d\n",clen);
32 return 100;
36 return 0;