diff --git a/src_features/signMessageEIP712/hash_bytes.c b/src_common/hash_bytes.c similarity index 67% rename from src_features/signMessageEIP712/hash_bytes.c rename to src_common/hash_bytes.c index 6f702a4..e6b6437 100644 --- a/src_features/signMessageEIP712/hash_bytes.c +++ b/src_common/hash_bytes.c @@ -1,5 +1,3 @@ -#ifdef HAVE_EIP712_FULL_SUPPORT - #include "hash_bytes.h" /** @@ -9,7 +7,7 @@ * @param[in] n number of bytes to hash * @param[in] hash_ctx pointer to the hashing context */ -void hash_nbytes(const uint8_t *const bytes_ptr, uint8_t n, cx_hash_t *const hash_ctx) { +void hash_nbytes(const uint8_t *bytes_ptr, size_t n, cx_hash_t *hash_ctx) { cx_hash(hash_ctx, 0, bytes_ptr, n, NULL, 0); } @@ -19,8 +17,6 @@ void hash_nbytes(const uint8_t *const bytes_ptr, uint8_t n, cx_hash_t *const has * @param[in] byte byte to hash * @param[in] hash_ctx pointer to the hashing context */ -void hash_byte(uint8_t byte, cx_hash_t *const hash_ctx) { +void hash_byte(uint8_t byte, cx_hash_t *hash_ctx) { hash_nbytes(&byte, 1, hash_ctx); } - -#endif // HAVE_EIP712_FULL_SUPPORT diff --git a/src_common/hash_bytes.h b/src_common/hash_bytes.h new file mode 100644 index 0000000..2928fab --- /dev/null +++ b/src_common/hash_bytes.h @@ -0,0 +1,10 @@ +#ifndef HASH_BYTES_H_ +#define HASH_BYTES_H_ + +#include +#include "cx.h" + +void hash_nbytes(const uint8_t *const bytes_ptr, size_t n, cx_hash_t *hash_ctx); +void hash_byte(uint8_t byte, cx_hash_t *hash_ctx); + +#endif // HASH_BYTES_H_ diff --git a/src_features/signMessageEIP712/hash_bytes.h b/src_features/signMessageEIP712/hash_bytes.h deleted file mode 100644 index 6c1d329..0000000 --- a/src_features/signMessageEIP712/hash_bytes.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef HASH_BYTES_H_ -#define HASH_BYTES_H_ - -#ifdef HAVE_EIP712_FULL_SUPPORT - -#include "cx.h" - -void hash_nbytes(const uint8_t *const bytes_ptr, uint8_t n, cx_hash_t *hash_ctx); -void hash_byte(uint8_t byte, cx_hash_t *hash_ctx); - -#endif // HAVE_EIP712_FULL_SUPPORT - -#endif // HASH_BYTES_H_