Skip to main content

Crate tc_rc_cipher

Crate tc_rc_cipher 

Source
Expand description

RC2, RC5 and RC6 single-block ciphers.

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.
Rc2ParamsOwned
Owned RC2 key and effective key size, wiped on drop.
Rc2ParamsRef
Borrowed RC2 key and effective key size.
Rc2RustCryptoEngine
RC2 engine backed by RustCrypto’s rc2 crate, with the rustcrypto feature.
Rc2TableEngine
Portable RC2 engine.
Rc5ParamsOwned
Owned RC5 key and round count, wiped on drop.
Rc5ParamsRef
Borrowed RC5 key and round count.
Rc6Engine
RC6-32/20 engine with a 16-byte block and a 1- to 255-byte key.
Rc532Engine
RC5-32 engine with an 8-byte block.
Rc564Engine
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.

Traits§

Rc2Params
Supplies an RC2 key and its effective size.
Rc5Params
Supplies an RC5 key and public round count.