@@ -485,16 +485,11 @@ keystore_error_t keystore_unlock(
485
485
return result ;
486
486
}
487
487
488
- bool keystore_unlock_bip39 (
489
- const uint8_t * seed ,
490
- size_t seed_length ,
491
- const char * mnemonic_passphrase ,
492
- uint8_t * root_fingerprint_out )
488
+ bool keystore_unlock_bip39_check (const uint8_t * seed , size_t seed_length )
493
489
{
494
490
if (!_is_unlocked_device ) {
495
491
return false;
496
492
}
497
- usb_processing_timeout_reset (LONG_TIMEOUT );
498
493
499
494
uint8_t seed_hashed [32 ] = {0 };
500
495
UTIL_CLEANUP_32 (seed_hashed );
@@ -505,6 +500,30 @@ bool keystore_unlock_bip39(
505
500
return false;
506
501
}
507
502
503
+ return true;
504
+ }
505
+
506
+ bool keystore_unlock_bip39_finalize (const uint8_t * bip39_seed )
507
+ {
508
+ if (!_retain_bip39_seed (bip39_seed )) {
509
+ return false;
510
+ }
511
+ _is_unlocked_bip39 = true;
512
+ return true;
513
+ }
514
+
515
+ bool keystore_unlock_bip39 (
516
+ const uint8_t * seed ,
517
+ size_t seed_length ,
518
+ const char * mnemonic_passphrase ,
519
+ uint8_t * root_fingerprint_out )
520
+ {
521
+ if (!keystore_unlock_bip39_check (seed , seed_length )) {
522
+ return false;
523
+ }
524
+
525
+ usb_processing_timeout_reset (LONG_TIMEOUT );
526
+
508
527
uint8_t bip39_seed [64 ] = {0 };
509
528
UTIL_CLEANUP_64 (bip39_seed );
510
529
rust_derive_bip39_seed (
@@ -513,11 +532,7 @@ bool keystore_unlock_bip39(
513
532
rust_util_bytes_mut (bip39_seed , sizeof (bip39_seed )),
514
533
rust_util_bytes_mut (root_fingerprint_out , 4 ));
515
534
516
- if (!_retain_bip39_seed (bip39_seed )) {
517
- return false;
518
- }
519
- _is_unlocked_bip39 = true;
520
- return true;
535
+ return keystore_unlock_bip39_finalize (bip39_seed );
521
536
}
522
537
523
538
void keystore_lock (void )
0 commit comments