mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-29 18:08:19 +00:00
fix(legacy): added whole definitions to EthereumSignTypedData
This commit is contained in:
parent
30cdde6902
commit
2af14f9897
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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)
|
||||
|
@ -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
|
1
legacy/firmware/protob/messages-ethereum-definitions.proto
Symbolic link
1
legacy/firmware/protob/messages-ethereum-definitions.proto
Symbolic link
@ -0,0 +1 @@
|
||||
../../vendor/trezor-common/protob/messages-ethereum-definitions.proto
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user