/// Create a new Cipher of `kind`
///
/// - Stream Ciphers initialize with IV
/// - AEAD Ciphers initialize with SALT
Create a new Cipher of `kind`
Stream Ciphers initialize with IV
AEAD Ciphers initialize with SALT
Create a new Cipher of ` kind ` Stream Ciphers initialize with IV AEAD Ciphers initialize with SALT
pub fn new(kind: CipherKind, key: &[u8], iv_or_salt: &[u8]) -> Cipher {
        let category = kind.category();
        match category {
            CipherCategory::None => {
                let _ = key;
                let _ = iv_or_salt;
                Cipher::Dummy(DummyCipher::new())
            }
            #[cfg(feature = "v1-stream")]
            CipherCategory::Stream => Cipher::Stream(StreamCipher::new(kind, key, iv_or_salt)),
            #[cfg(feature = "v1-aead")]
            CipherCategory::Aead => {
                use crypto2::kdf::HkdfSha1;
                // Gen SubKey
                let ikm = key;
                let mut okm = [0u8; Self::MAX_KEY_LEN];
                HkdfSha1::oneshot(&iv_or_salt, ikm, Self::SUBKEY_INFO, &mut okm[..ikm.len()]);
                let subkey = &okm[..ikm.len()];
                Cipher::Aead(AeadCipher::new(kind, subkey))
            }
        }
    }
pub fn new ( kind : CipherKind , key : & [ u8 ] , iv_or_salt : & [ u8 ] ) -> Cipher { let category = kind . category ( ) ; match category { CipherCategory :: None => { let _ = key ; let _ = iv_or_salt ; Cipher :: Dummy ( DummyCipher :: new ( ) ) } # [ cfg ( feature " " ) ] CipherCategory :: Stream => Cipher :: Stream ( StreamCipher :: new ( kind , key , iv_or_salt ) ) , # [ cfg ( feature " " ) ] CipherCategory :: Aead => { use crypto2 :: kdf :: HkdfSha1 ; // Gen SubKey let ikm = key ; let mut okm = [ 0u8 ; Self :: MAX_KEY_LEN ] ; HkdfSha1 :: oneshot ( & iv_or_salt , ikm , Self :: SUBKEY_INFO , & mut okm [ .. ikm . len ( ) ] ) ; let subkey = & okm [ .. ikm . len ( ) ] ; Cipher :: Aead ( AeadCipher :: new ( kind , subkey ) ) } } }
Create a new Cipher of `kind`
 Stream Ciphers initialize with IV
 AEAD Ciphers initialize with SALT
Create a new Cipher of ` kind ` Stream Ciphers initialize with IV AEAD Ciphers initialize with SALT
kind
CipherKind
key
&[u8]
iv_or_salt
&[u8]