@@ -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
+ usb_processing_timeout_reset (LONG_TIMEOUT );
504
+
505
+ return true;
506
+ }
507
+
508
+ bool keystore_unlock_bip39_finalize (const uint8_t * bip39_seed )
509
+ {
510
+ if (!_retain_bip39_seed (bip39_seed )) {
511
+ return false;
512
+ }
513
+ _is_unlocked_bip39 = true;
514
+ return true;
515
+ }
516
+
517
+ bool keystore_unlock_bip39 (
518
+ const uint8_t * seed ,
519
+ size_t seed_length ,
520
+ const char * mnemonic_passphrase ,
521
+ uint8_t * root_fingerprint_out )
522
+ {
523
+ if (!keystore_unlock_bip39_check (seed , seed_length )) {
524
+ return false;
525
+ }
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