Skip to content

Commit 3db5798

Browse files
committed
Stub out ChaCha20 non-HMAC encryption/decryption in fuzztarget
1 parent 482648b commit 3db5798

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use ln::msgs;
1919
use ln::msgs::{HandleError,ChannelMessageHandler,MsgEncodable,MsgDecodable};
2020
use util::{byte_utils, events, internal_traits, rng};
2121
use util::sha2::Sha256;
22+
use util::chacha20poly1305rfc::ChaCha20;
2223

2324
use crypto;
2425
use crypto::mac::{Mac,MacResult};
2526
use crypto::hmac::Hmac;
2627
use crypto::digest::Digest;
2728
use crypto::symmetriccipher::SynchronousStreamCipher;
28-
use crypto::chacha20::ChaCha20;
2929

3030
use std::{ptr, mem};
3131
use std::collections::HashMap;

src/util/chacha20poly1305rfc.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
#[cfg(not(feature = "fuzztarget"))]
1414
mod real_chachapoly {
1515
use crypto::aead::{AeadEncryptor,AeadDecryptor};
16-
use crypto::chacha20::ChaCha20;
1716
use crypto::symmetriccipher::SynchronousStreamCipher;
1817
use crypto::poly1305::Poly1305;
1918
use crypto::mac::Mac;
2019
use crypto::util::fixed_time_eq;
2120

21+
pub use crypto::chacha20::ChaCha20;
22+
2223
use util::byte_utils;
2324

2425
#[derive(Clone, Copy)]
@@ -104,11 +105,12 @@ mod real_chachapoly {
104105
}
105106
}
106107
#[cfg(not(feature = "fuzztarget"))]
107-
pub use self::real_chachapoly::ChaCha20Poly1305RFC;
108+
pub use self::real_chachapoly::{ChaCha20Poly1305RFC, ChaCha20};
108109

109110
#[cfg(feature = "fuzztarget")]
110111
mod fuzzy_chachapoly {
111112
use crypto::aead::{AeadEncryptor,AeadDecryptor};
113+
use crypto::symmetriccipher::SynchronousStreamCipher;
112114

113115
#[derive(Clone, Copy)]
114116
pub struct ChaCha20Poly1305RFC {
@@ -155,6 +157,22 @@ mod fuzzy_chachapoly {
155157
true
156158
}
157159
}
160+
161+
pub struct ChaCha20 {}
162+
163+
impl ChaCha20 {
164+
pub fn new(key: &[u8], nonce: &[u8]) -> ChaCha20 {
165+
assert!(key.len() == 16 || key.len() == 32);
166+
assert!(nonce.len() == 8 || nonce.len() == 12);
167+
Self {}
168+
}
169+
}
170+
171+
impl SynchronousStreamCipher for ChaCha20 {
172+
fn process(&mut self, input: &[u8], output: &mut [u8]) {
173+
output.copy_from_slice(input);
174+
}
175+
}
158176
}
159177
#[cfg(feature = "fuzztarget")]
160-
pub use self::fuzzy_chachapoly::ChaCha20Poly1305RFC;
178+
pub use self::fuzzy_chachapoly::{ChaCha20Poly1305RFC, ChaCha20};

0 commit comments

Comments
 (0)