shithub: blake2

Download patch

ref: 73dd9e9038e5d8ca8efad8c19efce70335292f17
parent: ae633ca8e2220236e28953299194bf0656da5d25
author: JP Aumasson <jeanphilippe.aumasson@gmail.com>
date: Tue Oct 11 16:48:16 EDT 2016

b2s xof unkeyed kats

--- a/ref/blake2.h
+++ b/ref/blake2.h
@@ -159,6 +159,9 @@
   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 );
 
--- a/ref/blake2bp-ref.c
+++ b/ref/blake2bp-ref.c
@@ -35,7 +35,8 @@
   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 @@
   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 ) );
--- a/ref/blake2sp-ref.c
+++ b/ref/blake2sp-ref.c
@@ -34,7 +34,8 @@
   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 @@
   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 ) );
--- a/ref/genkat-c.c
+++ b/ref/genkat-c.c
@@ -65,7 +65,30 @@
   \
 } 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 )
 {
   uint8_t key[64] = {0};
@@ -90,6 +113,7 @@
   MAKE_KEYED_KAT( blake2sp, BLAKE2S );
   MAKE_KAT( blake2bp, BLAKE2B );
   MAKE_KEYED_KAT( blake2bp, BLAKE2B );
+  MAKE_XOF_KAT( blake2xs );
   puts( "#endif" );
   return 0;
 }
--- a/ref/makefile
+++ b/ref/makefile
@@ -31,8 +31,8 @@
 	        ./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
 
--