pub fn feistel_network_decrypt(
input: &[u8],
key: u128,
rounds: u32,
) -> Result<Vec<u8>, &'static str>Expand description
Decrypts an array of bytes using the feistel cipher
§Arguments
input- The array of bytes to decryptkey- The key to use for decryptionrounds- The number of rounds to use for decryption
§Returns
A Result containing the decrypted data on success, or an error message on failure.
§Errors
Input must not be empty- If the input array is emptyInput length must be a multiple of 2- If the input length is not a multiple of 2Number of rounds must be greater than 0- If the number of rounds is less than 1HMAC creation failed- If there is an error in creating the HMAC for the round function in the Key Derivation Function
§Example
use cryptographic_primitives::{feistel_network_encrypt, feistel_network_decrypt};
let plaintext = b"Hello, world!";
let ciphertext = feistel_network_encrypt(plaintext, 15, 5).unwrap();
let decrypted = feistel_network_decrypt(&ciphertext, 15, 5).unwrap();
assert_eq!(decrypted, plaintext.to_vec());