diff --git a/legacy/firmware/Makefile b/legacy/firmware/Makefile index 078282af11..15e32487ee 100644 --- a/legacy/firmware/Makefile +++ b/legacy/firmware/Makefile @@ -141,6 +141,7 @@ OBJS += protob/messages-management.pb.o ifneq ($(BITCOIN_ONLY),1) OBJS += ../vendor/trezor-crypto/cash_addr.o OBJS += protob/messages-ethereum.pb.o +OBJS += protob/messages-ethereum-definitions.pb.o OBJS += protob/messages-nem.pb.o OBJS += protob/messages-stellar.pb.o endif diff --git a/legacy/firmware/ethereum.c b/legacy/firmware/ethereum.c index ac2cdb6d7a..c88547196f 100644 --- a/legacy/firmware/ethereum.c +++ b/legacy/firmware/ethereum.c @@ -555,8 +555,8 @@ static bool ethereum_signing_init_common(struct signing_params *params) { return true; } -static void ethereum_signing_handle_erc20(struct signing_params *params, - const EthereumDefinitionsDecoded *defs) { +static void ethereum_signing_handle_erc20( + struct signing_params *params, const EthereumDefinitionsDecoded *defs) { if (params->has_to && ethereum_parse(params->to, params->pubkeyhash)) { params->pubkeyhash_set = true; } else { @@ -1052,7 +1052,8 @@ bool ethereum_parse(const char *address, uint8_t pubkeyhash[20]) { } bool ethereum_path_check(uint32_t address_n_count, const uint32_t *address_n, - bool pubkey_export, const EthereumDefinitionsDecoded *defs) { + bool pubkey_export, + const EthereumDefinitionsDecoded *defs) { bool valid = (address_n_count >= 3); valid = valid && (address_n[0] == (PATH_HARDENED | 44)); valid = valid && (address_n[1] & PATH_HARDENED); diff --git a/legacy/firmware/ethereum.h b/legacy/firmware/ethereum.h index b7a43fc367..ff5d869d8b 100644 --- a/legacy/firmware/ethereum.h +++ b/legacy/firmware/ethereum.h @@ -45,5 +45,6 @@ void ethereum_typed_hash_sign(const EthereumSignTypedHash *msg, bool ethereum_parse(const char *address, uint8_t pubkeyhash[20]); bool ethereum_path_check(uint32_t address_n_count, const uint32_t *address_n, - bool pubkey_export, const EthereumDefinitionsDecoded *defs); + bool pubkey_export, + const EthereumDefinitionsDecoded *defs); #endif diff --git a/legacy/firmware/ethereum_definitions.c b/legacy/firmware/ethereum_definitions.c index 234675b75b..165bdd4871 100644 --- a/legacy/firmware/ethereum_definitions.c +++ b/legacy/firmware/ethereum_definitions.c @@ -146,8 +146,7 @@ bool _decode_definition(const pb_size_t size, const pb_byte_t *bytes, } if (MIN_DATA_VERSION > parsed_def->data_version) { - fsm_sendFailure(FailureType_Failure_DataError, - _("Definition is outdated")); + fsm_sendFailure(FailureType_Failure_DataError, _("Definition is outdated")); return false; } diff --git a/legacy/firmware/ethereum_definitions.h b/legacy/firmware/ethereum_definitions.h index bc6e86d922..cc390e1f03 100644 --- a/legacy/firmware/ethereum_definitions.h +++ b/legacy/firmware/ethereum_definitions.h @@ -20,7 +20,7 @@ #ifndef __ETHEREUM_DEFINITIONS_H__ #define __ETHEREUM_DEFINITIONS_H__ -#include "messages-ethereum.pb.h" +#include "messages-ethereum-definitions.pb.h" typedef struct { EthereumNetworkInfo network; diff --git a/legacy/firmware/fsm_msg_ethereum.h b/legacy/firmware/fsm_msg_ethereum.h index 2e4a1026db..d2f99c0844 100644 --- a/legacy/firmware/fsm_msg_ethereum.h +++ b/legacy/firmware/fsm_msg_ethereum.h @@ -96,9 +96,8 @@ void fsm_msgEthereumSignTx(const EthereumSignTx *msg) { const EthereumDefinitions_encoded_token_t *encoded_token = NULL; if (msg->has_definitions) { if (msg->definitions.has_encoded_network) { - encoded_network = - (const EthereumDefinitions_encoded_network_t *)&msg - ->definitions.encoded_network; + encoded_network = (const EthereumDefinitions_encoded_network_t *)&msg + ->definitions.encoded_network; } if (msg->definitions.has_encoded_token) { encoded_token = (const EthereumDefinitions_encoded_token_t *)&msg @@ -106,9 +105,9 @@ void fsm_msgEthereumSignTx(const EthereumSignTx *msg) { } } - const EthereumDefinitionsDecoded *defs = - get_EthereumDefinitionsDecoded(encoded_network, encoded_token, msg->chain_id, - msg->has_to ? msg->to : NULL); + const EthereumDefinitionsDecoded *defs = get_EthereumDefinitionsDecoded( + encoded_network, encoded_token, msg->chain_id, + msg->has_to ? msg->to : NULL); if (!defs || !fsm_ethereumCheckPath(msg->address_n_count, msg->address_n, false, defs)) { @@ -132,9 +131,8 @@ void fsm_msgEthereumSignTxEIP1559(const EthereumSignTxEIP1559 *msg) { const EthereumDefinitions_encoded_token_t *encoded_token = NULL; if (msg->has_definitions) { if (msg->definitions.has_encoded_network) { - encoded_network = - (const EthereumDefinitions_encoded_network_t *)&msg - ->definitions.encoded_network; + encoded_network = (const EthereumDefinitions_encoded_network_t *)&msg + ->definitions.encoded_network; } if (msg->definitions.has_encoded_token) { encoded_token = (const EthereumDefinitions_encoded_token_t *)&msg @@ -142,9 +140,9 @@ void fsm_msgEthereumSignTxEIP1559(const EthereumSignTxEIP1559 *msg) { } } - const EthereumDefinitionsDecoded *defs = - get_EthereumDefinitionsDecoded(encoded_network, encoded_token, msg->chain_id, - msg->has_to ? msg->to : NULL); + const EthereumDefinitionsDecoded *defs = get_EthereumDefinitionsDecoded( + encoded_network, encoded_token, msg->chain_id, + msg->has_to ? msg->to : NULL); if (!defs || !fsm_ethereumCheckPath(msg->address_n_count, msg->address_n, false, defs)) { @@ -174,12 +172,12 @@ void fsm_msgEthereumGetAddress(const EthereumGetAddress *msg) { const EthereumDefinitions_encoded_network_t *encoded_network = NULL; if (msg->has_encoded_network) { - encoded_network = (const EthereumDefinitions_encoded_network_t *)&msg - ->encoded_network; + encoded_network = + (const EthereumDefinitions_encoded_network_t *)&msg->encoded_network; } - const EthereumDefinitionsDecoded *defs = - get_EthereumDefinitionsDecoded(encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); + const EthereumDefinitionsDecoded *defs = get_EthereumDefinitionsDecoded( + encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); if (!defs || !fsm_ethereumCheckPath(msg->address_n_count, msg->address_n, false, defs)) { @@ -247,12 +245,12 @@ void fsm_msgEthereumSignMessage(const EthereumSignMessage *msg) { const EthereumDefinitions_encoded_network_t *encoded_network = NULL; if (msg->has_encoded_network) { - encoded_network = (const EthereumDefinitions_encoded_network_t *)&msg - ->encoded_network; + encoded_network = + (const EthereumDefinitions_encoded_network_t *)&msg->encoded_network; } - const EthereumDefinitionsDecoded *defs = - get_EthereumDefinitionsDecoded(encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); + const EthereumDefinitionsDecoded *defs = get_EthereumDefinitionsDecoded( + encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); if (!defs || !fsm_ethereumCheckPath(msg->address_n_count, msg->address_n, false, defs)) { @@ -343,12 +341,12 @@ void fsm_msgEthereumSignTypedHash(const EthereumSignTypedHash *msg) { const EthereumDefinitions_encoded_network_t *encoded_network = NULL; if (msg->has_encoded_network) { - encoded_network = (const EthereumDefinitions_encoded_network_t *)&msg - ->encoded_network; + encoded_network = + (const EthereumDefinitions_encoded_network_t *)&msg->encoded_network; } - const EthereumDefinitionsDecoded *defs = - get_EthereumDefinitionsDecoded(encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); + const EthereumDefinitionsDecoded *defs = get_EthereumDefinitionsDecoded( + encoded_network, NULL, CHAIN_ID_UNKNOWN, NULL); if (!defs || !fsm_ethereumCheckPath(msg->address_n_count, msg->address_n, false, defs)) { diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index a00dd41a76..a763416e00 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -15,7 +15,8 @@ SKIPPED_MESSAGES += Ethereum NEM Stellar endif PROTO_NAMES = messages messages-bitcoin messages-common messages-crypto messages-debug \ - messages-ethereum messages-management messages-nem messages-stellar + messages-ethereum messages-ethereum-definitions messages-management messages-nem \ + messages-stellar PROTO_OPTIONS = $(PROTO_NAMES:=.options) PROTO_COMPILED = $(PROTO_NAMES:=.pb) diff --git a/legacy/firmware/protob/messages-ethereum-definitions.options b/legacy/firmware/protob/messages-ethereum-definitions.options new file mode 100644 index 0000000000..9362fdeea7 --- /dev/null +++ b/legacy/firmware/protob/messages-ethereum-definitions.options @@ -0,0 +1,9 @@ +EthereumNetworkInfo.name max_size:256 +EthereumNetworkInfo.shortcut max_size:256 + +EthereumTokenInfo.name max_size:256 +EthereumTokenInfo.address max_size:20 +EthereumTokenInfo.symbol max_size:256 + +EthereumDefinitions.encoded_network max_size:1024 +EthereumDefinitions.encoded_token max_size:1024 diff --git a/legacy/firmware/protob/messages-ethereum-definitions.proto b/legacy/firmware/protob/messages-ethereum-definitions.proto new file mode 120000 index 0000000000..dd7688aaf0 --- /dev/null +++ b/legacy/firmware/protob/messages-ethereum-definitions.proto @@ -0,0 +1 @@ +../../vendor/trezor-common/protob/messages-ethereum-definitions.proto \ No newline at end of file diff --git a/legacy/firmware/protob/messages-ethereum.options b/legacy/firmware/protob/messages-ethereum.options index b61b95c75f..cebf7c1cb5 100644 --- a/legacy/firmware/protob/messages-ethereum.options +++ b/legacy/firmware/protob/messages-ethereum.options @@ -51,13 +51,3 @@ EthereumGetPublicKey.address_n max_count:8 EthereumAddress._old_address max_size:20 EthereumAddress.address max_size:43 EthereumPublicKey.xpub max_size:113 - -EthereumTokenInfo.name max_size:256 -EthereumTokenInfo.address max_size:20 -EthereumTokenInfo.symbol max_size:256 - -EthereumNetworkInfo.name max_size:256 -EthereumNetworkInfo.shortcut max_size:256 - -EthereumDefinitions.encoded_network max_size:1024 -EthereumDefinitions.encoded_token max_size:1024