mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
feat(crypto): API for clearing internal caches
This commit is contained in:
parent
0e27423cff
commit
2ce1e6ba7d
@ -374,6 +374,13 @@ static CONFIDENTIAL struct {
|
|||||||
HDNode node;
|
HDNode node;
|
||||||
} private_ckd_cache[BIP32_CACHE_SIZE];
|
} private_ckd_cache[BIP32_CACHE_SIZE];
|
||||||
|
|
||||||
|
void bip32_cache_clear(void) {
|
||||||
|
private_ckd_cache_root_set = false;
|
||||||
|
private_ckd_cache_index = 0;
|
||||||
|
memzero(&private_ckd_cache_root, sizeof(private_ckd_cache_root));
|
||||||
|
memzero(private_ckd_cache, sizeof(private_ckd_cache));
|
||||||
|
}
|
||||||
|
|
||||||
int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count,
|
int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count,
|
||||||
uint32_t *fingerprint) {
|
uint32_t *fingerprint) {
|
||||||
if (i_count == 0) {
|
if (i_count == 0) {
|
||||||
|
@ -89,6 +89,7 @@ void hdnode_public_ckd_address_optimized(const curve_point *pub,
|
|||||||
int addrsize, int addrformat);
|
int addrsize, int addrformat);
|
||||||
|
|
||||||
#if USE_BIP32_CACHE
|
#if USE_BIP32_CACHE
|
||||||
|
void bip32_cache_clear(void);
|
||||||
int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count,
|
int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count,
|
||||||
uint32_t *fingerprint);
|
uint32_t *fingerprint);
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,6 +44,11 @@ static CONFIDENTIAL struct {
|
|||||||
uint8_t seed[512 / 8];
|
uint8_t seed[512 / 8];
|
||||||
} bip39_cache[BIP39_CACHE_SIZE];
|
} bip39_cache[BIP39_CACHE_SIZE];
|
||||||
|
|
||||||
|
void bip39_cache_clear(void) {
|
||||||
|
memzero(bip39_cache, sizeof(bip39_cache));
|
||||||
|
bip39_cache_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *mnemonic_generate(int strength) {
|
const char *mnemonic_generate(int strength) {
|
||||||
|
@ -27,9 +27,15 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
#define BIP39_WORDS 2048
|
#define BIP39_WORDS 2048
|
||||||
#define BIP39_PBKDF2_ROUNDS 2048
|
#define BIP39_PBKDF2_ROUNDS 2048
|
||||||
|
|
||||||
|
#if USE_BIP39_CACHE
|
||||||
|
void bip39_cache_clear(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *mnemonic_generate(int strength); // strength in bits
|
const char *mnemonic_generate(int strength); // strength in bits
|
||||||
const char *mnemonic_from_data(const uint8_t *data, int len);
|
const char *mnemonic_from_data(const uint8_t *data, int len);
|
||||||
void mnemonic_clear(void);
|
void mnemonic_clear(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user