1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

feat(crypto): support all bip39 lengths in mnemonic_to_bits

This commit is contained in:
matejcik 2021-10-21 15:07:13 +02:00 committed by matejcik
parent 10e338e005
commit ea0dcff548

View File

@ -109,8 +109,11 @@ int mnemonic_to_bits(const char *mnemonic, uint8_t *bits) {
}
n++;
// check number of words
if (n != 12 && n != 18 && n != 24) {
// check that number of words is valid for BIP-39:
// (a) between 128 and 256 bits of initial entropy (12 - 24 words)
// (b) number of bits divisible by 33 (1 checksum bit per 32 input bits)
// - that is, (n * 11) % 33 == 0, so n % 3 == 0
if (n < 12 || n > 24 || (n % 3)) {
return 0;
}