diff --git a/firmware/fsm.c b/firmware/fsm.c index 9cc26c3141..97e87957e2 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -109,7 +109,7 @@ void fsm_msgInitialize(Initialize *msg) resp->has_patch_version = true; resp->patch_version = VERSION_PATCH; resp->has_device_id = true; strlcpy(resp->device_id, storage_uuid_str, sizeof(resp->device_id)); resp->has_pin_protection = true; resp->pin_protection = storage.has_pin; - resp->has_passphrase_protection = true; resp->passphrase_protection = storage.passphrase_protection; + resp->has_passphrase_protection = true; resp->passphrase_protection = storage.has_passphrase_protection && storage.passphrase_protection; #ifdef SCM_REVISION resp->has_revision = true; memcpy(resp->revision.bytes, SCM_REVISION, sizeof(resp->revision)); resp->revision.size = SCM_REVISION_LEN; #endif @@ -124,7 +124,8 @@ void fsm_msgInitialize(Initialize *msg) } resp->coins_count = COINS_COUNT; memcpy(resp->coins, coins, COINS_COUNT * sizeof(CoinType)); - resp->has_initialized = true; resp->initialized = storage_isInitialized(); + resp->has_initialized = true; resp->initialized = storage_isInitialized(); + resp->has_imported = true; resp->imported = storage.has_imported && storage.imported; msg_write(MessageType_MessageType_Features, resp); } diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index 22578bca68..8a13557efc 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -1,5 +1,5 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #include "messages.pb.h" @@ -18,7 +18,7 @@ const pb_field_t Initialize_fields[1] = { PB_LAST_FIELD }; -const pb_field_t Features_fields[15] = { +const pb_field_t Features_fields[16] = { PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, Features, vendor, vendor, 0), PB_FIELD2( 2, UINT32 , OPTIONAL, STATIC , OTHER, Features, major_version, vendor, 0), PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, Features, minor_version, major_version, 0), @@ -33,6 +33,7 @@ const pb_field_t Features_fields[15] = { PB_FIELD2( 12, BOOL , OPTIONAL, STATIC , OTHER, Features, initialized, coins, 0), PB_FIELD2( 13, BYTES , OPTIONAL, STATIC , OTHER, Features, revision, initialized, 0), PB_FIELD2( 14, BYTES , OPTIONAL, STATIC , OTHER, Features, bootloader_hash, revision, 0), + PB_FIELD2( 15, BOOL , OPTIONAL, STATIC , OTHER, Features, imported, bootloader_hash, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index 225e8ab092..22713c799c 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -1,5 +1,5 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #ifndef _PB_MESSAGES_PB_H_ #define _PB_MESSAGES_PB_H_ @@ -240,6 +240,8 @@ typedef struct _Features { Features_revision_t revision; bool has_bootloader_hash; Features_bootloader_hash_t bootloader_hash; + bool has_imported; + bool imported; } Features; typedef struct { @@ -485,6 +487,7 @@ extern const char SimpleSignTx_coin_name_default[17]; #define Features_initialized_tag 12 #define Features_revision_tag 13 #define Features_bootloader_hash_tag 14 +#define Features_imported_tag 15 #define FirmwareUpload_payload_tag 1 #define GetAddress_address_n_tag 1 #define GetAddress_coin_name_tag 2 @@ -542,7 +545,7 @@ extern const char SimpleSignTx_coin_name_default[17]; /* Struct field encoding specification for nanopb */ extern const pb_field_t Initialize_fields[1]; -extern const pb_field_t Features_fields[15]; +extern const pb_field_t Features_fields[16]; extern const pb_field_t ApplySettings_fields[3]; extern const pb_field_t ChangePin_fields[2]; extern const pb_field_t Ping_fields[5]; @@ -588,7 +591,7 @@ extern const pb_field_t DebugLinkLog_fields[4]; /* Maximum encoded size of messages (where known) */ #define Initialize_size 0 -#define Features_size (222 + 4*CoinType_size) +#define Features_size (224 + 4*CoinType_size) #define ApplySettings_size 54 #define ChangePin_size 2 #define Ping_size 265 diff --git a/firmware/protob/storage.pb.c b/firmware/protob/storage.pb.c index ac40b48b32..7625797cf2 100644 --- a/firmware/protob/storage.pb.c +++ b/firmware/protob/storage.pb.c @@ -1,11 +1,11 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #include "storage.pb.h" -const pb_field_t Storage_fields[9] = { +const pb_field_t Storage_fields[10] = { PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, Storage, version, version, 0), PB_FIELD2( 2, MESSAGE , OPTIONAL, STATIC , OTHER, Storage, node, version, &HDNodeType_fields), PB_FIELD2( 3, STRING , OPTIONAL, STATIC , OTHER, Storage, mnemonic, node, 0), @@ -14,6 +14,7 @@ const pb_field_t Storage_fields[9] = { PB_FIELD2( 6, STRING , OPTIONAL, STATIC , OTHER, Storage, pin, pin_failed_attempts, 0), PB_FIELD2( 7, STRING , OPTIONAL, STATIC , OTHER, Storage, language, pin, 0), PB_FIELD2( 8, STRING , OPTIONAL, STATIC , OTHER, Storage, label, language, 0), + PB_FIELD2( 9, BOOL , OPTIONAL, STATIC , OTHER, Storage, imported, label, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/storage.pb.h b/firmware/protob/storage.pb.h index 3e7824c97a..1814c27c47 100644 --- a/firmware/protob/storage.pb.h +++ b/firmware/protob/storage.pb.h @@ -1,5 +1,5 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #ifndef _PB_STORAGE_PB_H_ #define _PB_STORAGE_PB_H_ @@ -28,6 +28,8 @@ typedef struct _Storage { char language[17]; bool has_label; char label[33]; + bool has_imported; + bool imported; } Storage; /* Default values for struct fields */ @@ -41,12 +43,13 @@ typedef struct _Storage { #define Storage_pin_tag 6 #define Storage_language_tag 7 #define Storage_label_tag 8 +#define Storage_imported_tag 9 /* Struct field encoding specification for nanopb */ -extern const pb_field_t Storage_fields[9]; +extern const pb_field_t Storage_fields[10]; /* Maximum encoded size of messages (where known) */ -#define Storage_size (330 + HDNodeType_size) +#define Storage_size (332 + HDNodeType_size) #ifdef __cplusplus } /* extern "C" */ diff --git a/firmware/protob/types.pb.c b/firmware/protob/types.pb.c index 587f391dac..5b6ef600a0 100644 --- a/firmware/protob/types.pb.c +++ b/firmware/protob/types.pb.c @@ -1,5 +1,5 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #include "types.pb.h" diff --git a/firmware/protob/types.pb.h b/firmware/protob/types.pb.h index 9c2b7225c0..b910112621 100644 --- a/firmware/protob/types.pb.h +++ b/firmware/protob/types.pb.h @@ -1,5 +1,5 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.2.7 */ +/* Generated by nanopb-0.2.8 */ #ifndef _PB_TYPES_PB_H_ #define _PB_TYPES_PB_H_ diff --git a/firmware/storage.c b/firmware/storage.c index 3351d1482b..5a993f5aa9 100644 --- a/firmware/storage.c +++ b/firmware/storage.c @@ -141,6 +141,9 @@ void storage_loadDevice(LoadDevice *msg) { storage_reset(); + storage.has_imported = true; + storage.imported = true; + if (msg->has_pin > 0) { storage_setPin(msg->pin); } @@ -212,7 +215,7 @@ bool storage_getRootNode(HDNode *node) return false; } hdnode_from_xprv(storage.node.depth, storage.node.fingerprint, storage.node.child_num, storage.node.chain_code.bytes, storage.node.private_key.bytes, &sessionRootNode); - if (storage.has_passphrase_protection > 0) { + if (storage.has_passphrase_protection && storage.passphrase_protection) { // decrypt hd node aes_ctx ctx; aes_enc_key((const uint8_t *)sessionPassphrase, strlen(sessionPassphrase), &ctx); diff --git a/trezor-common b/trezor-common index e4f9dcd7c9..1865a0428d 160000 --- a/trezor-common +++ b/trezor-common @@ -1 +1 @@ -Subproject commit e4f9dcd7c966c136bd33ccc58321db8d8b83d09b +Subproject commit 1865a0428d1803416174f31a1d6b53b6632384a9