pub fn feistel_network_encrypt(
input: &[u8],
key: &u128,
rounds: u32
) -> Result<Vec<u8>, &'static str>
Expand description
Encrypts an array of bytes using the feistel cipher
§Arguments
input
- The array of bytes to encryptkey
- The key to use for encryptionrounds
- The number of rounds to use for encryption
§Example
use cryptographic_primitives::feistel_network_encrypt;
let plaintext = b"Hello, world!";
let ciphertext = feistel_network_encrypt(plaintext, &15, 5).unwrap();
assert_eq!(ciphertext, vec![20, 214, 205, 97, 45, 140, 194, 245, 186, 32, 98, 214, 120, 45]);
§Errors
Input must not be empty
- If the input array is emptyNumber 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 or the Key Derivation Function