From: Matt Corallo Date: Fri, 3 Aug 2018 00:05:14 +0000 (-0400) Subject: Stub out ChaCha20 non-HMAC encryption/decryption in fuzztarget X-Git-Tag: v0.0.12~354^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=3db5798246a9bfdcabee60d27740ba8783b27e22;p=rust-lightning Stub out ChaCha20 non-HMAC encryption/decryption in fuzztarget --- diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 76272d4e6..29d260ba6 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -19,13 +19,13 @@ use ln::msgs; use ln::msgs::{HandleError,ChannelMessageHandler,MsgEncodable,MsgDecodable}; use util::{byte_utils, events, internal_traits, rng}; use util::sha2::Sha256; +use util::chacha20poly1305rfc::ChaCha20; use crypto; use crypto::mac::{Mac,MacResult}; use crypto::hmac::Hmac; use crypto::digest::Digest; use crypto::symmetriccipher::SynchronousStreamCipher; -use crypto::chacha20::ChaCha20; use std::{ptr, mem}; use std::collections::HashMap; diff --git a/src/util/chacha20poly1305rfc.rs b/src/util/chacha20poly1305rfc.rs index 9c86d44b4..1aeaf61d2 100644 --- a/src/util/chacha20poly1305rfc.rs +++ b/src/util/chacha20poly1305rfc.rs @@ -13,12 +13,13 @@ #[cfg(not(feature = "fuzztarget"))] mod real_chachapoly { use crypto::aead::{AeadEncryptor,AeadDecryptor}; - use crypto::chacha20::ChaCha20; use crypto::symmetriccipher::SynchronousStreamCipher; use crypto::poly1305::Poly1305; use crypto::mac::Mac; use crypto::util::fixed_time_eq; + pub use crypto::chacha20::ChaCha20; + use util::byte_utils; #[derive(Clone, Copy)] @@ -104,11 +105,12 @@ mod real_chachapoly { } } #[cfg(not(feature = "fuzztarget"))] -pub use self::real_chachapoly::ChaCha20Poly1305RFC; +pub use self::real_chachapoly::{ChaCha20Poly1305RFC, ChaCha20}; #[cfg(feature = "fuzztarget")] mod fuzzy_chachapoly { use crypto::aead::{AeadEncryptor,AeadDecryptor}; + use crypto::symmetriccipher::SynchronousStreamCipher; #[derive(Clone, Copy)] pub struct ChaCha20Poly1305RFC { @@ -155,6 +157,22 @@ mod fuzzy_chachapoly { true } } + + pub struct ChaCha20 {} + + impl ChaCha20 { + pub fn new(key: &[u8], nonce: &[u8]) -> ChaCha20 { + assert!(key.len() == 16 || key.len() == 32); + assert!(nonce.len() == 8 || nonce.len() == 12); + Self {} + } + } + + impl SynchronousStreamCipher for ChaCha20 { + fn process(&mut self, input: &[u8], output: &mut [u8]) { + output.copy_from_slice(input); + } + } } #[cfg(feature = "fuzztarget")] -pub use self::fuzzy_chachapoly::ChaCha20Poly1305RFC; +pub use self::fuzzy_chachapoly::{ChaCha20Poly1305RFC, ChaCha20};