libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / libsodium / test / default / onetimeauth7.c
blob6d99134c6cf2a1bd81c8fc0130bd0e46a78371c6
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "windows/windows-quirks.h"
5 #define TEST_NAME "onetimeauth7"
6 #include "cmptest.h"
8 unsigned char key[32];
9 unsigned char c[10000];
10 unsigned char a[16];
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_onetimeauth_poly1305(a,c,clen,key);
19 if (crypto_onetimeauth_poly1305_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_onetimeauth_poly1305_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_onetimeauth_poly1305_verify(a,c,clen,key) == 0) {
31 printf("forgery %d\n",clen);
32 return 100;
36 return 0;