From a2a72edf830d11dd770fc1d4c4fb199d5bc9e3eb Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Thu, 28 Apr 2022 16:47:48 +0200 Subject: [PATCH] Now initializes field hash struct in eip712 context --- src_features/signMessageEIP712/context.c | 6 ++++++ src_features/signMessageEIP712/field_hash.c | 4 ++-- src_features/signMessageEIP712/field_hash.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src_features/signMessageEIP712/context.c b/src_features/signMessageEIP712/context.c index 56e5d36..de53326 100644 --- a/src_features/signMessageEIP712/context.c +++ b/src_features/signMessageEIP712/context.c @@ -5,6 +5,7 @@ #include "mem.h" #include "sol_typenames.h" #include "path.h" +#include "field_hash.h" uint8_t *typenames_array; uint8_t *structs_array; @@ -29,6 +30,11 @@ bool init_eip712_context(void) return false; } + if (field_hash_init() == false) + { + return false; + } + // set types pointer if ((structs_array = mem_alloc(sizeof(uint8_t))) == NULL) { diff --git a/src_features/signMessageEIP712/field_hash.c b/src_features/signMessageEIP712/field_hash.c index 24361b7..285be28 100644 --- a/src_features/signMessageEIP712/field_hash.c +++ b/src_features/signMessageEIP712/field_hash.c @@ -9,7 +9,7 @@ static s_field_hashing *fh = NULL; -static bool field_hash_init(void) +bool field_hash_init(void) { if (fh == NULL) { @@ -35,7 +35,7 @@ const uint8_t *field_hash(const uint8_t *data, uint8_t *hash_ptr = NULL; (void)data; - if ((fh == NULL) && (field_hash_init() == false)) + if (fh == NULL) { return NULL; } diff --git a/src_features/signMessageEIP712/field_hash.h b/src_features/signMessageEIP712/field_hash.h index 251f5a7..1d0e276 100644 --- a/src_features/signMessageEIP712/field_hash.h +++ b/src_features/signMessageEIP712/field_hash.h @@ -18,6 +18,7 @@ typedef struct uint8_t state; // e_field_hashing_state } s_field_hashing; +bool field_hash_init(void); const uint8_t *field_hash(const uint8_t *data, uint8_t data_length, bool partial);