1
1
mirror of https://github.com/BLAKE2/BLAKE2 synced 2024-11-23 02:42:10 +01:00

b2xs tests ok

This commit is contained in:
JP Aumasson 2016-10-11 21:08:09 +02:00
parent 73dd9e9038
commit c09fb30361
4 changed files with 17455 additions and 11 deletions

@ -160,7 +160,7 @@ extern "C" {
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 );
//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 );

@ -168,18 +168,17 @@ int main( void )
uint8_t hash[BLAKE2_KAT_LENGTH] = {0};
blake2xs( hash, outlen, buf, BLAKE2_KAT_LENGTH, key, BLAKE2S_KEYBYTES );
#if 0
if( 0 != memcmp( hash, blake2xs_keyed_kat[i-1], i ) )
if( 0 != memcmp( hash, blake2xs_keyed_kat[outlen-1], outlen ) )
{
goto fail;
}
#endif
}
/* Test streaming API */
for(step = 1; step < BLAKE2S_BLOCKBYTES; ++step) {
for (size_t outlen = 1; outlen <= BLAKE2_KAT_LENGTH; ++outlen) {
uint8_t hash[BLAKE2S_OUTBYTES];
uint8_t hash[BLAKE2_KAT_LENGTH];
blake2xs_state S;
uint8_t * p = buf;
size_t mlen = BLAKE2_KAT_LENGTH;
@ -203,7 +202,7 @@ int main( void )
goto fail;
}
if (0 != memcmp(hash, blake2s_keyed_kat[outlen-1], outlen)) {
if (0 != memcmp(hash, blake2xs_keyed_kat[outlen-1], outlen)) {
goto fail;
}
}

@ -70,7 +70,7 @@ do \
{ \
printf( "static const uint8_t " #name "_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
\
for( size_t i = 0; i < LENGTH; ++i ) \
for( size_t i = 1; i <= LENGTH; ++i ) \
{ \
name( hash, i, in, LENGTH, NULL, 0 ); \
printf( "\t{\n\t\t" ); \
@ -88,12 +88,35 @@ do \
\
} while (0)
#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
do \
{ \
printf( "static const uint8_t " #name "_keyed_kat[BLAKE2_KAT_LENGTH][BLAKE2_KAT_LENGTH] = \n{\n" ); \
\
for( size_t i = 1; i <= LENGTH; ++i ) \
{ \
name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
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 )
{
uint8_t key[64] = {0};
uint8_t in[LENGTH] = {0};
uint8_t hash[64] = {0};
uint8_t hash[LENGTH] = {0};
for( size_t i = 0; i < sizeof( in ); ++i )
in[i] = i;
@ -114,6 +137,9 @@ int main( int argc, char **argv )
MAKE_KAT( blake2bp, BLAKE2B );
MAKE_KEYED_KAT( blake2bp, BLAKE2B );
MAKE_XOF_KAT( blake2xs );
MAKE_XOF_KEYED_KAT( blake2xs, BLAKE2S );
//MAKE_XOF_KAT( blake2xs );
//MAKE_XOF_KEYED_KAT( blake2xs, BLAKE2S );
puts( "#endif" );
return 0;
}

File diff suppressed because it is too large Load Diff