From a8d951fd1d0d0de0e6d3ae36ebe18e9a50cf9ece Mon Sep 17 00:00:00 2001 From: Sarah GLINER Date: Mon, 20 Nov 2023 10:32:05 +0100 Subject: [PATCH] Revert "Fix: clang analyzer" This reverts commit 612610569aca163403bf5c328238abd41d40ccdb. --- src/btchip_apdu_hash_sign.c | 19 +++---------------- src/btchip_helpers.c | 2 +- src/btchip_transaction.c | 6 +++--- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/btchip_apdu_hash_sign.c b/src/btchip_apdu_hash_sign.c index b4284949..8e006af9 100644 --- a/src/btchip_apdu_hash_sign.c +++ b/src/btchip_apdu_hash_sign.c @@ -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); diff --git a/src/btchip_helpers.c b/src/btchip_helpers.c index 74de2a37..343ce74d 100644 --- a/src/btchip_helpers.c +++ b/src/btchip_helpers.c @@ -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) { diff --git a/src/btchip_transaction.c b/src/btchip_transaction.c index 345a3016..9cd29e61 100644 --- a/src/btchip_transaction.c +++ b/src/btchip_transaction.c @@ -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); } }