crypto::aes
The crypto::aes module provides an implementation of the Advanced Encryption
Standard per the crypto::cipher::block interface. Several implementations of
AES are provided which are optimized for different scenarios. To choose the most
appropriate one for your system, use aes.
When combined with a block cipher mode from crypto::cipher, suitable buffer
lengths for static allocation are provided as constants such as BLOCKSIZE,
CTR_BUFSIZE, and CBC_BUFSIZE.
This is a low-level module which implements cryptographic primitives. Direct use
of cryptographic primitives is not recommended for non-experts, as incorrect use
of these primitives can easily lead to the introduction of security
vulnerabilities. Non-experts are advised to use the high-level operations
available in the top-level crypto module.
Be advised that Hare's cryptography implementations have not been audited.
Submodules
Index
Types
type block;
Constants
const BLOCKSIZE: size;
const CBC_BUFSIZE: size;
const CTR_BUFSIZE: size;
Functions
fn aes() block;
fn hwsupport() bool;
fn init(*block, []u8) void;
Types
type block
Show undocumented member
type block = struct {
vtable: cipher::block,
rounds: u32,
expkey: [MAXEXPKEYSIZE]u8,
};
Constants
def BLOCKSIZE
def BLOCKSIZE: size;
The block size used by the AES algorithm.
Functions
fn aes
fn aes() block;
Returns an AES crypto::cipher::block cipher implementation that has
hardware support if possible. Check hwsupport to see if it is available.
The caller must call init to add a key to the cipher before using
the cipher, and must call crypto::cipher::finish when they are finished
using the cipher to securely erase any secret data stored in the cipher
state.
fn hwsupport
fn hwsupport() bool;
Checks whether hardware AES support is available.
fn init
fn init(b: *block, key: []u8) void;
Initializes the AES block with an encryption key.