1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

config: Remove unused functions config_hasMnemonic() and config_hasNode(). Since mnemonic and node are protected entries, these functions would always return false when storage is locked. We now instead use the INITIALIZED flag which is public.

This commit is contained in:
Andrew Kozlik 2019-02-13 17:12:55 +01:00 committed by Pavol Rusnak
parent 45193ffc1d
commit 6b66c7540c
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 11 additions and 32 deletions

View File

@ -165,12 +165,6 @@ static secbool config_get_bool(uint16_t key, bool *value)
}
}
static secbool config_has_key(uint16_t key)
{
uint16_t len = 0;
return storage_get(key, NULL, 0, &len);
}
static secbool config_get_string(uint16_t key, char *dest, uint16_t dest_size)
{
uint16_t len = 0;
@ -410,17 +404,19 @@ static void config_setNode(const HDNodeType *node) {
if (sectrue == storage_set(KEY_NODE, &storageHDNode, sizeof(storageHDNode))) {
config_set_bool(KEY_INITIALIZED, true);
}
memzero(&storageHDNode, sizeof(storageHDNode));
}
#if DEBUG_LINK
void config_dumpNode(HDNodeType *node)
bool config_dumpNode(HDNodeType *node)
{
memzero(node, sizeof(HDNodeType));
StorageHDNode storageNode;
uint16_t len = 0;
if (sectrue != storage_get(KEY_NODE, &storageNode, sizeof(storageNode), &len) || len != sizeof(StorageHDNode)) {
return;
memzero(&storageNode, sizeof(storageNode));
return false;
}
node->depth = storageNode.depth;
@ -437,6 +433,7 @@ void config_dumpNode(HDNodeType *node)
}
memzero(&storageNode, sizeof(storageNode));
return true;
}
#endif
@ -649,11 +646,6 @@ bool config_setMnemonic(const char *mnemonic)
return false;
}
if (sectrue != config_set_bool(KEY_INITIALIZED, true)) {
storage_delete(KEY_MNEMONIC);
return false;
}
StorageHDNode u2fNode;
memzero(&u2fNode, sizeof(u2fNode));
config_compute_u2froot(mnemonic, &u2fNode);
@ -662,22 +654,14 @@ bool config_setMnemonic(const char *mnemonic)
if (sectrue != ret) {
storage_delete(KEY_MNEMONIC);
storage_delete(KEY_INITIALIZED);
return false;
}
config_set_bool(KEY_INITIALIZED, true);
return true;
}
bool config_hasNode(void)
{
return sectrue == config_has_key(KEY_NODE);
}
bool config_hasMnemonic(void)
{
return sectrue == config_has_key(KEY_MNEMONIC);
}
bool config_getMnemonic(char *dest, uint16_t dest_size)
{
return sectrue == config_get_string(KEY_MNEMONIC, dest, dest_size);

View File

@ -113,12 +113,10 @@ bool session_getState(const uint8_t *salt, uint8_t *state, const char *passphras
bool config_setMnemonic(const char *mnemonic);
bool config_containsMnemonic(const char *mnemonic);
bool config_hasMnemonic(void);
bool config_getMnemonic(char *dest, uint16_t dest_size);
bool config_hasNode(void);
#if DEBUG_LINK
void config_dumpNode(HDNodeType *node);
bool config_dumpNode(HDNodeType *node);
#endif
bool config_containsPin(const char *pin);

View File

@ -52,12 +52,9 @@ void fsm_msgDebugLinkGetState(const DebugLinkGetState *msg)
resp.has_recovery_word_pos = true;
resp.recovery_word_pos = recovery_get_word_pos();
resp.has_mnemonic = config_getMnemonic(resp.mnemonic, sizeof(resp.mnemonic));
resp.has_mnemonic = config_getMnemonic(resp.mnemonic, sizeof(resp.mnemonic));
if (config_hasNode()) {
resp.has_node = true;
config_dumpNode(&(resp.node));
}
resp.has_node = config_dumpNode(&(resp.node));
resp.has_passphrase_protection = config_getPassphraseProtection(&(resp.passphrase_protection));