mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 03:50:58 +00:00
blake2s: add InitPersonal
This commit is contained in:
parent
669acd7331
commit
c26867d6f2
@ -30,8 +30,8 @@ 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, size_t personal_len);
|
||||
int blake2b_InitKey(blake2b_state *S, size_t outlen, const void *key, size_t keylen);
|
||||
int blake2b_InitPersonal(blake2b_state *S, size_t outlen, const void *personal, size_t personal_len);
|
||||
int blake2b_Update(blake2b_state *S, const void *pin, size_t inlen);
|
||||
int blake2b_Final(blake2b_state *S, void *out, size_t outlen);
|
||||
|
||||
|
23
blake2s.c
23
blake2s.c
@ -126,6 +126,29 @@ int blake2s_Init( blake2s_state *S, size_t outlen )
|
||||
return blake2s_init_param( S, P );
|
||||
}
|
||||
|
||||
int blake2s_InitPersonal( blake2s_state *S, size_t outlen, const void *personal, size_t personal_len)
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
if ( ( !personal ) || ( personal_len != BLAKE2S_PERSONALBYTES ) ) 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 );
|
||||
store16( &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, BLAKE2S_PERSONALBYTES );
|
||||
return blake2s_init_param( S, P );
|
||||
}
|
||||
|
||||
|
||||
int blake2s_InitKey( blake2s_state *S, size_t outlen, const void *key, size_t keylen )
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
@ -31,6 +31,7 @@ typedef struct __blake2s_state
|
||||
|
||||
int blake2s_Init(blake2s_state *S, size_t outlen);
|
||||
int blake2s_InitKey(blake2s_state *S, size_t outlen, const void *key, size_t keylen);
|
||||
int blake2s_InitPersonal(blake2s_state *S, size_t outlen, const void *personal, size_t personal_len);
|
||||
int blake2s_Update(blake2s_state *S, const void *pin, size_t inlen);
|
||||
int blake2s_Final(blake2s_state *S, void *out, size_t outlen);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user