@@ -33,7 +33,6 @@ use cursive::{
3333 RadioGroup , ResizedView , ScrollView , SelectView , TextArea , TextView ,
3434 } ,
3535} ;
36- use hex:: FromHex ;
3736use pass:: Result ;
3837use ripasso:: {
3938 crypto:: CryptoImpl ,
@@ -48,12 +47,12 @@ use unic_langid::LanguageIdentifier;
4847mod helpers;
4948mod wizard;
5049
51- use lazy_static:: lazy_static;
52- use zeroize:: Zeroize ;
53-
5450use crate :: helpers:: {
5551 get_value_from_input, is_checkbox_checked, is_radio_button_selected, recipients_widths,
5652} ;
53+ use lazy_static:: lazy_static;
54+ use ripasso:: crypto:: Fingerprint ;
55+ use zeroize:: Zeroize ;
5756
5857/// The 'pointer' to the current PasswordStore is of this convoluted type.
5958type PasswordStoreType = Arc < Mutex < Arc < Mutex < PasswordStore > > > > ;
@@ -1383,13 +1382,9 @@ fn get_stores(config: &config::Config, home: &Option<PathBuf>) -> Result<Vec<Pas
13831382 } ?;
13841383
13851384 let own_fingerprint = store. get ( "own_fingerprint" ) ;
1386- let own_fingerprint = match own_fingerprint {
1387- None => None ,
1388- Some ( k) => match k. clone ( ) . into_string ( ) {
1389- Err ( _) => None ,
1390- Ok ( key) => <[ u8 ; 20 ] >:: from_hex ( key) . ok ( ) ,
1391- } ,
1392- } ;
1385+ let own_fingerprint = own_fingerprint
1386+ . map ( |k| k. clone ( ) . into_string ( ) . map ( |key| key. as_str ( ) . try_into ( ) ) ?)
1387+ . transpose ( ) ?;
13931388
13941389 final_stores. push ( PasswordStore :: new (
13951390 store_name,
@@ -1507,7 +1502,7 @@ fn save_edit_config(
15071502 false => CryptoImpl :: GpgMe ,
15081503 } ;
15091504
1510- let own_fingerprint = < [ u8 ; 20 ] > :: from_hex ( own_fingerprint) . ok ( ) ;
1505+ let own_fingerprint: Fingerprint = own_fingerprint. as_str ( ) . try_into ( ) ? ;
15111506
15121507 let new_store = PasswordStore :: new (
15131508 e_n,
@@ -1516,7 +1511,7 @@ fn save_edit_config(
15161511 home,
15171512 & None ,
15181513 & pgp_impl,
1519- & own_fingerprint,
1514+ & Some ( own_fingerprint) ,
15201515 ) ;
15211516 if let Err ( err) = new_store {
15221517 helpers:: errorbox ( ui, & err) ;
@@ -1689,7 +1684,10 @@ fn edit_store_in_config(
16891684 fingerprint_fields. add_child (
16901685 EditView :: new ( )
16911686 . content ( hex:: encode_upper (
1692- store. get_crypto ( ) . own_fingerprint ( ) . unwrap_or ( [ 0 ; 20 ] ) ,
1687+ store
1688+ . get_crypto ( )
1689+ . own_fingerprint ( )
1690+ . unwrap_or ( Fingerprint :: V4 ( [ 0 ; 20 ] ) ) ,
16931691 ) )
16941692 . with_name ( "edit_own_fingerprint_input" )
16951693 . fixed_size ( ( 50_usize , 1_usize ) ) ,
0 commit comments