File syn_aes128.c¶
FileList > src > syntropic > util > syn_aes128.c
Go to the source code of this file
AES-128 implementation (S-Box, Key Expansion, ECB, CBC mode).
#include "syn_aes128.h"#include "syn_assert.h"#include <string.h>
Public Static Attributes¶
| Type | Name |
|---|---|
| const uint8_t | rcon = {0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36} |
| const uint8_t | rsbox = /* multi line expression */ |
| const uint8_t | sbox = /* multi line expression */ |
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. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint8_t | gmult (uint8_t a, uint8_t b) |
| uint8_t | gmult2 (uint8_t a) |
Public Static Attributes Documentation¶
variable rcon¶
variable rsbox¶
variable sbox¶
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:
ctxInitialized AES-128 context.iv16-byte initialization vector.inCiphertext buffer (multiple of 16 bytes).in_lenCiphertext length in bytes.outPlaintext output buffer.out_capacityOutput buffer size.out_lenDecrypted 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:
ctxInitialized AES-128 context.iv16-byte initialization vector.inPlaintext buffer.in_lenPlaintext length in bytes.outCiphertext buffer (must be large enough for in_len + PKCS7 padding).out_capacityMaximum size of output buffer.out_lenOutput byte count written.
Returns:
SYN_OK on success.
function syn_aes128_decrypt_block¶
Decrypt a single 16-byte block (ECB mode).
Parameters:
ctxInitialized AES-128 context.in16-byte ciphertext block.out16-byte plaintext block.
function syn_aes128_encrypt_block¶
Encrypt a single 16-byte block (ECB mode).
Parameters:
ctxInitialized AES-128 context.in16-byte plaintext block.out16-byte ciphertext block.
function syn_aes128_init¶
Initialize AES-128 context and expand 128-bit key.
Parameters:
ctxAES-128 context instance.key16-byte key buffer.
Returns:
SYN_OK on success.
Public Static Functions Documentation¶
function gmult¶
function gmult2¶
The documentation for this class was generated from the following file src/syntropic/util/syn_aes128.c