Skip to content

Commit

Permalink
Added mandatory Ledger embedded application manifest file
Browse files Browse the repository at this point in the history
  • Loading branch information
aido committed Nov 30, 2023
1 parent 0e3f5df commit a681e47
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 82 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
paths-ignore:
- '.github/workflows/*.yml'
- 'tests/*'
- 'build/*'

jobs:
ledger_app_analyse:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change log

## [1.5.4] - 2023-11-30
### Added
- Added mandatory Ledger embedded application manifest file

### Changed
- Combined BIP39 wordlist and SSKR wordlist unit tests

### Fixed
-

## [1.5.3] - 2023-11-18
### Added
- Added unit tests for BIP39
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ all: default
APPNAME = "Seed Tool"
APPVERSION_M = 1
APPVERSION_N = 5
APPVERSION_P = 3
APPVERSION_P = 4
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

APP_LOAD_PARAMS = --appFlags 0x10 $(COMMON_LOAD_PARAMS) --curve secp256k1 --path ""
Expand Down
8 changes: 8 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
unit_directory = "./tests/unit"
pytest_directory = "./tests/functional"
15 changes: 6 additions & 9 deletions src/nano/nanos_enter_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,12 @@ const bagl_element_t* screen_onboarding_restore_word_keyboard_callback(unsigned
// update the slider's possible words
// account for the extra clear word, and clear any previous word items (go back
// in the onboarding process)
if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_BIP39) {
bolos_ux_hslider3_init(G_bolos_ux_context.onboarding_words_checked +
MIN(G_bolos_ux_context.onboarding_step + 1,
RESTORE_BIP39_WORD_MAX_BACKWARD_STEPS));
} else if (G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_SSKR) {
bolos_ux_hslider3_init(G_bolos_ux_context.onboarding_words_checked +
MIN(G_bolos_ux_context.onboarding_step + 1,
RESTORE_SSKR_WORD_MAX_BACKWARD_STEPS));
}
bolos_ux_hslider3_init(
G_bolos_ux_context.onboarding_words_checked +
MIN(G_bolos_ux_context.onboarding_step + 1,
(G_bolos_ux_context.onboarding_type == ONBOARDING_TYPE_BIP39)
? RESTORE_BIP39_WORD_MAX_BACKWARD_STEPS
: RESTORE_SSKR_WORD_MAX_BACKWARD_STEPS));
screen_onboarding_restore_word_display_word_selection();
}
return NULL;
Expand Down
11 changes: 5 additions & 6 deletions src/nano/ux_nano_sskr.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ bool get_next_data(bool share_step) {
G_bolos_ux_context.sskr_share_index += share_step ? 1 : -1;
return true;
}
if (G_bolos_ux_context.sskr_share_index < 1) {
G_bolos_ux_context.sskr_share_index = 1;
}
if (G_bolos_ux_context.sskr_share_index > G_bolos_ux_context.sskr_share_count) {
G_bolos_ux_context.sskr_share_index = G_bolos_ux_context.sskr_share_count;
}
G_bolos_ux_context.sskr_share_index =
(G_bolos_ux_context.sskr_share_index < 1) ? 1
: (G_bolos_ux_context.sskr_share_index > G_bolos_ux_context.sskr_share_count)
? G_bolos_ux_context.sskr_share_count
: G_bolos_ux_context.sskr_share_index;

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ragger[tests,speculos]>=1.7.0
ragger[tests,speculos]>=1.13.0
14 changes: 5 additions & 9 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

# project information
project(unit_tests
VERSION 1.5.3
VERSION 1.5.4
DESCRIPTION "Unit tests for app-seed-tool Ledger Application"
LANGUAGES C)

