Skip to sessions and notes

These session notes are AI-generated and may contain mistakes. Verify important details against the original recording.

Post-Quantum Cryptography with .NET 11

Jeremy Barton

Session · 24:54 recording · 7 min read

At a glance

  • Cryptographic threat of Shor's algorithm on RSA and Elliptic Curve discrete log
  • Harvest Now, Decrypt Later (HNDL) retroactive key establishment threat
  • .NET 10 PQC baseline: ML-DSA (FIPS 204), SLH-DSA (FIPS 205), ML-KEM (FIPS 203)
  • Composite ML-KEM in .NET 11: combining traditional keys (RSA-4096 / ECDH) with ML-KEM
  • Dual compromise requirement preventing flaws in novel lattice cryptography

Executive Summary

As quantum computing architectures advance toward Cryptographically Relevant Quantum Computers (CRQCs), commonly referred to as "Q-Day", traditional asymmetric cryptography based on integer factorization and discrete logarithms (RSA, ECDSA, ECDH) faces complete mathematical obsolescence via Shor's algorithm.

In this session, Jeremy Barton (owner of the .NET cryptography stack) outlines the comprehensive post-quantum cryptographic roadmap across .NET 10 and .NET 11:

  1. The Core Threat & Harvest Now, Decrypt Later (HNDL): While digital signatures only lose non-repudiation on Q-Day without retroactive impact on historical read-only logs, key establishment is under active attack today. Adversaries record encrypted network sessions to decrypt retroactively once quantum hardware matures.
  2. Composite ML-KEM in .NET 11: Combines classical algorithms (RSA-4096 or ECDH) with NIST FIPS 203 Module-Lattice Key Encapsulation (ML-KEM-1024). Both mechanisms must be compromised to break the shared secret, providing a secure bridge between legacy trust and quantum resistance.
  3. Hybrid Public Key Encryption (HPKE, RFC 9180): A modern cryptographic standard integrating key encapsulation, KDF derivation, authenticated encryption (AEAD), nonce sequencing, and message ordering into safe Seal and Open streaming verbs, eliminating pervasive custom protocol bugs.
  4. Modernizing 21-Year-Old CMS (EnvelopedCms): Updating .NET's PKCS#7 / S/MIME engine to accept ML-KEM subject keys in X.509 public certificates.

Post-Quantum Cryptography Title
Post-Quantum Cryptography Title


Cryptographic Threat Landscape

graph TD
    subgraph "Classical Asymmetric Math (Broken by Shor's Algorithm)"
        ECC["Elliptic Curve (ECDSA, ECDH)<br/>Q = d * G (Discrete Log)"]
        RSA["RSA Cryptography<br/>N = P * Q (Integer Factorization)"]
    end

    subgraph "Shor's Algorithm on Quantum Computer"
        SHOR["Quantum Period Finding<br/>Solves Discrete Log & Factoring in Polynomial Time"]
    end

    subgraph "Post-Quantum Algorithms in .NET"
        MLDSA["ML-DSA / FIPS 204<br/>Module-Lattice Signatures"]
        SLHDSA["SLH-DSA / FIPS 205<br/>Stateless Hash-based Signatures"]
        MLKEM["ML-KEM / FIPS 203 (Kyber)<br/>Module-Lattice Key Encapsulation"]
        COMP["Composite ML-KEM<br/>Traditional (RSA/ECDH) + ML-KEM"]
        HPKE["HPKE / RFC 9180<br/>Hybrid Public Key Encryption"]
    end

    ECC --> SHOR
    RSA --> SHOR
    SHOR -.->|"Defeated"| ECC
    SHOR -.->|"Defeated"| RSA
    MLDSA & SLHDSA & MLKEM & COMP & HPKE -->|"Resistant to Shor & Grover"| SECURE[Quantum-Safe Cryptography]

1. Why Quantum Computers Defeat Classical Public Key Math

Elliptic Curve Cryptography (ECC)

In ECDSA and ECDH, the private key is a large scalar integer $d$, and the public key $Q$ is computed via elliptic curve point multiplication:
$$Q = d \times G$$
Classical security rests entirely on the assumption that point division is impossible (the Discrete Log Problem). Shor's algorithm on a quantum computer solves the discrete log problem in polynomial time, computing $d$ directly from public parameters $Q$ and $G$.

