Function aes_frast::aes_core::block_enc_k256 [] [src]

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

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

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

Examples

use aes_frast::aes_core::{setkey_enc_k256, block_enc_k256};
 
let input: [u8; 16] = [
    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
    0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
];
let origin_key: [u8; 32] = [
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
    0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
];
let mut scheduled_keys: [u32; 60] = [0; 60];
let mut output: [u8; 16] = [0; 16];
 
setkey_enc_k256(&origin_key, &mut scheduled_keys);
block_enc_k256(&input, &mut output, &scheduled_keys);
 
let expected: [u8; 16] = [
    0x8E, 0xA2, 0xB7, 0xCA, 0x51, 0x67, 0x45, 0xBF,
    0xEA, 0xFC, 0x49, 0x90, 0x4B, 0x49, 0x60, 0x89
];
for i in 0..16 {
    assert_eq!(output[i], expected[i]);
}