Skip to content

File syn_aes128.h

FileList > src > syntropic > util > syn_aes128.h

Go to the source code of this file

AES-128 cipher engine (ECB & CBC mode with PKCS#7 padding). More...

  • #include "../common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_AES128_Context
AES-128 Context — stores round keys.

Public Functions

Type Name
SYN_Status syn_aes128_cbc_decrypt (const SYN_AES128_Context * ctx, const uint8_t iv, const uint8_t * in, size_t in_len, uint8_t * out, size_t out_capacity, size_t * out_len)
Decrypt data using AES-128-CBC with PKCS#7 padding removal.
SYN_Status syn_aes128_cbc_encrypt (const SYN_AES128_Context * ctx, const uint8_t iv, const uint8_t * in, size_t in_len, uint8_t * out, size_t out_capacity, size_t * out_len)
Encrypt data using AES-128-CBC with PKCS#7 padding.
void syn_aes128_decrypt_block (const SYN_AES128_Context * ctx, const uint8_t in, uint8_t out)
Decrypt a single 16-byte block (ECB mode).
void syn_aes128_encrypt_block (const SYN_AES128_Context * ctx, const uint8_t in, uint8_t out)
Encrypt a single 16-byte block (ECB mode).
SYN_Status syn_aes128_init (SYN_AES128_Context * ctx, const uint8_t key)
Initialize AES-128 context and expand 128-bit key.

Macros

Type Name
define SYN_AES128_BLOCK_SIZE 16
define SYN_AES128_EXPANDED_KEY_SIZE 176
define SYN_AES128_KEY_SIZE 16

Detailed Description

Constant-time, zero-heap implementation designed for embedded systems. Supports 128-bit key expansion and CBC cipher block chaining.

Public Functions Documentation

function syn_aes128_cbc_decrypt

Decrypt data using AES-128-CBC with PKCS#7 padding removal.

SYN_Status syn_aes128_cbc_decrypt (
    const SYN_AES128_Context * ctx,
    const uint8_t iv,
    const uint8_t * in,
    size_t in_len,
    uint8_t * out,
    size_t out_capacity,
    size_t * out_len
) 

Parameters:

  • ctx Initialized AES-128 context.
  • iv 16-byte initialization vector.
  • in Ciphertext buffer (multiple of 16 bytes).
  • in_len Ciphertext length in bytes.
  • out Plaintext output buffer.
  • out_capacity Output buffer size.
  • out_len Decrypted plaintext byte count written.

Returns:

SYN_OK on success, or SYN_INVALID_PARAM on invalid padding.


function syn_aes128_cbc_encrypt

Encrypt data using AES-128-CBC with PKCS#7 padding.

SYN_Status syn_aes128_cbc_encrypt (
    const SYN_AES128_Context * ctx,
    const uint8_t iv,
    const uint8_t * in,
    size_t in_len,
    uint8_t * out,
    size_t out_capacity,
    size_t * out_len
) 

Parameters:

  • ctx Initialized AES-128 context.
  • iv 16-byte initialization vector.
  • in Plaintext buffer.
  • in_len Plaintext length in bytes.
  • out Ciphertext buffer (must be large enough for in_len + PKCS7 padding).
  • out_capacity Maximum size of output buffer.
  • out_len Output byte count written.

Returns:

SYN_OK on success.


function syn_aes128_decrypt_block

Decrypt a single 16-byte block (ECB mode).

void syn_aes128_decrypt_block (
    const SYN_AES128_Context * ctx,
    const uint8_t in,
    uint8_t out
) 

Parameters:

  • ctx Initialized AES-128 context.
  • in 16-byte ciphertext block.
  • out 16-byte plaintext block.

function syn_aes128_encrypt_block

Encrypt a single 16-byte block (ECB mode).

void syn_aes128_encrypt_block (
    const SYN_AES128_Context * ctx,
    const uint8_t in,
    uint8_t out
) 

Parameters:

  • ctx Initialized AES-128 context.
  • in 16-byte plaintext block.
  • out 16-byte ciphertext block.

function syn_aes128_init

Initialize AES-128 context and expand 128-bit key.

SYN_Status syn_aes128_init (
    SYN_AES128_Context * ctx,
    const uint8_t key
) 

Parameters:

  • ctx AES-128 context instance.
  • key 16-byte key buffer.

Returns:

SYN_OK on success.


Macro Definition Documentation

define SYN_AES128_BLOCK_SIZE

#define SYN_AES128_BLOCK_SIZE `16`

define SYN_AES128_EXPANDED_KEY_SIZE

#define SYN_AES128_EXPANDED_KEY_SIZE `176`

define SYN_AES128_KEY_SIZE

#define SYN_AES128_KEY_SIZE `16`


The documentation for this class was generated from the following file src/syntropic/util/syn_aes128.h