32#ifndef DETERMINISTICESPASYNCWEBSERVER_SSH_AESGCM_H
33#define DETERMINISTICESPASYNCWEBSERVER_SSH_AESGCM_H
40static constexpr size_t SSH_AESGCM_KEY_LEN = 32;
42static constexpr size_t SSH_AESGCM_IV_LEN = 12;
44static constexpr size_t SSH_AESGCM_TAG_LEN = 16;
47#include <mbedtls/aes.h>
54 uint8_t
iv[SSH_AESGCM_IV_LEN];
64 uint8_t
iv[SSH_AESGCM_IV_LEN];
92 const uint8_t tag[SSH_AESGCM_TAG_LEN], uint8_t *out);
GHASH (the GF(2^128) universal hash under AES-GCM, NIST SP 800-38D sec 6.3), 4-bit table.
void ssh_aesgcm_seal(SshAesGcmCtx *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *out)
Seal one packet: AES-256-GCM encrypt pt (pt_len bytes) and authenticate it together with aad....
void ssh_aesgcm_init(SshAesGcmCtx *ctx, const uint8_t key[SSH_AESGCM_KEY_LEN], const uint8_t iv[SSH_AESGCM_IV_LEN])
Initialize an AES-256-GCM context: expand the key, precompute H, latch the initial nonce.
void ssh_aesgcm_wipe(SshAesGcmCtx *ctx)
Zero the key schedule, H, and nonce (volatile wipe). Call on disconnect.
bool ssh_aesgcm_open(SshAesGcmCtx *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, const uint8_t tag[SSH_AESGCM_TAG_LEN], uint8_t *out)
Open one packet: verify the 16-byte tag over aad || ct in constant time, and only on success decrypt ...
4-bit GHASH table for a fixed subkey H = E(K, 0^128): M[i] = i*H as four big-endian uint32 words (M[i...
AES-256-GCM context for one SSH direction (HW AES on ESP32).
uint8_t h[16]
GHASH subkey H = E(K, 0^128).
GhashKey ghk
4-bit GHASH table built from H (once at init).
uint8_t iv[SSH_AESGCM_IV_LEN]
current nonce; low 8 bytes (invocation counter) ++ per packet.
bool ready
true once a key/IV is installed.
mbedtls_aes_context mbed
mbedtls context (HW-accelerated on ESP32), encrypt key schedule.