1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

legacy: small nitpicks related to the new passphrase handling

This commit is contained in:
Pavol Rusnak 2020-02-03 17:38:03 +00:00
parent 15ed5cd19e
commit 73ed2f3450
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
9 changed files with 12 additions and 10 deletions

View File

@ -20,7 +20,7 @@ enum BackupType {
* @next Features * @next Features
*/ */
message Initialize { message Initialize {
optional bytes session_id = 1; // assumed device session id; Trezor clears caches if it is different or empty optional bytes session_id = 3; // assumed device session id; Trezor clears caches if it is different or empty
} }
/** /**

View File

@ -4,6 +4,6 @@
#define VERSION_BUILD 0 #define VERSION_BUILD 0
#define FIX_VERSION_MAJOR 2 #define FIX_VERSION_MAJOR 2
#define FIX_VERSION_MINOR 3 #define FIX_VERSION_MINOR 2
#define FIX_VERSION_PATCH 0 #define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0 #define FIX_VERSION_BUILD 0

View File

@ -22,5 +22,5 @@ class Initialize(p.MessageType):
@classmethod @classmethod
def get_fields(cls) -> Dict: def get_fields(cls) -> Dict:
return { return {
1: ('session_id', p.BytesType, 0), 3: ('session_id', p.BytesType, 0),
} }

View File

@ -1,4 +1,4 @@
Version 1.9.0? [not yet released] Version 1.9.0 [not yet released]
* Disallow changing of settings via dry-run recovery * Disallow changing of settings via dry-run recovery
* Wipe code * Wipe code
* Make LoadDevice debug only and drop its XPRV feature * Make LoadDevice debug only and drop its XPRV feature

View File

@ -558,7 +558,7 @@ const uint8_t *config_getSeed(void) {
// if storage has mnemonic, convert it to node and use it // if storage has mnemonic, convert it to node and use it
char mnemonic[MAX_MNEMONIC_LEN + 1] = {0}; char mnemonic[MAX_MNEMONIC_LEN + 1] = {0};
if (config_getMnemonic(mnemonic, sizeof(mnemonic))) { if (config_getMnemonic(mnemonic, sizeof(mnemonic))) {
char passphrase[51]; char passphrase[MAX_PASSPHRASE_LEN + 1] = {0};
if (!protectPassphrase(passphrase)) { if (!protectPassphrase(passphrase)) {
memzero(mnemonic, sizeof(mnemonic)); memzero(mnemonic, sizeof(mnemonic));
memzero(passphrase, sizeof(passphrase)); memzero(passphrase, sizeof(passphrase));
@ -614,8 +614,7 @@ bool config_getRootNode(HDNode *node, const char *curve) {
if (seed == NULL) { if (seed == NULL) {
return false; return false;
} }
int result; int result = hdnode_from_seed(seed, 64, curve, node);
result = hdnode_from_seed(seed, 64, curve, node);
if (result == 0) { if (result == 0) {
fsm_sendFailure(FailureType_Failure_NotInitialized, _("Unsupported curve")); fsm_sendFailure(FailureType_Failure_NotInitialized, _("Unsupported curve"));
} }

View File

@ -22,6 +22,7 @@ void fsm_msgInitialize(const Initialize *msg) {
signing_abort(); signing_abort();
if (msg && msg->has_session_id && msg->session_id.size == 32) { if (msg && msg->has_session_id && msg->session_id.size == 32) {
if (0 != memcmp(session_getSessionId(), msg->session_id.bytes, 32)) { if (0 != memcmp(session_getSessionId(), msg->session_id.bytes, 32)) {
// If session id was specified but does not match -> clear the cache.
session_clear(false); // do not lock session_clear(false); // do not lock
} }
} else { } else {

View File

@ -351,10 +351,11 @@ bool protectChangeWipeCode(bool removal) {
} }
bool protectPassphrase(char *passphrase) { bool protectPassphrase(char *passphrase) {
memzero(passphrase, MAX_PASSPHRASE_LEN + 1);
bool passphrase_protection = false; bool passphrase_protection = false;
config_getPassphraseProtection(&passphrase_protection); config_getPassphraseProtection(&passphrase_protection);
if (!passphrase_protection) { if (!passphrase_protection) {
passphrase[0] = '\0'; // passphrase already set to empty by memzero above
return true; return true;
} }
@ -387,7 +388,6 @@ bool protectPassphrase(char *passphrase) {
result = false; result = false;
break; break;
} }
// TODO: ask - why ppa->passphrase.size is not working? because of tiny?
strlcpy(passphrase, ppa->passphrase, sizeof(ppa->passphrase)); strlcpy(passphrase, ppa->passphrase, sizeof(ppa->passphrase));
result = true; result = true;
break; break;

View File

@ -24,6 +24,8 @@
#include "messages-common.pb.h" #include "messages-common.pb.h"
#include "secbool.h" #include "secbool.h"
#define MAX_PASSPHRASE_LEN 50
bool protectButton(ButtonRequestType type, bool confirm_only); bool protectButton(ButtonRequestType type, bool confirm_only);
secbool protectPinUiCallback(uint32_t wait, uint32_t progress, secbool protectPinUiCallback(uint32_t wait, uint32_t progress,
const char* message); const char* message);

View File

@ -22,5 +22,5 @@ class Initialize(p.MessageType):
@classmethod @classmethod
def get_fields(cls) -> Dict: def get_fields(cls) -> Dict:
return { return {
1: ('session_id', p.BytesType, 0), 3: ('session_id', p.BytesType, 0),
} }