File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ pub fn encode_pkcs8_encrypted(
123123
124124 use rand_core:: Rng ;
125125 let mut rng = safe_rng ( ) ;
126- let mut salt = [ 0 ; 64 ] ;
126+ let mut salt = [ 0 ; 32 ] ;
127127 rng. fill_bytes ( & mut salt) ;
128128 let mut iv = [ 0 ; 16 ] ;
129129 rng. fill_bytes ( & mut iv) ;
Original file line number Diff line number Diff line change 1+ use ssh_key:: { Algorithm , PrivateKey } ;
2+
3+ use crate :: keys:: pkcs8:: { decode_pkcs8, encode_pkcs8_encrypted} ;
4+
15use super :: decode_secret_key;
26
37#[ test]
@@ -10,3 +14,13 @@ lpQg5vf23Fc9fFrQ9AnQKrb1dgTkoxQ=
1014-----END EC PRIVATE KEY-----"# ;
1115 decode_secret_key ( key, None ) . unwrap ( ) ;
1216}
17+
18+ #[ test]
19+ fn test_pkcs8_roundtrip ( ) {
20+ let password = b"SomePassword" ;
21+ let original_key = PrivateKey :: random ( & mut rand:: rng ( ) , Algorithm :: Ed25519 ) . unwrap ( ) ;
22+
23+ let encrypted = encode_pkcs8_encrypted ( password, 10 , & original_key) . unwrap ( ) ;
24+ let decrypted = decode_pkcs8 ( & encrypted, Some ( password) ) . unwrap ( ) ;
25+ assert_eq ! ( decrypted, original_key) ;
26+ }
You can’t perform that action at this time.
0 commit comments