mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 10:05:05 -07:00
Add a test for crypto_verify_*()
This commit is contained in:
parent
28ac480ad0
commit
cb2ce89a03
1
.gitignore
vendored
1
.gitignore
vendored
@ -100,6 +100,7 @@ test/default/stream3
|
||||
test/default/stream4
|
||||
test/default/stream5
|
||||
test/default/stream6
|
||||
test/default/verify1
|
||||
test-driver
|
||||
testing
|
||||
android-toolchain-*
|
||||
|
@ -48,7 +48,8 @@ EXTRA_DIST = \
|
||||
stream3.exp \
|
||||
stream4.exp \
|
||||
stream5.exp \
|
||||
stream6.exp
|
||||
stream6.exp \
|
||||
verify1.exp
|
||||
|
||||
DISTCLEANFILES = \
|
||||
auth.res \
|
||||
@ -97,7 +98,8 @@ DISTCLEANFILES = \
|
||||
stream3.res \
|
||||
stream4.res \
|
||||
stream5.res \
|
||||
stream6.res
|
||||
stream6.res \
|
||||
verify1.res
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-DTEST_SRCDIR=\"@srcdir@\" \
|
||||
@ -154,7 +156,8 @@ TESTS_TARGETS = \
|
||||
stream3 \
|
||||
stream4 \
|
||||
stream5 \
|
||||
stream6
|
||||
stream6 \
|
||||
verify1
|
||||
|
||||
check_PROGRAMS = $(TESTS_TARGETS)
|
||||
|
||||
@ -304,4 +307,7 @@ stream5_LDADD = $(TESTS_LDADD)
|
||||
stream6_SOURCE = cmptest.h stream6.c
|
||||
stream6_LDADD = $(TESTS_LDADD)
|
||||
|
||||
verify1_SOURCE = cmptest.h verify1.c
|
||||
verify1_LDADD = $(TESTS_LDADD)
|
||||
|
||||
verify: check
|
||||
|
34
test/default/verify1.c
Normal file
34
test/default/verify1.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TEST_NAME "verify1"
|
||||
#include "cmptest.h"
|
||||
|
||||
unsigned char v16[16], v16x[16];
|
||||
unsigned char v32[32], v32x[32];
|
||||
unsigned char v64[64], v64x[64];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
randombytes_buf(v16, sizeof v16);
|
||||
randombytes_buf(v32, sizeof v32);
|
||||
randombytes_buf(v64, sizeof v64);
|
||||
|
||||
memcpy(v16x, v16, sizeof v16);
|
||||
memcpy(v32x, v32, sizeof v32);
|
||||
memcpy(v64x, v64, sizeof v64);
|
||||
|
||||
printf("%d\n", crypto_verify_16(v16, v16x));
|
||||
printf("%d\n", crypto_verify_32(v32, v32x));
|
||||
printf("%d\n", crypto_verify_64(v64, v64x));
|
||||
|
||||
v16x[randombytes_random() & 15U]++;
|
||||
v32x[randombytes_random() & 31U]++;
|
||||
v64x[randombytes_random() & 63U]++;
|
||||
|
||||
printf("%d\n", crypto_verify_16(v16, v16x));
|
||||
printf("%d\n", crypto_verify_32(v32, v32x));
|
||||
printf("%d\n", crypto_verify_64(v64, v64x));
|
||||
|
||||
return 0;
|
||||
}
|
6
test/default/verify1.exp
Normal file
6
test/default/verify1.exp
Normal file
@ -0,0 +1,6 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
-1
|
||||
-1
|
||||
-1
|
Loading…
Reference in New Issue
Block a user