mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
use fixed param size for mnemonic function
This commit is contained in:
parent
6b66f29c3b
commit
02adc15ec9
7
bip39.c
7
bip39.c
@ -63,10 +63,9 @@ const char *mnemonic_from_data(const uint8_t *data, int len)
|
|||||||
return mnemo;
|
return mnemo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t *seed)
|
void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8])
|
||||||
{
|
{
|
||||||
static uint8_t k[8 + 256];
|
static uint8_t k[8 + 256];
|
||||||
uint8_t *m = seed;
|
|
||||||
int i, kl;
|
int i, kl;
|
||||||
|
|
||||||
kl = strlen(passphrase);
|
kl = strlen(passphrase);
|
||||||
@ -74,8 +73,8 @@ void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t *see
|
|||||||
memcpy(k + 8, passphrase, kl);
|
memcpy(k + 8, passphrase, kl);
|
||||||
kl += 8;
|
kl += 8;
|
||||||
|
|
||||||
hmac_sha512(k, kl, (const uint8_t *)mnemonic, strlen(mnemonic), m);
|
hmac_sha512(k, kl, (const uint8_t *)mnemonic, strlen(mnemonic), seed);
|
||||||
for (i = 1; i < HMAC_ROUNDS; i++) {
|
for (i = 1; i < HMAC_ROUNDS; i++) {
|
||||||
hmac_sha512(k, kl, m, 512 / 8, m);
|
hmac_sha512(k, kl, seed, 512 / 8, seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
bip39.h
2
bip39.h
@ -8,6 +8,6 @@ const char *mnemonic_generate(int strength); // strength in bits
|
|||||||
|
|
||||||
const char *mnemonic_from_data(const uint8_t *data, int len);
|
const char *mnemonic_from_data(const uint8_t *data, int len);
|
||||||
|
|
||||||
void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t *seed);
|
void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user