From 1a1ba46e2c18cecfeb2b5d9f7d7f17b4cd2cc596 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 6 Jun 2014 02:37:58 +0200 Subject: [PATCH] update protobuf --- firmware/protob/messages.options | 10 ++--- firmware/protob/messages.pb.c | 20 ++++----- firmware/protob/messages.pb.h | 69 ++++++++++++++------------------ trezor-common | 2 +- 4 files changed, 41 insertions(+), 60 deletions(-) diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index 1d80312653..6e2ffaf64c 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -57,13 +57,9 @@ VerifyMessage.message max_size:256 MessageSignature.address max_size:35 MessageSignature.signature max_size:65 -EncryptKeyValue.address_n max_count:8 -EncryptKeyValue.key max_size:256 -EncryptKeyValue.value max_size:1024 - -DecryptKeyValue.address_n max_count:8 -DecryptKeyValue.key max_size:256 -DecryptKeyValue.value max_size:1024 +CipherKeyValue.address_n max_count:8 +CipherKeyValue.key max_size:256 +CipherKeyValue.value max_size:1024 EstimateTxSize.coin_name max_size:17 diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index 077cd7ea38..63d11333ef 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -205,17 +205,13 @@ const pb_field_t MessageSignature_fields[3] = { PB_LAST_FIELD }; -const pb_field_t EncryptKeyValue_fields[4] = { - PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, EncryptKeyValue, address_n, address_n, 0), - PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, EncryptKeyValue, key, address_n, 0), - PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, EncryptKeyValue, value, key, 0), - PB_LAST_FIELD -}; - -const pb_field_t DecryptKeyValue_fields[4] = { - PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, DecryptKeyValue, address_n, address_n, 0), - PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, DecryptKeyValue, key, address_n, 0), - PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, DecryptKeyValue, value, key, 0), +const pb_field_t CipherKeyValue_fields[7] = { + PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, CipherKeyValue, address_n, address_n, 0), + PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CipherKeyValue, key, address_n, 0), + PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, CipherKeyValue, value, key, 0), + PB_FIELD2( 4, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, encrypt, value, 0), + PB_FIELD2( 5, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_encrypt, encrypt, 0), + PB_FIELD2( 6, BOOL , OPTIONAL, STATIC , OTHER, CipherKeyValue, ask_on_decrypt, ask_on_encrypt, 0), PB_LAST_FIELD }; @@ -311,7 +307,7 @@ const pb_field_t DebugLinkLog_fields[4] = { * numbers or field sizes that are larger than what can fit in 8 or 16 bit * field descriptors. */ -STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptKeyValue_DecryptKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog) +STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_CipherKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog) #endif #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index c3518d1415..b4b62261d5 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -34,8 +34,7 @@ typedef enum _MessageType { MessageType_MessageType_Cancel = 20, MessageType_MessageType_TxRequest = 21, MessageType_MessageType_TxAck = 22, - MessageType_MessageType_EncryptKeyValue = 23, - MessageType_MessageType_DecryptKeyValue = 24, + MessageType_MessageType_CipherKeyValue = 23, MessageType_MessageType_ApplySettings = 25, MessageType_MessageType_ButtonRequest = 26, MessageType_MessageType_ButtonAck = 27, @@ -124,6 +123,26 @@ typedef struct _ChangePin { bool remove; } ChangePin; +typedef struct { + size_t size; + uint8_t bytes[1024]; +} CipherKeyValue_value_t; + +typedef struct _CipherKeyValue { + size_t address_n_count; + uint32_t address_n[8]; + bool has_key; + char key[256]; + bool has_value; + CipherKeyValue_value_t value; + bool has_encrypt; + bool encrypt; + bool has_ask_on_encrypt; + bool ask_on_encrypt; + bool has_ask_on_decrypt; + bool ask_on_decrypt; +} CipherKeyValue; + typedef struct _DebugLinkDecision { bool yes_no; } DebugLinkDecision; @@ -170,34 +189,6 @@ typedef struct _DebugLinkState { uint32_t recovery_word_pos; } DebugLinkState; -typedef struct { - size_t size; - uint8_t bytes[1024]; -} DecryptKeyValue_value_t; - -typedef struct _DecryptKeyValue { - size_t address_n_count; - uint32_t address_n[8]; - bool has_key; - char key[256]; - bool has_value; - DecryptKeyValue_value_t value; -} DecryptKeyValue; - -typedef struct { - size_t size; - uint8_t bytes[1024]; -} EncryptKeyValue_value_t; - -typedef struct _EncryptKeyValue { - size_t address_n_count; - uint32_t address_n[8]; - bool has_key; - char key[256]; - bool has_value; - EncryptKeyValue_value_t value; -} EncryptKeyValue; - typedef struct { size_t size; uint8_t bytes[1024]; @@ -489,6 +480,12 @@ extern const char SimpleSignTx_coin_name_default[17]; #define ButtonRequest_code_tag 1 #define ButtonRequest_data_tag 2 #define ChangePin_remove_tag 1 +#define CipherKeyValue_address_n_tag 1 +#define CipherKeyValue_key_tag 2 +#define CipherKeyValue_value_tag 3 +#define CipherKeyValue_encrypt_tag 4 +#define CipherKeyValue_ask_on_encrypt_tag 5 +#define CipherKeyValue_ask_on_decrypt_tag 6 #define DebugLinkDecision_yes_no_tag 1 #define DebugLinkLog_level_tag 1 #define DebugLinkLog_bucket_tag 2 @@ -503,12 +500,6 @@ extern const char SimpleSignTx_coin_name_default[17]; #define DebugLinkState_reset_entropy_tag 8 #define DebugLinkState_recovery_fake_word_tag 9 #define DebugLinkState_recovery_word_pos_tag 10 -#define DecryptKeyValue_address_n_tag 1 -#define DecryptKeyValue_key_tag 2 -#define DecryptKeyValue_value_tag 3 -#define EncryptKeyValue_address_n_tag 1 -#define EncryptKeyValue_key_tag 2 -#define EncryptKeyValue_value_tag 3 #define Entropy_entropy_tag 1 #define EntropyAck_entropy_tag 1 #define EstimateTxSize_outputs_count_tag 1 @@ -619,8 +610,7 @@ extern const pb_field_t WordAck_fields[2]; extern const pb_field_t SignMessage_fields[4]; extern const pb_field_t VerifyMessage_fields[4]; extern const pb_field_t MessageSignature_fields[3]; -extern const pb_field_t EncryptKeyValue_fields[4]; -extern const pb_field_t DecryptKeyValue_fields[4]; +extern const pb_field_t CipherKeyValue_fields[7]; extern const pb_field_t EstimateTxSize_fields[4]; extern const pb_field_t TxSize_fields[2]; extern const pb_field_t SignTx_fields[4]; @@ -667,8 +657,7 @@ extern const pb_field_t DebugLinkLog_fields[4]; #define SignMessage_size 326 #define VerifyMessage_size 363 #define MessageSignature_size 104 -#define EncryptKeyValue_size 1334 -#define DecryptKeyValue_size 1334 +#define CipherKeyValue_size 1340 #define EstimateTxSize_size 31 #define TxSize_size 6 #define SignTx_size 31 diff --git a/trezor-common b/trezor-common index 06f4aee3fd..f264f01314 160000 --- a/trezor-common +++ b/trezor-common @@ -1 +1 @@ -Subproject commit 06f4aee3fd45ec533e7e0e5a2ac06c98ae9975d6 +Subproject commit f264f01314cefed2df4cfac84d7619d713fbc99a