silk.crypto.aes_round.
The steps of an AES round on one 16-byte state, computed with portable code: SubBytes, ShiftRows and MixColumns, and their inverses.
When to use#
Use this module to check or replace the AES instructions of silk.simd.x86 and
silk.simd.aarch64 on a CPU without them. To encrypt data, use silk.crypto.aes_gcm.
Details#
A state holds the AES state matrix column by column, as FIPS 197 and the AES instructions
do: lane 4 * c + r is row r of column c. SubBytes computes each byte's inverse in
GF(2^8) instead of reading a table, so its time does not depend on the data.
Examples#
Substitute one state#
import silk.crypto.aes_round
import silk.simd.u8x16
pub fn main() -> i32 {
let substituted = aes_round.subBytes(u8x16.splat(0))
if u8x16.extract(substituted, 5) != 99 {
return 1
}
return 0
}Import as aes with import silk.crypto.aes_round as aes.
Public declarations: 6.
subBytes#
pub fn subBytes(state: simd<u8, 16>) -> simd<u8, 16>SubBytes: each byte replaced by its AES S-box value.
It computes each byte's inverse in GF(2^8) instead of reading a table, so its time does not depend on the data.
inverseSubBytes#
pub fn inverseSubBytes(state: simd<u8, 16>) -> simd<u8, 16>InvSubBytes: each byte replaced by its inverse S-box value.
It computes each byte's inverse in GF(2^8) instead of reading a table, so its time does not depend on the data.
shiftRows#
pub fn shiftRows(state: simd<u8, 16>) -> simd<u8, 16>ShiftRows: row r rotated left by r columns.
The state holds the AES state matrix column by column: lane 4 * c + r is row r of column
c, as in FIPS 197.
inverseShiftRows#
pub fn inverseShiftRows(state: simd<u8, 16>) -> simd<u8, 16>InvShiftRows: row r rotated right by r columns.
The state holds the AES state matrix column by column: lane 4 * c + r is row r of column
c, as in FIPS 197.
mixColumns#
pub fn mixColumns(state: simd<u8, 16>) -> simd<u8, 16>MixColumns: each column multiplied by the AES MixColumns matrix.
The state holds the AES state matrix column by column: lane 4 * c + r is row r of column
c, as in FIPS 197.
inverseMixColumns#
pub fn inverseMixColumns(state: simd<u8, 16>) -> simd<u8, 16>InvMixColumns: each column multiplied by the inverse MixColumns matrix.
The state holds the AES state matrix column by column: lane 4 * c + r is row r of column
c, as in FIPS 197.
Category: Cryptography.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.