| 1 |
//! Legacy version of ChaCha20 with a 64-bit nonce |
| 2 |
|
| 3 |
use crate::{ChaChaCore, Key, R20, variants::Legacy}; |
| 4 |
use cipher::{ |
| 5 |
IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherCoreWrapper, |
| 6 |
array::Array, |
| 7 |
consts::{U8, U32}, |
| 8 |
}; |
| 9 |
|
| 10 |
/// Nonce type used by [`ChaCha20Legacy`]. |
| 11 |
pub type LegacyNonce = Array<u8, U8>; |
| 12 |
|
| 13 |
/// The ChaCha20 stream cipher (legacy "djb" construction with 64-bit nonce). |
| 14 |
pub type ChaCha20Legacy = StreamCipherCoreWrapper<ChaCha20LegacyCore>; |
| 15 |
|
| 16 |
/// The ChaCha20 stream cipher (legacy "djb" construction with 64-bit nonce). |
| 17 |
pub type ChaCha20LegacyCore = ChaChaCore<R20, Legacy>; |
| 18 |
|
| 19 |
impl KeySizeUser for ChaCha20LegacyCore { |
| 20 |
type KeySize = U32; |
| 21 |
} |
| 22 |
|
| 23 |
impl IvSizeUser for ChaCha20LegacyCore { |
| 24 |
type IvSize = U8; |
| 25 |
} |
| 26 |
|
| 27 |
impl KeyIvInit for ChaCha20LegacyCore { |
| 28 |
#[inline(always)] |
| 29 |
fn new(key: &Key, iv: &LegacyNonce) -> Self { |
| 30 |
ChaChaCore::<R20, Legacy>::new_internal(key.as_ref(), iv.as_ref()) |
| 31 |
} |
| 32 |
} |