pub fn sub_per_box_encrypt(
input: &[u8],
key: u128,
rounds: u32,
) -> Result<Vec<u8>, &'static str>Expand description
Encrypts an array of bytes using the substitution-permutation network
§Arguments
input- The array of bytes to encryptkey- The key to use for encryptionrounds- The number of rounds to use for encryption
§Returns
A Result containing the encrypted data on success, or an error message on failure.
§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 in the Key Derivation Function
§Example
use cryptographic_primitives::sub_per_box_encrypt;
let plaintext = b"Hello, world!";
let ciphertext = sub_per_box_encrypt(plaintext, 15, 3).unwrap();
assert_eq!(ciphertext, vec![88, 16, 91, 161, 233, 130, 28, 216, 159, 37, 150, 29, 125, 37, 247, 49]);