One more test
This commit is contained in:
parent
c04d4816fb
commit
79f24e04e3
@ -14,6 +14,7 @@ AC_SUBST(ISODATE)
|
||||
|
||||
LX_CFLAGS=${CFLAGS-NONE}
|
||||
AC_PROG_CC_C99
|
||||
AM_PROG_CC_C_O
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/libsodium/include
|
||||
-I$(top_srcdir)/src/libsodium/include \
|
||||
-I$(top_srcdir)/src/libsodium/include/sodium
|
||||
|
||||
TESTS_TARGETS = \
|
||||
test-randombytes
|
||||
test-randombytes \
|
||||
auth
|
||||
|
||||
check_PROGRAMS = $(TESTS_TARGETS)
|
||||
|
||||
@ -15,4 +16,7 @@ TESTS_LDADD = $(top_srcdir)/src/libsodium/libsodium.la
|
||||
test_randombytes_SOURCES = test-randombytes.c
|
||||
test_randombytes_LDADD = $(TESTS_LDADD)
|
||||
|
||||
auth_SOURCES = auth.c cmptest.h
|
||||
auth_LDADD = $(TESTS_LDADD)
|
||||
|
||||
verify: check
|
||||
|
22
test/auth.c
Normal file
22
test/auth.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include "crypto_auth_hmacsha512256.h"
|
||||
|
||||
#define TEST_NAME "auth"
|
||||
#include "cmptest.h"
|
||||
|
||||
/* "Test Case 2" from RFC 4231 */
|
||||
unsigned char key[32] = "Jefe";
|
||||
unsigned char c[28] = "what do ya want for nothing?";
|
||||
|
||||
unsigned char a[32];
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
crypto_auth_hmacsha512256(a,c,sizeof c,key);
|
||||
for (i = 0;i < 32;++i) {
|
||||
printf(",0x%02x",(unsigned int) a[i]);
|
||||
if (i % 8 == 7) printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
4
test/auth.out
Normal file
4
test/auth.out
Normal file
@ -0,0 +1,4 @@
|
||||
,0x16,0x4b,0x7a,0x7b,0xfc,0xf8,0x19,0xe2
|
||||
,0xe3,0x95,0xfb,0xe7,0x3b,0x56,0xe0,0xa3
|
||||
,0x87,0xbd,0x64,0x22,0x2e,0x83,0x1f,0xd6
|
||||
,0x10,0x27,0x0c,0xd7,0xea,0x25,0x05,0x54
|
40
test/cmptest.h
Normal file
40
test/cmptest.h
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef __CMPTEST_H__
|
||||
#define __CMPTEST_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TEST_NAME_RES TEST_NAME ".res"
|
||||
#define TEST_NAME_OUT TEST_NAME ".out"
|
||||
|
||||
FILE *fp_res;
|
||||
int xmain(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
FILE *fp_out;
|
||||
int c;
|
||||
|
||||
if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) {
|
||||
perror("fopen(" TEST_NAME_RES ")");
|
||||
return 99;
|
||||
}
|
||||
xmain();
|
||||
rewind(fp_res);
|
||||
if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) {
|
||||
perror("fopen(" TEST_NAME_OUT ")");
|
||||
return 99;
|
||||
}
|
||||
do {
|
||||
if ((c = fgetc(fp_res)) != fgetc(fp_out)) {
|
||||
return 99;
|
||||
}
|
||||
} while (c != EOF);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define printf(...) fprintf(fp_res, __VA_ARGS__)
|
||||
#define main xmain
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user