package core:crypto/aes
Overview
package aes implements the AES block cipher and some common modes.
See: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197-upd1.pdf https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
Index
Types (4)
Variables (0)
This section is empty.
Procedure Groups (0)
This section is empty.
Types
Context_CTR ¶
Context_CTR :: struct { _impl: Context_Impl, _buffer: [16]u8, _off: int, _ctr_hi: u64, _ctr_lo: u64, _is_initialized: bool, }
Context_CTR is a keyed AES-CTR instance.
Related Procedures With Parameters
Context_ECB ¶
Context_ECB :: struct { _impl: Context_Impl, _is_initialized: bool, }
Context_ECB is a keyed AES-ECB instance.
WARNING: Using ECB mode is strongly discouraged unless it is being used to implement higher level constructs.
Related Procedures With Parameters
Context_GCM ¶
Context_GCM :: struct { _impl: Context_Impl, _is_initialized: bool, }
Context_GCM is a keyed AES-GCM instance.
Related Procedures With Parameters
Implementation ¶
Implementation :: enum int { Portable, Hardware, }
Implementation is an AES implementation. Most callers will not need
to use this as the package will automatically select the most performant
implementation available (See is_hardware_accelerated()
).
Related Procedures With Parameters
Related Constants
Constants
DEFAULT_IMPLEMENTATION ¶
DEFAULT_IMPLEMENTATION :: Implementation.Hardware
DEFAULT_IMPLEMENTATION is the implementation that will be used by default if possible.
GCM_IV_SIZE_MAX ¶
GCM_IV_SIZE_MAX :: 0x2000000000000000
GCM_IV_SIZE_MAX is the maximum size of the GCM IV in bytes.
Variables
This section is empty.
Procedures
decrypt_ecb ¶
decrypt_ecb :: proc(ctx: ^Context_ECB, dst, src: []u8) {…}
decrypt_ecb decrypts the BLOCK_SIZE buffer src, and writes the result to dst.
encrypt_ecb ¶
encrypt_ecb :: proc(ctx: ^Context_ECB, dst, src: []u8) {…}
encrypt_ecb encrypts the BLOCK_SIZE buffer src, and writes the result to dst.
init_ctr ¶
init_ctr :: proc(ctx: ^Context_CTR, key, iv: []u8, impl: Implementation = DEFAULT_IMPLEMENTATION) {…}
init_ctr initializes a Context_CTR with the provided key and IV.
init_ecb ¶
init_ecb :: proc(ctx: ^Context_ECB, key: []u8, impl: Implementation = DEFAULT_IMPLEMENTATION) {…}
init_ecb initializes a Context_ECB with the provided key.
init_gcm ¶
init_gcm :: proc(ctx: ^Context_GCM, key: []u8, impl: Implementation = DEFAULT_IMPLEMENTATION) {…}
init_gcm initializes a Context_GCM with the provided key.
is_hardware_accelerated ¶
is_hardware_accelerated :: proc "contextless" () -> bool {…}
is_hardware_accelerated returns true iff hardware accelerated AES is supported.
keystream_bytes_ctr ¶
keystream_bytes_ctr :: proc(ctx: ^Context_CTR, dst: []u8) {…}
keystream_bytes_ctr fills dst with the raw AES-CTR keystream output.
open_gcm ¶
open_gcm :: proc( ctx: ^Context_GCM, dst, iv, aad, ciphertext, tag: []u8, ) -> bool {…}
open_gcm authenticates the aad and ciphertext, and decrypts the ciphertext, with the provided Context_GCM, iv, and tag, and stores the output in dst, returning true iff the authentication was successful. If authentication fails, the destination buffer will be zeroed.
dst and plaintext MUST alias exactly or not at all.
reset_ctr ¶
reset_ctr :: proc "contextless" (ctx: ^Context_CTR) {…}
reset_ctr sanitizes the Context_CTR. The Context_CTR must be re-initialized to be used again.
reset_ecb ¶
reset_ecb :: proc "contextless" (ctx: ^Context_ECB) {…}
reset_ecb sanitizes the Context_ECB. The Context_ECB must be re-initialized to be used again.
reset_gcm ¶
reset_gcm :: proc "contextless" (ctx: ^Context_GCM) {…}
reset_gcm sanitizes the Context_GCM. The Context_GCM must be re-initialized to be used again.
seal_gcm ¶
seal_gcm :: proc( ctx: ^Context_GCM, dst, tag, iv, aad, plaintext: []u8, ) {…}
seal_gcm encrypts the plaintext and authenticates the aad and ciphertext, with the provided Context_GCM and iv, stores the output in dst and tag.
dst and plaintext MUST alias exactly or not at all.
xor_bytes_ctr ¶
xor_bytes_ctr :: proc(ctx: ^Context_CTR, dst, src: []u8) {…}
xor_bytes_ctr XORs each byte in src with bytes taken from the AES-CTR keystream, and writes the resulting output to dst. dst and src MUST alias exactly or not at all.
Procedure Groups
This section is empty.
Source Files
- aes.odin
- aes_ctr.odin
- aes_ctr_hw_intel.odin
- aes_ecb.odin
- aes_ecb_hw_intel.odin
- aes_gcm.odin
- aes_gcm_hw_intel.odin
- aes_impl.odin
- aes_impl_hw_intel.odin
Generation Information
Generated with odin version dev-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-20 21:10:45.855771000 +0000 UTC