1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

blake2b: add personal_len to blake2b_InitPersonal

This commit is contained in:
Pavol Rusnak 2018-06-15 10:19:10 +02:00
parent 620902b9b3
commit 669acd7331
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 7 additions and 6 deletions

View File

@ -131,11 +131,12 @@ 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 )
int blake2b_InitPersonal( blake2b_state *S, size_t outlen, const void *personal, size_t personal_len)
{
blake2b_param P[1];
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
if ( ( !personal ) || ( personal_len != BLAKE2B_PERSONALBYTES ) ) return -1;
P->digest_length = (uint8_t)outlen;
P->key_length = 0;

View File

@ -30,7 +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_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_Update(blake2b_state *S, const void *pin, size_t inlen);
int blake2b_Final(blake2b_state *S, void *out, size_t outlen);

View File

@ -38,16 +38,16 @@ void hasher_Init(Hasher *hasher, HasherType type) {
groestl512_Init(&hasher->ctx.groestl);
break;
case HASHER_OVERWINTER_PREVOUTS:
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashPrevoutHash");
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashPrevoutHash", 16);
break;
case HASHER_OVERWINTER_SEQUENCE:
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSequencHash");
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSequencHash", 16);
break;
case HASHER_OVERWINTER_OUTPUTS:
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashOutputsHash");
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashOutputsHash", 16);
break;
case HASHER_OVERWINTER_PREIMAGE:
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSigHash\x19\x1b\xa8\x5b"); // BRANCH_ID = 0x5ba81b19
blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSigHash\x19\x1b\xa8\x5b", 16); // BRANCH_ID = 0x5ba81b19
break;
}
}