Expand Down Expand Up @@ -79,14 +79,10 @@ add_executable(test_roundtrip ./tests/roundtrip.c ../../src/ux_common/onboarding
target_include_directories(test_roundtrip PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../src ${CMAKE_CURRENT_SOURCE_DIR}/../../src/ux_common)
target_link_libraries(test_roundtrip PUBLIC cmocka gcov testutils sskr shamir)

add_executable(test_bip39_words ./tests/bip39_words.c ../../src/ux_common/onboarding_seed_rom_variables.c ../../src/ux_common/onboarding_seed_bip39.c)
target_include_directories(test_bip39_words PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../src/ux_common)
target_link_libraries(test_bip39_words PUBLIC cmocka gcov testutils)
add_executable(test_words ./tests/words.c ../../src/ux_common/onboarding_seed_rom_variables.c ../../src/ux_common/onboarding_seed_bip39.c ../../src/ux_common/onboarding_seed_sskr.c)
target_include_directories(test_words PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../src/ux_common)
target_link_libraries(test_words PUBLIC cmocka gcov testutils sskr shamir)

add_executable(test_sskr_words ./tests/sskr_words.c ../../src/ux_common/onboarding_seed_rom_variables.c ../../src/ux_common/onboarding_seed_sskr.c ../../src/ux_common/onboarding_seed_bip39.c)
target_include_directories(test_sskr_words PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../src/ux_common)
target_link_libraries(test_sskr_words PUBLIC cmocka gcov testutils sskr shamir)

foreach(target test_shamir test_sskr test_bip39 test_roundtrip test_bip39_words test_sskr_words)
foreach(target test_shamir test_sskr test_bip39 test_roundtrip test_words)
add_test(NAME ${target} COMMAND ${target})
endforeach()
54 changes: 0 additions & 54 deletions tests/unit/tests/sskr_words.c

This file was deleted.

44 changes: 42 additions & 2 deletions tests/unit/tests/bip39_words.c → tests/unit/tests/words.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#include "testutils.h"
#include "common_bip39.h"
#include "common_sskr.h"

static void test_bip39_words(void **state) {
static void test_words_bip39(void **state) {
unsigned char next_letters[27] = {0};
size_t return_num = 0;
unsigned char prefix[] = "ab";
Expand Down Expand Up @@ -46,9 +47,48 @@ static void test_bip39_words(void **state) {
assert_string_equal(next_letters, "eo");
}

static void test_words_sskr(void **state) {
unsigned char next_letters[27] = {0};
size_t return_num = 0;
unsigned char prefix[] = "ab";
unsigned char buffer[5] = {0};

return_num = bolos_ux_sskr_get_word_idx_starting_with((const unsigned char *) prefix, 2);
assert_int_equal(return_num, 0);

return_num = bolos_ux_sskr_idx_strcpy(return_num, buffer);
assert_int_equal(return_num, 4);
assert_string_equal(buffer, "able");

return_num = bolos_ux_sskr_get_word_count_starting_with((const unsigned char *) prefix, 2);
assert_int_equal(return_num, 1);

return_num = bolos_ux_sskr_get_word_next_letters_starting_with((const unsigned char *) prefix, 2, next_letters);
assert_int_equal(return_num, 1);
assert_string_equal(next_letters, "l");

prefix[0] = 'z';
memset(next_letters,0,sizeof(next_letters));

return_num = bolos_ux_sskr_get_word_idx_starting_with((const unsigned char *) prefix, 1);
assert_int_equal(return_num, 250);

return_num = bolos_ux_sskr_idx_strcpy(return_num, buffer);
assert_int_equal(return_num, 4);
assert_string_equal(buffer, "zaps");

return_num = bolos_ux_sskr_get_word_count_starting_with((const unsigned char *) prefix, 1);
assert_int_equal(return_num, 6);

return_num = bolos_ux_sskr_get_word_next_letters_starting_with((const unsigned char *) prefix, 1, next_letters);
assert_int_equal(return_num, 4);
assert_string_equal(next_letters, "aeio");
}

int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_bip39_words)
cmocka_unit_test(test_words_bip39),
cmocka_unit_test(test_words_sskr)
};
return cmocka_run_group_tests(tests, NULL, NULL);
}

0 comments on commit a681e47

Please sign in to comment.