Function decrypt

Source
pub fn decrypt<W: Word>(
    key: &[u8],
    ciphertext: &[u8],
    rounds: usize,
) -> Result<Vec<u8>, Error>
Expand description

Given a key and ciphertext, returns the plaintext using a parametrized RC5.

This is the generic RC5 implementation, which uses a generic word size and rounds count.

The word size is specified by using a type parameter, which must implement Word trait. The key size is specified by the length of the key slice. The rounds count is specified by the rounds parameter.

Usage example:

use rc5_rs::decrypt;
let key = [
  0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
  0x48, 0x81, 0xFF, 0x48,
];

let pt = vec![0xEA, 0x02, 0x47, 0x14, 0xAD, 0x5C, 0x4D, 0x84];
let ct = vec![0x11, 0xE4, 0x3B, 0x86, 0xD2, 0x31, 0xEA, 0x64];
let res = decrypt::<u32>(&key, &ct, 12).unwrap();
assert_eq!(pt, res);