Encryption, Hashing, and Threshold Schemes: Types and Applications
In day-to-day development, "encryption" tends to be used as a catch-all: HTTPS, password storage, file checksums, API signing… In reality there are at least several distinct capabilities behind it: confidentiality (encryption/decryption), integrity (digests), identity and key distribution (asymmetric cryptography), and the threshold control (secret sharing) commonly seen in HSM scenarios. Separating these categories is more useful than memorizing a pile of algorithm names.
This post walks through common algorithms grouped as digests, symmetric encryption, asymmetric encryption (RSA / ECC), and threshold secret sharing, covering each from both the principle and the application side; the last section briefly touches on post-quantum cryptography (PQC). For details on certificates and trust chains, see the earlier post PKI Architecture and Certificate Trust Chains.
First, identify the problem you are solving
| Goal | Typical mechanism | In one sentence |
|---|---|---|
| Confidentiality | Symmetric / asymmetric encryption | Without the key, nobody can read the plaintext |
| Integrity | Digest (hash) | Any modification to the content is detectable |
| Authentication / non-repudiation | Signatures, MAC | Prove "who sent it", or authenticate a message under a shared key |
| Key distribution | Asymmetric crypto, key agreement | Establish a shared key over an untrusted channel |
| Threshold control | Secret sharing (e.g. Shamir) | Any set of shares below the threshold cannot reconstruct the secret |
Real systems almost always combine these: TLS uses asymmetric crypto for identity and the handshake, then AES to protect the session; Git and software packages use digests for integrity; HSMs use threshold shares to manage master keys and admin tokens. The sections below go through each algorithm family.
Digest algorithms: turning arbitrary input into a fixed-size fingerprint
Principle: a one-way, collision-resistant compression function
A digest (hash) algorithm maps input of arbitrary length to output of fixed length; SHA-256, for example, produces 256 bits. Desired properties include:
- One-wayness: recovering the input from the digest is infeasible
- Collision resistance: it is hard to find two different inputs with the same digest
- Avalanche effect: flipping one input bit changes the output beyond recognition
Common members:
| Algorithm | Output length | Status (engineering view) |
|---|---|---|
| MD5 | 128 bit | No longer suitable for security use; collision attacks are mature |
| SHA-1 | 160 bit | Not suitable for new systems; long deprecated by browsers/CAs |
| SHA-256 / SHA-384 / SHA-512 | 256/384/512 bit | Current mainstream default |
| SHA-3 (e.g. SHA3-256) | Variable | Backup family; structurally different from SHA-2 |
| BLAKE2 / BLAKE3 | Variable | Performance-friendly; used by some newer protocols |
Note: a digest is not encryption. Digest outputs are usually public; they provide no confidentiality, only a "fingerprint". When you need integrity plus keyed authentication, use HMAC (e.g. HMAC-SHA256) rather than a bare hash of a password or of API parameters.
Password storage typically uses slow hashes / key derivation functions: bcrypt, scrypt, Argon2, PBKDF2, and so on. Their goal is to be deliberately slow and resist brute force, which is a different problem from storing a plain SHA-256 hash of the password.
Applications: verification, signature preprocessing, key derivation
- Integrity checks: ISO images, software packages, object storage ETag / Content-MD5 (legacy), Git object IDs
- Input to digital signatures: RSA / ECDSA usually sign the message digest, not the full plaintext
- Certificates and PKI: certificate fingerprints, OCSP / CRL identifiers; algorithm choice affects the whole trust chain (see the PKI post)
- TLS / protocols: hashing the handshake transcript, key derivation such as HKDF
- Deduplication and indexing: content-addressable storage (CAS) uses hashes as keys; here uniqueness and performance matter most, and the collision-resistance requirement depends on the scenario
Recommendation: new systems should default to SHA-256 (or SHA-384/512 as the protocol requires); do not use MD5/SHA-1 for anything security-related. Legacy systems that show "SHA1 fingerprints" should be flagged as tech debt with a migration plan.
AES: the workhorse of symmetric encryption
Principle: one shared key, the same algorithm for encryption and decryption
In symmetric encryption, encryption and decryption use the same key. AES (Advanced Encryption Standard) is a block cipher: plaintext is processed in fixed 128-bit blocks, with a key length of 128, 192, or 256 bits.
The algorithm alone is not enough; you also need to pick a mode of operation:
- GCM: the most common authenticated encryption (AEAD) mode today, providing both confidentiality and integrity
- CBC and others: still found in older systems; they need a separate MAC and carry higher misuse risk
- ECB: really only good as a textbook counterexample; identical plaintext blocks produce identical ciphertext blocks
The security boundary is clear: key secrecy ≈ security. A public algorithm and open-source implementation do not weaken security; what really hurts is key leakage, weak randomness, the wrong mode, or plaintext keys hardcoded in source.
Compared with asymmetric crypto, AES is fast and suited to large volumes of data; its weakness is that both parties must first share the key securely.
Applications: disks, TLS sessions, application-level sealing
- Full-disk / volume encryption: BitLocker, FileVault, LUKS, etc. commonly use AES underneath
- TLS record layer: after the handshake, application data is mostly protected by AES-GCM (or ChaCha20-Poly1305)
- Application layer: database field encryption, server-side encryption in object storage, sealing message payloads in middleware
- Tokens and local storage: some frameworks wrap sessions or sensitive config with AES (the master key still needs proper management)
In practice the hard part is rarely "choosing AES"; it is where the key comes from, where it is stored, how it is rotated, and who is allowed to decrypt. Establishing a shared key across a network for the first time is where asymmetric crypto or key-agreement protocols come in.
RSA: the classic asymmetric scheme
Principle: the hardness of factoring large integers
Asymmetric schemes use a key pair: the public key can be published, while the private key is kept only by its owner. RSA's security rests on the difficulty of factoring large integers: choose large primes and , set the modulus , then choose a public exponent and private exponent such that . The public key is , and the private key contains (implementations usually also store , , and other parameters for speedups).
Do not confuse its two main uses:
- Encryption: encrypt with the public key → decrypt with the private key (usually to wrap a small symmetric key, not to encrypt large files directly)
- Signing: sign with the private key → verify with the public key (proves possession of the private key and that the content was not tampered with; usually signs a digest)
RSA operations are modular exponentiations, more than an order of magnitude slower than AES, with larger keys. New systems today typically start at 2048 bits, with 3072 and above for long-term or high-assurance needs. Using RSA to "encrypt an entire disk" is both slow and unnecessary; the standard approach is RSA/ECC carries the key, AES carries the data (hybrid encryption).
Padding is not optional: use OAEP for encryption and PSS for signatures (or whatever the protocol specifies). Raw RSA or misuse of the old PKCS#1 v1.5 has been a breeding ground for historical vulnerabilities.
Applications: certificates, signatures, key wrapping
- TLS / HTTPS: RSA was once used for key exchange; in modern cipher suites RSA certificates mainly serve the signing role, while key agreement is usually done with ECDHE
- Certificates and PKI: many server certificates and code-signing certificates still carry RSA public keys
- Code signing, document signing, S/MIME email: the private key proves the publisher's identity
- JWT / JWS, etc.: algorithms like
RS256mean "SHA-256 + RSA signature"
Common pitfalls: keys that are too short, private keys committed to repositories, using one key pair for both encryption and signing with a muddled lifecycle, and home-made "encryption padding". If a system or mature library offers a high-level API, do not assemble modular exponentiation yourself.
ECC: shorter keys, equivalent strength
Principle: the elliptic curve discrete logarithm
Elliptic curve cryptography (ECC) is built on the discrete logarithm problem over the group of points on a curve: given a base point and the scalar multiple , recovering the scalar is hard. The core operation is scalar multiplication of points, and for the same security level, keys are much shorter than RSA's; a curve with roughly 256-bit strength is broadly comparable to RSA with thousands of bits.
Common curves and their uses (briefly):
- NIST P-256 and similar: very common in TLS and the certificate ecosystem
- X25519: key agreement (a Diffie–Hellman variant)
- Ed25519: signatures (EdDSA), with a simple implementation and good performance
Shorter keys mean smaller certificates and faster handshakes, which particularly helps mobile clients and high-concurrency TLS termination. The cost is that curves and parameters must come from a trusted set; "inventing your own curve" is usually a preview of an incident.
Applications: the default choice for modern TLS and mobile
- ECDHE: key agreement with forward secrecy in TLS (leaking a session key does not expose past traffic)
- ECDSA / EdDSA: certificate signatures, JWT (e.g.
ES256), SSH host and user keys - Trade-off with RSA: new systems should prefer ECC (performance, size); keep RSA when you must support old clients or existing RSA certificate chains
The "public key algorithm" field in a certificate is exactly where RSA / ECC show up; for how relying parties validate the full chain, see the PKI post.
Threshold schemes and secret sharing: Shamir and others
What is commonly called Shamir's Secret Sharing (SSS) was proposed by Adi Shamir. It is not an encryption algorithm like AES, nor a public-key algorithm like RSA/ECC; it is a secret sharing scheme. With the constraint "at least t shares are needed to reconstruct", it is often classified under the broader category of threshold cryptography / threshold schemes.
Do not mix up neighboring concepts:
| Name | What it solves |
|---|---|
| Secret sharing (e.g. Shamir) | Split a secret into n shares; any t shares reconstruct it, fewer than t reveal nothing |
| Threshold signatures / threshold decryption | Multiple private key shares cooperate to sign or decrypt; the full private key need never exist in one place |
| Plain backup copies | Every copy is the full key; any single leak compromises everything, with no threshold protection |
Principle: t-of-n and polynomial interpolation
The intuition behind Shamir's scheme: over a finite field, construct a random polynomial of degree and put the secret in the constant term (or at an agreed evaluation point); give each participant one point on the curve (a share). Any t points uniquely determine the polynomial and therefore recover the secret; fewer than t points yield no useful information about the secret in the information-theoretic sense.
The engineering parameter is written as t-of-n (or m-of-n): for example 3-of-5 means 5 admin shares are issued, any 3 can be combined, and 2 cannot. The threshold provides both:
- Resistance to a single bad actor: no one person can obtain the full master key / admin token
- Resistance to partial loss: a few shares can be lost and recovery is still possible (as long as t remain)
The shares themselves must still be handled as sensitive material (separate people, locations, media); the algorithm only guarantees "below the threshold, nothing combines", and does not replace physical and procedural controls.
Applications: HSM administration and key ceremonies
The most typical use is in HSMs and high-assurance key management:
- Threshold tokens / admin card distribution: during device initialization or a key ceremony, the master key, unseal key, or admin privileges are split across multiple smart cards / tokens handed to several administrators; booting, unsealing, and critical operations require a quorum
- Root keys and CA ceremonies: the root private key or seed is not held by any single person, reducing insider threat and single-person error
- System unsealing: for example, some key management systems split the master key with Shamir, and starting the cluster requires several operators to unseal it together
Relationship to AES/RSA: a threshold scheme governs "who is allowed to assemble that critical key"; once assembled, business data is still usually encrypted with AES and signed with RSA/ECC. A common combination in HSMs is: business keys stay inside the device, while administrative privileges are controlled by threshold tokens for export, unsealing, and dual-control review.
PQC: algorithm families for the quantum era
Principle: switch to a different set of "hard problems"
If large-scale fault-tolerant quantum computers become available, Shor's algorithm would seriously threaten the mathematical problems that RSA and ECC depend on. Symmetric algorithms and hashes are comparatively robust: the main countermeasure is longer keys / outputs (e.g. AES-256, longer digests), not replacing the whole family.
Post-quantum cryptography (PQC) uses problems believed to be quantum-resistant (lattices, hash-based signatures, etc.). NIST has been driving standardization, and the directions you commonly hear about in engineering include:
- ML-KEM (Kyber): a key encapsulation mechanism (KEM), used to negotiate/wrap symmetric keys
- ML-DSA (Dilithium) and others: digital signatures
The transition period commonly uses hybrid mode: a classical algorithm (such as X25519) runs alongside a PQC KEM, and the session is only at risk if both are broken, which reduces the risk of "betting everything on one scheme before the standards settle".
Applications: standards rollout and migration reality
- TLS / certificates: browsers and some CDNs and cloud providers are already experimenting with or gradually rolling out hybrid key exchange; PQC signatures and dual certificate chains on the certificate side are still evolving
- Engineering cost: public keys and ciphertexts are often larger, increasing handshake size and CPU; protocols, hardware, HSMs, and compliance checklists all need to change
- Pragmatic judgment: secrets with very long retention ("harvest now, decrypt later") should be assessed first; typical web workloads can simply follow mainstream protocols and vendor roadmaps, with no need to implement PQC primitives yourself
PQC is a long-term migration problem, not a switch that replaces RSA everywhere tomorrow. Retiring MD5/SHA-1 for digests, using AEAD for symmetric encryption, and getting asymmetric key lengths and padding right yield more certain returns first.
Comparison and selection: what to use where
| Category | Representative | Good at | Main cost |
|---|---|---|---|
| Digest | SHA-256 | Integrity, signature preprocessing, derivation | No confidentiality; never use MD5/SHA-1 for security |
| MAC | HMAC-SHA256 | Message authentication under a shared key | Requires a pre-shared key |
| Symmetric encryption | AES-GCM | Confidentiality + integrity for bulk data | Key distribution and custody |
| Asymmetric (RSA) | RSA-OAEP / RSA-PSS | Widely compatible key wrapping and signatures | Slow, large keys |
| Asymmetric (ECC) | X25519 / Ed25519 / P-256 | Cost-effective key agreement and signatures | Choice of curve and ecosystem |
| Threshold / secret sharing | Shamir t-of-n | Multi-party custody, no single point, fault-tolerant recovery | Process and share custody overhead |
| PQC | ML-KEM / ML-DSA, etc. | Long-term quantum-resistant security | Size and ecosystem maturity |
A typical pipeline fits in one sentence:
Digests preserve integrity → asymmetric crypto identifies parties / delivers keys → symmetric crypto protects bulk data; critical master keys can be held in threshold shares.
Take TLS: the certificate (RSA/ECC public key + signature) proves the server's identity → ECDHE (or hybrid PQC) negotiates the session key → AES-GCM encrypts application data, with SHA-family hashes used repeatedly throughout. On the HSM side there is a separate administrative chain: Shamir threshold tokens → unseal/authorize → symmetric or asymmetric operations for business inside the device.
Summary
- Digests answer "has this been modified?"; symmetric encryption answers "how do we keep large amounts of data confidential?"; asymmetric crypto answers "how are keys distributed and identities proven?"; threshold secret sharing (e.g. Shamir) answers "how do we prevent any one person from holding the complete secret?".
- A reasonable default for new systems is roughly: SHA-256 (or as the protocol specifies), AES-GCM, and ECC (key agreement/signatures); RSA appears mostly for compatibility and existing certificates; HSM administration commonly uses t-of-n shares.
- PQC is worth tracking, but get the classical algorithms right first: retire MD5/SHA-1, use AEAD, and use sufficient key lengths with correct padding.