Cryptography Basics

What each algorithm is for, and which of the three properties it gives you. Most cryptography questions are answered by knowing whether the scenario needs confidentiality, integrity, or authenticity.

What each property needs

You needUseExample
ConfidentialityEncryptionAES for data, TLS for traffic
IntegrityHashingSHA-256 checksum on a download
AuthenticityDigital signatureSign with a private key, verify with the public one
Integrity and authenticityHMAC or a signatureHMAC-SHA256 on an API request
Non-repudiationDigital signatureThe signer cannot deny signing
Key exchange over an untrusted linkAsymmetric or Diffie-HellmanTLS handshake

Symmetric algorithms

AlgorithmTypeKey sizeStatus
AESBlock, 128-bit blocks128 / 192 / 256Current standard
ChaCha20Stream256Current, common on mobile
3DESBlock168 effectiveDeprecated
DESBlock56Broken, do not use
RC4Stream40 to 2048Broken, do not use
Blowfish / TwofishBlockUp to 448 / 256Legacy, largely replaced by AES

Asymmetric and hashing

AlgorithmPurposeNotes
RSAKey exchange, signatures2048-bit minimum, 3072 preferred
ECDSASignatures256-bit ECC is roughly 3072-bit RSA
ECDHKey exchangeElliptic curve Diffie-Hellman
Diffie-HellmanKey exchangeDoes not authenticate on its own
SHA-256 / SHA-3HashingCurrent standards
SHA-1HashingCollision attacks demonstrated, deprecated
MD5HashingBroken, non-security checksums only
bcrypt / scrypt / Argon2Password storageDeliberately slow, salted
PBKDF2Key derivationIteration count is the work factor

PKI components

ComponentWhat it does
Certificate Authority (CA)Issues and signs certificates
Registration Authority (RA)Verifies identity before the CA issues
Root CATop of the chain, kept offline
Intermediate CASigns end-entity certificates so the root stays offline
CSRThe request sent to a CA, carries the public key
CRLPublished list of revoked certificates
OCSPLive revocation check for one certificate
OCSP staplingThe server presents its own fresh OCSP response
Key escrowA third party holds a copy of the private key
Wildcard certificateCovers one level of subdomain, *.example.com
SAN certificateCovers several named hosts on one certificate
Self-signed certificateNo third-party trust, fine internally

Now test yourself

Memorizing a table is a start. Practice questions are what make it stick, and every answer carries the full explanation.