Making OpenSSL optional
[?]
Jun 22, 2021, 11:56 AM
MCS77Y4VJGB6TU2HOLASGSRW4B6MT74XABD4KYALIRS54GGN2DDQCDependencies
- [2]
Q323RFJSVersion bump - [3]
ELRPPXSGFixing conflicts - [4]
MFMCIUMJFixing authentication with RSA - [5]
AWVLXGAWRemoving anyhows on Windows - [6]
CROEJT6QMinor fixes in Thrussh-keys (parsing key files) - [7]
7FRJYUI6Reboot because of a bad change - [8]
2WEO7OZLVersion updates: getting rid of anyhow + moving to Tokio 1.0 - [9]
63PFETNDfix compile errors in tests and examples - [10]
FT67GGO4Version bump (Pijul and Thrussh) - [11]
634OYCNMTokio 0.3
Change contents
- replacement in thrussh-keys/src/lib.rs at line 7
//! The following example shows how to do all these in a single//! example: start and SSH agent server, connect to it with a client,//! decipher an encrypted private key (the password is `b"blabla"`),//! send it to the agent, and ask the agent to sign a piece of data//! (`b"Please sign this", below).//! The following example (which uses the `openssl` feature) shows how//! to do all these in a single example: start and SSH agent server,//! connect to it with a client, decipher an encrypted private key//! (the password is `b"blabla"`), send it to the agent, and ask the//! agent to sign a piece of data (`b"Please sign this", below). - replacement in thrussh-keys/src/lib.rs at line 20
//! fn confirm(&self, _: std::sync::Arc<key::KeyPair>) -> Box<dyn Future<Output = bool> + Send + Unpin> {//! Box::new(futures::future::ready(true))//! fn confirm(self, _: std::sync::Arc<key::KeyPair>) -> Box<dyn Future<Output = (Self, bool)> + Send + Unpin> {//! Box::new(futures::future::ready((self, true))) - replacement in thrussh-keys/src/lib.rs at line 38
//! thrussh_keys::agent::server::serve(listener.incoming(), X {}).await//! thrussh_keys::agent::server::serve(tokio_stream::wrappers::UnixListenerStream::new(listener), X {}).await - replacement in thrussh-keys/src/lib.rs at line 40
//! let key = decode_secret_key(PKCS8_ENCRYPTED, Some(b"blabla")).unwrap();//! let key = decode_secret_key(PKCS8_ENCRYPTED, Some("blabla")).unwrap(); - replacement in thrussh-keys/src/lib.rs at line 48
//! let sig = client.sign_request(&public, buf).await?.unwrap();//! assert!(public.verify_detached(buf, sig.as_ref()));//! let sig = client.sign_request(&public, cryptovec::CryptoVec::from_slice(&buf[..])).await.1.unwrap();//! // Here, `sig` is encoded in a format usable internally by the SSH protocol. - edit in thrussh-keys/src/lib.rs at line 56
extern crate thrussh_libsodium as sodium; - edit in thrussh-keys/src/lib.rs at line 77
mod bcrypt_pbkdf;mod blowfish; - edit in thrussh-keys/src/lib.rs at line 116
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 120
#[error(transparent)]BlockMode(#[from] block_modes::BlockModeError), - edit in thrussh-keys/src/lib.rs at line 197
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 223
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 247
password: Option<&[u8]>,password: Option<&str>, - edit in thrussh-keys/src/lib.rs at line 409
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 423
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 456
decode_secret_key(ED25519_KEY, Some(b"blabla")).unwrap();decode_secret_key(ED25519_KEY, Some("blabla")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 460
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 468
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 519
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 528
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 562
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 593
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 627
let key = decode_secret_key(key, Some(b"passphrase")).unwrap();let key = decode_secret_key(key, Some("passphrase")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 635
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 670
decode_secret_key(key, Some(b"12345")).unwrap();decode_secret_key(key, Some("12345")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 673
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 677
decode_secret_key(PKCS8_RSA, Some(b"blabla")).unwrap();decode_secret_key(PKCS8_RSA, Some("blabla")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 680
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 713
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 746
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 750
decode_secret_key(PKCS8_ENCRYPTED, Some(b"blabla")).unwrap();decode_secret_key(PKCS8_ENCRYPTED, Some("blabla")).unwrap(); - replacement in thrussh-keys/src/lib.rs at line 767
let mut rt = tokio::runtime::Runtime::new().unwrap();let rt = tokio::runtime::Runtime::new().unwrap(); - replacement in thrussh-keys/src/lib.rs at line 779
assert!(public.verify_detached(a, b));match key {key::KeyPair::Ed25519 { .. } => {let sig = &b[b.len() - 64..];assert!(public.verify_detached(a, sig));}_ => {}} - replacement in thrussh-keys/src/lib.rs at line 795
let key = decode_secret_key(ED25519_KEY, Some(b"blabla")).unwrap();let key = decode_secret_key(ED25519_KEY, Some("blabla")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 800
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 802
let key = decode_secret_key(PKCS8_ENCRYPTED, Some(b"blabla")).unwrap();let key = decode_secret_key(PKCS8_ENCRYPTED, Some("blabla")).unwrap(); - edit in thrussh-keys/src/lib.rs at line 807
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/lib.rs at line 814
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/lib.rs at line 820
let mut core = tokio::runtime::Runtime::new().unwrap();let core = tokio::runtime::Runtime::new().unwrap(); - replacement in thrussh-keys/src/lib.rs at line 845
let key = decode_secret_key(PKCS8_ENCRYPTED, Some(b"blabla")).unwrap();let key = decode_secret_key(PKCS8_ENCRYPTED, Some("blabla")).unwrap(); - replacement in thrussh-keys/src/lib.rs at line 859
assert!(public.verify_detached(a, b));match key {key::KeyPair::Ed25519 { .. } => {let sig = &b[b.len() - 64..];assert!(public.verify_detached(a, sig));}_ => {}} - edit in thrussh-keys/src/key.rs at line 19
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 21
use thrussh_libsodium as sodium; - replacement in thrussh-keys/src/key.rs at line 25
pub use sodium::ed25519::{keypair, sign_detached, verify_detached, PublicKey, SecretKey};pub use thrussh_libsodium::ed25519::{keypair, sign_detached, verify_detached, PublicKey, SecretKey,}; - edit in thrussh-keys/src/key.rs at line 88
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/key.rs at line 103
Ed25519(sodium::ed25519::PublicKey),Ed25519(thrussh_libsodium::ed25519::PublicKey), - edit in thrussh-keys/src/key.rs at line 105
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 113
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 116
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 118
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 124
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 126
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/key.rs at line 151
b"ssh-rsa" | b"rsa-sha2-256" | b"rsa-sha2-512" => {let mut p = pubkey.reader(0);let key_algo = p.read_string()?;debug!("{:?}", std::str::from_utf8(key_algo));if key_algo != b"ssh-rsa"&& key_algo != b"rsa-sha2-256"&& key_algo != b"rsa-sha2-512"b"ssh-rsa" | b"rsa-sha2-256" | b"rsa-sha2-512" if cfg!(feature = "openssl") => {#[cfg(feature = "openssl")]{let mut p = pubkey.reader(0);let key_algo = p.read_string()?;debug!("{:?}", std::str::from_utf8(key_algo));if key_algo != b"ssh-rsa" && key_algo != b"rsa-sha2-256" && key_algo != b"rsa-sha2-512" {return Err(Error::CouldNotReadKey.into());}let key_e = p.read_string()?;let key_n = p.read_string()?;use openssl::bn::BigNum;use openssl::pkey::PKey;use openssl::rsa::Rsa;Ok(PublicKey::RSA {key: OpenSSLPKey(PKey::from_rsa(Rsa::from_public_components(BigNum::from_slice(key_n)?,BigNum::from_slice(key_e)?,)?)?),hash: {if algo == b"rsa-sha2-256" {SignatureHash::SHA2_256} else if algo == b"rsa-sha2-512" {SignatureHash::SHA2_512} else {SignatureHash::SHA1}},})}#[cfg(not(feature = "openssl"))] - replacement in thrussh-keys/src/key.rs at line 183
return Err(Error::CouldNotReadKey.into());unreachable!() - edit in thrussh-keys/src/key.rs at line 185
let key_e = p.read_string()?;let key_n = p.read_string()?;use openssl::bn::BigNum;use openssl::pkey::PKey;use openssl::rsa::Rsa;Ok(PublicKey::RSA {key: OpenSSLPKey(PKey::from_rsa(Rsa::from_public_components(BigNum::from_slice(key_n)?,BigNum::from_slice(key_e)?,)?)?),hash: {if algo == b"rsa-sha2-256" {SignatureHash::SHA2_256} else if algo == b"rsa-sha2-512" {SignatureHash::SHA2_512} else {SignatureHash::SHA1}},}) - edit in thrussh-keys/src/key.rs at line 194
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 205
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/key.rs at line 222
data_encoding::BASE64_NOPAD.encode(&openssl::sha::sha256(&key[..]))use sha2::{Sha256, Digest};let mut hasher = Sha256::new();hasher.update(&key[..]);data_encoding::BASE64_NOPAD.encode(&hasher.finalize()) - edit in thrussh-keys/src/key.rs at line 227
- edit in thrussh-keys/src/key.rs at line 229
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 240
}#[cfg(not(feature = "openssl"))]pub fn set_algorithm(&mut self, _: &[u8]) { - edit in thrussh-keys/src/key.rs at line 259
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 274
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 295
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/key.rs at line 303
.unwrap();.unwrap(); - edit in thrussh-keys/src/key.rs at line 316
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 328
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 340
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 366
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 391
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/key.rs at line 405
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/key.rs at line 435
use sodium::ed25519;use thrussh_libsodium::ed25519; - replacement in thrussh-keys/src/key.rs at line 444
let e = pos.read_string()?;let n = pos.read_string()?;use openssl::bn::*;use openssl::pkey::*;use openssl::rsa::*;return Ok(PublicKey::RSA {key: OpenSSLPKey(PKey::from_rsa(Rsa::from_public_components(BigNum::from_slice(n)?,BigNum::from_slice(e)?,)?)?),hash: SignatureHash::SHA2_256,});#[cfg(feature = "openssl")]{let e = pos.read_string()?;let n = pos.read_string()?;use openssl::bn::*;use openssl::pkey::*;use openssl::rsa::*;return Ok(PublicKey::RSA {key: OpenSSLPKey(PKey::from_rsa(Rsa::from_public_components(BigNum::from_slice(n)?,BigNum::from_slice(e)?,)?)?),hash: SignatureHash::SHA2_256,});} - edit in thrussh-keys/src/format/pkcs8.rs at line 3
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/pkcs8.rs at line 7
use openssl::hash::MessageDigest;#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/pkcs8.rs at line 9
use openssl::rand::rand_bytes;#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/pkcs8.rs at line 11
use openssl::symm::{decrypt, encrypt, Cipher}; - edit in thrussh-keys/src/format/pkcs8.rs at line 21
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/pkcs8.rs at line 27
// let mut sec = Vec::new(); - replacement in thrussh-keys/src/format/pkcs8.rs at line 97
Ok(Ok(MessageDigest::sha256()))Ok(Ok(())) - replacement in thrussh-keys/src/format/pkcs8.rs at line 102
Ok(digest.map(|digest| KeyDerivation::Pbkdf2 {Ok(digest.map(|()| KeyDerivation::Pbkdf2 { - edit in thrussh-keys/src/format/pkcs8.rs at line 105
digest, - edit in thrussh-keys/src/format/pkcs8.rs at line 163
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/pkcs8.rs at line 204
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/pkcs8.rs at line 242
}#[cfg(not(feature = "openssl"))]fn read_key_v0(_: &mut BERReaderSeq) -> Result<key::KeyPair, Error> {Err(Error::CouldNotReadKey.into()) - edit in thrussh-keys/src/format/pkcs8.rs at line 259
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/pkcs8.rs at line 264
use openssl::pkcs5::pbkdf2_hmac; - edit in thrussh-keys/src/format/pkcs8.rs at line 265
use aes::*;use block_modes::block_padding::NoPadding;use block_modes::BlockMode;type Aes128Cbc = block_modes::Cbc<Aes128, NoPadding>;type Aes256Cbc = block_modes::Cbc<Aes256, NoPadding>; - edit in thrussh-keys/src/format/pkcs8.rs at line 277
use rand::RngCore;let mut rng = rand::thread_rng(); - replacement in thrussh-keys/src/format/pkcs8.rs at line 280
rand_bytes(&mut salt)?;rng.fill_bytes(&mut salt); - replacement in thrussh-keys/src/format/pkcs8.rs at line 282
rand_bytes(&mut iv)?;rng.fill_bytes(&mut iv); - replacement in thrussh-keys/src/format/pkcs8.rs at line 284
pbkdf2_hmac(pass,&salt,rounds as usize,MessageDigest::sha256(),&mut dkey,)?;pbkdf2::pbkdf2::<hmac::Hmac<sha2::Sha256>>(pass, &salt, rounds, &mut dkey); - replacement in thrussh-keys/src/format/pkcs8.rs at line 290
let ciphertext = encrypt(Cipher::aes_256_cbc(), &dkey, Some(&iv), &plaintext)?;let c = Aes256Cbc::new_from_slices(&dkey, &iv).unwrap();let n = plaintext.len();c.encrypt(&mut plaintext, n).unwrap(); - replacement in thrussh-keys/src/format/pkcs8.rs at line 304
writer.next().write_bytes(&ciphertext[..])writer.next().write_bytes(&plaintext[..]) - edit in thrussh-keys/src/format/pkcs8.rs at line 314
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/pkcs8.rs at line 382
digest,} => pbkdf2_hmac(password, salt, rounds as usize, digest, key)?,} => {pbkdf2::pbkdf2::<hmac::Hmac<sha2::Sha256>>(password, salt, rounds as u32, key)// pbkdf2_hmac(password, salt, rounds as usize, digest, key)?}, - edit in thrussh-keys/src/format/pkcs8.rs at line 391
#[derive(Debug)] - replacement in thrussh-keys/src/format/pkcs8.rs at line 425
let (cipher, iv) = match *self {Encryption::Aes128Cbc(ref iv) => (Cipher::aes_128_cbc(), iv),Encryption::Aes256Cbc(ref iv) => (Cipher::aes_256_cbc(), iv),};let mut dec = decrypt(cipher, &key, Some(&iv[..]), ciphertext)?;pkcs_unpad(&mut dec);Ok(dec)match *self {Encryption::Aes128Cbc(ref iv) => {let c = Aes128Cbc::new_from_slices(key, iv).unwrap();let mut dec = ciphertext.to_vec();c.decrypt(&mut dec)?;pkcs_unpad(&mut dec);Ok(dec)},Encryption::Aes256Cbc(ref iv) => {let c = Aes256Cbc::new_from_slices(key, iv).unwrap();let mut dec = ciphertext.to_vec();c.decrypt(&mut dec)?;pkcs_unpad(&mut dec);Ok(dec)},} - edit in thrussh-keys/src/format/pkcs8.rs at line 448
digest: MessageDigest, - replacement in thrussh-keys/src/format/pkcs5.rs at line 1
use super::{decode_rsa, pkcs_unpad, Encryption};use super::{pkcs_unpad, Encryption}; - replacement in thrussh-keys/src/format/pkcs5.rs at line 5
use openssl::hash::{Hasher, MessageDigest};use openssl::symm::{decrypt, Cipher};use aes::*;use block_modes::block_padding::NoPadding;use block_modes::BlockMode;type Aes128Cbc = block_modes::Cbc<Aes128, NoPadding>; - edit in thrussh-keys/src/format/pkcs5.rs at line 12
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/pkcs5.rs at line 15
password: Option<&[u8]>,password: Option<&str>, - replacement in thrussh-keys/src/format/pkcs5.rs at line 21
let mut h = Hasher::new(MessageDigest::md5()).unwrap();h.update(pass).unwrap();h.update(&iv[..8]).unwrap();let md5 = h.finish().unwrap();let mut dec = decrypt(Cipher::aes_128_cbc(), &md5, Some(&iv[..]), secret)?;let mut 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();let mut dec = secret.to_vec();c.decrypt(&mut dec).unwrap(); - replacement in thrussh-keys/src/format/pkcs5.rs at line 34
decode_rsa(&sec)super::decode_rsa(&sec) - edit in thrussh-keys/src/format/openssh.rs at line 1
use crate::bcrypt_pbkdf; - replacement in thrussh-keys/src/format/openssh.rs at line 4
use cryptovec::CryptoVec;use bcrypt_pbkdf;#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/openssh.rs at line 7
use openssl::symm::{Cipher, Crypter, Mode}; - replacement in thrussh-keys/src/format/openssh.rs at line 10
pub fn decode_openssh(secret: &[u8], password: Option<&[u8]>) -> Result<key::KeyPair, Error> {pub fn decode_openssh(secret: &[u8], password: Option<&str>) -> Result<key::KeyPair, Error> { - replacement in thrussh-keys/src/format/openssh.rs at line 42
} else if key_type == KEYTYPE_RSA {let n = BigNum::from_slice(position.read_string()?)?;let e = BigNum::from_slice(position.read_string()?)?;let d = BigNum::from_slice(position.read_string()?)?;let iqmp = BigNum::from_slice(position.read_string()?)?;let p = BigNum::from_slice(position.read_string()?)?;let q = BigNum::from_slice(position.read_string()?)?;} else if key_type == KEYTYPE_RSA && cfg!(feature = "openssl") {#[cfg(feature = "openssl")]{let n = BigNum::from_slice(position.read_string()?)?;let e = BigNum::from_slice(position.read_string()?)?;let d = BigNum::from_slice(position.read_string()?)?;let iqmp = BigNum::from_slice(position.read_string()?)?;let p = BigNum::from_slice(position.read_string()?)?;let q = BigNum::from_slice(position.read_string()?)?; - replacement in thrussh-keys/src/format/openssh.rs at line 52
let mut ctx = openssl::bn::BigNumContext::new()?;let un = openssl::bn::BigNum::from_u32(1)?;let mut p1 = openssl::bn::BigNum::new()?;let mut q1 = openssl::bn::BigNum::new()?;p1.checked_sub(&p, &un)?;q1.checked_sub(&q, &un)?;let mut dmp1 = openssl::bn::BigNum::new()?; // d mod p-1dmp1.checked_rem(&d, &p1, &mut ctx)?;let mut dmq1 = openssl::bn::BigNum::new()?; // d mod q-1dmq1.checked_rem(&d, &q1, &mut ctx)?;let mut ctx = openssl::bn::BigNumContext::new()?;let un = openssl::bn::BigNum::from_u32(1)?;let mut p1 = openssl::bn::BigNum::new()?;let mut q1 = openssl::bn::BigNum::new()?;p1.checked_sub(&p, &un)?;q1.checked_sub(&q, &un)?;let mut dmp1 = openssl::bn::BigNum::new()?; // d mod p-1dmp1.checked_rem(&d, &p1, &mut ctx)?;let mut dmq1 = openssl::bn::BigNum::new()?; // d mod q-1dmq1.checked_rem(&d, &q1, &mut ctx)?; - replacement in thrussh-keys/src/format/openssh.rs at line 63
let key = openssl::rsa::RsaPrivateKeyBuilder::new(n, e, d)?.set_factors(p, q)?.set_crt_params(dmp1, dmq1, iqmp)?.build();key.check_key().unwrap();return Ok(key::KeyPair::RSA {key,hash: key::SignatureHash::SHA2_512,});let key = openssl::rsa::RsaPrivateKeyBuilder::new(n, e, d)?.set_factors(p, q)?.set_crt_params(dmp1, dmq1, iqmp)?.build();key.check_key().unwrap();return Ok(key::KeyPair::RSA {key,hash: key::SignatureHash::SHA2_512,});} - edit in thrussh-keys/src/format/openssh.rs at line 83
use aes::*;use block_modes::block_padding::NoPadding;type Aes128Cbc = block_modes::Cbc<Aes128, NoPadding>;type Aes256Cbc = block_modes::Cbc<Aes256, NoPadding>; - replacement in thrussh-keys/src/format/openssh.rs at line 92
password: Option<&[u8]>,password: Option<&str>, - replacement in thrussh-keys/src/format/openssh.rs at line 102
let mut key = CryptoVec::new();let cipher = match ciphername {b"aes128-cbc" => {key.resize(16 + 16);Cipher::aes_128_cbc()}b"aes128-ctr" => {key.resize(16 + 16);Cipher::aes_128_ctr()}b"aes256-cbc" => {key.resize(16 + 32);Cipher::aes_256_cbc()}b"aes256-ctr" => {key.resize(16 + 32);Cipher::aes_256_ctr()}let mut key = [0; 48];let n = match ciphername {b"aes128-cbc" | b"aes128-ctr" => 32,b"aes256-cbc" | b"aes256-ctr" => 48, - edit in thrussh-keys/src/format/openssh.rs at line 108
- replacement in thrussh-keys/src/format/openssh.rs at line 113
bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, &mut key);bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, &mut key[..n]).unwrap(); - replacement in thrussh-keys/src/format/openssh.rs at line 119
let iv = &key[32..];let key = &key[..32];let mut c = Crypter::new(cipher, Mode::Decrypt, &key, Some(&iv))?;c.pad(false);let mut dec = vec![0; secret_key.len() + 32];let n = c.update(&secret_key, &mut dec)?;let n = n + c.finalize(&mut dec[n..])?;dec.truncate(n);let (key, iv) = key.split_at(n - 16);let mut dec = secret_key.to_vec();dec.resize(dec.len() + 32, 0u8);use aes::cipher::{NewCipher, StreamCipher};use block_modes::BlockMode;match ciphername {b"aes128-cbc" => {let cipher = Aes128Cbc::new_from_slices(key, iv).unwrap();let n = cipher.decrypt(&mut dec)?.len();dec.truncate(n)}b"aes256-cbc" => {let cipher = Aes256Cbc::new_from_slices(key, iv).unwrap();let n = cipher.decrypt(&mut dec)?.len();dec.truncate(n)}b"aes128-ctr" => {let mut cipher = Aes128Ctr::new_from_slices(key, iv).unwrap();cipher.apply_keystream(&mut dec);dec.truncate(secret_key.len())}b"aes256-ctr" => {let mut cipher = Aes256Ctr::new_from_slices(key, iv).unwrap();cipher.apply_keystream(&mut dec);dec.truncate(secret_key.len())}_ => {}} - edit in thrussh-keys/src/format/mod.rs at line 4
#[cfg(not(feature = "openssl"))]use data_encoding::BASE64_MIME;#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 8
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 16
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 18
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 36
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 39
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/mod.rs at line 47
pub fn decode_secret_key(secret: &str, password: Option<&[u8]>) -> Result<key::KeyPair, Error> {pub fn decode_secret_key(secret: &str, password: Option<&str>) -> Result<key::KeyPair, Error> { - replacement in thrussh-keys/src/format/mod.rs at line 60
let iv_: Vec<u8> =HEXLOWER_PERMISSIVE.decode(l.split_at(AES_128_CBC.len()).1.as_bytes())?;if iv_.len() != 16 {return Err(Error::CouldNotReadKey.into());#[cfg(feature = "openssl")]{let iv_: Vec<u8> = HEXLOWER_PERMISSIVE.decode(l.split_at(AES_128_CBC.len()).1.as_bytes())?;if iv_.len() != 16 {return Err(Error::CouldNotReadKey.into());}let mut iv = [0; 16];iv.clone_from_slice(&iv_);format = Some(Format::Pkcs5Encrypted(Encryption::Aes128Cbc(iv))) - edit in thrussh-keys/src/format/mod.rs at line 71
let mut iv = [0; 16];iv.clone_from_slice(&iv_);format = Some(Format::Pkcs5Encrypted(Encryption::Aes128Cbc(iv))) - replacement in thrussh-keys/src/format/mod.rs at line 76
} else if l == "-----BEGIN RSA PRIVATE KEY-----" {started = true;format = Some(Format::Rsa);} else if l == "-----BEGIN RSA PRIVATE KEY-----" && cfg!(feature = "openssl") {#[cfg(feature = "openssl")]{started = true;format = Some(Format::Rsa);} - edit in thrussh-keys/src/format/mod.rs at line 96
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/format/mod.rs at line 98
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/format/mod.rs at line 101
self::pkcs8::decode_pkcs8(&secret, password)self::pkcs8::decode_pkcs8(&secret, password.map(|x| x.as_bytes())) - edit in thrussh-keys/src/format/mod.rs at line 128
#[cfg(feature = "openssl")] - replacement in thrussh-keys/src/bcrypt_pbkdf.rs at line 11
use openssl::sha::Sha512;use sha2::{Sha512, Digest}; - replacement in thrussh-keys/src/bcrypt_pbkdf.rs at line 54
hasher.finish()hasher.finalize() - replacement in thrussh-keys/src/bcrypt_pbkdf.rs at line 65
let hsalt = hasher.finish();let hsalt = hasher.finalize(); - replacement in thrussh-keys/src/bcrypt_pbkdf.rs at line 71
let mut hasher = Sha512::new();let mut hasher = sha2::Sha512::new(); - replacement in thrussh-keys/src/bcrypt_pbkdf.rs at line 73
let hsalt = hasher.finish();let hsalt = hasher.finalize(); - edit in thrussh-keys/src/agent/server.rs at line 3
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/agent/server.rs at line 257
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/agent/client.rs at line 109
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/agent/client.rs at line 244
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/agent/client.rs at line 312
#[cfg(feature = "openssl")] - edit in thrussh-keys/src/agent/client.rs at line 476
#[cfg(feature = "openssl")] - replacement in thrussh-keys/Cargo.toml at line 33
byteorder = "1.3"tokio = { version = "1.4", features = [ "io-util", "rt-multi-thread", "time", "net" ] }byteorder = "1.4"tokio = { version = "1.6", features = [ "io-util", "rt-multi-thread", "time", "net" ] }tokio-stream = { version = "0.1", features = [ "net" ] } - replacement in thrussh-keys/Cargo.toml at line 41
openssl = "0.10"openssl = { version = "0.10", optional = true } - edit in thrussh-keys/Cargo.toml at line 43
thrussh-libsodium = "0.2.0" - edit in thrussh-keys/Cargo.toml at line 48
thrussh-libsodium = "0.2"sha2 = "0.9"pbkdf2 = "0.8"hmac = "0.11"rand = "0.8"block-modes = "0.8"aes = { version = "0.7", features = [ "ctr" ] }bcrypt-pbkdf = "0.6"md5 = "*" - replacement in thrussh/src/server/mod.rs at line 574
.map_err(crate::Error::from)?;2 .map_err(crate::Error::from)?;