Skip to content

FuturistCoder25/PQC-TLS-QUIC-Simplifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PQC-TLS-QUIC-Simplifier

Automated setup tool for Post-Quantum Cryptography (PQC) testing with nginx and curl

A Python-based automation tool for installing, configuring, and testing nginx-pqc and curl-pqc with support for:

  • TLS 1.3 with Post-Quantum Key Exchange
  • QUIC (HTTP/3) with Post-Quantum Key Exchange
  • Hybrid curves (classical + PQC)
  • Pure PQC curves (MLKEM512, MLKEM768, MLKEM1024)

Based on patterns from Cisco FTD PQC SSL Inspection test framework.


πŸ“‹ Table of Contents


✨ Features

Server Setup

  • βœ… Automatic installation of nginx-pqc with QUIC/HTTP3 support
  • βœ… Automatic installation of OpenSSL 3.x with OQS provider
  • βœ… PQC-compatible certificate generation
  • βœ… nginx configuration templates for TLS and QUIC
  • βœ… Service management (start/stop/reload)
  • βœ… Port availability checking
  • βœ… Firewall configuration assistance

Client Testing

  • βœ… Automatic installation of curl-pqc with QUIC/HTTP3 support
  • βœ… Generated test scripts for TLS and QUIC
  • βœ… Support for multiple PQC curves in single test run
  • βœ… Verbose output with SSL/TLS details
  • βœ… HTTP/3 Alt-Svc support

PQC Support

  • βœ… Pure PQC: MLKEM512, MLKEM768, MLKEM1024
  • βœ… Hybrid: X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024
  • βœ… TLS 1.3 with PQC key exchange
  • βœ… QUIC (HTTP/3) with PQC key exchange
  • βœ… Session resumption with 0-RTT

πŸ” Supported PQC Curves

Curve Name Type Security Level Description
MLKEM512 Pure PQC 128-bit NIST ML-KEM Level 1
MLKEM768 Pure PQC 192-bit NIST ML-KEM Level 3 (Recommended)
MLKEM1024 Pure PQC 256-bit NIST ML-KEM Level 5
X25519MLKEM768 Hybrid 192-bit X25519 + MLKEM768
SecP256r1MLKEM768 Hybrid 192-bit P-256 + MLKEM768
SecP384r1MLKEM1024 Hybrid 256-bit P-384 + MLKEM1024

Recommended: Start with MLKEM768 or X25519MLKEM768 for balanced security and performance.


πŸ“¦ Requirements

System Requirements

  • OS: Linux (Ubuntu 20.04+, CentOS 8+, RHEL 8+)
  • CPU: 4+ cores (for compilation)
  • RAM: 4GB+ (for compilation)
  • Disk: 5GB+ free space
  • Root access: Required for installation

Software Dependencies

  • Python 3.6+
  • git
  • cmake
  • ninja-build
  • gcc/g++
  • OpenSSL development headers

Note: The script automatically installs dependencies on supported systems.


πŸš€ Installation

Option 1: Full Automatic Installation (Recommended)

# Clone repository
git clone https://github.com/yourusername/PQC-TLS-QUIC-Simplifier.git
cd PQC-TLS-QUIC-Simplifier

# Run full installation (nginx-pqc + curl-pqc + OpenSSL)
sudo python3 pqc_setup.py --mode both --install-all

This will:

  1. Install system dependencies
  2. Build and install liboqs (Open Quantum Safe library)
  3. Build and install OpenSSL 3.x with OQS provider
  4. Build and install nginx with QUIC and PQC support
  5. Build and install curl with QUIC and PQC support
  6. Generate PQC certificates
  7. Configure nginx for TLS and QUIC
  8. Generate client test scripts

Installation time: ~20-30 minutes (depending on system)

Option 2: Configuration Only (If Already Installed)

# Configure nginx and generate test scripts (no installation)
sudo python3 pqc_setup.py --mode both --no-install

Option 3: Clean Reinstall (If Build Failed)

# Remove all previous builds and reinstall from scratch
sudo python3 pqc_setup.py --mode both --install-all --clean

