diff --git a/firmware/fsm_msg_coin.h b/firmware/fsm_msg_coin.h index 4f086a5e73..2eb8e3a574 100644 --- a/firmware/fsm_msg_coin.h +++ b/firmware/fsm_msg_coin.h @@ -209,6 +209,8 @@ void fsm_msgGetAddress(GetAddress *msg) void fsm_msgSignMessage(SignMessage *msg) { + // CHECK_PARAM(is_ascii_only(msg->message.bytes, msg->message.size), _("Cannot sign non-ASCII strings")); + RESP_INIT(MessageSignature); CHECK_INITIALIZED diff --git a/firmware/layout2.c b/firmware/layout2.c index 5f8a4ab37d..7ad7e27aac 100644 --- a/firmware/layout2.c +++ b/firmware/layout2.c @@ -296,17 +296,20 @@ void layoutConfirmOutput(const CoinInfo *coin, const TxAck_TransactionType_TxOut render_address_dialog(coin, address, _("Confirm sending"), str_out, extra_line); } -void layoutConfirmOpReturn(const uint8_t *data, uint32_t size) +bool is_valid_ascii(const uint8_t *data, uint32_t size) { - bool ascii_only = true; for (uint32_t i = 0; i < size; i++) { if (data[i] < ' ' || data[i] > '~') { - ascii_only = false; - break; + return false; } } + return true; +} + +void layoutConfirmOpReturn(const uint8_t *data, uint32_t size) +{ const char **str; - if (!ascii_only) { + if (!is_valid_ascii(data, size)) { char hex[65]; memset(hex, 0, sizeof(hex)); data2hex(data, (size > 32) ? 32 : size, hex); diff --git a/firmware/layout2.h b/firmware/layout2.h index b41a1546bd..5c38ad5c22 100644 --- a/firmware/layout2.h +++ b/firmware/layout2.h @@ -72,5 +72,6 @@ void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *defini void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, const uint8_t *data, uint32_t len, bool final_sign); const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen); +bool is_valid_ascii(const uint8_t *data, uint32_t size); #endif