Skip to content

Commit

Permalink
Revert "Fix: clang analyzer"
Browse files Browse the repository at this point in the history
This reverts commit 6126105.
  • Loading branch information
sgliner-ledger committed Nov 20, 2023
1 parent 6126105 commit a8d951f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
19 changes: 3 additions & 16 deletions src/btchip_apdu_hash_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,20 @@ unsigned short btchip_apdu_hash_sign() {

void btchip_bagl_user_action_signtx(unsigned char confirming, unsigned char direct) {
unsigned short sw = BTCHIP_SW_OK;
int error = 0;
// confirm and finish the apdu exchange //spaghetti
if (confirming) {
unsigned char hash[32];
if (btchip_context_D.usingOverwinter) {
error = cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32);
cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32);
}
else {
error = cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, CX_LAST,
cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, CX_LAST,
hash, 0, hash, 32);
PRINTF("Hash1\n%.*H\n", sizeof(hash), hash);

// Rehash
error |= cx_hash_sha256(hash, sizeof(hash), hash, 32);
cx_hash_sha256(hash, sizeof(hash), hash, 32);
}

if (error) {
sw = BTCHIP_SW_CONDITIONS_OF_USE_NOT_SATISFIED;
btchip_context_D.outLength = 0;
G_io_apdu_buffer[btchip_context_D.outLength++] = sw >> 8;
G_io_apdu_buffer[btchip_context_D.outLength++] = sw;

io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, btchip_context_D.outLength);
ui_transaction_error();
return;
}

PRINTF("Hash2\n%.*H\n", sizeof(hash), hash);
// Sign
size_t out_len = sizeof(G_io_apdu_buffer);
Expand Down
2 changes: 1 addition & 1 deletion src/btchip_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,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);
(void)cx_hash_no_throw(&riprip.header, CX_LAST, buffer, 32, out, 20);
cx_hash_no_throw(&riprip.header, CX_LAST, buffer, 32, out, 20);
}

void btchip_compute_checksum(unsigned char* in, unsigned short inlen, unsigned char * output) {
Expand Down
6 changes: 3 additions & 3 deletions src/btchip_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ 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) {
(void)cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, 0, btchip_context_D.transactionBufferPointer, value, NULL, 0);
cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, 0, btchip_context_D.transactionBufferPointer, value, NULL, 0);
}
else {
(void)cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, 0,
cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0);
}
}
if ((btchip_context_D.transactionHashOption &
TRANSACTION_HASH_AUTHORIZATION) != 0) {
PRINTF("--- ADD TO HASH AUTH:\n%.*H\n", value, btchip_context_D.transactionBufferPointer);
(void)cx_hash_no_throw(&btchip_context_D.transactionHashAuthorization.header, 0,
cx_hash_no_throw(&btchip_context_D.transactionHashAuthorization.header, 0,
btchip_context_D.transactionBufferPointer, value, NULL, 0);
}
}
Expand Down

0 comments on commit a8d951f

Please sign in to comment.