From ae7aea7611a6e7bac909b1cb7cc5fe8f1e1399df Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Wed, 26 Jul 2023 15:48:40 +0200 Subject: [PATCH] [clean] Cleaning deprecated SDK functions --- src/nano/nanos_enter_phrase.c | 10 +++++++--- src/nano/nanox_enter_phrase.c | 12 ++++++++---- tests/functional/test_fatstacks_options.py | 5 ++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/nano/nanos_enter_phrase.c b/src/nano/nanos_enter_phrase.c index fb85be5d..fa830c1a 100644 --- a/src/nano/nanos_enter_phrase.c +++ b/src/nano/nanos_enter_phrase.c @@ -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 occurred while comparing the recovery phrase\n"); + return; + } PRINTF("Root key from device: \n%.*H\n", 64, buffer_device); // compare both rootkey diff --git a/src/nano/nanox_enter_phrase.c b/src/nano/nanox_enter_phrase.c index 77d3f617..39f9bbda 100644 --- a/src/nano/nanox_enter_phrase.c +++ b/src/nano/nanox_enter_phrase.c @@ -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]; @@ -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 occurred while comparing the recovery phrase\n"); + return 0; + } PRINTF("Root key from device: \n%.*H\n", 64, buffer_device); // compare both rootkey diff --git a/tests/functional/test_fatstacks_options.py b/tests/functional/test_fatstacks_options.py index 1f2bd285..cc148dd2 100644 --- a/tests/functional/test_fatstacks_options.py +++ b/tests/functional/test_fatstacks_options.py @@ -12,14 +12,13 @@ def test_check_info_then_leave(navigator: StaxNavigator, functional_test_directory: str): instructions = format_instructions([ CustomNavInsID.HOME_TO_SETTINGS, - CustomNavInsID.SETTINGS_TO_HOME, - CustomNavInsID.HOME_TO_QUIT + CustomNavInsID.SETTINGS_TO_HOME ]) navigator.navigate_and_compare(functional_test_directory, "check_info_then_leave", instructions, screen_change_before_first_instruction=False, - screen_change_after_last_instruction=False) + screen_change_after_last_instruction=True) def test_check_all_passphrase_lengths(navigator: StaxNavigator, functional_test_directory: str):