diff --git a/firmware/crypto.c b/firmware/crypto.c index b3e3ce152..0f8344efe 100644 --- a/firmware/crypto.c +++ b/firmware/crypto.c @@ -141,7 +141,7 @@ int cryptoMessageSign(const CoinType *coin, HDNode *node, const uint8_t *message return result; } -int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t message_len, uint32_t address_type, const uint8_t *address_raw, const uint8_t *signature) +int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t message_len, const uint8_t *address_raw, const uint8_t *signature) { SHA256_CTX ctx; uint8_t pubkey[65], addr_raw[MAX_ADDR_RAW_SIZE], hash[32]; @@ -172,8 +172,8 @@ int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t mes pubkey[0] = 0x02 | (pubkey[64] & 1); } // check if the address is correct - ecdsa_get_address_raw(pubkey, address_type, addr_raw); - if (memcmp(addr_raw, address_raw, prefixBytesByAddressType(address_type) + 20) != 0) { + ecdsa_get_address_raw(pubkey, coin->address_type, addr_raw); + if (memcmp(addr_raw, address_raw, prefixBytesByAddressType(coin->address_type) + 20) != 0) { return 2; } return 0; diff --git a/firmware/crypto.h b/firmware/crypto.h index ff97f91f2..28f11bf05 100644 --- a/firmware/crypto.h +++ b/firmware/crypto.h @@ -39,10 +39,9 @@ int gpgMessageSign(HDNode *node, const uint8_t *message, size_t message_len, uin int cryptoGetECDHSessionKey(const HDNode *node, const uint8_t *peer_public_key, uint8_t *session_key); - int cryptoMessageSign(const CoinType *coin, HDNode *node, const uint8_t *message, size_t message_len, uint8_t *signature); -int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t message_len, uint32_t address_type, const uint8_t *address_raw, const uint8_t *signature); +int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t message_len, const uint8_t *address_raw, const uint8_t *signature); /* ECIES disabled int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, size_t msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t *payload, size_t *payload_len, uint8_t *hmac, size_t *hmac_len, const uint8_t *privkey, const uint8_t *address_raw); diff --git a/firmware/fsm.c b/firmware/fsm.c index c2b5dd57a..144b8d1b4 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -756,12 +756,11 @@ void fsm_msgVerifyMessage(VerifyMessage *msg) if (!coin) return; layoutProgressSwipe("Verifying", 0); uint8_t addr_raw[MAX_ADDR_RAW_SIZE]; - uint32_t address_type; - if (!getAddressType(coin, (const uint8_t *) msg->address, &address_type) || !ecdsa_address_decode(msg->address, address_type, addr_raw)) { + if (!ecdsa_address_decode(msg->address, coin->address_type, addr_raw)) { fsm_sendFailure(FailureType_Failure_InvalidSignature, "Invalid address"); return; } - if (msg->signature.size == 65 && cryptoMessageVerify(coin, msg->message.bytes, msg->message.size, address_type, addr_raw, msg->signature.bytes) == 0) { + if (msg->signature.size == 65 && cryptoMessageVerify(coin, msg->message.bytes, msg->message.size, addr_raw, msg->signature.bytes) == 0) { layoutVerifyAddress(msg->address); if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) { fsm_sendFailure(FailureType_Failure_ActionCancelled, "Message verification cancelled");