From f0d6a2bba19e15570b45915ce6572ba60211d445 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 18 May 2022 15:00:43 +0200 Subject: [PATCH] Now filters out all fields but the name in the EIP712Domain in the half-blind mode --- src_features/signMessageEIP712/field_hash.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src_features/signMessageEIP712/field_hash.c b/src_features/signMessageEIP712/field_hash.c index 6dde239..da1a997 100644 --- a/src_features/signMessageEIP712/field_hash.c +++ b/src_features/signMessageEIP712/field_hash.c @@ -56,6 +56,10 @@ bool field_hash(const uint8_t *data, { return false; } +#ifdef HAVE_EIP712_HALF_BLIND + uint8_t keylen; + const char *key = get_struct_field_keyname(field_ptr, &keylen); +#endif // HAVE_EIP712_HALF_BLIND field_type = struct_field_type(field_ptr); if (fh->state == FHS_IDLE) // first packet for this frame { @@ -69,9 +73,12 @@ bool field_hash(const uint8_t *data, #ifdef HAVE_EIP712_HALF_BLIND if (path_get_root_type() == ROOT_DOMAIN) { + if ((keylen == 4) && (strncmp(key, "name", keylen) == 0)) + { #endif // HAVE_EIP712_HALF_BLIND ui_712_new_field(field_ptr, data, data_length); #ifdef HAVE_EIP712_HALF_BLIND + } } #endif // HAVE_EIP712_HALF_BLIND } @@ -133,9 +140,14 @@ bool field_hash(const uint8_t *data, #ifdef HAVE_EIP712_HALF_BLIND if (path_get_root_type() == ROOT_DOMAIN) { + uint8_t keylen; + const char *key = get_struct_field_keyname(field_ptr, &keylen); + if ((keylen == 4) && (strncmp(key, "name", keylen) == 0)) + { #endif // HAVE_EIP712_HALF_BLIND ui_712_new_field(field_ptr, data, data_length); #ifdef HAVE_EIP712_HALF_BLIND + } } #endif // HAVE_EIP712_HALF_BLIND } @@ -174,7 +186,8 @@ bool field_hash(const uint8_t *data, path_advance(); fh->state = FHS_IDLE; #ifdef HAVE_EIP712_HALF_BLIND - if (path_get_root_type() == ROOT_MESSAGE) + if ((path_get_root_type() == ROOT_MESSAGE) || + ((keylen != 4) || (strncmp(key, "name", keylen) != 0))) { G_io_apdu_buffer[0] = 0x90; G_io_apdu_buffer[1] = 0x00;