The security vocabulary every CS graduate is expected to have: the CIA triad, symmetric and asymmetric cryptography, hashing, digital signatures, TLS, and the attack classes that keep recurring.
| CIA triad | Guarantees | Broken by | Provided by |
|---|---|---|---|
| Confidentiality | Only authorised parties can read the data | Eavesdropping, data breach | Encryption, access control |
| Integrity | Data has not been altered undetectably | Tampering, corruption | Hashes, MACs, digital signatures |
| Availability | The system is usable when needed | Denial of service, hardware failure | Redundancy, backups, rate limiting |
| Symmetric | Asymmetric (public key) | |
|---|---|---|
| Keys | One shared secret key | A key pair - public and private |
| Encrypt with | The shared key | The recipient's public key |
| Decrypt with | The same shared key | The recipient's private key |
| Speed | Fast - suitable for bulk data | Slow - often 100–1000× slower |
| Key distribution | The hard problem - how do both parties get the key? | Solved - the public key may be published |
| Keys for n parties | ||
| Algorithms | AES, DES, 3DES, ChaCha20 | RSA, ECC, Diffie-Hellman, ElGamal |
| Property | Achieved by |
|---|---|
| Confidentiality | Encrypt with the recipient's public key |
| Authentication & non-repudiation | Sign with your own private key |
| Both | Sign with your private key, then encrypt the result with their public key |
| Algorithm | Digest | Status |
|---|---|---|
| MD5 | 128 bits | Broken - collisions are trivially constructible |
| SHA-1 | 160 bits | Broken - practical collisions demonstrated in 2017 |
| SHA-256 / SHA-3 | 256 bits | Secure for integrity; too fast for passwords |
| bcrypt / scrypt / Argon2 | Varies | Correct for passwords - deliberately slow and tunable |
WRONG: store(password) plaintext - catastrophic
WRONG: store(md5(password)) broken hash, no salt
WRONG: store(sha256(password)) unsalted; GPUs try billions/sec
BETTER: store(sha256(salt + password), salt) salted, but still fast
RIGHT: store(argon2(password, salt, cost)) salted AND deliberately slow
Verification never decrypts. It re-computes:
hash(supplied_password, stored_salt) == stored_hash ?
The cost factor is tunable: raise it as hardware gets faster, so an
offline guessing attack stays expensive for decades.| Mechanism | Provides | Requires | Non-repudiation? |
|---|---|---|---|
| Hash | Integrity only | Nothing - anyone can recompute it | No |
| MAC / HMAC | Integrity and authentication | A shared secret key | No - either party could have produced it |
| Digital signature | Integrity, authentication and non-repudiation | The signer's private key | Yes - only the key holder could sign |
Public-key cryptography solves key distribution but creates a new problem: how do you know a public key really belongs to the party it claims? The answer is a certificate - a public key plus identity information, signed by a Certificate Authority that both parties already trust.
Client hello
Server hello and certificate
Certificate validation
Key agreement
Encrypted session
| Attack | Mechanism | Primary defence |
|---|---|---|
| SQL injection | User input is concatenated into a query and changes its structure | Parameterised queries - never string concatenation. Input validation is secondary |
| XSS (cross-site scripting) | Attacker-supplied script is stored or reflected and runs in another user's browser | Context-aware output encoding, Content Security Policy, HttpOnly cookies |
| CSRF | A victim's authenticated browser is tricked into issuing an unintended request | Anti-CSRF tokens, SameSite cookies, checking the Origin header |
| Buffer overflow | Writing past a buffer's bounds overwrites the return address | Bounds checking, stack canaries, ASLR, non-executable stack, memory-safe languages |
| Man-in-the-middle | An attacker relays and possibly alters traffic between two parties | TLS with certificate validation; certificate pinning |
| Replay attack | A valid captured message is retransmitted later | Nonces, timestamps, sequence numbers |
| Privilege escalation | Gaining rights beyond those granted | Least privilege, patching, careful setuid use |
# VULNERABLE - user input becomes part of the query's STRUCTURE
query = "SELECT * FROM users WHERE name = '" + name + "'"
# name = "' OR '1'='1" -> WHERE name = '' OR '1'='1' (matches everything)
# name = "'; DROP TABLE users; --" (two statements)
# SAFE - the query structure is fixed before the data is ever seen.
# The driver sends structure and parameters separately, so input can
# never be reinterpreted as SQL.
cursor.execute("SELECT * FROM users WHERE name = %s", (name,))10 questions on Security & Cryptography · misses join your review queue, on this device only