@@ -19,7 +19,6 @@ use alloc::vec::Vec;
1919
2020use core:: convert:: TryInto ;
2121
22- use crate :: input:: SafeInputString ;
2322use bitbox02_sys:: keystore_error_t;
2423
2524pub const BIP39_WORDLIST_LEN : u16 = bitbox02_sys:: BIP39_WORDLIST_LEN as u16 ;
@@ -62,12 +61,12 @@ impl core::convert::From<keystore_error_t> for Error {
6261 }
6362}
6463
65- pub fn unlock ( password : & SafeInputString ) -> Result < ( ) , Error > {
64+ pub fn unlock ( password : & str ) -> Result < ( ) , Error > {
6665 let mut remaining_attempts: u8 = 0 ;
6766 let mut securechip_result: i32 = 0 ;
6867 match unsafe {
6968 bitbox02_sys:: keystore_unlock (
70- password. as_cstr ( ) ,
69+ crate :: util :: str_to_cstr_vec ( password) . unwrap ( ) . as_ptr ( ) ,
7170 & mut remaining_attempts,
7271 & mut securechip_result,
7372 )
@@ -85,18 +84,24 @@ pub fn lock() {
8584 unsafe { bitbox02_sys:: keystore_lock ( ) }
8685}
8786
88- pub fn unlock_bip39 ( mnemonic_passphrase : & SafeInputString ) -> Result < ( ) , Error > {
89- if unsafe { bitbox02_sys:: keystore_unlock_bip39 ( mnemonic_passphrase. as_cstr ( ) ) } {
87+ pub fn unlock_bip39 ( mnemonic_passphrase : & str ) -> Result < ( ) , Error > {
88+ if unsafe {
89+ bitbox02_sys:: keystore_unlock_bip39 (
90+ crate :: util:: str_to_cstr_vec ( mnemonic_passphrase)
91+ . unwrap ( )
92+ . as_ptr ( ) ,
93+ )
94+ } {
9095 Ok ( ( ) )
9196 } else {
9297 Err ( Error :: CannotUnlockBIP39 )
9398 }
9499}
95100
96- pub fn create_and_store_seed ( password : & SafeInputString , host_entropy : & [ u8 ] ) -> Result < ( ) , Error > {
101+ pub fn create_and_store_seed ( password : & str , host_entropy : & [ u8 ] ) -> Result < ( ) , Error > {
97102 match unsafe {
98103 bitbox02_sys:: keystore_create_and_store_seed (
99- password. as_cstr ( ) ,
104+ crate :: util :: str_to_cstr_vec ( password) . unwrap ( ) . as_ptr ( ) ,
100105 host_entropy. as_ptr ( ) ,
101106 host_entropy. len ( ) as _ ,
102107 )
@@ -304,9 +309,13 @@ pub fn bip39_mnemonic_to_seed(mnemonic: &str) -> Result<zeroize::Zeroizing<Vec<u
304309 }
305310}
306311
307- pub fn encrypt_and_store_seed ( seed : & [ u8 ] , password : & SafeInputString ) -> Result < ( ) , Error > {
312+ pub fn encrypt_and_store_seed ( seed : & [ u8 ] , password : & str ) -> Result < ( ) , Error > {
308313 match unsafe {
309- bitbox02_sys:: keystore_encrypt_and_store_seed ( seed. as_ptr ( ) , seed. len ( ) , password. as_cstr ( ) )
314+ bitbox02_sys:: keystore_encrypt_and_store_seed (
315+ seed. as_ptr ( ) ,
316+ seed. len ( ) ,
317+ crate :: util:: str_to_cstr_vec ( password) . unwrap ( ) . as_ptr ( ) ,
318+ )
310319 } {
311320 keystore_error_t:: KEYSTORE_OK => Ok ( ( ) ) ,
312321 err => Err ( err. into ( ) ) ,
0 commit comments