Skip to content

Commit

Permalink
refactor: handle blake2b error
Browse files Browse the repository at this point in the history
  • Loading branch information
homura committed Jul 16, 2024
1 parent 0684808 commit 69a2105
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/apdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ void handle_apdu_get_wallet_id(uint8_t __attribute__((unused)) instruction) {

int rv = 0;
cx_blake2b_t hashState;
cx_blake2b_init_no_throw(&hashState, 512);
if(cx_blake2b_init_no_throw(&hashState, 512) != CX_OK) {
THROW(APDU_RESPONSE_UNKNOWN);
}

WITH_KEY_PAIR(id_path, key_pair, size_t, ({
PRINTF("\nPublic Key: %.*h\n", key_pair->public_key.W_len, key_pair->public_key.W);
Expand Down Expand Up @@ -120,7 +122,7 @@ void main_loop(apdu_handler const *const handlers, size_t const handlers_size) {
if (rx == 0) {
// no apdu received, well, reset the session, and reset the
// bootloader configuration
THROW(EXC_SECURITY);
THROW(EXC_INVALID_INS);
}

if (G_io_apdu_buffer[OFFSET_CLA] != CLA) {
Expand Down

0 comments on commit 69a2105

Please sign in to comment.