aes.h

AES-GCM, AES-CCM, AES-CBC implementation \par License: GNU GPL v3.0 \par Source: https://github.com/B-Con/crypto-algorithms/.

Author

Anthony Cagliano

Defines

TLS_AES_BLOCK_SIZE
TLS_AES_IV_SIZE
TLS_AES_AUTH_TAG_SIZE

Enums

enum tls_aes_modes

Values:

enumerator TLS_AES_GCM
enumerator TLS_AES_CBC
enumerator TLS_AES_CCM

Functions

bool tls_aes_init(struct tls_aes_context *ctx, uint8_t mode, const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len)
bool tls_aes_ccm_init(struct tls_aes_context *ctx, const uint8_t *key, size_t key_len, const uint8_t *nonce, size_t nonce_len, uint8_t tag_len, size_t msg_len, size_t aad_len)
bool tls_aes_ccm_encrypt(const uint8_t *key, size_t key_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *aad, size_t aad_len, const uint8_t *plaintext, size_t pt_len, uint8_t *ciphertext, uint8_t *tag, size_t tag_len)
bool tls_aes_ccm_decrypt(const uint8_t *key, size_t key_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *aad, size_t aad_len, const uint8_t *ciphertext, size_t ct_len, const uint8_t *tag, size_t tag_len, uint8_t *plaintext)
bool tls_aes_update_aad(struct tls_aes_context *ctx, const uint8_t *aad, size_t aad_len)
bool tls_aes_encrypt(struct tls_aes_context *ctx, const uint8_t *inbuf, size_t in_len, uint8_t *outbuf)
bool tls_aes_update_ciphertext(struct tls_aes_context *ctx, const uint8_t *ct, size_t ct_len)
bool tls_aes_digest(struct tls_aes_context *ctx, uint8_t *digest)
bool tls_aes_decrypt(struct tls_aes_context *ctx, const uint8_t *inbuf, size_t in_length, uint8_t *outbuf)
bool tls_aes_verify(struct tls_aes_context *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ciphertext, size_t ciphertext_len, const uint8_t *tag)
struct _gcm_private
#include <aes.h>

Public Members

uint8_t ghash_key[16]
uint8_t auth_tag[16]
uint8_t last_block[16]
uint8_t last_block_len
uint8_t aad_cache[16]
uint8_t aad_cache_len
uint8_t auth_j0[16]
size_t aad_len
size_t ct_len
uint8_t lock

sets allowed operations on the context.

struct _ccm_private
#include <aes.h>

Public Members

uint8_t nonce[15]
uint8_t nonce_len
uint8_t tag_len
uint8_t L
uint8_t mac[16]
uint8_t ctr[16]
uint8_t s0[16]
uint8_t msg_cache[16]
uint8_t msg_cache_len
size_t aad_len_total
size_t aad_len
size_t msg_len
size_t msg_processed
uint8_t lock
struct tls_aes_context
#include <aes.h>

Public Members

uint8_t mode
uint24_t keysize
uint32_t round_keys[60]
uint8_t iv[16]
uint8_t op_assoc

sets to either encrypt or decrypt based on first operation done on context.

struct _ccm_private ccm
struct _gcm_private gcm
union tls_aes_context private