Function aes_frast::aes_core::block_enc_k128 [] [src]

pub fn block_enc_k128(input: &[u8], output: &mut [u8], keys: &[u32])

Encrypt a block with scheduled keys (from 128bit key).

[Attention!] The first and second parameters must possess 16 elements each in the slice, and the third 44.

Examples

use aes_frast::aes_core::{setkey_enc_k128, block_enc_k128};
 
let input: [u8; 16] = [
    0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D,
    0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34
];
let origin_key: [u8; 16] = [
    0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
    0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
];
let mut scheduled_keys: [u32; 44] = [0; 44];
let mut output: [u8; 16] = [0; 16];
 
setkey_enc_k128(&origin_key, &mut scheduled_keys);
block_enc_k128(&input, &mut output, &scheduled_keys);
 
let expected: [u8; 16] = [
    0x39, 0x25, 0x84, 0x1D, 0x02, 0xDC, 0x09, 0xFB,
    0xDC, 0x11, 0x85, 0x97, 0x19, 0x6A, 0x0B, 0x32
];
for i in 0..16 {
    assert_eq!(output[i], expected[i]);
}