Elliptic Curve Threat
Elliptic Curve Threat

RSA Factorization

In RSA, the public modulus is $N = P \times Q$ where $P$ and $Q$ are large primes. Because integer factorization reduces mathematically to the order-finding discrete log problem, Shor's algorithm completely breaks RSA modulus factoring.

Symmetric Ciphers are Safe (AES, ChaCha20)

Unlike asymmetric algorithms, symmetric cryptography (AES-256, ChaCha20-Poly1305) is unaffected by Shor's algorithm. Grover's algorithm provides only a quadratic quantum speedup (effectively halving bit strength), meaning AES-256 retains 128 bits of post-quantum security—far beyond practical brute-force capabilities. The critical vulnerability lies exclusively in how symmetric session keys are established over the wire.


2. The Two Buckets: Digital Signatures vs. Key Establishment

Quantum Threat Comparison
Quantum Threat Comparison

Property Digital Signing (Sign / Verify) Key Establishment (Encapsulate / Decapsulate)
Security Objective Integrity, Non-Repudiation, Accountability Confidentiality, Secrecy
Quantum Threat Type Forward-facing only (trust erodes on "Q-Day") Retroactive & Immediate Threat
Attack Vector Forging new signatures after Q-Day Harvest Now, Decrypt Later (HNDL)
Urgency Low retroactive risk for static files/logs Critical urgency: Intercepted traffic today will be decrypted later

Harvest Now, Decrypt Later (HNDL)

Adversaries and nation-states are actively recording encrypted TLS, VPN, and database transit traffic today. As soon as a quantum computer with sufficient logical qubits is brought online, attackers will calculate the private key from captured public key exchanges, derive the session secrets, and decrypt the recorded AES payloads.


3. The PQC Evolution: .NET 10 to .NET 11

Baseline Added in .NET 10

In .NET 10, initial primitives for NIST-standardized algorithms were introduced:

  • Digital Signatures: ML-DSA (Module-Lattice Digital Signature Algorithm, FIPS 204 / Dilithium), SLH-DSA (Stateless Hash-based DSA, FIPS 205 / SPHINCS+), and Composite ML-DSA.
  • Key Establishment: ML-KEM (Module-Lattice Key Encapsulation Mechanism, FIPS 203 / Kyber) and underlying platform support for TLS 1.3 Hybrid KEM (X25519MLKEM768).

.NET 10 PQC Baseline
.NET 10 PQC Baseline


4. New in .NET 11: Composite ML-KEM

To mitigate the risk of undiscovered mathematical flaws in new lattice-based algorithms while simultaneously defending against quantum attacks on classical keys, .NET 11 introduces Composite ML-KEM (IETF LAMPS specification).

Composite ML-KEM Concept
Composite ML-KEM Concept

Mechanism & Dual-Key Security

Composite ML-KEM binds an ML-KEM key with a traditional asymmetric key (such as RSA-4096 or ECDH P-384). Key encapsulation occurs across both algorithms, and the results are combined such that both mathematical layers must be compromised simultaneously to reveal the final shared secret.

API Verbs: Encapsulate and Decapsulate

Unlike legacy asymmetric encryption which handled arbitrary byte blocks, KEMs operate strictly on encapsulation:

// --- SENDER / INITIATOR ---
byte[] sharedSecret;
byte[] ciphertext;

// 1. Import recipient composite key (e.g., MLKEM1024 with RSA4096)
using (var recipientKey = CompositeMLKem.ImportEncapsulationKey(recip.Alg, recip.EncapsKeyBytes))
{
    // 2. Encapsulate generates the ciphertext to transmit and the local shared secret
    recipientKey.Encapsulate(out ciphertext, out sharedSecret);
}

// 3. Transmit ciphertext to recipient over network or file header
Send(recip, ciphertext);

// 4. Derive AES symmetric key via a Key Derivation Function (KDF)
byte[] aesKey = HKDF.DeriveKey(HashAlgorithmName.SHA384, sharedSecret, 32);

// 5. Symmetric encryption
using (AesGcm aesGcm = new AesGcm(aesKey, tagSizeInBytes: 16))
{
    // Encrypt payload...
}

// --- RECIPIENT ---
// Recipient imports private decapsulation key and decapsulates ciphertext:
byte[] recipientSharedSecret = privateKey.Decapsulate(ciphertext);
// Both parties now possess identical shared secrets

