From fd31def094d2fef399fca55eb45a17216493115c Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 2 May 2022 15:35:31 +0200 Subject: [PATCH] Update app context wrapping --- src_features/signMessageEIP712/hash_wrap.c | 33 ---------------------- src_features/signMessageEIP712/hash_wrap.h | 17 ----------- src_features/signMessageEIP712/type_hash.c | 2 +- 3 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 src_features/signMessageEIP712/hash_wrap.c delete mode 100644 src_features/signMessageEIP712/hash_wrap.h diff --git a/src_features/signMessageEIP712/hash_wrap.c b/src_features/signMessageEIP712/hash_wrap.c deleted file mode 100644 index be54c26..0000000 --- a/src_features/signMessageEIP712/hash_wrap.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include "hash_wrap.h" - -cx_sha3_t global_sha3; - -int cx_keccak_init(cx_hash_t *hash, size_t size) -{ - sha3_context *ctx = (sha3_context*)hash; - - (void)size; - sha3_Init256(ctx); - sha3_SetFlags(ctx, SHA3_FLAGS_KECCAK); - return 0; -} - -int cx_hash(cx_hash_t *hash, int mode, const unsigned char *in, - unsigned int len, unsigned char *out, unsigned int out_len) -{ - sha3_context *ctx = (sha3_context*)hash; - const uint8_t *result; - - sha3_Update(ctx, in, len); - if (mode == CX_LAST) - { - result = sha3_Finalize(ctx); - if (out != NULL) - { - memmove(out, result, out_len); - } - } - return out_len; -} diff --git a/src_features/signMessageEIP712/hash_wrap.h b/src_features/signMessageEIP712/hash_wrap.h deleted file mode 100644 index 5910322..0000000 --- a/src_features/signMessageEIP712/hash_wrap.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef HASH_WRAP_H_ -#define HASH_WRAP_H_ - -#include -#include "sha3.h" - -#define CX_LAST 1 - -typedef sha3_context cx_sha3_t; -typedef struct {} cx_hash_t; - -extern cx_sha3_t global_sha3; - -int cx_keccak_init(cx_hash_t *hash, size_t size); -int cx_hash(cx_hash_t *hash, int mode, const unsigned char *in, - unsigned int len, unsigned char *out, unsigned int out_len); -#endif // HASH_WRAP_H_ diff --git a/src_features/signMessageEIP712/type_hash.c b/src_features/signMessageEIP712/type_hash.c index 3ccad3c..fdd46c7 100644 --- a/src_features/signMessageEIP712/type_hash.c +++ b/src_features/signMessageEIP712/type_hash.c @@ -4,7 +4,7 @@ #include "mem.h" #include "encode_type.h" #include "type_hash.h" -#include "hash_wrap.h" +#include "shared_context.h" const uint8_t *type_hash(const void *const structs_array, const char *const struct_name,