Code improvements / Fix warnings

- Fix CodeQL warnings
- Port lots of improvements/fixes from PR #225
- replace 'array_hexstr' and '%*H' format by sdk function 'format_hex'
- Add 'noreturn' attribute in 'main.c'
This commit is contained in:
Charles-Edouard de la Vergne
2024-04-12 16:40:05 +02:00
parent 90d536402b
commit aa38ee9959
29 changed files with 103 additions and 71 deletions

View File

@@ -2,6 +2,7 @@
#include "shared_context.h"
#include "ui_callbacks.h"
#include "ui_nbgl.h"
#include "uint_common.h"
static void reviewReject(void) {
io_seproxyhal_touch_address_cancel(NULL);
@@ -21,7 +22,10 @@ static void reviewChoice(bool confirm) {
}
static void buildScreen(void) {
snprintf(strings.tmp.tmp, 100, "0x%.*H", 48, tmpCtx.publicKeyContext.publicKey.W);
bytes_to_string(strings.tmp.tmp,
sizeof(strings.tmp.tmp),
tmpCtx.publicKeyContext.publicKey.W,
48);
nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice);
}

View File

@@ -4,13 +4,14 @@
#include "network.h"
#include "ui_message_signing.h"
#include "ui_signing.h"
#include "uint_common.h"
static nbgl_layoutTagValue_t pairs[2];
static void start_review(void); // forward declaration
static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) {
snprintf(buffer + offset, buffer_size - offset, "0x%.*H", KECCAK256_HASH_BYTESIZE, hash);
bytes_to_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE);
return buffer + offset;
}