Composite ML-KEM Code Verbs
Composite ML-KEM Code Verbs


5. Hybrid Public Key Encryption (HPKE, RFC 9180)

Implementing custom encryption protocols frequently leads to subtle, catastrophic security bugs: nonce reuse in GCM, missing ciphertext authentication tags, or out-of-order packet rejections. .NET 11 introduces native support for HPKE (Hybrid Public Key Encryption, IRTF RFC 9180).

HPKE Overview
HPKE Overview

Core Guarantees of HPKE:

  1. Integrated Key Establishment: Embeds KEM negotiation internally.
  2. Automated Nonce & IV Sequencing: Eliminates nonce reuse vulnerabilities.
  3. AEAD Tag Verification: Guarantees cryptographic integrity.
  4. Message Ordering Enforcement: Detects packet reordering or replay attacks; out-of-order messages fail authentication automatically.
  5. Streaming & One-Shot Modes: Supports both multi-message streams and simplified one-shot data transfers.

HPKE Sender & Recipient Code (Seal and Open)

// --- SENDER ---
HpkeSender sender;
byte[] encapsulatedSecret;

// Import HPKE encapsulation key configured with specific suite (KEM + KDF + AEAD)
using (Hpke recipientKey = Hpke.ImportEncapsulationKey(recip.Suite, recip.HpkeKeyBytes))
{
    sender = recipientKey.CreateSender(out encapsulatedSecret);
}

Send(encapsulatedSecret);

using (sender)
{
    // Seal packages message with authenticated sequential framing
    byte[] ciphertext1 = sender.Seal(message1);
    Send(ciphertext1);

    byte[] ciphertext2 = sender.Seal(message2);
    Send(ciphertext2);
}

// --- RECIPIENT ---
using (HpkeRecipient recipient = privateKey.CreateRecipient(encapsulatedSecret))
{
    // Open verifies sequence ordering and decrypts
    byte[] decrypted1 = recipient.Open(ciphertext1);
    byte[] decrypted2 = recipient.Open(ciphertext2);
}

HPKE Seal and Open Code
HPKE Seal and Open Code


6. Modernizing EnvelopedCms (PKCS#7 / S/MIME)

The EnvelopedCms class—a staple of .NET Framework since 2.0 (2005)—has been upgraded in .NET 11 to support ML-KEM recipient keys.

EnvelopedCms with ML-KEM
EnvelopedCms with ML-KEM

  • Enables post-quantum encrypted email (S/MIME) and CMS container structures.
  • Binds an ML-KEM public key as the subject key within standard X.509 certificates.
  • Composite ML-KEM support in EnvelopedCms is scheduled for .NET 11 servicing releases.

7. The Farther Future & Roadmap

Jeremy Barton shared the long-term vision for .NET cryptography beyond .NET 11:

The Farther Future: Multi-Certificate TLS
The Farther Future: Multi-Certificate TLS

  1. Graduation from [Experimental]: PQC APIs carry [Experimental] attributes while IETF drafts finalize. With Composite ML-KEM recently ratified as an RFC, these attributes will be stripped in .NET 12.
  2. Multi-Certificate TLS Negotiation: Expanding SslStream and Kestrel beyond single-certificate SNI. Servers will maintain a bag of certificates (RSA, ECDSA, ML-DSA, Merkle Tree Certificates / MTC) and dynamically select the optimal certificate matching the client's supported cipher suites in the TLS ClientHello.
  3. Defeating the "Power Set Problem": Creating composite combinations for every algorithm pair produces an unsustainable combinatorial explosion. Long-term protocol standards (COSE, JOSE) will migrate toward accepting multiple independent public keys natively.

Key Takeaways for Developers

  1. Mitigate HNDL Today: Audit external-facing APIs and data transmission channels. Transition sensitive high-retention data pipelines to Composite ML-KEM or TLS 1.3 Hybrid KEM.
  2. Use HPKE Instead of Custom Crypto: Adopt Hpke for message-based application encryption to eliminate nonce, tag, and sequencing mistakes.
  3. Do Not Roll Custom KEM Handshakes: Always pass shared secrets from Encapsulate() through an approved KDF (such as HKDF) before passing into symmetric encryption.