Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ref
diff options
context:
space:
mode:
authorJP Aumasson <jeanphilippe.aumasson@gmail.com>2016-10-11 22:08:09 +0300
committerJP Aumasson <jeanphilippe.aumasson@gmail.com>2016-10-11 22:08:09 +0300
commitc09fb303618abdb41947ec85c7dc5cd2f53d4f76 (patch)
tree1716b70136a0473d393b3878ae8175d3a32f57a9 /ref
parent73dd9e9038e5d8ca8efad8c19efce70335292f17 (diff)
b2xs tests ok
Diffstat (limited to 'ref')
-rw-r--r--ref/blake2.h2
-rw-r--r--ref/blake2xs-ref.c9
-rw-r--r--ref/genkat-c.c30
3 files changed, 33 insertions, 8 deletions
diff --git a/ref/blake2.h b/ref/blake2.h
index cef9bf2..eef10a1 100644
--- a/ref/blake2.h
+++ b/ref/blake2.h
@@ -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 );
diff --git a/ref/blake2xs-ref.c b/ref/blake2xs-ref.c
index 817e39e..45c9c4b 100644
--- a/ref/blake2xs-ref.c
+++ b/ref/blake2xs-ref.c
@@ -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;
}
}
diff --git a/ref/genkat-c.c b/ref/genkat-c.c
index 52df0ee..a8405ae 100644
--- a/ref/genkat-c.c
+++ b/ref/genkat-c.c
@@ -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;
}