Skip to content

Commit

Permalink
Update tx_accept_sign result handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Nov 2, 2023
1 parent 9443d09 commit ded1162
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,13 @@ void tx_accept_sign() {
tx_get_buffer_length(),
G_io_apdu_buffer,
&length);

if (result == 1) {
set_code(G_io_apdu_buffer, length, APDU_CODE_OK);
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, length + 2);
} else {
set_code(G_io_apdu_buffer, length, APDU_CODE_SIGN_VERIFY_ERROR);
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, length + 2);

uint16_t return_code = APDU_CODE_OK;
if (result != 1) {
return_code = APDU_CODE_SIGN_VERIFY_ERROR;

This comment has been minimized.

Copy link
@cedelavergne-ledger

cedelavergne-ledger Nov 2, 2023

I am Ok, but usually, from security standpoint, I prefer the inverse:

uint16_t return_code = APDU_CODE_SIGN_VERIFY_ERROR;
if (result == 1) {
    return_code = APDU_CODE_OK;
}
set_code(G_io_apdu_buffer, length, APDU_CODE_OK);	
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, length + 2);
}
set_code(G_io_apdu_buffer, length, return_code);
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, length + 2);
}

void tx_reject() {
Expand Down

0 comments on commit ded1162

Please sign in to comment.