Documentation

Hybrid post-quantum key exchange, signatures and session layer in C++20. Classical ECDH and ML-KEM run side by side, peers authenticate with ML-DSA, and traffic moves over AES-256-GCM, so the channel stays safe even if one of the two worlds (classical or post-quantum) breaks.

Pick the trade-off with one build switch (AEGIS_PROFILE):

  • performance (default): OpenSSL 3.5+ for ML-KEM, ECDH, AES and HKDF, plus the vendored, formally verified mldsa-native for fast ML-DSA (AVX2 / NEON). About 1 ms for a full Level 3 mutual handshake.

  • fips: everything through the OpenSSL FIPS provider (FIPS 140-3 validated with ML-KEM / ML-DSA, cert #5586), NIST curves P-256 / P-384 for the classical half, nothing else compiled in.

  • openssl (OpenSSL only, X25519) and liboqs (research) are there too.

Every profile speaks the same FIPS 203 / 204 bytes, so a FIPS server and a performance-mode device talk to each other.

Why this matters now: see the post-quantum transition brief for the December 2026 industry joint statement, the U.S. deadlines, what AegisPQC solves today and where it goes next.

Diagram#

┌─────────────────────────────────────────────────────────────────────────┐
│                    APPLICATION / HOST LAYER (C++20 / C-ABI)             │
│                                                                         │
│  ┌───────────────────────┐                  ┌────────────────────────┐  │
│  │     Client/Server     │ ───────────────► │   AegisSession Engine  │  │
│  │   Application Logic   │ ◄─── frames ──── │ (Handshake State Machine)│
│  └───────────────────────┘                  └───────────┬────────────┘  │
└─────────────────────────────────────────────────────────┼───────────────┘
                                                          │
                                   Config / Policy Params │ (NIST Level Selection)
                                                          ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                       AEGISPQC FRAMEWORK CORE                           │
│                                                                         │
│  ┌───────────────────────────────────────────────────────────────────┐  │
│  │          CryptoAgilityEngine / PolicyManager (Suite 1 / 3 / 5)    │  │
│  └─────────────────────────────────┬─────────────────────────────────┘  │
│                                    │                                    │
│                 ┌──────────────────┴──────────────────┐                 │
│                 ▼                                     ▼                 │
│  ┌───────────────────────────────┐   ┌───────────────────────────────┐  │
│  │    Hybrid KEM Engine          │   │  Quantum Signature Engine     │  │
│  │  (X25519/X448 + ML-KEM)       │   │  (ML-DSA-44 / 65 / 87)        │  │
│  └──────────────┬────────────────┘   └──────────────┬────────────────┘  │
│                 │                                   │                   │
│                 │ Derives                           │ Validates         │
│                 ▼                                   ▼                   │
│  ┌───────────────────────────────┐   ┌───────────────────────────────┐  │
│  │  X-Wing style HKDF Combiner   │   │  Trust Store (Pinned          │  │
│  │  + Transcript Key Schedule    │   │  Identities) & Verification   │  │
│  └──────────────┬────────────────┘   └───────────────────────────────┘  │
│                 │                                                       │
│                 ▼                                                       │
│  ┌───────────────────────────────────────────────────────────────────┐  │
│  │  Record Layer: AES-256-GCM, per-direction keys, seq numbers       │  │
│  │  Wire Layer : framed messages, bounds-checked parsers             │  │
│  └───────────────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────────────┘
                  │
                  ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                  PRIMITIVE LIBRARIES & HARDWARE LAYER                   │
│                                                                         │
│  ┌───────────────────────────────┐   ┌───────────────────────────────┐  │
│  │ OpenSSL 3.5+ (Libcrypto)      │   │ mldsa-native (third_party/)   │  │
│  │ - ML-KEM (FIPS 203)           │   │ - ML-DSA (FIPS 204)           │  │
│  │ - X25519/X448/P-256/P-384     │   │ - AVX2 / NEON assembly        │  │
│  │ - AES-GCM / HKDF / HMAC       │   │ - CBMC + HOL-Light proofs     │  │
│  │ - FIPS provider (fips profile)│   │ - performance profile         │  │
│  └───────────────────────────────┘   └───────────────────────────────┘  │
│                                                                         │
│  ┌───────────────────────────────┐   ┌───────────────────────────────┐  │
│  │ liboqs (optional)             │   │ OpenSSL ML-DSA                │  │
│  │ - research / interop only     │   │ - openssl & fips profiles     │  │
│  └───────────────────────────────┘   └───────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────────────┘

Logic Flow and Architecture#

1. Security Level and Policy Selection#

When an application establishes a secure channel, aegis_session queries crypto_agility_engine with a configured security target (e.g. nist_level_3). The policy manager maps every level to its own full cipher suite and instantiates the matching primitives, without forcing application code refactoring.

Level Family Suite ID Classical Post-Quantum KEM Signature AEAD Hash
nist_level_1 standard 0x01 X25519 ML-KEM-512 ML-DSA-44 AES-256-GCM SHA-256
nist_level_3 standard 0x03 X25519 ML-KEM-768 ML-DSA-65 AES-256-GCM SHA-256
nist_level_5 standard 0x05 X448 ML-KEM-1024 ML-DSA-87 AES-256-GCM SHA-384
nist_level_1 fips 0x11 P-256 ML-KEM-512 ML-DSA-44 AES-256-GCM SHA-256
nist_level_3 fips 0x13 P-256 ML-KEM-768 ML-DSA-65 AES-256-GCM SHA-256
nist_level_5 fips 0x15 P-384 ML-KEM-1024 ML-DSA-87 AES-256-GCM SHA-384
  • suite_family::standard uses X25519 / X448 (fast, modern). suite_family::fips uses the NIST curves, because X25519 / X448 are not FIPS approved for key agreement. P-256 + ML-KEM-768 and P-384 + ML-KEM-1024 are the same pairs the IETF uses for TLS.

  • The default family is fips in a fips build and standard everywhere else. Any build can run the fips family (aegis_session(role, level, suite_family::fips)), so a non-FIPS device can talk to a FIPS server. A fips build refuses the standard family outright.

  • No silent fallback: asking for Level 5 gives you ML-KEM-1024 + ML-DSA-87, never Level 3. An unknown level throws.

  • The suite ID travels in every handshake message. Both peers must run the same suite, a mismatch aborts the handshake (no negotiation = no downgrade).

  • If the backend is missing an algorithm (e.g. OpenSSL older than 3.5), engine creation fails loudly instead of picking something else.

2. Long-Term Identity and Trust Pinning#

Every endpoint owns a long-term ML-DSA identity keypair. Identities are exchanged out of band (provisioning, config file, QR code, an admin pasting a fingerprint) and pinned in a trust_store:

  • initialize_identity() generates a fresh identity, load_identity() restores one from your own storage (the halves are checked to belong together).

  • trust_peer_identity(pubkey) pins a peer. identity_fingerprint() gives the SHA-256 fingerprint to compare by eye.

  • The handshake refuses to start without at least one pinned peer, and refuses any peer whose identity key is not pinned. A signature alone proves nothing without a trust anchor, this is what stops the man-in-the-middle.

3. Three-Message Mutual Handshake#

   Initiator (Alice)                                          Responder (Bob)
   ─────────────────                                          ───────────────
   fresh hybrid KEM keypair
   client_hello ─────────────────────────────────────────────────────►
     [ver | suite | client_random | kem_pk | alice_identity]
                                                     check alice_identity is pinned
                                                     hybrid encapsulate(kem_pk) -> ct, ss
                                                     sig_bob over H(transcript)
                                                     key schedule from (ss, H(transcript))
   ◄───────────────────────────────────────────────────── server_hello
     [ver | suite | server_random | ct | bob_identity | sig_bob | server_finished]
   check bob_identity is pinned
   verify sig_bob over H(transcript)
   hybrid decapsulate(ct) -> ss, wipe KEM secret key
   key schedule, verify server_finished
   client_finished ──────────────────────────────────────────────────►
     [sig_alice over H(transcript) | client_finished]
                                                     verify sig_alice, verify client_finished
   ════════════════════ handshake_complete on both sides ═════════════════════
  • Both sides sign the transcript, so both identities, both randoms, the KEM public key and the ciphertext are bound together. Swap any byte and a signature or a finished MAC fails.

  • Finished messages are HMACs under keys derived from the shared secret, which gives key confirmation: you only reach handshake_complete if the other side derived the exact same keys.

  • The initiator's KEM keypair is generated per handshake and wiped right after decapsulation (forward secrecy).

4. Hybrid Encapsulation and Decapsulation#

Peer Combined PubKey: [ X25519 PubKey (32B) || ML-KEM-768 PubKey (1184B) ]
                          │                         │
        ┌─────────────────┴─┐                     ┌─┴─────────────────┐
        │  X25519 ECDH      │                     │ ML-KEM-768        │
        │  (ephemeral key)  │                     │ Encapsulation     │
        └─────────┬─────────┘                     └─────────┬─────────┘
                  │                                         │
                  ▼                                         ▼
        Shared Secret 1 (32B)                     Shared Secret 2 (32B)
                  │                                         │
                  └──────────────────┬──────────────────────┘
                                     ▼
       [ SS_mlkem || SS_x25519 || X25519 eph PubKey || X25519 peer PubKey ]
                                     │
                                     ▼
                HKDF(label = "aegispqc/v1 hybrid kem <suite>")
                                     │
                                     ▼
                       Hybrid Shared Secret (256-bit)

Ciphertext on the wire: [ X25519 eph PubKey (32B) || ML-KEM-768 Ciphertext (1088B) ]
  • Every length is validated before a single byte reaches the backend (network input is hostile input). With the OpenSSL backend, ML-KEM public keys also go through the FIPS 203 encapsulation key check on import.

  • Every OpenSSL return value is checked. A low order / all-zero X25519 point aborts the handshake instead of silently zeroing the classical half.

  • Level 5 uses the same flow with X448 (56B keys) and ML-KEM-1024.

  • FIPS suites use P-256 / P-384 ECDH (SP 800-56A): peer points must be uncompressed and pass OpenSSL's full public key validation (on curve, correct order, not infinity) before any derive, which blocks invalid curve attacks.

5. HKDF Key Combiner (SNDL Defense)#

The engine joins the two secrets plus the classical public values (the X-Wing construction) and passes them through HKDF:

HybridSecret = HKDF(SS_mlkem || SS_classical || ClassicalEphPub || ClassicalPeerPub, suite label)

If an adversary captures traffic today and later breaks X25519 via Shor's algorithm on a quantum computer (Store-Now-Decrypt-Later), the ML-KEM component preserves confidentiality. If ML-KEM suffers a mathematical breakthrough, X25519 maintains classical security. Binding the classical public keys matters because raw ECDH is not a CCA-secure KEM on its own.

6. Transcript-Bound Key Schedule#

The hybrid secret is never used directly. It goes through a TLS 1.3 style schedule salted with the transcript hash:

PRK = HKDF-Extract(salt = H(client_hello || server_hello up to signature), IKM = HybridSecret)

c2s key / iv        = HKDF-Expand(PRK, "aegispqc/v1 c2s key" / "c2s iv")
s2c key / iv        = HKDF-Expand(PRK, "aegispqc/v1 s2c key" / "s2c iv")
client / server fin = HKDF-Expand(PRK, "aegispqc/v1 client finished" / "server finished")
exporter secret     = HKDF-Expand(PRK, "aegispqc/v1 exporter")
  • Separate keys per direction: a record can never be reflected back to its sender.

  • session_id() = hash of the full transcript, identical on both ends.

  • export_keying_material(label, len) derives extra keys for other protocols from the session (RFC 5705 style).

7. Record Layer (AES-256-GCM)#

  • Nonce = static IV XOR 64-bit sequence number, so a nonce never repeats under a key.

  • The sequence number is sent in the clear and authenticated as AAD together with any caller AAD.

  • The receiver expects strictly increasing sequence numbers: replayed, reordered or dropped records are rejected. Run it over an ordered transport (TCP, a pipe, a serial link).

  • Hard cap of 2^24 records per key, after which encrypt_record refuses until you start a new session.

8. Fail-Closed Session State Machine#

uninitialized ──► key_generated ──► client_hello_sent ─────────► handshake_complete   (initiator)
                               └──► awaiting_client_finished ──► handshake_complete   (responder)
                     any error ──► failed (terminal, key material wiped)
  • Any parse error, bad signature, unpinned identity, finished mismatch, tag mismatch or replay throws and moves the session to failed. Authentication failures throw aegis::security_error (C-ABI: AEGIS_ERROR_SECURITY).

  • Calling a step in the wrong state or role throws std::logic_error and leaves the session untouched.

  • Secrets live in secure_vector, which wipes memory with OPENSSL_cleanse on release. Ephemeral and traffic keys are wiped as soon as they are no longer needed or the session fails.

Build Profiles (Best of Each Library)#

The ML-KEM / ML-DSA calls live behind one small internal layer (src/crypto/pq_backend.hpp), and the KEM and the signatures pick their backend independently. Everything above it (hybrid KEM, signer, session, C-ABI) is identical in every profile.

-DAEGIS_PROFILE= ML-KEM + ECDH + AES + HKDF ML-DSA Classical curves Use it for
performance (default) OpenSSL 3.5+ mldsa-native (vendored, AVX2 / NEON) X25519 / X448 (+ P-256 / P-384 on request) Production, speed
fips OpenSSL FIPS provider OpenSSL FIPS provider P-256 / P-384 only FIPS 140-3 deployments, federal contractors
openssl OpenSSL 3.5+ OpenSSL 3.5+ X25519 / X448 (+ P-256 / P-384) Only OpenSSL in the trust base
liboqs liboqs liboqs X25519 / X448 (+ P-256 / P-384) Research and prototyping only

Why mldsa-native for ML-DSA#

  • OpenSSL's ML-DSA is portable C, and ML-DSA signing is where a handshake spends its time. mldsa-native (PQ Code Package, Linux Foundation) is the code liboqs and AWS-LC ship for their fast ML-DSA.

  • Its C code has CBMC proofs of memory safety (no out-of-bounds access, no integer overflow) and its x86-64 / AArch64 assembly is proven correct and memory safe at object code level with HOL-Light.

  • It is vendored unmodified (third_party/mldsa-native, release v2.1.0, see AEGIS_VENDOR.md), compiled straight into libaegispqc_core, and gets its randomness from OpenSSL's CSPRNG. No extra dependency to install.

  • With AEGIS_MLDSA_NATIVE_ASM=ON (default) the AVX2 backend is used when the build machine supports it. The resulting binary then needs an AVX2 + BMI2 CPU (anything from roughly 2013 on). Set it OFF to ship one binary to older x86 machines; aarch64 always gets NEON.

Why a separate fips profile#

  • FIPS 140-3 requires every algorithm to come from the validated module. In the fips profile the library loads the OpenSSL FIPS provider, sets fips=yes as the default property (so even HKDF, HMAC, AES-GCM and the DRBG run inside it), refuses X25519 / X448, and does not compile mldsa-native at all.

  • If the FIPS provider is not installed and configured, the library refuses to run (see "FIPS Setup" below). It never quietly falls back to the default provider.

Interop and speed#

  • Every backend speaks the exact FIPS 203 / FIPS 204 byte formats. tests/test_backend_interop.cpp signs with each compiled backend and verifies with every other one (and decapsulates across OpenSSL / liboqs) for all parameter sets. Identities and peers survive any profile switch.

  • aegis::backend_name() reports what the build uses at runtime, e.g. openssl+mldsa-native.

  • Full mutual handshake, one cloud vCPU, OpenSSL 3.6.5 (your numbers will differ, run aegis_bench):

Profile Level 1 Level 3 Level 5 ML-DSA-65 signing
performance ~0.75 ms ~1.0 ms ~2.3 ms ~105 µs
openssl ~2.9 ms ~4.4 ms ~6.6 ms ~930 µs
fips (P-256 / P-384) ~4.9 ms ~9 ms ~14 ms ~1.75 ms
  • The record layer (AES-256-GCM) runs at the same speed in every profile.

Wire Format#

Every message is a frame:

[magic 'AG' (2)] [type (1)] [payload length, big-endian (4)] [payload ...]
Type Frame Payload
0x01 client_hello ver(1) suite(1) client_random(32) len(4)+kem_pk len(4)+identity
0x02 server_hello ver(1) suite(1) server_random(32) len(4)+kem_ct len(4)+identity len(4)+signature len(4)+finished
0x03 client_finished len(4)+signature len(4)+finished
0x04 encrypted_record seq(8) ciphertext tag(16)
  • Payloads are capped at 16 MiB, unknown types and trailing bytes are rejected, every field read is bounds checked (wire_reader).

  • unpack_frame returns frame_size, so stream readers can cut several frames out of one buffer.

Handshake sizes on the wire (all three messages, identities included):

Suite Standard FIPS
Level 1 ~9.3 KB ~9.3 KB
Level 3 ~13.0 KB ~13.1 KB
Level 5 ~17.9 KB ~18.0 KB

Source Code Files and Structural Responsibilities (/include, /src)#

1. include/aegis/common.hpp (Shared Types & Structs)#

Defines memory layout, security level enumerations, and byte structures shared across all framework modules.

  • secure_allocator / secure_vector: zeroizing allocator, plus wipe() to clear secrets on demand.

  • enum class security_level: nist_level_1, nist_level_3, nist_level_5.

  • struct key_pair, struct encapsulated_secret, class security_error (authentication failures).

2. include/aegis/suite.hpp + src/policy/suite.cpp (Cipher Suites)#

  • suite_params: family, classical curve, ML-KEM and ML-DSA parameter sets, hash, wire ID and name for each level.

  • suite_for(level, family), suite_from_id(id), suite_available(suite), fips_build(), backend_name().

3. include/aegis/crypto_interface.hpp (Core Abstraction Layer)#

Exposes pure virtual C++ interfaces for crypto primitives, isolating application logic from underlying vendor libraries.

  • class ikem_engine: generate_keypair(), encapsulate(), decapsulate() and exact public_key_size() / secret_key_size() / ciphertext_size().

  • class isignature_engine: generate_keypair(), sign(), verify() and exact key / signature sizes.

4. src/crypto/hybrid_kem.cpp (Dual Key Exchange Implementation)#

Implements ikem_engine using OpenSSL for the classical half and the active PQ backend for ML-KEM, for any suite.

  • generate_keypair(): EVP_PKEY_keygen() for X25519/X448 and the backend's ML-KEM keygen.

  • encapsulate(): ephemeral ECDH alongside ML-KEM encapsulation, then the X-Wing style combiner.

  • decapsulate(): validates lengths, decrypts both ciphertext streams and derives the hybrid secret.

5. src/crypto/mldsa_signer.cpp (Post-Quantum Signatures)#

Implements isignature_engine wrapping NIST FIPS 204 (ML-DSA / Dilithium) at 44 / 65 / 87 on top of the active backend.

  • sign(): quantum-safe digital signatures for arbitrary message buffers (pure ML-DSA, empty context, hedged randomized signing).

  • verify(): validates signatures against peer public keys, wrong sized input is simply invalid.

5b. src/crypto/pq_backend.hpp, pq_params.cpp, backend_*.cpp (PQ Backends)#

  • pq_params.cpp: the FIPS 203 / 204 size tables, the single source of truth for every length check.

  • backend_openssl.cpp: EVP_PKEY_keygen, EVP_PKEY_encapsulate / EVP_PKEY_decapsulate, EVP_DigestSign / EVP_DigestVerify with raw FIPS key import/export.

  • backend_mldsa_native.cpp: ML-DSA-44/65/87 over the vendored mldsa-native (performance profile).

  • backend_liboqs.cpp: the same functions over OQS_KEM_* / OQS_SIG_* (only compiled when liboqs is enabled).

5c. third_party/mldsa-native/ + src/crypto/mldsa_native/ (Vendored ML-DSA)#

  • third_party/mldsa-native/: upstream v2.1.0 source tree, unmodified, with its license and AEGIS_VENDOR.md (version, commit, how to update).

  • aegis_mldsa_config.h: multilevel build, aegis_mldsa* symbol prefix, OpenSSL RNG hook, native backend switch. aegis_mldsa_all.c / aegis_mldsa_asm.S compile the three levels and the shared assembly once.

6. include/aegis/kdf.hpp + src/crypto/kdf.cpp (Key Derivation)#

  • hkdf_extract(), hkdf_expand(), hkdf() (RFC 5869, checked against the RFC test vector), digest(), hmac(), constant_time_equal().

7. include/aegis/aead.hpp + src/crypto/aead.cpp (Symmetric Encryption)#

  • aead_encrypt_with_iv(): AES-256-GCM with a caller nonce (used by the record layer).

  • aead_encrypt() (random IV) / aead_decrypt() for standalone use. Tag failure throws security_error and wipes the partial plaintext.

8. src/policy/policy_manager.cpp + fips.cpp (Crypto-Agility Engine & FIPS Policy)#

Represents cryptographic engines dynamically based on system policy.

  • crypto_agility_engine(level, family)::create_kem_engine() / create_signature_engine(): return the engines for the configured level and family, after checking the backend actually ships them. In a fips build it refuses the standard family and switches the FIPS provider on first.

  • aegis::fips::enable(), provider_active(), status(): load the OpenSSL FIPS provider and make fips=yes mandatory for every fetch.

9. include/aegis/trust_store.hpp + src/session/trust_store.cpp (Identity & Public Key Trust)#

  • trust_store::pin() / is_trusted() (constant time compare), fingerprint().

10. src/session/aegis_session.cpp (High-Level Protocol State Machine)#

Manages the end-to-end handshake execution flow between endpoints.

  • aegis_session: identity management, the three-message handshake, transcript hashing, key schedule, key confirmation, the AES-256-GCM record layer and the exporter. Fail closed on any error.

11. include/aegis/frame.hpp / wire.hpp + src/net/frame.cpp (Wire Layer)#

  • pack_frame(), unpack_frame(), expect_frame(); wire_writer / wire_reader for big-endian, bounds-checked message bodies.

12. include/aegis/c_api.h + src/c_api.cpp (C-ABI)#

  • Stable C interface for C, Rust, Go, Python (ctypes/cffi), Swift and friends. Pass NULL as the output buffer to query the size, a length query never changes session state.

13. src/main.cpp (Integration Driver)#

Executable demonstration running identity pinning, the full handshake, transcript comparison, records in both directions, and showing a replay and a man-in-the-middle getting rejected.

14. tests/, benchmarks/, fuzz/#

  • tests/test_attack_regressions.cpp: one test per attack from the v0.1 review (MITM, out of bounds read, Level 5 downgrade, replay/reflection, low order point). They used to succeed, now they must fail closed.

  • tests/test_backend_interop.cpp: every compiled ML-DSA backend (OpenSSL, mldsa-native, liboqs) signs and verifies for every other one; OpenSSL ↔ liboqs ML-KEM when liboqs is enabled.

  • tests/test_attack_regressions.cpp also covers invalid curve attacks on P-256 / P-384 (Attack 6).

  • tests/test_*.cpp: crypto, session, AEAD, frame/wire, C-ABI and secure memory tests (Catch2).

  • benchmarks/bench_crypto.cpp: KEM, signature and full handshake latency for every level, plus AEAD throughput.

  • fuzz/fuzz_handshake.cpp: libFuzzer harness over the frame parser and both handshake parsers.

Usage#

C++#

#include "aegis/aegis_session.hpp"
using namespace aegis::session;

// --- setup (once): identities + out of band pinning ---
aegis_session alice(role::initiator, aegis::security_level::nist_level_3);
aegis_session bob(role::responder, aegis::security_level::nist_level_3);
alice.initialize_identity();                 // or alice.load_identity(stored_keys)
bob.initialize_identity();
alice.trust_peer_identity(bob_identity_pubkey);
bob.trust_peer_identity(alice_identity_pubkey);

// --- handshake: send each returned frame to the other side ---
auto client_hello    = alice.create_client_hello();
auto server_hello    = bob.process_client_hello(client_hello);
auto client_finished = alice.process_server_hello(server_hello);
bob.process_client_finished(client_finished);

// --- records ---
auto record = alice.encrypt_record(plaintext, aad);
auto pt     = bob.decrypt_record(record, aad);    // secure_vector, wiped on release

C-ABI#

aegis_session_handle_t* s = NULL;
aegis_session_create(AEGIS_ROLE_INITIATOR, AEGIS_SEC_LEVEL_NIST_3, &s);
/* or pick the family explicitly, e.g. talk to a FIPS server from a performance build:
   aegis_session_create_ex(AEGIS_ROLE_INITIATOR, AEGIS_SEC_LEVEL_NIST_3, AEGIS_SUITE_FIPS, &s); */
aegis_session_initialize_identity(s);
aegis_session_trust_peer_identity(s, peer_id, peer_id_len);

aegis_session_create_client_hello(s);
size_t len = 0;
aegis_session_read_outbound(s, NULL, 0, &len);      // length query
aegis_session_read_outbound(s, buf, sizeof buf, &len);
/* send buf, receive server_hello ... */
aegis_session_process_server_hello(s, sh, sh_len);
aegis_session_read_outbound(s, buf, sizeof buf, &len);  // client_finished

if (aegis_session_is_established(s)) { /* aegis_session_encrypt_record(...) */ }
aegis_session_destroy(s);

Build Pipeline & Run#

Building AegisPQC#

# 1. Generate CMake build directory
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release

# 2. Compile binaries and link against OpenSSL (3.5+)
cmake --build build -j$(nproc)

# 3. Execute demo driver
./build/aegis_demo

# 4. Run the unit + attack regression tests
./build/aegis_tests            # or: ctest --test-dir build

Build Options#

Option Default What it does
AEGIS_PROFILE performance performance, fips, openssl or liboqs (see Build Profiles)
AEGIS_MLDSA_NATIVE_ASM ON AVX2 / NEON assembly for mldsa-native when the build machine supports it
AEGIS_ENABLE_LIBOQS OFF Also compile liboqs and include it in the interop tests (not with fips)
AEGIS_BUILD_DEMO ON aegis_demo
AEGIS_BUILD_TESTS ON aegis_tests (fetches Catch2 v3.5.2 if not installed)
AEGIS_BUILD_BENCHMARKS ON aegis_bench
AEGIS_ENABLE_SANITIZERS OFF ASan + UBSan for everything
AEGIS_BUILD_FUZZERS OFF aegis_fuzz_handshake (clang + libFuzzer)

Sanitizers, Benchmarks & Fuzzing#

# memory sanitizers & hardening
cmake -B build-san -S . -DCMAKE_BUILD_TYPE=Debug -DAEGIS_ENABLE_SANITIZERS=ON
cmake --build build-san -j$(nproc) && ./build-san/aegis_tests

# performance benchmarking (every NIST level)
cmake -B build-bench -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build-bench -j$(nproc) && ./build-bench/aegis_bench

# backend interop (OpenSSL <-> mldsa-native <-> liboqs)
cmake -B build-interop -S . -DAEGIS_ENABLE_LIBOQS=ON -DCMAKE_PREFIX_PATH=/usr/local
cmake --build build-interop -j$(nproc) && ./build-interop/aegis_tests "[interop]"

# other profiles
cmake -B build-openssl -S . -DAEGIS_PROFILE=openssl
cmake -B build-oqs -S . -DAEGIS_PROFILE=liboqs -DCMAKE_PREFIX_PATH=/usr/local
cmake -B build-fips -S . -DAEGIS_PROFILE=fips          # needs the FIPS provider, see below

# fuzzing the network parsers
cmake -B build-fuzz -S . -DCMAKE_CXX_COMPILER=clang++ -DAEGIS_BUILD_FUZZERS=ON -DAEGIS_BUILD_TESTS=OFF
cmake --build build-fuzz -j$(nproc)
mkdir -p corpus && ./build-fuzz/aegis_fuzz_handshake -max_total_time=300 -max_len=8192 corpus

FIPS Setup (fips profile)#

The fips profile needs OpenSSL's FIPS provider installed and configured. For a real FIPS 140-3 claim it has to be the validated provider build (cert #5586), not just any enable-fips build.

# 1. FIPS provider module (distro package, or build OpenSSL with: ./Configure enable-fips && make install_fips)
# 2. Generate its config (module MAC + self test status)
openssl fipsinstall -out /usr/local/ssl/fipsmodule.cnf -module /usr/local/lib/ossl-modules/fips.so

# 3. An openssl.cnf that includes it
cat > aegis-fips.cnf <<'EOF2'
config_diagnostics = 1
openssl_conf = openssl_init
.include /usr/local/ssl/fipsmodule.cnf

[openssl_init]
providers = provider_sect

[provider_sect]
fips = fips_sect
base = base_sect

[base_sect]
activate = 1
EOF2

# 4. Build and run
cmake -B build-fips -S . -DAEGIS_PROFILE=fips -DOPENSSL_ROOT_DIR=/path/to/fips/openssl
cmake --build build-fips -j$(nproc)
OPENSSL_CONF=$PWD/aegis-fips.cnf ./build-fips/aegis_tests
OPENSSL_CONF=$PWD/aegis-fips.cnf ./build-fips/aegis_demo    # prints "fips provider active (...)"

Without that config the library stops with a setup message instead of running outside the provider.

Install & Consume#

sudo cmake --install build      # headers, libaegispqc_core, CMake package, pkg-config file
find_package(AegisPQC 0.4 REQUIRED)
target_link_libraries(my_app PRIVATE AegisPQC::core)
pkg-config --cflags --libs aegispqc

System Requirements & Dependencies#

  • C++20 and C99 compilers (the C one builds the vendored mldsa-native), CMake 3.20+

  • OpenSSL 3.5+ (ML-KEM, ML-DSA, X25519, X448, P-256, P-384, HKDF, AES-GCM, SHA-2, HMAC). That's the only external crypto dependency; mldsa-native ships inside the repo.

  • fips profile: the OpenSSL FIPS provider (see FIPS Setup).

  • Optional: liboqs 0.10+ (0.16.0 recommended) for -DAEGIS_PROFILE=liboqs or the interop tests. With the liboqs profile OpenSSL 3.0+ is enough.

# Arch Linux / EndeavourOS (ships a current OpenSSL 3.x)

sudo pacman -S --needed base-devel cmake ninja openssl

# macOS

brew install openssl@3 cmake ninja

# Debian / Ubuntu: needs a release with OpenSSL 3.5+, or build OpenSSL 3.5 LTS into /opt
# and pass -DOPENSSL_ROOT_DIR=/opt/openssl-3.5 to cmake

# --- optional: liboqs (research backend / interop tests) ---

brew install liboqs   # macOS

# Or build it directly

git clone --depth 1 -b 0.16.0 https://github.com/open-quantum-safe/liboqs.git
cd liboqs
cmake -G Ninja -B build -DBUILD_SHARED_LIBS=ON -DOQS_DIST_BUILD=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DOQS_USE_OPENSSL=ON
ninja -C build
sudo ninja -C build install
sudo ldconfig

Security Status#

AegisPQC v0.4.0 closes every issue from the v0.1 review (see the hardening log in the post-quantum transition brief), runs on OpenSSL + formally verified mldsa-native by default with a strict FIPS profile next to it, is tested under ASan/UBSan in every profile and has been fuzzed, but:

  • It has not had an independent audit or formal verification yet.

  • The performance profile is strong but is not a FIPS validated module (mldsa-native is not part of OpenSSL's certificate). When a FIPS 140-3 claim is required, build the fips profile against the validated provider.

  • A FIPS 140-3 certificate covers the cryptographic module (OpenSSL's provider), not AegisPQC's protocol. Using validated primitives is necessary for compliance, not a full compliance claim on its own.

  • The liboqs backend is for research and interop testing only; its maintainers advise against relying on it in production.

  • For ordinary HTTPS, use TLS 1.3 with the standard X25519MLKEM768 hybrid group (OpenSSL 3.5+, BoringSSL, rustls, Go). AegisPQC is for channels TLS does not cover well: device to device, embedded links, internal message buses, app-level end-to-end encryption.

Post-Quantum Transition & Roadmap#

The full write-up lives in the post-quantum transition brief: why the migration is urgent, how AegisPQC lines up with the U.S. guidance, the v0.1 → v0.4 hardening log, and the future possibilities (session resumption, suite negotiation, rekeying, PQ certificates, SLH-DSA, HQC, a crypto inventory scanner, language bindings and formal verification).