mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
show verified message & wait for button
This commit is contained in:
parent
efe6e552da
commit
c8faf4aeaa
@ -591,9 +591,8 @@ void fsm_msgVerifyMessage(VerifyMessage *msg)
|
||||
{
|
||||
const char *address = msg->has_address ? msg->address : 0;
|
||||
if (msg->signature.size == 65 && transactionMessageVerify(msg->message.bytes, msg->message.size, msg->signature.bytes, address)) {
|
||||
// TODO: show verified message & wait for button
|
||||
// layoutDialogSwipe(DIALOG_ICON_INFO, NULL, "OK", NULL, "Verified message", NULL, NULL, NULL, NULL, NULL);
|
||||
// protectButton(ButtonRequestType_ButtonRequest_Other, true);
|
||||
layoutVerifyMessage(msg->message.bytes, msg->message.size);
|
||||
protectButton(ButtonRequestType_ButtonRequest_Other, true);
|
||||
fsm_sendSuccess("Message verified");
|
||||
} else {
|
||||
fsm_sendFailure(FailureType_Failure_InvalidSignature, "Invalid signature");
|
||||
|
@ -189,3 +189,45 @@ void layoutSignMessage(const uint8_t *msg, uint32_t len)
|
||||
ascii ? "Sign text message?" : "Sign binary message?",
|
||||
str[0], str[1], str[2], str[3], NULL);
|
||||
}
|
||||
|
||||
void layoutVerifyMessage(const uint8_t *msg, uint32_t len)
|
||||
{
|
||||
bool ascii = true;
|
||||
uint32_t i;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (msg[i] < 0x20 || msg[i] >= 0x80) {
|
||||
ascii = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char str[4][17];
|
||||
memset(str, 0, sizeof(str));
|
||||
if (ascii) {
|
||||
strlcpy(str[0], (char *)msg, 17);
|
||||
if (len > 16) {
|
||||
strlcpy(str[1], (char *)msg + 16, 17);
|
||||
}
|
||||
if (len > 32) {
|
||||
strlcpy(str[2], (char *)msg + 32, 17);
|
||||
}
|
||||
if (len > 48) {
|
||||
strlcpy(str[3], (char *)msg + 48, 17);
|
||||
}
|
||||
} else {
|
||||
data2hex(msg, len > 8 ? 8 : len, str[0]);
|
||||
if (len > 8) {
|
||||
data2hex(msg + 8, len > 16 ? 8 : len - 8, str[1]);
|
||||
}
|
||||
if (len > 16) {
|
||||
data2hex(msg + 16, len > 24 ? 8 : len - 16, str[2]);
|
||||
}
|
||||
if (len > 24) {
|
||||
data2hex(msg + 24, len > 32 ? 8 : len - 24, str[3]);
|
||||
}
|
||||
}
|
||||
|
||||
layoutDialogSwipe(DIALOG_ICON_INFO, NULL, "OK", NULL,
|
||||
ascii ? "Message contents:" : "Bin message contents:",
|
||||
str[0], str[1], str[2], str[3], NULL);
|
||||
}
|
||||
|
@ -31,5 +31,6 @@ void layoutConfirmOutput(const CoinType *coin, const TxOutputType *out);
|
||||
void layoutConfirmTx(const CoinType *coin, uint64_t amount_out, uint64_t amount_fee);
|
||||
void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee, uint32_t kb);
|
||||
void layoutSignMessage(const uint8_t *msg, uint32_t len);
|
||||
void layoutVerifyMessage(const uint8_t *msg, uint32_t len);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user