Update ethereum plugin-sdk

This commit is contained in:
Charles-Edouard de la Vergne
2024-05-07 16:01:12 +02:00
parent 817e7a846a
commit c0d19fdf6d
8 changed files with 23 additions and 42 deletions

View File

@@ -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;
}

View File

@@ -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_

View File

@@ -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

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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,

View File

@@ -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;
}