mirror of
https://github.com/BLAKE2/BLAKE2
synced 2024-11-07 14:49:17 +01:00
b2s xof unkeyed kats
This commit is contained in:
parent
ae633ca8e2
commit
73dd9e9038
@ -159,6 +159,9 @@ extern "C" {
|
||||
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
int blake2xs( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
/* This is simply an alias for blake2b */
|
||||
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
|
@ -35,7 +35,8 @@ static int blake2bp_init_leaf( blake2b_state *S, size_t outlen, size_t keylen, u
|
||||
P->fanout = PARALLELISM_DEGREE;
|
||||
P->depth = 2;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, offset );
|
||||
store32( &P->node_offset, offset );
|
||||
store32( &P->xof_length, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = BLAKE2B_OUTBYTES;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
@ -52,7 +53,8 @@ static int blake2bp_init_root( blake2b_state *S, size_t outlen, size_t keylen )
|
||||
P->fanout = PARALLELISM_DEGREE;
|
||||
P->depth = 2;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
store32( &P->node_offset, 0 );
|
||||
store32( &P->xof_length, 0 );
|
||||
P->node_depth = 1;
|
||||
P->inner_length = BLAKE2B_OUTBYTES;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
|
@ -34,7 +34,8 @@ static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, u
|
||||
P->fanout = PARALLELISM_DEGREE;
|
||||
P->depth = 2;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store48( P->node_offset, offset );
|
||||
store32( &P->node_offset, offset );
|
||||
store16( &P->xof_length, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = BLAKE2S_OUTBYTES;
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
@ -50,7 +51,8 @@ static int blake2sp_init_root( blake2s_state *S, size_t outlen, size_t keylen )
|
||||
P->fanout = PARALLELISM_DEGREE;
|
||||
P->depth = 2;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store48( P->node_offset, 0ULL );
|
||||
store32( &P->node_offset, 0ULL );
|
||||
store16( &P->xof_length, 0ULL );
|
||||
P->node_depth = 1;
|
||||
P->inner_length = BLAKE2S_OUTBYTES;
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
|
@ -65,6 +65,29 @@ do \
|
||||
\
|
||||
} while (0)
|
||||
|
||||
#define MAKE_XOF_KAT(name) \
|
||||
do \
|
||||
{ \
|
||||
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
|
||||
\
|
||||
for( size_t i = 0; i < LENGTH; ++i ) \
|
||||
{ \
|
||||
name( hash, i, in, LENGTH, NULL, 0 ); \
|
||||
printf( "\t{\n\t\t" ); \
|
||||
\
|
||||
for( int j = 0; j < i; ++j ) \
|
||||
printf( "0x%02X%s", hash[j], j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||
\
|
||||
for( int j = i; j < LENGTH; ++j ) \
|
||||
printf( "0x00%s", ( j + 1 ) == LENGTH ? "\n" : j && !( ( j + 1 ) % 8 ) ? ",\n\t\t" : ", " ); \
|
||||
\
|
||||
printf( "\t},\n" ); \
|
||||
} \
|
||||
\
|
||||
printf( "};\n\n\n\n\n" ); \
|
||||
\
|
||||
} while (0)
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
@ -90,6 +113,7 @@ int main( int argc, char **argv )
|
||||
MAKE_KEYED_KAT( blake2sp, BLAKE2S );
|
||||
MAKE_KAT( blake2bp, BLAKE2B );
|
||||
MAKE_KEYED_KAT( blake2bp, BLAKE2B );
|
||||
MAKE_XOF_KAT( blake2xs );
|
||||
puts( "#endif" );
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ check: blake2s blake2b blake2sp blake2bp blake2xs blake2xb
|
||||
./blake2xb
|
||||
|
||||
kat:
|
||||
$(CC) $(CFLAGS) -o genkat-c genkat-c.c blake2b-ref.c blake2s-ref.c blake2sp-ref.c blake2bp-ref.c
|
||||
$(CC) $(CFLAGS) -g -o genkat-json genkat-json.c blake2b-ref.c blake2s-ref.c blake2sp-ref.c blake2bp-ref.c
|
||||
$(CC) $(CFLAGS) -o genkat-c genkat-c.c blake2b-ref.c blake2s-ref.c blake2sp-ref.c blake2bp-ref.c blake2xs-ref.c blake2xb-ref.c
|
||||
$(CC) $(CFLAGS) -o genkat-json genkat-json.c blake2b-ref.c blake2s-ref.c blake2sp-ref.c blake2bp-ref.c blake2xs-ref.c blake2xb-ref.c
|
||||
./genkat-c > blake2-kat.h
|
||||
./genkat-json > blake2-kat.json
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user