Skip to content

Commit

Permalink
[clean] Cleaning deprecated SDK functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lpascal-ledger committed Oct 4, 2023
1 parent 1652c11 commit 58f90b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/nano/nanos_enter_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,18 @@ void compare_recovery_phrase(void) {
cx_hmac_sha512_t ctx;
const char key[] = "Bitcoin seed";

cx_hmac_sha512_init(&ctx, (const uint8_t*) key, strlen(key));
cx_hmac((cx_hmac_t*) &ctx, CX_LAST, buffer, 64, buffer, 64);
cx_hmac_sha512_init_no_throw(&ctx, (const uint8_t*) key, strlen(key));
cx_hmac_no_throw((cx_hmac_t*) &ctx, CX_LAST, buffer, 64, buffer, 64);
PRINTF("Root key from input:\n%.*H\n", 64, buffer);

// get rootkey from device's seed
uint8_t buffer_device[64];

os_perso_derive_node_bip32(CX_CURVE_256K1, NULL, 0, buffer_device, buffer_device + 32);
if (os_derive_bip32_no_throw(CX_CURVE_256K1, NULL, 0, buffer_device, buffer_device + 32) !=
CX_OK) {
PRINTF("An error occured while comparing the recovery phrase\n");

Check failure on line 241 in src/nano/nanos_enter_phrase.c

View workflow job for this annotation

GitHub Actions / Check misspellings

occured ==> occurred
return;
}
PRINTF("Root key from device: \n%.*H\n", 64, buffer_device);

// compare both rootkey
Expand Down
12 changes: 8 additions & 4 deletions src/nano/nanox_enter_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const bagl_element_t* screen_onboarding_4_restore_word_before_element_display_ca
return element;
}

uint8_t compare_recovery_phrase(void) {
static uint8_t compare_recovery_phrase(void) {
// convert mnemonic to hex-seed
uint8_t buffer[64];

Expand All @@ -410,14 +410,18 @@ uint8_t compare_recovery_phrase(void) {
cx_hmac_sha512_t ctx;
const char key[] = "Bitcoin seed";

cx_hmac_sha512_init(&ctx, (const uint8_t*) key, strlen(key));
cx_hmac((cx_hmac_t*) &ctx, CX_LAST, buffer, 64, buffer, 64);
cx_hmac_sha512_init_no_throw(&ctx, (const uint8_t*) key, strlen(key));
cx_hmac_no_throw((cx_hmac_t*) &ctx, CX_LAST, buffer, 64, buffer, 64);
PRINTF("Root key from input:\n%.*H\n", 64, buffer);

// get rootkey from device's seed
uint8_t buffer_device[64];

os_perso_derive_node_bip32(CX_CURVE_256K1, NULL, 0, buffer_device, buffer_device + 32);
if (os_derive_bip32_no_throw(CX_CURVE_256K1, NULL, 0, buffer_device, buffer_device + 32) !=
CX_OK) {
PRINTF("An error occured while comparing the recovery phrase\n");

Check failure on line 422 in src/nano/nanox_enter_phrase.c

View workflow job for this annotation

GitHub Actions / Check misspellings

occured ==> occurred
return 0;
}
PRINTF("Root key from device: \n%.*H\n", 64, buffer_device);

// compare both rootkey
Expand Down

0 comments on commit 58f90b4

Please sign in to comment.