mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 15:30:55 +00:00
layout2: refactor is_valid_ascii function
This commit is contained in:
parent
a3555b9c7c
commit
a6de54520d
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user