diff --git a/ethereum-plugin-sdk b/ethereum-plugin-sdk index 2bf928b..2ced76b 160000 --- a/ethereum-plugin-sdk +++ b/ethereum-plugin-sdk @@ -1 +1 @@ -Subproject commit 2bf928b2c14b15e4f3f42a24af4caf54493fb5b3 +Subproject commit 2ced76b8a311456ac7d27ec7d37b683d65a24a4d diff --git a/src/uint_common.c b/src/uint_common.c index bdb51f4..5fe06a7 100644 --- a/src/uint_common.c +++ b/src/uint_common.c @@ -58,20 +58,3 @@ void reverseString(char *const str, uint32_t length) { str[j] = c; } } - -int bytes_to_string(char *out, size_t outl, const void *value, size_t len) { - if (outl <= 2) { - // Need at least '0x' and 1 digit - return -1; - } - if (strlcpy(out, "0x", outl) != 2) { - goto err; - } - if (format_hex(value, len, out + 2, outl - 2) < 0) { - goto err; - } - return 0; -err: - *out = '\0'; - return -1; -} diff --git a/src/uint_common.h b/src/uint_common.h index 59c726a..c0e9ac2 100644 --- a/src/uint_common.h +++ b/src/uint_common.h @@ -35,6 +35,4 @@ void read_u64_be(const uint8_t *const in, uint64_t *const out); uint64_t readUint64BE(const uint8_t *const buffer); void reverseString(char *const str, uint32_t length); -int bytes_to_string(char *out, size_t outl, const void *value, size_t len); - #endif //_UINT_COMMON_H_ diff --git a/src_bagl/ui_flow_getEth2PublicKey.c b/src_bagl/ui_flow_getEth2PublicKey.c index 2eedfa0..cccf070 100644 --- a/src_bagl/ui_flow_getEth2PublicKey.c +++ b/src_bagl/ui_flow_getEth2PublicKey.c @@ -5,10 +5,10 @@ #include "uint_common.h" void prepare_eth2_public_key() { - bytes_to_string(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - tmpCtx.publicKeyContext.publicKey.W, - 48); + array_bytes_string(strings.tmp.tmp, + sizeof(strings.tmp.tmp), + tmpCtx.publicKeyContext.publicKey.W, + 48); } // clang-format off diff --git a/src_bagl/ui_flow_signMessage712_v0.c b/src_bagl/ui_flow_signMessage712_v0.c index 386c502..72c6435 100644 --- a/src_bagl/ui_flow_signMessage712_v0.c +++ b/src_bagl/ui_flow_signMessage712_v0.c @@ -4,17 +4,17 @@ #include "uint_common.h" void prepare_domain_hash_v0() { - bytes_to_string(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - tmpCtx.messageSigningContext712.domainHash, - KECCAK256_HASH_BYTESIZE); + array_bytes_string(strings.tmp.tmp, + sizeof(strings.tmp.tmp), + tmpCtx.messageSigningContext712.domainHash, + KECCAK256_HASH_BYTESIZE); } void prepare_message_hash_v0() { - bytes_to_string(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - tmpCtx.messageSigningContext712.messageHash, - KECCAK256_HASH_BYTESIZE); + array_bytes_string(strings.tmp.tmp, + sizeof(strings.tmp.tmp), + tmpCtx.messageSigningContext712.messageHash, + KECCAK256_HASH_BYTESIZE); } // clang-format off diff --git a/src_features/signMessageEIP712/ui_logic.c b/src_features/signMessageEIP712/ui_logic.c index 54598f1..1c5b4dd 100644 --- a/src_features/signMessageEIP712/ui_logic.c +++ b/src_features/signMessageEIP712/ui_logic.c @@ -166,10 +166,10 @@ void ui_712_message_hash(void) { const char *const title = "Message hash"; ui_712_set_title(title, strlen(title)); - bytes_to_string(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - tmpCtx.messageSigningContext712.messageHash, - KECCAK256_HASH_BYTESIZE); + array_bytes_string(strings.tmp.tmp, + sizeof(strings.tmp.tmp), + tmpCtx.messageSigningContext712.messageHash, + KECCAK256_HASH_BYTESIZE); ui_712_redraw_generic_step(); } @@ -286,7 +286,7 @@ static bool ui_712_format_bool(const uint8_t *const data, uint8_t length) { */ static void ui_712_format_bytes(const uint8_t *const data, uint8_t length) { if (ui_712_field_shown()) { - bytes_to_string(strings.tmp.tmp, sizeof(strings.tmp.tmp), data, length); + array_bytes_string(strings.tmp.tmp, sizeof(strings.tmp.tmp), data, length); // +2 for the "0x" // x2 for each byte value is represented by 2 ASCII characters if ((2 + (length * 2)) > (sizeof(strings.tmp.tmp) - 1)) { diff --git a/src_nbgl/ui_get_eth2_public_key.c b/src_nbgl/ui_get_eth2_public_key.c index 4c1a5f6..99d09a5 100644 --- a/src_nbgl/ui_get_eth2_public_key.c +++ b/src_nbgl/ui_get_eth2_public_key.c @@ -21,10 +21,10 @@ static void reviewChoice(bool confirm) { } void ui_display_public_eth2(void) { - bytes_to_string(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - tmpCtx.publicKeyContext.publicKey.W, - 48); + array_bytes_string(strings.tmp.tmp, + sizeof(strings.tmp.tmp), + tmpCtx.publicKeyContext.publicKey.W, + 48); strlcpy(g_stax_shared_buffer, "Verify ETH2\naddress", sizeof(g_stax_shared_buffer)); nbgl_useCaseAddressReview(strings.tmp.tmp, NULL, diff --git a/src_nbgl/ui_sign_712_v0.c b/src_nbgl/ui_sign_712_v0.c index 6c8a81d..85e6bd4 100644 --- a/src_nbgl/ui_sign_712_v0.c +++ b/src_nbgl/ui_sign_712_v0.c @@ -18,7 +18,7 @@ static void messageReviewChoice_cb(bool confirm) { } static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) { - bytes_to_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE); + array_bytes_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE); return buffer + offset; }