ssh-cipher 0.3.0-rc.10

Pure Rust implementation of SSH symmetric encryption including support for the modern aes128-gcm@openssh.com/aes256-gcm@openssh.com and chacha20-poly1305@openssh.com algorithms as well as legacy support for older ciphers. Built on the pure Rust cryptography implementations maintained by the RustCrypto organization.
Documentation
//! Integration tests for `ssh-cipher`.
// TODO(tarcieri): test vectors for each supported cipher

use ssh_cipher::Cipher;

#[test]
fn round_trip() {
    const MSG: &[u8] = b"Testing 1 2 3...";
    const CIPHERS: &[Cipher] = &[
        #[cfg(feature = "aes")]
        Cipher::Aes128Cbc,
        #[cfg(feature = "aes")]
        Cipher::Aes192Cbc,
        #[cfg(feature = "aes")]
        Cipher::Aes256Cbc,
        #[cfg(feature = "aes")]
        Cipher::Aes128Ctr,
        #[cfg(feature = "aes")]
        Cipher::Aes192Ctr,
        #[cfg(feature = "aes")]
        Cipher::Aes256Ctr,
        #[cfg(feature = "aes")]
        Cipher::Aes128Gcm,
        #[cfg(feature = "aes")]
        Cipher::Aes256Gcm,
        #[cfg(feature = "chacha20poly1305")]
        Cipher::ChaCha20Poly1305,
        #[cfg(feature = "tdes")]
        Cipher::TdesCbc,
    ];

    for &cipher in CIPHERS {
        let (key_len, iv_len) = cipher.key_and_iv_size().unwrap();

        // TODO(tarcieri): randomize keys?
        let key = vec![0; key_len];
        let iv = vec![0; iv_len];
        let mut buffer = Vec::from(MSG);

        let tag = cipher.encrypt(&key, &iv, &mut buffer).unwrap();
        assert_ne!(buffer, MSG);

        cipher.decrypt(&key, &iv, &mut buffer, tag).unwrap();
        assert_eq!(buffer, MSG);
    }
}