feat(crypto): API for clearing internal caches

pull/2091/head
matejcik 2 years ago committed by matejcik
parent 0e27423cff
commit 2ce1e6ba7d

@ -374,6 +374,13 @@ static CONFIDENTIAL struct {
HDNode node;
} 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,
uint32_t *fingerprint) {
if (i_count == 0) {

@ -89,6 +89,7 @@ void hdnode_public_ckd_address_optimized(const curve_point *pub,
int addrsize, int addrformat);
#if USE_BIP32_CACHE
void bip32_cache_clear(void);
int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count,
uint32_t *fingerprint);
#endif

@ -44,6 +44,11 @@ static CONFIDENTIAL struct {
uint8_t seed[512 / 8];
} bip39_cache[BIP39_CACHE_SIZE];
void bip39_cache_clear(void) {
memzero(bip39_cache, sizeof(bip39_cache));
bip39_cache_index = 0;
}
#endif
const char *mnemonic_generate(int strength) {

@ -27,9 +27,15 @@
#include <stdbool.h>
#include <stdint.h>
#include "options.h"
#define BIP39_WORDS 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_from_data(const uint8_t *data, int len);
void mnemonic_clear(void);

Loading…
Cancel
Save