@@ -52,10 +52,6 @@ static uint8_t _mock_bip39_seed[64] = {
52
52
0x33 , 0x33 , 0x33 , 0x33 , 0x33 , 0x33 , 0x33 , 0x33 , 0x44 , 0x44 , 0x44 , 0x44 , 0x44 , 0x44 , 0x44 , 0x44 ,
53
53
};
54
54
55
- static uint8_t _unstretched_retained_bip39_seed_encryption_key [32 ] =
56
- "\x9b\x44\xc7\x04\x88\x93\xfa\xaf\x6e\x2d\x76\x25\xd1\x3d\x8f\x1c\xab\x07\x65\xfd\x61\xf1\x59"
57
- "\xd9\x71\x3e\x08\x15\x5d\x06\x71\x7c" ;
58
-
59
55
static const uint32_t _keypath [] = {
60
56
44 + BIP32_INITIAL_HARDENED_CHILD ,
61
57
0 + BIP32_INITIAL_HARDENED_CHILD ,
@@ -69,10 +65,6 @@ static const uint8_t _expected_seckey[32] = {
69
65
0x58 , 0x92 , 0x32 , 0x9d , 0x67 , 0xdf , 0xd4 , 0xad , 0x05 , 0xe9 , 0xc3 , 0xd0 , 0x6e , 0xdf , 0x74 , 0xfb ,
70
66
};
71
67
72
- const uint8_t _expected_retained_bip39_seed_secret [32 ] =
73
- "\x85\x6d\x9a\x8c\x1e\xa4\x2a\x69\xae\x76\x32\x42\x44\xac\xe6\x74\x39\x7f\xf1\x36\x0a\x4b\xa4"
74
- "\xc8\x5f\xfb\xd4\x2c\xee\x8a\x7f\x29" ;
75
-
76
68
// Same as Python:
77
69
// import hmac, hashlib; hmac.digest(b"unit-test", b"password", hashlib.sha256).hex()
78
70
// See also: securechip_mock.c
@@ -120,16 +112,8 @@ void __wrap_random_32_bytes(uint8_t* buf)
120
112
memcpy (buf , (const void * )mock (), 32 );
121
113
}
122
114
123
- static void _expect_retain_bip39_seed (void )
124
- {
125
- will_return (__wrap_random_32_bytes , _unstretched_retained_bip39_seed_encryption_key );
126
- }
127
-
128
115
void _mock_unlocked (const uint8_t * seed , size_t seed_len , const uint8_t * bip39_seed )
129
116
{
130
- if (bip39_seed != NULL ) {
131
- _expect_retain_bip39_seed ();
132
- }
133
117
keystore_mock_unlocked (seed , seed_len , bip39_seed );
134
118
}
135
119
@@ -236,36 +220,6 @@ static void _expect_encrypt_and_store_seed(void)
236
220
will_return (__wrap_memory_is_initialized , false);
237
221
}
238
222
239
- static void _test_keystore_unlock_bip39 (void * * state )
240
- {
241
- keystore_lock ();
242
- assert_false (keystore_unlock_bip39 ("" ));
243
-
244
- _mock_unlocked (_mock_seed , sizeof (_mock_seed ), NULL );
245
- assert_true (keystore_is_locked ());
246
-
247
- _expect_retain_bip39_seed ();
248
- assert_true (keystore_unlock_bip39 ("foo" ));
249
- // Check that the retained bip39 seed was encrypted with the expected encryption key.
250
- size_t encrypted_len = 0 ;
251
- const uint8_t * retained_bip39_seed_encrypted =
252
- keystore_test_get_retained_bip39_seed_encrypted (& encrypted_len );
253
- size_t decrypted_len = encrypted_len - 48 ;
254
- uint8_t out [decrypted_len ];
255
- assert_true (cipher_aes_hmac_decrypt (
256
- retained_bip39_seed_encrypted ,
257
- encrypted_len ,
258
- out ,
259
- & decrypted_len ,
260
- _expected_retained_bip39_seed_secret ));
261
- assert_int_equal (decrypted_len , 64 );
262
- const uint8_t expected_bip39_seed [64 ] =
263
- "\x2b\x3c\x63\xde\x86\xf0\xf2\xb1\x3c\xc6\xa3\x6c\x1b\xa2\x31\x4f\xbc\x1b\x40\xc7\x7a\xb9"
264
- "\xcb\x64\xe9\x6b\xa4\xd5\xc6\x2f\xc2\x04\x74\x8c\xa6\x62\x6a\x9f\x03\x5e\x7d\x43\x1b\xce"
265
- "\x8c\x92\x10\xec\x0b\xdf\xfc\x2e\x7d\xb8\x73\xde\xe5\x6c\x8a\xc2\x15\x3e\xee\x9a" ;
266
- assert_memory_equal (out , expected_bip39_seed , decrypted_len );
267
- }
268
-
269
223
static void _test_keystore_lock (void * * state )
270
224
{
271
225
_mock_unlocked (NULL , 0 , NULL );
@@ -328,7 +282,6 @@ static void _mock_with_mnemonic(const char* mnemonic, const char* passphrase)
328
282
assert_true (keystore_bip39_mnemonic_to_seed (mnemonic , seed , & seed_len ));
329
283
330
284
_mock_unlocked (seed , seed_len , NULL );
331
- _expect_retain_bip39_seed ();
332
285
assert_true (keystore_unlock_bip39 (passphrase ));
333
286
}
334
287
@@ -442,7 +395,6 @@ int main(void)
442
395
const struct CMUnitTest tests [] = {
443
396
cmocka_unit_test (_test_keystore_secp256k1_nonce_commit ),
444
397
cmocka_unit_test (_test_keystore_secp256k1_sign ),
445
- cmocka_unit_test (_test_keystore_unlock_bip39 ),
446
398
cmocka_unit_test (_test_keystore_lock ),
447
399
cmocka_unit_test (_test_keystore_create_and_store_seed ),
448
400
cmocka_unit_test (_test_secp256k1_schnorr_sign ),
0 commit comments