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:
parent
67c09020ab
commit
2cedc687e6
@ -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'),
|
||||
|
@ -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'),
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user