Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Oct 17, 2023
1 parent 693ef99 commit c29194e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define MAX_DER_SIGNATURE_LENGTH 72U

#define CURVE_SECP256K1 0x00
#define CURVE_256R1 0x01
#define CURVE_SECP256R1 0x01

#define ENCODING_BYTES_ARRAY 0x00
#define ENCODING_BASE_64_URL 0x01
Expand Down Expand Up @@ -86,6 +86,10 @@ typedef struct swap_app_context_s {
};
};

// During TX reception, we don't know if we'll receive the signature of the (TX), or the
// signature of the ('.' + TX).
// Storing the whole TX to calculate the hash during signature checking would use too much
// stack, so we calculate the two hashes and we'll decide later which one to use.
uint8_t sha256_digest_prefixed[32];
uint8_t sha256_digest_no_prefix[32];

Expand Down
2 changes: 2 additions & 0 deletions src/process_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ static bool calculate_sha256_digest(buf_t payload) {
cx_sha256_init(&sha256_prefix);
cx_sha256_init(&sha256_no_prefix);

// Calculate both WITH and WITHOUT the dot prefix.
// We don't know which one we'll need yet
unsigned char dot = '.';
if (cx_hash_no_throw(&sha256_prefix.header, 0, &dot, 1, NULL, 0) != CX_OK) {
PRINTF("Error: cx_hash_no_throw\n");
Expand Down
2 changes: 1 addition & 1 deletion src/set_partner_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static uint16_t parse_set_partner_key_command(const command_t *cmd,
}
if (curve_id == CURVE_SECP256K1) {
*curve = CX_CURVE_SECP256K1;
} else if (curve_id == CURVE_256R1) {
} else if (curve_id == CURVE_SECP256R1) {
*curve = CX_CURVE_256R1;
} else {
PRINTF("Error: Incorrect curve specifier %d\n", curve_id);
Expand Down

0 comments on commit c29194e

Please sign in to comment.