Library · |crypto⟩ Today's cryptography

How today's cryptography works

Symmetric and public-key cryptography, RSA, Diffie–Hellman, elliptic curves, hashes and signatures, and a walk through a TLS handshake.

Before you can judge what a quantum computer would break, you need a clear map of what today's cryptography does. Banks and large enterprises use dozens of algorithms across thousands of systems, but they fall into a small number of families, and only some of those families are at risk.

This article explains each family with enough mathematics to see why it works, using small numbers you can check by hand. It then walks through a TLS 1.3 handshake, lists where each algorithm shows up in a bank, and closes with a table of which parts a quantum computer breaks.

Symmetric encryption

In symmetric encryption, both sides share one secret key. The sender uses it to scramble data and the receiver uses the same key to unscramble it. The standard algorithm is AES (the Advanced Encryption Standard), published by NIST in 2001. It works on 128-bit blocks and accepts 128-, 192- or 256-bit keys.[1]

AES is fast, often built into the processor, and trusted. It encrypts database fields, backups, disks, card data, and the bulk of every TLS connection. A mode of operation decides how blocks combine into a long message. Modern deployments use an authenticated mode such as GCM, which also detects tampering.

Symmetric encryption has one problem it cannot solve alone. Both sides must already hold the key. Distributing keys to millions of customers, servers and devices needs another tool, and that tool is public-key cryptography. Older symmetric algorithms have also been retired for classical reasons. NIST disallowed three-key Triple DES for encryption after 2023.[10]

Hashes and MACs

A hash function turns any input into a fixed-size fingerprint. SHA-256, from the SHA-2 family, produces 256 bits. A good hash is one-way (you cannot recover the input), and it is infeasible to find two inputs with the same output. Hashes verify file integrity, build Merkle trees, and feed into signatures.

A MAC (message authentication code) combines a hash with a secret key, so that only someone with the key can produce a valid tag. HMAC is the standard construction. Payment messages, API requests and session cookies commonly carry a MAC.

Old hashes fail for classical reasons. Researchers from CWI and Google published a practical SHA-1 collision in 2017, and NIST announced in December 2022 that SHA-1 should be phased out by 31 December 2030.[11]Passwords need a different tool again. They should be stored with a deliberately slow, salted function, which this article does not cover.

Public-key cryptography

Public-key (asymmetric) cryptography uses a pair of keys. One is public and can be published. The other is private and stays with its owner. Whitfield Diffie and Martin Hellman described the idea in 1976.[3]Two main jobs follow.

  • Key establishment. Two parties derive a shared secret over an open channel. They then use it as an AES key.
  • Digital signatures. The owner of a private key produces a value that anyone with the public key can verify, which proves who produced it and that the data has not changed.

These tools rest on mathematical problems that are easy in one direction and hard in the other. Three constructions carry nearly all the deployed use: RSA, finite-field Diffie–Hellman, and elliptic curves.

RSA, with numbers you can check

RSA was published in 1978 by Rivest, Shamir and Adleman.[2] It relies on the fact that multiplying two large primes is easy and recovering them from the product is hard. The public key contains the product n and a number e. The private key contains a number d that can be computed only by someone who knows the two primes.

The classic textbook example uses small primes.

RSA key generation with p = 61 and q = 53
StepCalculationResult
Choose two primesp = 61, q = 53—
Multiply themn = 61 × 53n = 3233
Compute φ(n)(61 − 1) × (53 − 1) = 60 × 523120
Pick a public exponent e coprime to 3120e = 17e = 17
Find d with e × d ≡ 1 (mod 3120)17 × 2753 = 46801 = 15 × 3120 + 1d = 2753

The public key is (n = 3233, e = 17). The private key is d = 2753. To encrypt a message m, which must be a number smaller than n, compute m to the power e, then take the remainder on division by n. To decrypt, raise the result to the power d and take the remainder again. With m = 65:

c = 65¹⁷ mod 3233 = 2790, and 2790²⁷⁵³ mod 3233 = 65

An eavesdropper sees n = 3233, e = 17 and the value 2790. To compute d they need φ(n), and for that they need the primes. Here a child can factor 3233 by trial division. Real moduli have 2048 bits or more, about 617 decimal digits, and no classical method is known that can factor them in practice.

