crypto::aes +linux +x86_64

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

// Undocumented 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[link]

Show undocumented member
type block = struct {
	vtable: cipher::block,
	rounds: u32,
	expkey: [MAXEXPKEYSIZE]u8,
};

Constants

def BLOCKSIZE[link]

def BLOCKSIZE: size;

The block size used by the AES algorithm.

def CBC_BUFSIZE[link]

def CBC_BUFSIZE: size;

Size of the buffer used for crypto::cipher::cbc_encryptor and crypto::cipher::cbc_decryptor.

def CTR_BUFSIZE[link]

def CTR_BUFSIZE: size;

Size of the buffer used for crypto::cipher::ctr.

Functions

fn aes[link]

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[link]

fn hwsupport() bool;

Checks whether hardware AES support is available.

fn init[link]

fn init(b: *block, key: []u8) void;

Initializes the AES block with an encryption key.