mirror of
https://github.com/BLAKE2/BLAKE2
synced 2024-11-23 02:42:10 +01:00
adding xof_length for b2x support
This commit is contained in:
parent
c314fb42d4
commit
97c8a0cd55
5
.gitignore
vendored
5
.gitignore
vendored
@ -14,3 +14,8 @@ sse/blake2b
|
||||
sse/blake2bp
|
||||
sse/blake2s
|
||||
sse/blake2sp
|
||||
ref/blake2xs
|
||||
ref/blake2xb
|
||||
sse/blake2xs
|
||||
sse/blake2xb
|
||||
**tags
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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 ) );
|
||||
|
@ -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) ); */
|
||||
|
23
ref/makefile
23
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)
|
||||
|
Loading…
Reference in New Issue
Block a user