Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Commit

Permalink
fix static usage
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Jun 9, 2014
1 parent b16e36f commit e588906
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bip39.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const char *mnemonic_generate(int strength)
if (strength % 32 || strength < 128 || strength > 256) {
return 0;
}
static uint8_t data[32];
uint8_t data[32];
random_buffer(data, 32);
return mnemonic_from_data(data, strength / 8);
}
Expand All @@ -47,10 +47,11 @@ const char *mnemonic_from_data(const uint8_t *data, int len)
}

uint8_t bits[32 + 1];
memcpy(bits, data, len);

sha256_Raw(data, len, bits);
// checksum
bits[len] = bits[0];
// data
memcpy(bits, data, len);

int mlen = len * 3 / 4;
Expand Down Expand Up @@ -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))
{
static uint8_t salt[8 + 256 + 4];
uint8_t salt[8 + 256 + 4];
int saltlen = strlen(passphrase);
memcpy(salt, "mnemonic", 8);
memcpy(salt + 8, passphrase, saltlen);
Expand Down

0 comments on commit e588906

Please sign in to comment.