Merge pull request #27 from jhoenicke/bip39fix

Off by one error in word length.
pull/25/head
Pavol Rusnak 9 years ago
commit d4df66a8d0

@ -103,7 +103,7 @@ int mnemonic_check(const char *mnemonic)
while (mnemonic[i]) { while (mnemonic[i]) {
j = 0; j = 0;
while (mnemonic[i] != ' ' && mnemonic[i] != 0) { while (mnemonic[i] != ' ' && mnemonic[i] != 0) {
if (j >= sizeof(current_word)) { if (j >= sizeof(current_word) - 1) {
return 0; return 0;
} }
current_word[j] = mnemonic[i]; current_word[j] = mnemonic[i];
@ -145,6 +145,7 @@ int mnemonic_check(const char *mnemonic)
return 0; return 0;
} }
// passphrase must be at most 256 characters or code may crash
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))
{ {
uint8_t salt[8 + 256 + 4]; uint8_t salt[8 + 256 + 4];

@ -34,6 +34,7 @@ const char *mnemonic_from_data(const uint8_t *data, int len);
int mnemonic_check(const char *mnemonic); int mnemonic_check(const char *mnemonic);
// passphrase must be at most 256 characters or code may crash
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));
const char * const *mnemonic_wordlist(void); const char * const *mnemonic_wordlist(void);

Loading…
Cancel
Save