1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! RC2, RC5 and RC6 single-block ciphers.
//!
//! - RC2: [`Rc2Engine`] takes a 1- to 128-byte key and an effective key size
//! of 1 to 1024 bits through [`Rc2Params`]. [`Rc2ParamsRef::new`] uses the
//! key's full length; [`Rc2ParamsRef::with_effective_key_bits`] picks a size.
//! - RC5: [`Rc532Engine`] and [`Rc564Engine`] take a 1- to 255-byte key and 0
//! to 255 rounds through [`Rc5Params`], such as [`Rc5ParamsRef`].
//! - RC6: [`Rc6Engine`] is RC6-32/20 and takes a 1- to 255-byte key through any
//! `KeyParams`, such as `tc_block_cipher::KeyRef`.
//!
//! Everything is exported at the crate root; constants carry the algorithm in
//! their name, such as [`RC2_BLOCK_BYTES`] and [`RC6_MAX_KEY_BYTES`].
//!
//! These ciphers exist for interoperability with existing formats; prefer a
//! modern authenticated cipher for new designs. The `rustcrypto` feature makes
//! [`Rc2Engine`] use RustCrypto's `rc2` crate, and the `alloc` feature adds
//! `Rc2ParamsOwned` and `Rc5ParamsOwned`, which own their key and wipe it on
//! drop.
//!
//! # Example
//!
//! Encrypting the RFC 2268 test block with RC2:
//!
//! ```
//! use tc_block_cipher::{BlockCipher, BlockCipherInit, CipherDirection};
//! use tc_rc_cipher::{Rc2Engine, Rc2ParamsRef};
//!
//! let mut engine = Rc2Engine::new();
//! engine.init(
//! CipherDirection::Encrypt,
//! &Rc2ParamsRef::with_effective_key_bits(&[0; 8], 63),
//! )?;
//! let mut ciphertext = [0; 8];
//! engine.process_block(&[0; 8], &mut ciphertext)?;
//! assert_eq!(ciphertext, [0xeb, 0xb7, 0x73, 0xf9, 0x93, 0x27, 0x8e, 0xff]);
//! # Ok::<(), Box<dyn core::error::Error>>(())
//! ```
extern crate alloc;
pub use ;
pub use ;
pub use Rc2RustCryptoEngine;
pub use ;
pub use ;
pub use ;
pub use ;