Expand description
The aes_core
mod provides the essential functions of AES, including key scheduling and
single-block crypto.
aes_core
aes_core
is the core part of AES crypto, including key scheduling, block encryption and
decryption.
This module provides low-level API.
In this library, AES is implemented by looking-up-tables.
Attention!
This low-level API does NOT provide error handling.
Please be careful with the lengths of the slices when passing it as the parameters of a
function. Otherwise, it will panic at index out of bounds
or assertion failed
.
Block cipher
The AES algorithm only supports 128-bit (16 bytes) block.
It supports 128-bit (16 bytes), 192-bit (24 bytes) and 265-bit (32 bytes) keys.
AES block crypto uses sub-keys (aka working keys), which are derived from a key. This derivation process is called key schedule or key expansion.
key size in bits | key size in bytes | sub-keys size in 32-bit words |
---|---|---|
128 | 16 | 44 |
192 | 24 | 52 |
256 | 32 | 60 |
Constants
- AES block size in bytes, which is 16.
- 128bit key size in bytes, which is 16.
- 192bit key size in bytes, which is 24.
- 256bit key size in bytes, which is 32.
- Sub-keys size in words (u32) from 128bit key, which is 44.
- Sub-keys size in words (u32) from 192bit key, which is 52.
- Sub-keys size in words (u32) from 256bit key, which is 60.
Functions
- Decrypt a block with scheduled keys (from 128bit key).
- Decrypt a block with scheduled keys (from 128bit key) in place.
- Decrypt a block with scheduled keys (from 192bit key).
- Decrypt a block with scheduled keys (from 192bit key) in place.
- Decrypt a block with scheduled keys (from 256bit key).
- Decrypt a block with scheduled keys (from 256bit key) in place.
- Encrypt a block with scheduled keys (from 128bit key).
- Encrypt a block with scheduled keys (from 128bit key) in place.
- Encrypt a block with scheduled keys (from 192bit key).
- Encrypt a block with scheduled keys (from 192bit key) in place.
- Encrypt a block with scheduled keys (from 256bit key).
- Encrypt a block with scheduled keys (from 256bit key) in place.
- Schedule a 128bit key to sub-keys for decryption.
- Schedule a 192bit key to sub-keys for decryption.
- Schedule a 256bit key to sub-keys for decryption.
- Schedule a key to sub-keys for decryption with auto-selected key-size.
- Schedule a 128bit key to sub-keys for encryption.
- Schedule a 192bit key to sub-keys for encryption.
- Schedule a 256bit key to sub-keys for encryption.
- Schedule a key to sub-keys for encryption with auto-selected key-size.