Skip to content

Commit

Permalink
coucou
Browse files Browse the repository at this point in the history
  • Loading branch information
sgliner-ledger committed Nov 15, 2023
1 parent 687d167 commit c23f764
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/btchip_apdu_hash_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,31 @@ 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) {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32);
error = cx_hash_no_throw(&btchip_context_D.transactionHashFull.blake2b.header, CX_LAST, hash, 0, hash, 32);
}
else {
cx_hash_no_throw(&btchip_context_D.transactionHashFull.sha256.header, CX_LAST,
error = 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
cx_hash_sha256(hash, sizeof(hash), hash, 32);
error |= 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
Expand Down

0 comments on commit c23f764

Please sign in to comment.