1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00

firmware: return mnemonic as bytes in debug link

This commit is contained in:
Tomas Susanka 2019-03-12 14:52:55 +01:00
parent 57423c9f54
commit 2646c0901c
4 changed files with 21 additions and 2 deletions

View File

@ -172,6 +172,18 @@ static secbool config_get_bool(uint16_t key, bool *value)
}
}
static secbool config_get_bytes(uint16_t key, uint8_t *dest, uint16_t dest_size, uint16_t *real_size)
{
if (dest_size == 0) {
return secfalse;
}
if (sectrue != storage_get(key, dest, dest_size, real_size)) {
return secfalse;
}
return sectrue;
}
static secbool config_get_string(uint16_t key, char *dest, uint16_t dest_size)
{
if (dest_size == 0) {
@ -688,6 +700,11 @@ bool config_setMnemonic(const char *mnemonic)
return true;
}
bool config_getMnemonicBytes(uint8_t *dest, uint16_t dest_size, uint16_t *real_size)
{
return sectrue == config_get_bytes(KEY_MNEMONIC, dest, dest_size, real_size);
}
bool config_getMnemonic(char *dest, uint16_t dest_size)
{
return sectrue == config_get_string(KEY_MNEMONIC, dest, dest_size);

View File

@ -114,6 +114,7 @@ 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_getMnemonic(char *dest, uint16_t dest_size);
bool config_getMnemonicBytes(uint8_t *dest, uint16_t dest_size, uint16_t *real_size);
#if DEBUG_LINK
bool config_dumpNode(HDNodeType *node);

View File

@ -49,7 +49,8 @@ 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_secret = config_getMnemonicBytes(resp.mnemonic_secret.bytes, sizeof(resp.mnemonic_secret.bytes), &resp.mnemonic_secret.size);
resp.mnemonic_type = 0; // BIP-39
resp.has_node = config_dumpNode(&(resp.node));

View File

@ -3,7 +3,7 @@ DebugLinkDecision.input max_size:33
DebugLinkState.layout max_size:1024
DebugLinkState.pin max_size:10
DebugLinkState.matrix max_size:10
DebugLinkState.mnemonic max_size:241
DebugLinkState.mnemonic_secret max_size:240
DebugLinkState.reset_word max_size:12
DebugLinkState.reset_entropy max_size:128
DebugLinkState.recovery_fake_word max_size:12