summaryrefslogtreecommitdiff
path: root/nacl/tests/secretbox7.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/tests/secretbox7.c')
-rw-r--r--nacl/tests/secretbox7.c32
1 files changed, 0 insertions, 32 deletions
diff --git a/nacl/tests/secretbox7.c b/nacl/tests/secretbox7.c
deleted file mode 100644
index d4be9b49..00000000
--- a/nacl/tests/secretbox7.c
+++ /dev/null
@@ -1,32 +0,0 @@
1#include <stdio.h>
2#include "crypto_secretbox.h"
3#include "randombytes.h"
4
5unsigned char k[crypto_secretbox_KEYBYTES];
6unsigned char n[crypto_secretbox_NONCEBYTES];
7unsigned char m[10000];
8unsigned char c[10000];
9unsigned char m2[10000];
10
11main()
12{
13 int mlen;
14 int i;
15
16 for (mlen = 0;mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;++mlen) {
17 randombytes(k,crypto_secretbox_KEYBYTES);
18 randombytes(n,crypto_secretbox_NONCEBYTES);
19 randombytes(m + crypto_secretbox_ZEROBYTES,mlen);
20 crypto_secretbox(c,m,mlen + crypto_secretbox_ZEROBYTES,n,k);
21 if (crypto_secretbox_open(m2,c,mlen + crypto_secretbox_ZEROBYTES,n,k) == 0) {
22 for (i = 0;i < mlen + crypto_secretbox_ZEROBYTES;++i)
23 if (m2[i] != m[i]) {
24 printf("bad decryption\n");
25 break;
26 }
27 } else {
28 printf("ciphertext fails verification\n");
29 }
30 }
31 return 0;
32}