|
13 | 13 | #[cfg(not(feature = "fuzztarget"))]
|
14 | 14 | mod real_chachapoly {
|
15 | 15 | use crypto::aead::{AeadEncryptor,AeadDecryptor};
|
16 |
| - use crypto::chacha20::ChaCha20; |
17 | 16 | use crypto::symmetriccipher::SynchronousStreamCipher;
|
18 | 17 | use crypto::poly1305::Poly1305;
|
19 | 18 | use crypto::mac::Mac;
|
20 | 19 | use crypto::util::fixed_time_eq;
|
21 | 20 |
|
| 21 | + pub use crypto::chacha20::ChaCha20; |
| 22 | + |
22 | 23 | use util::byte_utils;
|
23 | 24 |
|
24 | 25 | #[derive(Clone, Copy)]
|
@@ -104,11 +105,12 @@ mod real_chachapoly {
|
104 | 105 | }
|
105 | 106 | }
|
106 | 107 | #[cfg(not(feature = "fuzztarget"))]
|
107 |
| -pub use self::real_chachapoly::ChaCha20Poly1305RFC; |
| 108 | +pub use self::real_chachapoly::{ChaCha20Poly1305RFC, ChaCha20}; |
108 | 109 |
|
109 | 110 | #[cfg(feature = "fuzztarget")]
|
110 | 111 | mod fuzzy_chachapoly {
|
111 | 112 | use crypto::aead::{AeadEncryptor,AeadDecryptor};
|
| 113 | + use crypto::symmetriccipher::SynchronousStreamCipher; |
112 | 114 |
|
113 | 115 | #[derive(Clone, Copy)]
|
114 | 116 | pub struct ChaCha20Poly1305RFC {
|
@@ -155,6 +157,22 @@ mod fuzzy_chachapoly {
|
155 | 157 | true
|
156 | 158 | }
|
157 | 159 | }
|
| 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 | + } |
158 | 176 | }
|
159 | 177 | #[cfg(feature = "fuzztarget")]
|
160 |
| -pub use self::fuzzy_chachapoly::ChaCha20Poly1305RFC; |
| 178 | +pub use self::fuzzy_chachapoly::{ChaCha20Poly1305RFC, ChaCha20}; |
0 commit comments