package core:crypto/aes

⌘K
Ctrl+K
or
/

    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

    BLOCK_SIZE ¶

    BLOCK_SIZE :: _aes.BLOCK_SIZE
     

    BLOCK_SIZE is the AES block size in bytes.

    CTR_IV_SIZE ¶

    CTR_IV_SIZE :: 16
     

    CTR_IV_SIZE is the size of the CTR mode IV in bytes.

    DEFAULT_IMPLEMENTATION ¶

    DEFAULT_IMPLEMENTATION :: Implementation.Hardware
     

    DEFAULT_IMPLEMENTATION is the implementation that will be used by default if possible.

    GCM_IV_SIZE ¶

    GCM_IV_SIZE :: 12
     

    GCM_IV_SIZE is the default size of the GCM IV in bytes.

    GCM_IV_SIZE_MAX ¶

    GCM_IV_SIZE_MAX :: 0x2000000000000000
     

    GCM_IV_SIZE_MAX is the maximum size of the GCM IV in bytes.

    GCM_TAG_SIZE ¶

    GCM_TAG_SIZE :: _aes.GHASH_TAG_SIZE
     

    GCM_TAG_SIZE is the size of a GCM tag in bytes.

    KEY_SIZE_128 ¶

    KEY_SIZE_128 :: _aes.KEY_SIZE_128
     

    KEY_SIZE_128 is the AES-128 key size in bytes.

    KEY_SIZE_192 ¶

    KEY_SIZE_192 :: _aes.KEY_SIZE_192
     

    KEY_SIZE_192 is the AES-192 key size in bytes.

    KEY_SIZE_256 ¶

    KEY_SIZE_256 :: _aes.KEY_SIZE_256
     

    KEY_SIZE_256 is the AES-256 key size 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

    Generation Information

    Generated with odin version dev-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-20 21:10:45.855771000 +0000 UTC