37
37
that seeding/unlocking/derivations work as expected. */
38
38
39
39
static const char * _some_password = "foo" ;
40
- static const char * _some_other_password = "bar" ;
41
40
42
41
static uint8_t _seed [KEYSTORE_MAX_SEED_LENGTH ] =
43
42
"\xcb\x33\xc2\x0c\xea\x62\xa5\xc2\x77\x52\x7e\x20\x02\xda\x82\xe6\xe2\xb3\x74\x50\xa7\x55\x14"
@@ -58,42 +57,6 @@ static void _smarteeprom_reset(void)
58
57
bitbox02_smarteeprom_init ();
59
58
}
60
59
61
- static void _test_seeds (void * * state )
62
- {
63
- _smarteeprom_reset ();
64
- assert_true (keystore_is_locked ());
65
- uint8_t read_seed [KEYSTORE_MAX_SEED_LENGTH ];
66
- size_t read_seed_len ;
67
- assert_false (keystore_copy_seed (read_seed , & read_seed_len ));
68
-
69
- will_return (__wrap_memory_is_initialized , true);
70
- assert_int_equal (
71
- keystore_encrypt_and_store_seed (_seed , 32 , _some_password ), KEYSTORE_ERR_MEMORY );
72
-
73
- uint32_t seed_sizes [3 ] = {16 , 24 , 32 };
74
- for (size_t seed_size_idx = 0 ; seed_size_idx < 3 ; seed_size_idx ++ ) {
75
- uint32_t seed_size = seed_sizes [seed_size_idx ];
76
- will_return (__wrap_memory_is_initialized , false);
77
- assert_int_equal (
78
- keystore_encrypt_and_store_seed (_seed , seed_size , _some_password ), KEYSTORE_OK );
79
- uint8_t remaining_attempts ;
80
- will_return (__wrap_memory_is_seeded , true);
81
- assert_int_equal (
82
- KEYSTORE_ERR_INCORRECT_PASSWORD ,
83
- keystore_unlock (_some_other_password , & remaining_attempts , NULL ));
84
- // First time: unlock. After unlock, it becomes a password check.
85
- for (int i = 0 ; i < 3 ; i ++ ) {
86
- will_return (__wrap_memory_is_seeded , true);
87
- assert_int_equal (
88
- KEYSTORE_OK , keystore_unlock (_some_password , & remaining_attempts , NULL ));
89
- }
90
- assert_true (keystore_copy_seed (read_seed , & read_seed_len ));
91
- assert_int_equal (seed_size , read_seed_len );
92
- assert_memory_equal (read_seed , _seed , seed_size );
93
- keystore_lock ();
94
- }
95
- }
96
-
97
60
static void _check_mnemonic (const char * expected )
98
61
{
99
62
uint8_t seed [KEYSTORE_MAX_SEED_LENGTH ];
@@ -231,9 +194,9 @@ static void _test_fixtures(void** state)
231
194
int main (void )
232
195
{
233
196
mock_memory_set_salt_root (_salt_root );
197
+ _smarteeprom_reset ();
234
198
235
199
const struct CMUnitTest tests [] = {
236
- cmocka_unit_test (_test_seeds ),
237
200
cmocka_unit_test (_test_fixtures ),
238
201
};
239
202
return cmocka_run_group_tests (tests , NULL , NULL );
0 commit comments