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
diff options
context:
space:
mode:
authorJP Aumasson <jeanphilippe.aumasson@gmail.com>2016-10-11 15:54:09 +0300
committerJP Aumasson <jeanphilippe.aumasson@gmail.com>2016-10-11 15:54:09 +0300
commit97c8a0cd5595d281a9e968124172fc151b9bac14 (patch)
tree239c9cc128cac657fb29c47d8bab9ba73b76a44a
parentc314fb42d4bafa0577de5a7d04c944ad175819c1 (diff)
adding xof_length for b2x support
-rw-r--r--.gitignore5
-rw-r--r--ref/blake2-impl.h11
-rw-r--r--ref/blake2.h6
-rw-r--r--ref/blake2b-ref.c6
-rw-r--r--ref/blake2s-ref.c6
-rw-r--r--ref/makefile23
6 files changed, 44 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 955bd6b..531c8f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,8 @@ sse/blake2b
sse/blake2bp
sse/blake2s
sse/blake2sp
+ref/blake2xs
+ref/blake2xb
+sse/blake2xs
+sse/blake2xb
+**tags
diff --git a/ref/blake2-impl.h b/ref/blake2-impl.h
index 03df0b5..f8c7e75 100644
--- a/ref/blake2-impl.h
+++ b/ref/blake2-impl.h
@@ -64,6 +64,17 @@ static BLAKE2_INLINE uint64_t load64( const void *src )
#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)
diff --git a/ref/blake2.h b/ref/blake2.h
index 6a3069b..7822e52 100644
--- a/ref/blake2.h
+++ b/ref/blake2.h
@@ -94,7 +94,8 @@ extern "C" {
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 @@ extern "C" {
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 */
diff --git a/ref/blake2b-ref.c b/ref/blake2b-ref.c
index f1c7055..0d36fb0 100644
--- a/ref/blake2b-ref.c
+++ b/ref/blake2b-ref.c
@@ -106,7 +106,8 @@ int blake2b_init( blake2b_state *S, size_t outlen )
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 @@ int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t k
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 ) );
diff --git a/ref/blake2s-ref.c b/ref/blake2s-ref.c
index b570fd9..cca1762 100644
--- a/ref/blake2s-ref.c
+++ b/ref/blake2s-ref.c
@@ -102,7 +102,8 @@ int blake2s_init( blake2s_state *S, size_t outlen )
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 @@ int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t k
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) ); */
diff --git a/ref/makefile b/ref/makefile
index 7815544..7835313 100644
--- 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,11 +16,19 @@ blake2sp: blake2sp-ref.c blake2s-ref.c
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
@@ -28,4 +37,4 @@ kat:
./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)