1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

core: disable trezor-crypto BIP32 cache

This commit is contained in:
matejcik 2020-04-29 10:59:10 +02:00 committed by matejcik
parent 67c09020ab
commit 2cedc687e6
3 changed files with 13 additions and 12 deletions

View File

@ -36,6 +36,7 @@ CPPDEFINES_MOD += [
'AES_128', 'AES_128',
'AES_192', 'AES_192',
'RAND_PLATFORM_INDEPENDENT', 'RAND_PLATFORM_INDEPENDENT',
('USE_BIP32_CACHE', '0'),
('USE_KECCAK', '1'), ('USE_KECCAK', '1'),
('USE_ETHEREUM', '1' if EVERYTHING else '0'), ('USE_ETHEREUM', '1' if EVERYTHING else '0'),
('USE_MONERO', '1' if EVERYTHING else '0'), ('USE_MONERO', '1' if EVERYTHING else '0'),

View File

@ -34,6 +34,7 @@ CPPPATH_MOD += [
CPPDEFINES_MOD += [ CPPDEFINES_MOD += [
'AES_128', 'AES_128',
'AES_192', 'AES_192',
('USE_BIP32_CACHE', '0'),
('USE_KECCAK', '1'), ('USE_KECCAK', '1'),
('USE_ETHEREUM', '1' if EVERYTHING else '0'), ('USE_ETHEREUM', '1' if EVERYTHING else '0'),
('USE_MONERO', '1' if EVERYTHING else '0'), ('USE_MONERO', '1' if EVERYTHING else '0'),

View File

@ -240,19 +240,18 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_derive_path(mp_obj_t self,
mp_raise_ValueError("Path cannot be longer than 32 indexes"); mp_raise_ValueError("Path cannot be longer than 32 indexes");
} }
// convert path to int array for (uint32_t pi = 0; pi < plen; pi++) {
uint32_t pi; if (pi == plen - 1) {
uint32_t pints[plen]; // fingerprint is calculated from the parent of the final derivation
for (pi = 0; pi < plen; pi++) { o->fingerprint = hdnode_fingerprint(&o->hdnode);
pints[pi] = trezor_obj_get_uint(pitems[pi]);
} }
uint32_t pitem = trezor_obj_get_uint(pitems[pi]);
if (!hdnode_private_ckd_cached(&o->hdnode, pints, plen, &o->fingerprint)) { if (!hdnode_private_ckd(&o->hdnode, pitem)) {
// derivation failed, reset the state and raise
o->fingerprint = 0; o->fingerprint = 0;
memzero(&o->hdnode, sizeof(o->hdnode)); memzero(&o->hdnode, sizeof(o->hdnode));
mp_raise_ValueError("Failed to derive path"); mp_raise_ValueError("Failed to derive path");
} }
}
return mp_const_none; return mp_const_none;
} }