fixed salsa and chacha key

This commit is contained in:
Y. T. Chung
2016-10-30 21:17:10 +08:00
parent 1b28dbebd6
commit ee7d7fbbec

View File

@@ -36,9 +36,10 @@ pub enum CryptoCipher {
impl CryptoCipher {
/// Creates an instance
pub fn new(t: CipherType, key: &[u8], iv: &[u8]) -> CryptoCipher {
let key = t.bytes_to_key(key);
match t {
CipherType::ChaCha20 => CryptoCipher::ChaCha20(ChaCha20::new(key, iv)),
CipherType::Salsa20 => CryptoCipher::Salsa20(Salsa20::new(key, iv)),
CipherType::ChaCha20 => CryptoCipher::ChaCha20(ChaCha20::new(&key[..], iv)),
CipherType::Salsa20 => CryptoCipher::Salsa20(Salsa20::new(&key[..], iv)),
_ => panic!("Rust Crypto does not support {:?} cipher", t),
}
}