Expand description
RC2, RC5 and RC6 single-block ciphers.
- RC2:
Rc2Enginetakes a 1- to 128-byte key and an effective key size of 1 to 1024 bits throughRc2Params.Rc2ParamsRef::newuses the key’s full length;Rc2ParamsRef::with_effective_key_bitspicks a size. - RC5:
Rc532EngineandRc564Enginetake a 1- to 255-byte key and 0 to 255 rounds throughRc5Params, such asRc5ParamsRef. - RC6:
Rc6Engineis RC6-32/20 and takes a 1- to 255-byte key through anyKeyParams, such astc_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]);Structs§
- Rc2Engine
- RC2 engine whose backend is chosen at build time.
- Rc2Params
Owned - Owned RC2 key and effective key size, wiped on drop.
- Rc2Params
Ref - Borrowed RC2 key and effective key size.
- Rc2Rust
Crypto Engine - RC2 engine backed by RustCrypto’s
rc2crate, with therustcryptofeature. - Rc2Table
Engine - Portable RC2 engine.
- Rc5Params
Owned - Owned RC5 key and round count, wiped on drop.
- Rc5Params
Ref - Borrowed RC5 key and round count.
- Rc6Engine
- RC6-32/20 engine with a 16-byte block and a 1- to 255-byte key.
- Rc532
Engine - RC5-32 engine with an 8-byte block.
- Rc564
Engine - RC5-64 engine with a 16-byte block.
Constants§
- RC2_
ALGO_ NAME - Algorithm display name.
- RC2_
BLOCK_ BYTES - RC2 block length in bytes (64 bits).
- RC2_
MAX_ EFFECTIVE_ KEY_ BITS - Maximum RC2 effective key size in bits.
- RC2_
MAX_ KEY_ BYTES - Maximum RC2 key length in bytes.
- RC5_
32_ ALGO_ NAME - RC5-32 display name.
- RC5_
32_ BLOCK_ BYTES - RC5-32 block length in bytes.
- RC5_
64_ ALGO_ NAME - RC5-64 display name.
- RC5_
64_ BLOCK_ BYTES - RC5-64 block length in bytes.
- RC5_
DEFAULT_ ROUNDS - Standard RC5 round count.
- RC5_
MAX_ KEY_ BYTES - Maximum RC5 key length in bytes.
- RC5_
MAX_ ROUNDS - Maximum RC5 round count defined by RFC 2040.
- RC6_
ALGO_ NAME - Algorithm name written by the engine.
- RC6_
BLOCK_ BYTES - RC6 block length in bytes.
- RC6_
MAX_ KEY_ BYTES - Maximum accepted RC6 key length in bytes.
- RC6_
ROUNDS - RC6 round count.