1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +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_192',
'RAND_PLATFORM_INDEPENDENT',
('USE_BIP32_CACHE', '0'),
('USE_KECCAK', '1'),
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
('USE_MONERO', '1' if EVERYTHING else '0'),

View File

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

View File

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