ref: 97c8a0cd5595d281a9e968124172fc151b9bac14
parent: c314fb42d4bafa0577de5a7d04c944ad175819c1
author: JP Aumasson <jeanphilippe.aumasson@gmail.com>
date: Tue Oct 11 10:54:09 EDT 2016
adding xof_length for b2x support
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,8 @@
sse/blake2bp
sse/blake2s
sse/blake2sp
+ref/blake2xs
+ref/blake2xb
+sse/blake2xs
+sse/blake2xb
+**tags
--- a/ref/blake2-impl.h
+++ b/ref/blake2-impl.h
@@ -64,6 +64,17 @@
#endif
}
+static BLAKE2_INLINE void store16( void *dst, uint16_t w )
+{
+#if defined(NATIVE_LITTLE_ENDIAN)
+ memcpy(dst, &w, sizeof w);
+#else
+ uint8_t *p = ( uint8_t * )dst;
+ *p++ = ( uint8_t )w; w >>= 8;
+ *p++ = ( uint8_t )w;
+#endif
+}
+
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
--- a/ref/blake2.h
+++ b/ref/blake2.h
@@ -94,7 +94,8 @@
uint8_t fanout; /* 3 */
uint8_t depth; /* 4 */
uint32_t leaf_length; /* 8 */
- uint8_t node_offset[6];/* 14 */
+ uint32_t node_offset; /* 12 */
+ uint16_t xof_length; /* 14 */
uint8_t node_depth; /* 15 */
uint8_t inner_length; /* 16 */
/* uint8_t reserved[0]; */
@@ -111,7 +112,8 @@
uint8_t fanout; /* 3 */
uint8_t depth; /* 4 */
uint32_t leaf_length; /* 8 */
- uint64_t node_offset; /* 16 */
+ uint32_t node_offset; /* 12 */
+ uint32_t xof_length; /* 16 */
uint8_t node_depth; /* 17 */
uint8_t inner_length; /* 18 */
uint8_t reserved[14]; /* 32 */
--- a/ref/blake2b-ref.c
+++ b/ref/blake2b-ref.c
@@ -106,7 +106,8 @@
P->fanout = 1;
P->depth = 1;
store32( &P->leaf_length, 0 );
- store64( &P->node_offset, 0 );
+ store32( &P->node_offset, 0 );
+ store32( &P->xof_length, 0 );
P->node_depth = 0;
P->inner_length = 0;
memset( P->reserved, 0, sizeof( P->reserved ) );
@@ -129,7 +130,8 @@
P->fanout = 1;
P->depth = 1;
store32( &P->leaf_length, 0 );
- store64( &P->node_offset, 0 );
+ store32( &P->node_offset, 0 );
+ store32( &P->xof_length, 0 );
P->node_depth = 0;
P->inner_length = 0;
memset( P->reserved, 0, sizeof( P->reserved ) );
--- a/ref/blake2s-ref.c
+++ b/ref/blake2s-ref.c
@@ -102,7 +102,8 @@
P->fanout = 1;
P->depth = 1;
store32( &P->leaf_length, 0 );
- store48( &P->node_offset, 0 );
+ store32( &P->node_offset, 0 );
+ store16( &P->xof_length, 0 );
P->node_depth = 0;
P->inner_length = 0;
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
@@ -124,7 +125,8 @@
P->fanout = 1;
P->depth = 1;
store32( &P->leaf_length, 0 );
- store48( &P->node_offset, 0 );
+ store32( &P->node_offset, 0 );
+ store16( &P->xof_length, 0 );
P->node_depth = 0;
P->inner_length = 0;
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
--- a/ref/makefile
+++ b/ref/makefile
@@ -1,7 +1,8 @@
CC=gcc
CFLAGS=-O2 -I../testvectors
+BLAKEBINS=blake2s blake2b blake2sp blake2bp blake2xs blake2xb
-all: blake2s blake2b blake2sp blake2bp check
+all: $(BLAKEBINS) check
blake2s: blake2s-ref.c
$(CC) blake2s-ref.c -o $@ $(CFLAGS) -DBLAKE2S_SELFTEST
@@ -15,12 +16,20 @@
blake2bp: blake2bp-ref.c blake2b-ref.c
$(CC) blake2bp-ref.c blake2b-ref.c -o $@ $(CFLAGS) -DBLAKE2BP_SELFTEST
-check: blake2s blake2b blake2sp blake2bp
- ./blake2s
- ./blake2b
- ./blake2sp
- ./blake2bp
+blake2xs: blake2xs-ref.c blake2s-ref.c
+ $(CC) blake2xs-ref.c blake2s-ref.c -o $@ $(CFLAGS) -DBLAKE2XS_SELFTEST
+blake2xb: blake2xb-ref.c blake2b-ref.c
+ $(CC) blake2xb-ref.c blake2b-ref.c -o $@ $(CFLAGS) -DBLAKE2XB_SELFTEST
+
+check: blake2s blake2b blake2sp blake2bp blake2xs blake2xb
+ ./blake2s
+ ./blake2b
+ ./blake2sp
+ ./blake2bp
+ ./blake2xs
+ ./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
@@ -28,4 +37,4 @@
./genkat-json > blake2-kat.json
clean:
- rm -rf *.o genkat-c genkat-json blake2s blake2b blake2sp blake2bp
+ rm -rf *.o genkat-c genkat-json $(BLAKEBINS)
--
⑨