mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-02 02:41:28 +00:00
Revert "simplify cryptoMessageVerify call"
This reverts commit 3a42032c63
.
This commit is contained in:
parent
c0181b1aec
commit
7ddccdb7f4
@ -142,7 +142,7 @@ int cryptoMessageSign(const CoinType *coin, HDNode *node, const uint8_t *message
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t message_len, const uint8_t *address_raw, const 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)
|
||||||
{
|
{
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
uint8_t pubkey[65], addr_raw[MAX_ADDR_RAW_SIZE], hash[32];
|
uint8_t pubkey[65], addr_raw[MAX_ADDR_RAW_SIZE], hash[32];
|
||||||
@ -173,10 +173,6 @@ int cryptoMessageVerify(const CoinType *coin, const uint8_t *message, size_t mes
|
|||||||
pubkey[0] = 0x02 | (pubkey[64] & 1);
|
pubkey[0] = 0x02 | (pubkey[64] & 1);
|
||||||
}
|
}
|
||||||
// check if the address is correct
|
// check if the address is correct
|
||||||
uint32_t address_type;
|
|
||||||
if (!coinExtractAddressType(coin, address_raw, &address_type)) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
ecdsa_get_address_raw(pubkey, address_type, addr_raw);
|
ecdsa_get_address_raw(pubkey, address_type, addr_raw);
|
||||||
if (memcmp(addr_raw, address_raw, address_prefix_bytes_len(address_type) + 20) != 0) {
|
if (memcmp(addr_raw, address_raw, address_prefix_bytes_len(address_type) + 20) != 0) {
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -41,7 +41,7 @@ int cryptoGetECDHSessionKey(const HDNode *node, const uint8_t *peer_public_key,
|
|||||||
|
|
||||||
int cryptoMessageSign(const CoinType *coin, HDNode *node, const uint8_t *message, size_t message_len, uint8_t *signature);
|
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, const uint8_t *address_raw, const 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);
|
||||||
|
|
||||||
/* ECIES disabled
|
/* 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);
|
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);
|
||||||
|
@ -756,11 +756,12 @@ void fsm_msgVerifyMessage(VerifyMessage *msg)
|
|||||||
if (!coin) return;
|
if (!coin) return;
|
||||||
layoutProgressSwipe("Verifying", 0);
|
layoutProgressSwipe("Verifying", 0);
|
||||||
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
|
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
|
||||||
if (!ecdsa_address_decode(msg->address, coin->address_type, addr_raw)) {
|
uint32_t address_type;
|
||||||
|
if (!coinExtractAddressType(coin, (const uint8_t *)msg->address, &address_type) || !ecdsa_address_decode(msg->address, address_type, addr_raw)) {
|
||||||
fsm_sendFailure(FailureType_Failure_InvalidSignature, "Invalid address");
|
fsm_sendFailure(FailureType_Failure_InvalidSignature, "Invalid address");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg->signature.size == 65 && cryptoMessageVerify(coin, msg->message.bytes, msg->message.size, addr_raw, msg->signature.bytes) == 0) {
|
if (msg->signature.size == 65 && cryptoMessageVerify(coin, msg->message.bytes, msg->message.size, address_type, addr_raw, msg->signature.bytes) == 0) {
|
||||||
layoutVerifyAddress(msg->address);
|
layoutVerifyAddress(msg->address);
|
||||||
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
||||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Message verification cancelled");
|
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Message verification cancelled");
|
||||||
|
Loading…
Reference in New Issue
Block a user