mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
blake2b: Add init with personal key
Necessary for zcash hashing
This commit is contained in:
parent
dba2361728
commit
a4c1d02865
20
blake2b.c
20
blake2b.c
@ -131,6 +131,26 @@ int blake2b_Init( blake2b_state *S, size_t outlen )
|
||||
return blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
int blake2b_InitPersonal( blake2b_state *S, size_t outlen, const void *personal )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
P->digest_length = (uint8_t)outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 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 ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memcpy( P->personal, personal, BLAKE2B_PERSONALBYTES );
|
||||
return blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
int blake2b_InitKey( blake2b_state *S, size_t outlen, const void *key, size_t keylen )
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ typedef struct __blake2b_state
|
||||
#define BLAKE2B_KEY_LENGTH BLAKE2B_KEYBYTES
|
||||
|
||||
int blake2b_Init(blake2b_state *S, size_t outlen);
|
||||
int blake2b_InitPersonal(blake2b_state *S, size_t outlen, const void *personal);
|
||||
int blake2b_InitKey(blake2b_state *S, size_t outlen, const void *key, size_t keylen);
|
||||
int blake2b_Update(blake2b_state *S, const void *pin, size_t inlen);
|
||||
int blake2b_Final(blake2b_state *S, void *out, size_t outlen);
|
||||
|
Loading…
Reference in New Issue
Block a user