{ "nbformat": 4, "nbformat_minor": 5, "metadata": { "colab": { "name": "The Infosiast \u2014 Post-Quantum TLS 1.3 (ML-KEM-768 & ML-DSA) Handshake & MTU Benchmark", "provenance": [], "gpuType": "T4" }, "accelerator": "GPU", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.0" } }, "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# The Infosiast \u2014 Post-Quantum Cryptography (NIST FIPS 203 & 204) Packet & Latency Benchmark\n", "**Prepared by [Kshitij Gupta](https://www.linkedin.com/in/kshitij-gupta-855535134/) for [The Infosiast](https://theinfosiast.com/)**\n", "\n", "Accompanies: [Post-Quantum Cryptography: Zero-Trust Migration Blueprint](https://theinfosiast.com/post-quantum-cryptography-zero-trust-migration-blueprint/)\n", "\n", "This notebook compares payload sizes, Ethernet MTU fragmentation thresholds (`1500` bytes), and cryptographic handshake overhead across classical `X25519`, hybrid `X25519MLKEM768` (FIPS 203), and `ML-DSA-65` (FIPS 204) certificate chains.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1: NIST FIPS 203 (ML-KEM) & FIPS 204 (ML-DSA) Wire-Size & MTU Fragmentation Analysis\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import math\n", "import pandas as pd\n", "\n", "ETHERNET_MSS = 1460 # Standard TCP Maximum Segment Size over 1500-byte Ethernet MTU\n", "\n", "primitives = [\n", " {'Algorithm': 'X25519 (Classical ECDHE)', 'Standard': 'RFC 7748', 'Public Key (B)': 32, 'Ciphertext / Sig (B)': 32},\n", " {'Algorithm': 'X25519MLKEM768 (Hybrid KEX)', 'Standard': 'NIST FIPS 203 + X25519', 'Public Key (B)': 1216, 'Ciphertext / Sig (B)': 1120},\n", " {'Algorithm': 'ML-KEM-1024 (PQC KEX Level 5)', 'Standard': 'NIST FIPS 203', 'Public Key (B)': 1568, 'Ciphertext / Sig (B)': 1568},\n", " {'Algorithm': 'ECDSA P-256 (Classical Auth)', 'Standard': 'FIPS 186-5', 'Public Key (B)': 64, 'Ciphertext / Sig (B)': 64},\n", " {'Algorithm': 'ML-DSA-65 (PQC Signature)', 'Standard': 'NIST FIPS 204', 'Public Key (B)': 1952, 'Ciphertext / Sig (B)': 3309},\n", " {'Algorithm': 'SLH-DSA-SHA2-128f (Hash Sig)', 'Standard': 'NIST FIPS 205', 'Public Key (B)': 32, 'Ciphertext / Sig (B)': 17088},\n", "]\n", "\n", "for row in primitives:\n", " handshake_bytes = 320 + row['Public Key (B)'] + row['Ciphertext / Sig (B)']\n", " row['Total Wire Overhead (B)'] = handshake_bytes\n", " row['TCP Segments (1460B MSS)'] = math.ceil(handshake_bytes / ETHERNET_MSS)\n", "\n", "df = pd.DataFrame(primitives)\n", "print(df.to_string(index=False))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2: Live TLS 1.3 Cipher & Ephemeral Key Exchange Verification\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ssl, socket\n", "\n", "hostname = 'theinfosiast.com'\n", "ctx = ssl.create_default_context()\n", "with socket.create_connection((hostname, 443), timeout=10) as sock:\n", " with ctx.wrap_socket(sock, server_hostname=hostname) as ssock:\n", " print('Connected Host :', hostname)\n", " print('TLS Version :', ssock.version())\n", " print('Negotiated Suite:', ssock.cipher())\n" ] } ] }