Use --clean when:

  • Build failed midway and you need fresh start
  • Switching OpenSSL versions
  • Resolving dependency conflicts
  • Starting over after errors

What --clean removes:

  • /tmp/pqc-build/* (all build artifacts)
  • /opt/liboqs, /opt/openssl-pqc, /opt/nginx-pqc, /opt/curl-pqc
  • /opt/nghttp3, /opt/ngtcp2

⚑ Quick Start

1. Setup Server (TLS + QUIC)

# Full setup with default curves (MLKEM768, X25519MLKEM768)
sudo python3 pqc_setup.py --mode both --install-all

# Setup with specific curves
sudo python3 pqc_setup.py --mode both --install-all \
  --curves MLKEM768 MLKEM1024 X25519MLKEM768

2. Test TLS Connection

# Run generated TLS test script
~/PQC-TLS-QUIC-Simplifier/scripts/test_tls.sh

Expected output:

πŸ” Testing PQC TLS 1.3...
================================

Testing curve: MLKEM768
---
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* Server certificate: CN=pqc-test.local
* SSL-Session: Protocol: TLSv1.3
* Peer signing digest: SHA256
PQC TLS Test OK
Curve: mlkem768
Protocol: TLS 1.3
Cipher: TLS_AES_256_GCM_SHA384

3. Test QUIC (HTTP/3) Connection

# Run generated QUIC test script
~/PQC-TLS-QUIC-Simplifier/scripts/test_quic.sh

Expected output:

πŸš€ Testing PQC QUIC (HTTP/3)...
================================

Testing curve: X25519MLKEM768
---
* Using HTTP/3
* Connected to pqc-test.local (127.0.0.1) port 443
* h3 [:method: GET]
PQC QUIC Test OK
Protocol: HTTP/3.0
Curve: X25519MLKEM768

πŸ“– Usage Examples

Example 1: TLS Server with MLKEM768

sudo python3 pqc_setup.py \
  --mode tls \
  --install-all \
  --curves MLKEM768 \
  --server-name myserver.local \
  --https-port 8443

Example 2: QUIC Server with Hybrid Curves

sudo python3 pqc_setup.py \
  --mode quic \
  --install-all \
  --curves X25519MLKEM768 SecP256r1MLKEM768 \
  --server-name quic-test.local \
  --quic-port 443

Example 3: Both TLS and QUIC with All PQC Curves

sudo python3 pqc_setup.py \
  --mode both \
  --install-all \
  --curves MLKEM512 MLKEM768 MLKEM1024 \
          X25519MLKEM768 SecP256r1MLKEM768 SecP384r1MLKEM1024 \
  --server-name pqc-full.local

Example 4: Custom SSL Configuration

sudo python3 pqc_setup.py \
  --mode tls \
  --curves MLKEM768 \
  --ssl-protocols "TLSv1.3" \
  --ssl-ciphers "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256" \
  --ssl-session-cache "shared:SSL:20m" \
  --ssl-session-timeout "30m" \
  --ssl-early-data on

Example 5: Generate Client Scripts Only

# No installation or root required
python3 pqc_setup.py \
  --mode client \
  --curves MLKEM768 X25519MLKEM768 \
  --server-name existing-server.local

Example 6: Manual Testing with curl-pqc

# TLS 1.3 with MLKEM768
/opt/curl-pqc/bin/curl --tlsv1.3 \
  --curves MLKEM768 \
  --cacert /etc/nginx/pqc-certs/server.crt \
  --verbose \
  https://pqc-test.local:443/test

# QUIC (HTTP/3) with X25519MLKEM768
/opt/curl-pqc/bin/curl --http3 \
  --curves X25519MLKEM768 \
  --cacert /etc/nginx/pqc-certs/server.crt \
  --verbose \
  https://pqc-test.local:443/test

βš™οΈ Configuration Options

Command Line Arguments

Argument Default Description
--mode both Setup mode: tls, quic, both, or client
--install-all - Install nginx-pqc, curl-pqc, and dependencies
--no-install - Skip installation, configure only
--http-port 80 HTTP port (redirect to HTTPS)
--https-port 443 HTTPS port
--quic-port 443 QUIC (UDP) port
--server-name pqc-test.local Server name
--cert-dir /etc/nginx/pqc-certs Certificate directory
--nginx-config-dir /etc/nginx nginx configuration directory
--curves MLKEM768 X25519MLKEM768 PQC curves to enable
--ssl-protocols TLSv1.3 SSL protocols
--ssl-ciphers TLS_AES_256_GCM_SHA384:... SSL cipher suites
--ssl-session-cache shared:SSL:10m SSL session cache
--ssl-session-timeout 10m SSL session timeout
--ssl-session-tickets on SSL session tickets
--ssl-early-data off SSL early data (0-RTT)

Environment Variables

# Override binary paths
export CURL_PQC_BINARY="/custom/path/curl"
export NGINX_PQC_BINARY="/custom/path/nginx"
export OPENSSL_BINARY="/custom/path/openssl"

πŸ§ͺ Testing

Automated Test Scripts

After setup, test scripts are generated in ~/PQC-TLS-QUIC-Simplifier/scripts/:

  1. test_tls.sh - Test TLS 1.3 with all configured curves
  2. test_quic.sh - Test QUIC (HTTP/3) with all configured curves
# Run all TLS tests
~/PQC-TLS-QUIC-Simplifier/scripts/test_tls.sh

# Run all QUIC tests
~/PQC-TLS-QUIC-Simplifier/scripts/test_quic.sh

Manual Testing

Check nginx Status

# Test configuration
/opt/nginx-pqc/sbin/nginx -t

# View running processes
ps aux | grep nginx

# Check listening ports
netstat -tulpn | grep nginx

View Logs

# Error log
tail -f /var/log/nginx/error.log

# Access log
tail -f /var/log/nginx/access.log

Test Endpoints

# Basic connectivity
curl -k https://pqc-test.local/test

# Check HTTP/3 support
curl -k --http3 https://pqc-test.local/test

Verify PQC Curve Usage

# Capture TLS handshake with tcpdump
sudo tcpdump -i any -s 0 -w pqc-capture.pcap port 443

# Analyze with Wireshark or tshark
tshark -r pqc-capture.pcap -Y "tls.handshake.type == 1" -T fields \
  -e tls.handshake.extensions.supported_groups

πŸ—οΈ Architecture

Component Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  PQC-TLS-QUIC-Simplifier                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚         Installation Phase (Optional)         β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚  1. System Dependencies (gcc, cmake, etc.)    β”‚
    β”‚  2. liboqs (Open Quantum Safe)                β”‚
    β”‚  3. OpenSSL 3.x + OQS Provider                β”‚
    β”‚  4. nginx with QUIC + PQC                     β”‚
    β”‚  5. curl with QUIC + PQC                      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚          Configuration Phase                   β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚  1. Generate PQC Certificates                 β”‚
    β”‚  2. Create nginx Config (TLS/QUIC)            β”‚
    β”‚  3. Start nginx Service                       β”‚
    β”‚  4. Generate Test Scripts                     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚            Testing Phase                       β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚  TLS 1.3:  curl-pqc β†’ nginx-pqc (TCP 443)    β”‚
    β”‚  QUIC:     curl-pqc β†’ nginx-pqc (UDP 443)    β”‚
    β”‚            with PQC key exchange               β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Directory Structure

PQC-TLS-QUIC-Simplifier/
β”œβ”€β”€ pqc_setup.py              # Main setup script
β”œβ”€β”€ README.md                 # This file
β”œβ”€β”€ LICENSE                   # License file
β”œβ”€β”€ .gitignore               # Git ignore patterns
β”‚
β”œβ”€β”€ certs/                    # Generated certificates (runtime)
β”‚   β”œβ”€β”€ server.crt
β”‚   └── server.key
β”‚
β”œβ”€β”€ configs/                  # Generated nginx configs (runtime)
β”‚   β”œβ”€β”€ nginx.conf           # TLS configuration
β”‚   └── nginx-quic.conf      # QUIC configuration
β”‚
β”œβ”€β”€ scripts/                  # Generated test scripts (runtime)
β”‚   β”œβ”€β”€ test_tls.sh          # TLS test script
β”‚   └── test_quic.sh         # QUIC test script
β”‚
└── tests/                    # Example test files
    └── index.html           # Test HTML file

Installation Paths

/opt/
β”œβ”€β”€ openssl-pqc/             # OpenSSL with PQC support
β”‚   β”œβ”€β”€ bin/openssl
β”‚   └── lib/ossl-modules/oqsprovider.so
β”‚
β”œβ”€β”€ liboqs/                  # Open Quantum Safe library
β”‚   β”œβ”€β”€ include/
β”‚   └── lib/
β”‚
β”œβ”€β”€ nginx-pqc/               # nginx with QUIC + PQC
β”‚   β”œβ”€β”€ sbin/nginx
β”‚   └── conf/
β”‚
└── curl-pqc/                # curl with QUIC + PQC
    └── bin/curl

/etc/nginx/
β”œβ”€β”€ nginx.conf               # TLS configuration
β”œβ”€β”€ nginx-quic.conf          # QUIC configuration
└── pqc-certs/              # PQC certificates
    β”œβ”€β”€ server.crt
    └── server.key

πŸ”§ Troubleshooting

Issue: Port Already in Use

Symptom: Address already in use error

Solution:

# Check what's using the port
sudo netstat -tulpn | grep :443

# Stop conflicting service
sudo systemctl stop apache2  # or nginx

Issue: Certificate Errors

Symptom: SSL certificate problem: self signed certificate

Solution:

# Use --insecure flag for testing
curl --insecure https://pqc-test.local/test

# Or add to system CA store
sudo cp /etc/nginx/pqc-certs/server.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

Issue: nginx Fails to Start

Symptom: nginx configuration test fails

Solution:

# Check configuration syntax
/opt/nginx-pqc/sbin/nginx -t

# Check error log
tail -f /var/log/nginx/error.log

# Verify permissions
ls -la /etc/nginx/pqc-certs/

Issue: QUIC Not Working

Symptom: curl falls back to TCP

Solution:

# Verify UDP port is open
sudo ufw allow 443/udp

# Check nginx QUIC support
/opt/nginx-pqc/sbin/nginx -V | grep quic

# Test with tcpdump
sudo tcpdump -i any -n udp port 443

Issue: PQC Curve Not Supported

Symptom: SSL: no ciphers available or curve errors

Solution:

# Verify OpenSSL OQS provider
/opt/openssl-pqc/bin/openssl list -providers

# Check available curves
/opt/openssl-pqc/bin/openssl list -kem-algorithms

# Rebuild with latest liboqs
sudo python3 pqc_setup.py --install-all

Build Issues

Symptom: Compilation errors

Solution:

# Install missing dependencies
sudo apt-get install build-essential libssl-dev zlib1g-dev

# Clean reinstall (recommended)
sudo python3 pqc_setup.py --mode both --install-all --clean

The --clean flag automatically:

  • Removes all build artifacts
  • Removes all installed components
  • Starts fresh installation

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • Support for additional PQC algorithms (Falcon, Dilithium signatures)
  • Docker container support
  • Automated testing framework
  • Performance benchmarking tools
  • Additional platform support (macOS, Windows WSL)
  • Integration with Let's Encrypt for PQC certificates

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Open Quantum Safe (OQS) - liboqs and oqs-provider
  • NIST PQC Project - ML-KEM standardization
  • nginx - Web server with QUIC support
  • curl - HTTP client with QUIC support
  • Cisco FTD SSL Inspection Team - Test framework patterns and PQC testing methodology

πŸ“š References

PQC Standards

Libraries & Tools

Related Projects


πŸ“ž Contact & Support

For questions, issues, or feature requests:


Made with ❀️ for the Post-Quantum future

About

Automated setup for Post-Quantum Cryptography testing with nginx and curl, supporting TLS 1.3 and QUIC (HTTP/3)

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors