Skip to content

Commit

Permalink
Merge pull request #252 from LedgerHQ/fix-analyzer
Browse files Browse the repository at this point in the history
Clean: remove clang warnings
  • Loading branch information
sgliner-ledger authored Dec 19, 2023
2 parents 1b0ac85 + f58ec31 commit 61f525d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/btchip_apdu_hash_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "btchip_bagl_extensions.h"
#include "btchip_display_variables.h"
#include "ui.h"
#include "ledger_assert.h"

#define SIGHASH_ALL 0x01

Expand Down Expand Up @@ -169,11 +170,11 @@ void btchip_bagl_user_action_signtx(unsigned char confirming, unsigned char dire
if (confirming) {
unsigned char hash[32];
if (btchip_context_D.usingOverwinter) {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32);
LEDGER_ASSERT(cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32) == CX_OK, "Hash Failed");
}
else {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, CX_LAST,
hash, 0, hash, 32);
LEDGER_ASSERT(cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, CX_LAST,
hash, 0, hash, 32) == CX_OK, "Hash Failed");
PRINTF("Hash1\n%.*H\n", sizeof(hash), hash);

// Rehash
Expand Down
3 changes: 2 additions & 1 deletion src/btchip_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "btchip_apdu_constants.h"
#include "lib_standard_app/crypto_helpers.h"
#include "bip32_path.h"
#include "ledger_assert.h"

const unsigned char TRANSACTION_OUTPUT_SCRIPT_PRE[] = {
0x19, 0x76, 0xA9,
Expand Down Expand Up @@ -215,7 +216,7 @@ void btchip_public_key_hash160(unsigned char *in, unsigned short inlen,
unsigned char buffer[32];
cx_hash_sha256(in, inlen, buffer, 32);
cx_ripemd160_init(&riprip);
cx_hash_no_throw(&riprip.header, CX_LAST, buffer, 32, out, 20);
LEDGER_ASSERT(cx_hash_no_throw(&riprip.header, CX_LAST, buffer, 32, out, 20) == CX_OK, "hash160");
}

void btchip_compute_checksum(unsigned char* in, unsigned short inlen, unsigned char * output) {
Expand Down
11 changes: 6 additions & 5 deletions src/btchip_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "btchip_internal.h"
#include "btchip_apdu_constants.h"
#include "btchip_display_variables.h"
#include "ledger_assert.h"

#define CONSENSUS_BRANCH_ID_OVERWINTER 0x5ba81b19
#define CONSENSUS_BRANCH_ID_SAPLING 0x76b809bb
Expand Down Expand Up @@ -87,18 +88,18 @@ void transaction_offset(unsigned char value) {
if ((btchip_context_D.transactionHashOption & TRANSACTION_HASH_FULL) != 0) {
PRINTF("--- ADD TO HASH FULL:\n%.*H\n", value, btchip_context_D.transactionBufferPointer);
if (btchip_context_D.usingOverwinter) {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, 0, btchip_context_D.transactionBufferPointer, value, NULL, 0);
LEDGER_ASSERT(cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, 0, btchip_context_D.transactionBufferPointer, value, NULL, 0) == CX_OK, "Hash Failed");
}
else {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0);
LEDGER_ASSERT(cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0) == CX_OK, "Hash Failed");
}
}
if ((btchip_context_D.transactionHashOption &
TRANSACTION_HASH_AUTHORIZATION) != 0) {
PRINTF("--- ADD TO HASH AUTH:\n%.*H\n", value, btchip_context_D.transactionBufferPointer);
cx_hash_no_throw(&btchip_context_D.transactionHashAuthorization.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0);
LEDGER_ASSERT(cx_hash_no_throw(&btchip_context_D.transactionHashAuthorization.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0) == CX_OK, "Hash Failed");
}
}

Expand Down

0 comments on commit 61f525d

Please sign in to comment.