1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-15 09:50:57 +00:00

fix static usage

This commit is contained in:
Pavol Rusnak 2014-06-09 13:51:31 +02:00
parent b16e36f10e
commit e588906f81

View File

@ -35,7 +35,7 @@ const char *mnemonic_generate(int strength)
if (strength % 32 || strength < 128 || strength > 256) { if (strength % 32 || strength < 128 || strength > 256) {
return 0; return 0;
} }
static uint8_t data[32]; uint8_t data[32];
random_buffer(data, 32); random_buffer(data, 32);
return mnemonic_from_data(data, strength / 8); return mnemonic_from_data(data, strength / 8);
} }
@ -47,10 +47,11 @@ const char *mnemonic_from_data(const uint8_t *data, int len)
} }
uint8_t bits[32 + 1]; uint8_t bits[32 + 1];
memcpy(bits, data, len);
sha256_Raw(data, len, bits); sha256_Raw(data, len, bits);
// checksum
bits[len] = bits[0]; bits[len] = bits[0];
// data
memcpy(bits, data, len); memcpy(bits, data, len);
int mlen = len * 3 / 4; int mlen = len * 3 / 4;
@ -146,7 +147,7 @@ int mnemonic_check(const char *mnemonic)
void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8], void (*progress_callback)(uint32_t current, uint32_t total)) void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8], void (*progress_callback)(uint32_t current, uint32_t total))
{ {
static uint8_t salt[8 + 256 + 4]; uint8_t salt[8 + 256 + 4];
int saltlen = strlen(passphrase); int saltlen = strlen(passphrase);
memcpy(salt, "mnemonic", 8); memcpy(salt, "mnemonic", 8);
memcpy(salt + 8, passphrase, saltlen); memcpy(salt + 8, passphrase, saltlen);