libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / libsodium / test / default / auth5.c
blobded9489c5d652682c96f8bbe7a2f6c7bcb38db8b
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "windows/windows-quirks.h"
5 #define TEST_NAME "auth5"
6 #include "cmptest.h"
8 unsigned char key[32];
9 unsigned char c[10000];
10 unsigned char a[32];
12 int main(void)
14 int clen;
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[rand() % clen] += 1 + (rand() % 255);
25 if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) {
26 printf("forgery %d\n",clen);
27 return 100;
29 a[rand() % sizeof a] += 1 + (rand() % 255);
30 if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) {
31 printf("forgery %d\n",clen);
32 return 100;
36 return 0;