Real RSA adds padding (OAEP for encryption, PSS or PKCS#1 v1.5 for signatures). Textbook RSA without padding is insecure, and the example above is for understanding only. For signing, the roles swap. The owner applies d to a hash of the message, and anyone can check the result with e.

Diffie–Hellman with small numbers

Diffie–Hellman (DH) lets two parties agree on a secret without ever sending it.[3] It uses arithmetic on a clock. Pick a prime p and a base g. Raising g to a power and taking the remainder on division by p is easy. Recovering the power from the result, the discrete logarithm, is hard when p is large.

Take p = 23 and g = 5. Alice and Bob each choose a secret number.

A Diffie–Hellman exchange with p = 23 and g = 5
StepAliceBob
Secret numbera = 6b = 15
Sends the public valueA = 5⁶ mod 23 = 8B = 5¹⁵ mod 23 = 19
Computes the shared secretB⁶ mod 23 = 19⁶ mod 23 = 2A¹⁵ mod 23 = 8¹⁵ mod 23 = 2

Both end up with 2, because (5¹⁵)⁶ and (5⁶)¹⁵ are both 5⁹⁰. An eavesdropper sees 23, 5, 8 and 19. To find the secret they must recover 6 or 15, which here takes a moment and with a 2048-bit prime is infeasible for classical computers. The shared secret becomes the input to a key-derivation function that produces AES keys.

Plain DH is not authenticated. An attacker in the middle can run one exchange with each side. That is why key exchange is paired with a signature or a certificate, as in TLS.

Elliptic curves

An elliptic curve is a set of points satisfying an equation, with a rule for adding two points to get a third. Adding a point to itself k times gives another point, and that is "multiplying" the point by k. Computing the result is quick even for a huge k. Starting from the result and the original point, finding k is the elliptic-curve discrete logarithm problem. For well-chosen curves it is much harder than the equivalent problem in the integers, so keys can be much smaller. A 256-bit curve key gives roughly 128-bit classical security, where RSA needs 3072 bits for the same.

Three algorithm families use curves.

  • ECDH is Diffie–Hellman on a curve. X25519, on Curve25519, is the most common form, and its public keys are 32 bytes.[5] NIST curves such as P-256 are also widely used.
  • ECDSA is a signature scheme on NIST curves such as P-256, in FIPS 186-5.[4] It is common in certificates, JWTs and payment systems.
  • EdDSA, usually as Ed25519, is a newer signature scheme with 32-byte public keys and 64-byte signatures.[6] It is used in SSH, code signing and modern protocols.

An ECDSA signature needs a fresh random number for each signature, and a repeated or predictable value leaks the private key. EdDSA avoids that risk by deriving the value from the message and key. Small keys make elliptic curves the default in new designs, which is also why a bank may find them in more places than RSA.

Signatures, certificates and PKI

A digital signature binds a message to a private key. The signer hashes the message and applies the private key to the hash. A verifier recomputes the hash and checks it against the signature using the public key. A valid signature shows that the holder of the private key signed and that no byte changed since.

That raises a question: how does a verifier know that a public key belongs to a particular bank? The answer is a certificate, a signed statement that links a name, such as a website's domain, to a public key. The X.509 standard defines the format.[7] A certificate authority (CA) signs the certificate with its own private key. Browsers and operating systems ship with a list of root CAs they trust. A root usually signs an intermediate CA, which signs the leaf certificate for a server, so a verifier checks a chain.

Together, CAs, certificates, revocation and the policies around them are called public-key infrastructure (PKI). A bank runs its own PKI internally for devices, users, code signing and document signing, and relies on public PKI for its websites. Every certificate in the chain carries a public key and a signature algorithm. Replacing them takes more coordination than replacing a cipher, because certificates have lifetimes, are pinned or embedded in devices, and depend on trust relationships with other organisations.

A TLS 1.3 handshake, step by step

TLS 1.3, specified in RFC 8446 in 2018, protects HTTPS and many other connections.[8] It shows all three families at work in a few milliseconds.

  1. ClientHello

    The client sends the cipher suites and signature algorithms it supports, and a key share: its public value for a key-exchange group, commonly X25519. It guesses which group the server will accept, to save a round trip.

  2. ServerHello

    The server picks a suite and sends its own key share. Both sides now compute the same shared secret with ECDH, and derive handshake keys from it with a key-derivation function (HKDF, built on HMAC). Everything after this point is encrypted.

  3. Server certificate and signature

    The server sends its certificate chain, then a CertificateVerify message: a signature over the handshake transcript, made with the private key that matches the certificate. The signature may be RSA-PSS, ECDSA or Ed25519. It proves the server holds the private key and ties the key exchange to its identity.

  4. Verification by the client

    The client checks the chain up to a trusted root, the domain name, the validity dates and the signature. A failure ends the connection.

  5. Finished

    Each side sends a Finished message, a MAC over the whole handshake. This detects any tampering with the negotiation.

  6. Application data

    Traffic keys are derived, and the data flows under an authenticated symmetric cipher such as AES-GCM or ChaCha20-Poly1305. A symmetric cipher does all the heavy work.

In this one handshake, the key exchange (ECDH) and the signature (RSA or ECDSA) are public-key operations, which a quantum computer breaks. The cipher and the hash-based parts are symmetric operations, which it does not. The post-quantum change to TLS replaces or supplements the first two.

Where each algorithm appears in a bank

Typical uses in a bank or large enterprise
AlgorithmWhere it appearsTypical role
AES-128 / AES-256Database and disk encryption, backups, card-data stores, TLS and VPN traffic, HSM key wrappingBulk encryption
SHA-256 / SHA-384, HMACDigital signatures, file integrity, API request signing, session tokens, audit-log chainingIntegrity and authentication
RSA (2048 and above)Web and API certificates, internal CAs, code signing, SAML and JWT signing, SWIFT and payment PKI, smart cards, S/MIMESignatures and key transport
ECDH (X25519, P-256)TLS 1.3 key exchange, SSH, IPsec VPNs, mobile apps, messagingKey agreement
ECDSA (P-256, P-384)Server certificates, JWTs, mobile app and payment-terminal signing, document signingSignatures
Ed25519SSH host and user keys, software-update and signing toolsSignatures
Finite-field DHOlder TLS and SSH configurations, IPsec groups, some legacy appliancesKey agreement
3DES, SHA-1, MD5Older payment and mainframe systems, legacy file transfer, old certificatesLegacy, already weak classically

The same algorithm turns up at several levels of the estate, in application code, libraries, protocol settings, certificates and vendor products. The article Where cryptography hides in an organisation describes each level.

What a quantum computer breaks

Peter Shor's 1994 algorithm solves both factoring and discrete logarithms in polynomial time on a large quantum computer.[9] That covers every public-key algorithm in the table above. Grover's algorithm gives a smaller, generic speed-up against symmetric keys and hashes.

Effect of a large fault-tolerant quantum computer
AlgorithmUsed forQuantum effectResponse
RSASignatures, key transportBroken by Shor's algorithmReplace: ML-DSA, SLH-DSA, ML-KEM
Diffie–Hellman, ECDH, X25519Key agreementBroken by Shor's algorithmReplace or hybridise with ML-KEM
ECDSA, EdDSA, DSASignaturesBroken by Shor's algorithmReplace: ML-DSA, SLH-DSA, FN-DSA
AES-128Bulk encryptionWeakened by Grover, about 2⁶⁴ iterations in theoryPrefer AES-256 for long-lived data
AES-256Bulk encryptionWeakened to about 2¹²⁸ iterations, still infeasibleKeep
SHA-256, SHA-384, HMACIntegrity, MACsWeakened at most by generic searchKeep; SHA-384 or above for the longest horizons
3DES, SHA-1, MD5LegacyAlready weak against classical attackRemove regardless of quantum

What to do now

  • List the public-key use. Run qsc scan on repositories, configuration and infrastructure code, and add --target host:443 for live TLS endpoints. The output names RSA, DH and elliptic-curve use with the file or host where it was found.
  • Keep a CBOM. Output in CycloneDX 1.6 format records each algorithm as an asset you can track and share with auditors.
  • Clear the legacy items first. Retire 3DES, SHA-1 and MD5 now. They are weak against ordinary computers, and removing them also simplifies later work.
  • Check symmetric strength. Plan on AES-256 and SHA-384 or above for data with a long life.
  • Re-scan to prove progress. Use qsc scan --baseline and qsc diff to show what has been replaced.

Where cryptography hides in an organisation turns this map into a search plan. How Shor's algorithm breaks RSA shows the attack on the mathematics above, and The NIST post-quantum standards describes the replacements.

Sources

  1. NIST. FIPS 197: Advanced Encryption Standard (AES). 2001-11-26.
  2. Rivest, Shamir and Adleman, Communications of the ACM 21(2), 120–126. A method for obtaining digital signatures and public-key cryptosystems. 1978.
  3. Diffie and Hellman, IEEE Transactions on Information Theory 22(6), 644–654. New directions in cryptography. 1976.
  4. NIST. FIPS 186-5: Digital Signature Standard (DSS). 2023-02.
  5. IETF. RFC 7748: Elliptic Curves for Security (X25519 and X448). 2016-01.
  6. IETF. RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA). 2017-01.
  7. IETF. RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile. 2008-05.
  8. IETF. RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3. 2018-08.
  9. Peter Shor (FOCS 1994; SIAM Journal on Computing 26(5), 1997). Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. 1997. https://arxiv.org/abs/quant-ph/9508027
  10. NIST. NIST SP 800-131A Rev. 2: Transitioning the Use of Cryptographic Algorithms and Key Lengths. 2019-03.
  11. CWI and Google; NIST. SHA-1 collision (SHAttered, Stevens, Bursztein, Karpman, Albertini and Markov, 2017) and NIST's December 2022 announcement that SHA-1 should be phased out by 31 December 2030. 2017; 2022-12.
  12. NIST. NIST IR 8547 (initial public draft): Transition to Post-Quantum Cryptography Standards. 2024-11-12. https://csrc.nist.gov/pubs/ir/8547/ipd