Skip to content

Commit

Permalink
Clean warnings: handle error in address_from_pubkey() and in crypto_s…
Browse files Browse the repository at this point in the history
…ign_message()
  • Loading branch information
vldmkr committed Jan 23, 2024
1 parent 7721e41 commit 12f221b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ bool address_from_pubkey(const uint8_t public_key[static 32], uint8_t *out, size
if (error != CX_OK) {
return false;
}
cx_hash_update((cx_hash_t *) &sha3, public_key, 32);
cx_hash_update((cx_hash_t *) &sha3, &signature_scheme_id, 1);
cx_hash_final((cx_hash_t *) &sha3, address);
error = cx_hash_update((cx_hash_t *) &sha3, public_key, 32);
if (error != CX_OK) {
return false;
}
error = cx_hash_update((cx_hash_t *) &sha3, &signature_scheme_id, 1);
if (error != CX_OK) {
return false;
}
error = cx_hash_final((cx_hash_t *) &sha3, address);
if (error != CX_OK) {
return false;
}

memmove(out, address, ADDRESS_LEN);

Expand Down
6 changes: 5 additions & 1 deletion src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ cx_err_t crypto_sign_message() {
}

size_t size;
cx_ecdomain_parameters_length(private_key.curve, &size);
error = cx_ecdomain_parameters_length(private_key.curve, &size);
if (error != CX_OK) {
explicit_bzero(&private_key, sizeof(private_key));
return error;
}
G_context.tx_info.signature_len = 2 * size;

PRINTF("Signature: %.*H\n", G_context.tx_info.signature_len, G_context.tx_info.signature);
Expand Down

0 comments on commit 12f221b

Please sign in to comment.