usesuper::{pkcs_unpad, Encryption};usecrate::key;usecrate::Error;useaes::*;useblock_modes::block_padding::NoPadding;useblock_modes::BlockMode;typeAes128Cbc=block_modes::Cbc<Aes128, NoPadding>;/// Decode a secret key in the PKCS#5 format, possible deciphering it
/// using the supplied password.
#[cfg(feature ="openssl")]pubfndecode_pkcs5(secret:&[u8],
password:Option<&str>,
enc: Encryption,
)->Result<key::KeyPair, Error>{ifletSome(pass)= password {let sec =match enc {Encryption::Aes128Cbc(ref iv)=>{letmut c =md5::Context::new();
c.consume(pass.as_bytes());
c.consume(&iv[..8]);let md5 = c.compute();let c =Aes128Cbc::new_from_slices(&md5.0,&iv[..]).unwrap();letmut dec = secret.to_vec();
c.decrypt(&mut dec).unwrap();pkcs_unpad(&mut dec);
dec
}Encryption::Aes256Cbc(_)=>unimplemented!(),};super::decode_rsa(&sec)}else{Err(Error::KeyIsEncrypted.into())}}