Cryptography
Cryptography tests whether you can choose the right primitive and explain what it does-and does not-protect.
Core rules
- Symmetric encryption (AES, per FIPS 197) is fast for bulk data; key distribution is the hard problem. Asymmetric encryption (RSA, ECC) solves distribution and supports signatures but is slower.
- Hashing (SHA-256/SHA-3) provides integrity, not confidentiality. HMAC combines a hash with a shared secret for message authentication. A digital signature uses the signer’s private key and verifies with the public key.
- PKI binds identities to public keys through certificates; validate chain, revocation, name, and validity. TLS combines asymmetric key exchange, certificates, symmetric session encryption, and MAC/AEAD.
- Key management covers generation, distribution, storage, rotation, recovery, and destruction. IVs must be unique for modes such as CBC/GCM; salts defeat precomputed password attacks.
Worked example
Alice must send a confidential, tamper-evident contract to Bob and prove she sent it. She generates a hash of the contract, signs the hash with her private key, encrypts the contract plus signature with a symmetric key, and encrypts that key with Bob’s public key. Bob decrypts the key with his private key, verifies Alice’s signature with her public key, and compares the hash. Confidentiality comes from encryption; integrity and nonrepudiation come from the signature.
Traps
Hashing is not encryption, and encryption does not prove authorship. Do not encrypt with the sender’s private key for confidentiality. A certificate proves a public-key binding after validation, not that the holder is trustworthy. Salting does not make a weak password strong.