mirror of
https://github.com/BLAKE2/BLAKE2
synced 2024-11-08 14:59:19 +01:00
c89 compliance
This commit is contained in:
parent
f5c56ea028
commit
7a39ee4736
@ -30,12 +30,12 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -50,12 +50,12 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -70,15 +70,15 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, i, in, LENGTH, NULL, 0 ); \
|
name( hash, i, in, LENGTH, NULL, 0 ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
for( int j = i; j < LENGTH; ++j ) \
|
for( j = i; j < LENGTH; ++j ) \
|
||||||
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -93,15 +93,15 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
for( int j = i; j < LENGTH; ++j ) \
|
for( j = i; j < LENGTH; ++j ) \
|
||||||
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -112,16 +112,17 @@ do \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main()
|
||||||
{
|
{
|
||||||
uint8_t key[64] = {0};
|
uint8_t key[64] = {0};
|
||||||
uint8_t in[LENGTH] = {0};
|
uint8_t in[LENGTH] = {0};
|
||||||
uint8_t hash[LENGTH] = {0};
|
uint8_t hash[LENGTH] = {0};
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( in ); ++i )
|
for( i = 0; i < sizeof( in ); ++i )
|
||||||
in[i] = i;
|
in[i] = i;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( key ); ++i )
|
for( i = 0; i < sizeof( key ); ++i )
|
||||||
key[i] = i;
|
key[i] = i;
|
||||||
|
|
||||||
puts( "#ifndef BLAKE2_KAT_H\n"
|
puts( "#ifndef BLAKE2_KAT_H\n"
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
#define MAKE_KAT(name,size_prefix) \
|
#define MAKE_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"\",\n");\
|
printf(" \"key\": \"\",\n");\
|
||||||
@ -42,7 +42,7 @@ do \
|
|||||||
\
|
\
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -52,23 +52,23 @@ do \
|
|||||||
#define MAKE_KEYED_KAT(name,size_prefix) \
|
#define MAKE_KEYED_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"");\
|
printf(" \"key\": \"");\
|
||||||
for( int j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
||||||
printf("\",\n");\
|
printf("\",\n");\
|
||||||
printf(" \"out\": \"");\
|
printf(" \"out\": \"");\
|
||||||
\
|
\
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -78,13 +78,13 @@ do \
|
|||||||
#define MAKE_XOF_KAT(name) \
|
#define MAKE_XOF_KAT(name) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"\",\n");\
|
printf(" \"key\": \"\",\n");\
|
||||||
@ -92,7 +92,7 @@ do \
|
|||||||
\
|
\
|
||||||
name( hash, i, in, LENGTH, NULL, 0 ); \
|
name( hash, i, in, LENGTH, NULL, 0 ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -102,23 +102,23 @@ do \
|
|||||||
#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
|
#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"");\
|
printf(" \"key\": \"");\
|
||||||
for( int j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
||||||
printf("\",\n");\
|
printf("\",\n");\
|
||||||
printf(" \"out\": \"");\
|
printf(" \"out\": \"");\
|
||||||
\
|
\
|
||||||
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -126,16 +126,17 @@ do \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main()
|
||||||
{
|
{
|
||||||
uint8_t key[64] = {0};
|
uint8_t key[64] = {0};
|
||||||
uint8_t in[LENGTH] = {0};
|
uint8_t in[LENGTH] = {0};
|
||||||
uint8_t hash[LENGTH] = {0};
|
uint8_t hash[LENGTH] = {0};
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( in ); ++i )
|
for( i = 0; i < sizeof( in ); ++i )
|
||||||
in[i] = i;
|
in[i] = i;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( key ); ++i )
|
for( i = 0; i < sizeof( key ); ++i )
|
||||||
key[i] = i;
|
key[i] = i;
|
||||||
|
|
||||||
printf("[");
|
printf("[");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-O2 -I../testvectors -Wall
|
CFLAGS=-O2 -I../testvectors -Wall --std=c89
|
||||||
BLAKEBINS=blake2s blake2b blake2sp blake2bp blake2xs blake2xb
|
BLAKEBINS=blake2s blake2b blake2sp blake2bp blake2xs blake2xb
|
||||||
|
|
||||||
all: $(BLAKEBINS) check
|
all: $(BLAKEBINS) check
|
||||||
|
@ -30,12 +30,12 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -50,12 +50,12 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][" #size_prefix "_OUTBYTES] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == size_prefix ## _OUTBYTES ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -70,15 +70,15 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, i, in, LENGTH, NULL, 0 ); \
|
name( hash, i, in, LENGTH, NULL, 0 ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
for( int j = i; j < LENGTH; ++j ) \
|
for( j = i; j < LENGTH; ++j ) \
|
||||||
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -93,15 +93,15 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
||||||
\
|
\
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
||||||
printf( "\t{\n\t\t" ); \
|
printf( "\t{\n\t\t" ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x%02X%s", hash[j], ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
for( int j = i; j < LENGTH; ++j ) \
|
for( j = i; j < LENGTH; ++j ) \
|
||||||
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||||
\
|
\
|
||||||
printf( "\t},\n" ); \
|
printf( "\t},\n" ); \
|
||||||
@ -112,16 +112,17 @@ do \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main()
|
||||||
{
|
{
|
||||||
uint8_t key[64] = {0};
|
uint8_t key[64] = {0};
|
||||||
uint8_t in[LENGTH] = {0};
|
uint8_t in[LENGTH] = {0};
|
||||||
uint8_t hash[LENGTH] = {0};
|
uint8_t hash[LENGTH] = {0};
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( in ); ++i )
|
for( i = 0; i < sizeof( in ); ++i )
|
||||||
in[i] = i;
|
in[i] = i;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( key ); ++i )
|
for( i = 0; i < sizeof( key ); ++i )
|
||||||
key[i] = i;
|
key[i] = i;
|
||||||
|
|
||||||
puts( "#ifndef BLAKE2_KAT_H\n"
|
puts( "#ifndef BLAKE2_KAT_H\n"
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
#define MAKE_KAT(name,size_prefix) \
|
#define MAKE_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"\",\n");\
|
printf(" \"key\": \"\",\n");\
|
||||||
@ -42,7 +42,7 @@ do \
|
|||||||
\
|
\
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -52,23 +52,23 @@ do \
|
|||||||
#define MAKE_KEYED_KAT(name,size_prefix) \
|
#define MAKE_KEYED_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
for( i = 0; i < LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"");\
|
printf(" \"key\": \"");\
|
||||||
for( int j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
||||||
printf("\",\n");\
|
printf("\",\n");\
|
||||||
printf(" \"out\": \"");\
|
printf(" \"out\": \"");\
|
||||||
\
|
\
|
||||||
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -78,13 +78,13 @@ do \
|
|||||||
#define MAKE_XOF_KAT(name) \
|
#define MAKE_XOF_KAT(name) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"\",\n");\
|
printf(" \"key\": \"\",\n");\
|
||||||
@ -92,7 +92,7 @@ do \
|
|||||||
\
|
\
|
||||||
name( hash, i, in, LENGTH, NULL, 0 ); \
|
name( hash, i, in, LENGTH, NULL, 0 ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -102,23 +102,23 @@ do \
|
|||||||
#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
|
#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
for( size_t i = 1; i <= LENGTH; ++i ) \
|
for( i = 1; i <= LENGTH; ++i ) \
|
||||||
{ \
|
{ \
|
||||||
printf("\n{\n");\
|
printf("\n{\n");\
|
||||||
\
|
\
|
||||||
printf(" \"hash\": \"" #name "\",\n");\
|
printf(" \"hash\": \"" #name "\",\n");\
|
||||||
printf(" \"in\": \"");\
|
printf(" \"in\": \"");\
|
||||||
for( int j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
|
||||||
\
|
\
|
||||||
printf( "\",\n" ); \
|
printf( "\",\n" ); \
|
||||||
printf(" \"key\": \"");\
|
printf(" \"key\": \"");\
|
||||||
for( int j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
|
||||||
printf("\",\n");\
|
printf("\",\n");\
|
||||||
printf(" \"out\": \"");\
|
printf(" \"out\": \"");\
|
||||||
\
|
\
|
||||||
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
|
||||||
\
|
\
|
||||||
for( int j = 0; j < i; ++j ) \
|
for( j = 0; j < i; ++j ) \
|
||||||
printf( "%02x", hash[j]);\
|
printf( "%02x", hash[j]);\
|
||||||
printf( "\"\n" ); \
|
printf( "\"\n" ); \
|
||||||
printf( "}," ); \
|
printf( "}," ); \
|
||||||
@ -126,16 +126,17 @@ do \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main()
|
||||||
{
|
{
|
||||||
uint8_t key[64] = {0};
|
uint8_t key[64] = {0};
|
||||||
uint8_t in[LENGTH] = {0};
|
uint8_t in[LENGTH] = {0};
|
||||||
uint8_t hash[LENGTH] = {0};
|
uint8_t hash[LENGTH] = {0};
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( in ); ++i )
|
for( i = 0; i < sizeof( in ); ++i )
|
||||||
in[i] = i;
|
in[i] = i;
|
||||||
|
|
||||||
for( size_t i = 0; i < sizeof( key ); ++i )
|
for( i = 0; i < sizeof( key ); ++i )
|
||||||
key[i] = i;
|
key[i] = i;
|
||||||
|
|
||||||
printf("[");
|
printf("[");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-O3 -I../testvectors -Wall
|
CFLAGS=-O3 -I../testvectors -Wall --std=c89
|
||||||
BLAKEBINS=blake2s blake2b blake2sp blake2bp blake2xs blake2xb
|
BLAKEBINS=blake2s blake2b blake2sp blake2bp blake2xs blake2xb
|
||||||
|
|
||||||
all: $(BLAKEBINS) check
|
all: $(BLAKEBINS) check
|
||||||
|
Loading…
Reference in New Issue
Block a user