iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Confidentiality, Integrity, Auth

The CIA triad — Confidentiality, Integrity, Availability — is the lens to ask what a system actually needs from cryptography.

Crypto — the CIA triad

EXAMPLE
# ===== Confidentiality =====
# 'Can the wrong people read this?'
# Tools:
#   - Symmetric encryption (AES-GCM, ChaCha20-Poly1305)
#   - Public-key encryption / hybrid (RSA-OAEP, ECDH + AEAD)
#   - Transport encryption (TLS 1.3)
#   - Disk encryption (LUKS, BitLocker, FileVault)
#   - Field-level encryption with KMS-wrapped data keys (envelope encryption)

# ===== Integrity =====
# 'Could the message have been altered?'
# Tools:
#   - Authenticated encryption (AEAD: AES-GCM, ChaCha20-Poly1305) -- combines C + I
#   - HMAC (HMAC-SHA-256) for messages without secrecy
#   - Digital signatures (Ed25519, ECDSA, RSA-PSS) for non-repudiation
#   - Merkle trees for batched integrity (git, transparency logs)

# ===== Availability =====
# 'Will the data be reachable when needed?'
# Tools:
#   - Redundancy (replicas, multi-region storage)
#   - Backups + tested restore (3-2-1: 3 copies, 2 media, 1 off-site)
#   - DDoS mitigation (CDN, anycast)
#   - Capacity planning + autoscaling
#   - Incident response runbooks

# ===== Map the triad onto a real system =====
# Example: a SaaS that stores customer documents.
#   Confidentiality:
#     - TLS 1.3 in transit
#     - Disk encryption at rest
#     - Field encryption for PII (names, emails) with KMS-wrapped data keys
#     - Tight IAM: least privilege roles
#   Integrity:
#     - AEAD for the field-level encryption (GCM/ChaCha20-Poly1305)
#     - Digital signatures on deployment artifacts
#     - Immutable audit log with HMAC chains or Merkle proofs
#   Availability:
#     - Multi-AZ replicas
#     - Daily backups + monthly restore drills
#     - CDN for static + WAF for app
#     - SLOs + on-call rotation

# ===== Tension: confidentiality vs availability =====
# 'If we lose the key, the data is unrecoverable.'
# Reconcile with:
#   - KMS keys with key rotation + a recovery plan
#   - Multi-region key replication (KMS feature)
#   - Backup wrapped data keys to a second KMS or HSM
#   - Documented incident plan for key compromise (you ARE going to deal with it)

# ===== Tension: integrity vs performance =====
# Signing every event is expensive at scale.
# Reconcile with:
#   - Batched signing (sign the Merkle root of N events)
#   - Move signing off the hot path
#   - HMAC for high-throughput integrity; ECDSA / Ed25519 only when non-repudiation matters

# ===== Tension: availability vs confidentiality =====
# Easier to be available if you replicate widely; harder to keep secrets in many places.
# Reconcile with:
#   - Per-region KMS, replicate ciphertext only
#   - 'Encrypted everywhere' policies that don't compromise on tier replication
#   - Quotas and rate limits per region

# ===== Threat models map to the triad =====
# Confidentiality breach: data leak, unauthorised disclosure
# Integrity breach:       message tampering, supply chain compromise
# Availability breach:    outage, DDoS, ransomware (which crosses all three)

# ===== Pattern: write a CIA table for the system =====
# | Asset           | C            | I            | A            |
# |-----------------|--------------|--------------|--------------|
# | User passwords  | Argon2 hash  | DB row hash  | Rotated bckp |
# | Audit log       | TLS in trans | HMAC chain   | Replicated   |
# | App binaries    | Signed       | Signed       | Multi-region |
# Marking what each control buys you, per asset, makes gaps obvious.

# ===== Patterns to internalise =====
# - AEAD by default; you get C and I in one primitive
# - Treat availability as a crypto concern (lose the key, lose the data)
# - Map the triad to your real system on a whiteboard before picking primitives
# - Tensions between C/I/A are how you discover hidden requirements
# - Backups + restore drills are crypto, not 'ops'

# ===== Pitfalls =====
# - Encrypting without authenticating (CBC without HMAC, ECB) -> integrity hole
# - Strong confidentiality on data you can never restore -> business risk
# - Treating availability as someone else's problem (it overlaps with key management)
# - Adding crypto where access control would have sufficed (and added less risk)

Why it matters

CIA is not three boxes; it is a lens. Walk every important asset through C, I, and A — and write the controls that buy each property. The tensions you uncover are the unstated requirements that bite during incident reviews. Better to map them on a whiteboard than during a 3am page.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// Confidentiality: encryption (AES-GCM, ChaCha20-Poly1305).
// Integrity:       MAC / authenticated encryption (don't use "encrypt" without auth).
// Authentication:  signatures (Ed25519), HMAC, password hashes.
Try it Yourself »

Discussion

Loading…