Cryptography Key Usage - Quick Review

Updated 14 Oct 2026

v# 🔐 Cryptography Key Usage — Quick Review


1. Symmetric Key Cryptography

Same key for both Encrypt and Decrypt\boxed{\text{Same key for both Encrypt and Decrypt}}

Alice ──[Key K]──► Encrypt(M) ──► Ciphertext ──► Decrypt(C) ──[Key K]──► Bob
  • Alice and Bob share the exact same secret key
  • Must exchange the key securely beforehand (the key distribution problem!)
  • Examples: AES, ChaCha20, DES
✅ Pros❌ Cons
Very fastKey must be shared securely first
Low overheadDoesn't scale — nn users need n(n−1)2\frac{n(n-1)}{2} keys
Great for bulk data encryptionNo built-in identity proof

🔑 Analogy: Both Alice and Bob have a copy of the same house key. Anyone with the key can lock or unlock the door.

Real-World Use

  • TLS session — after handshake, AES symmetric key encrypts actual data
  • Full-disk encryption — BitLocker / FileVault uses AES
  • File encryption — encrypting a ZIP archive with a password

2. Asymmetric (Public Key) Cryptography

Two different keys: Public Key (anyone can have) + Private Key (owner only)\boxed{\text{Two different keys: Public Key (anyone can have) + Private Key (owner only)}}

KeyWho has it?Can be shared?
Public KeyEveryone✅ Yes — share freely
Private KeyOwner only❌ Never share

🏦 Analogy: A public key is like a mailbox slot — anyone can drop a letter in (encrypt). Only the mailbox owner has the key to open it (decrypt).


2.1 Encryption — Sending Secret Info to Someone

Goal: Only Bob can read the message.

Encrypt with Bob’s PUBLIC key→Decrypt with Bob’s PRIVATE key\boxed{\text{Encrypt with Bob's PUBLIC key} \rightarrow \text{Decrypt with Bob's PRIVATE key}}

Alice wants to send secret M to Bob:

① Alice gets Bob's PUBLIC KEY (from certificate, key server, etc.)
② Alice encrypts:   C = Encrypt(M, Bob's Public Key)
③ Alice sends C to Bob
④ Bob decrypts:     M = Decrypt(C, Bob's Private Key)

Key rule: Encrypted with public key → only private key owner can decrypt

✉️ Only Bob has the private key → only Bob can read the message → confidentiality guaranteed


2.2 Digital Signature — Proving Identity / Non-Repudiation

Goal: Prove the message came from Alice and wasn't tampered with.

Sign with Alice’s PRIVATE key→Verify with Alice’s PUBLIC key\boxed{\text{Sign with Alice's PRIVATE key} \rightarrow \text{Verify with Alice's PUBLIC key}}

Alice wants to prove she sent message M:

① Alice hashes the message:    h = Hash(M)   e.g., SHA-256
② Alice signs the hash:        σ = Sign(h, Alice's Private Key)
③ Alice sends M + σ to Bob
④ Bob verifies:
    - Bob re-hashes the message: h' = Hash(M)
    - Bob decrypts signature:    h  = Verify(σ, Alice's Public Key)
    - If h' == h → ✅ Signature valid (came from Alice, message intact)
    - If h' ≠ h  → ❌ Message tampered or wrong sender

Key rule: Signed with private key → anyone with public key can verify

🖊️ Analogy: A handwritten signature — only you can write it (private key), but anyone can look at it and confirm it's yours (public key).


2.3 Sign vs. Encrypt — Side by Side

GoalActionKey UsedWho Can
Confidentiality (only Bob reads)EncryptBob's Public keyAnyone can encrypt; only Bob decrypts
Authentication (prove it's Alice)SignAlice's Private keyOnly Alice signs; anyone can verify

2.4 Both: Encrypt AND Sign (Full Security)

Goal: Only Bob can read it, AND Bob knows it came from Alice.

① Alice signs message M:     σ = Sign(Hash(M), Alice's Private Key)
② Alice encrypts (M + σ):    C = Encrypt(M + σ, Bob's Public Key)
③ Alice sends C to Bob
④ Bob decrypts with:         Bob's Private Key → gets M + σ
⑤ Bob verifies signature:   Verify(σ, Alice's Public Key) → confirms Alice sent it

Sign first with sender’s PRIVATE→Encrypt with receiver’s PUBLIC\boxed{\text{Sign first with sender's PRIVATE} \rightarrow \text{Encrypt with receiver's PUBLIC}}


3. Key Usage Rules — The Golden Table ⭐

OperationUse Whose Key?TypePurpose
Encrypt a message to BobBob's Public keyAsymmetricOnly Bob can decrypt → Confidentiality
Decrypt a message from AliceYour own Private keyAsymmetricYou are the intended recipient
Sign a message as AliceAlice's Private keyAsymmetricProves Alice sent it → Authentication
Verify Alice's signatureAlice's Public keyAsymmetricAnyone can confirm it came from Alice
Encrypt/Decrypt data (fast)Shared Secret keySymmetricBulk data encryption

🧠 Memory trick:

  • Private key = your secret actions (decrypt your mail, sign your name)
  • Public key = public-facing actions (anyone locks mail for you, anyone checks your signature)

4. Hybrid Encryption (How TLS/S-MIME Actually Work)

Asymmetric is slow for large data → use it only to exchange the symmetric key, then switch.

Asymmetric (Public Key)→Exchange symmetric key securely→Symmetric (AES) for data\boxed{\text{Asymmetric (Public Key)} \rightarrow \text{Exchange symmetric key securely} \rightarrow \text{Symmetric (AES) for data}}

① Alice generates a random AES session key K
② Alice encrypts K with Bob's PUBLIC key:   Enc(K, Bob_PK)
③ Bob decrypts to get K:                    Dec(Enc(K, Bob_PK), Bob_SK) = K
④ Both now share K
⑤ All data encrypted with fast symmetric AES using K

🚗 Analogy: Asymmetric = expensive armored van that delivers the house key. Symmetric = the normal key you use every day to unlock your door.

Examples:

  • TLS — ECDHE/RSA handshake to agree on session key → AES-GCM encrypts traffic
  • S/MIME — RSA/ECC encrypts the session key → Triple DES/AES encrypts the email
  • PGP — RSA/ECC wraps the session key → AES encrypts the file

5. Hash Functions (One-Way, Not Reversible)

h=Hash(M)—— cannot reverse to get M\boxed{h = \text{Hash}(M) \quad \text{—— cannot reverse to get } M}

PropertyMeaning
DeterministicSame input → always same output
One-wayCannot reverse hash to get original message
Avalanche effectTiny change in input → completely different hash
Collision resistantHard to find two different inputs with same hash

Used in:

  • Digital signatures (sign the hash, not the whole message — faster)
  • Password storage (store hash, not plaintext)
  • File integrity checks (compare hash before/after)
  • TLS (HMAC for record integrity)

Examples: SHA-256, SHA-3, HMAC-SHA256


6. Complete Scenario Walkthroughs

Scenario A — Alice sends a SECRET email to Bob (S/MIME style)

Goal: Confidentiality only (Bob can read it, content hidden from others)

① Generate random session key K (e.g., AES-256)
② Encrypt message M:    Enc_AES(M, K) = Ciphertext
③ Encrypt key K:        Enc(K, Bob's Public Key) = Wrapped Key
④ Send both:            [Ciphertext + Wrapped Key] → Bob

Bob:
⑤ Decrypt wrapped key:  Dec(Wrapped Key, Bob's Private Key) = K
⑥ Decrypt message:      Dec_AES(Ciphertext, K) = M ✅

Scenario B — Alice SIGNS a message (non-repudiation)

Goal: Bob can verify the message came from Alice and wasn't modified

① Hash message:         h = SHA256(M)
② Sign hash:            σ = RSA_Sign(h, Alice's Private Key)
③ Send:                 [M + σ] → Bob

Bob:
④ Re-hash message:      h' = SHA256(M)
⑤ Verify signature:     h  = RSA_Verify(σ, Alice's Public Key)
⑥ If h == h' → ✅ Valid. Came from Alice, not modified.

Scenario C — Alice sends SIGNED and ENCRYPTED email (Full Security)

Goal: Only Bob reads it + Bob knows it came from Alice

① Hash + Sign:          σ = Sign(Hash(M), Alice's Private Key)
② Encrypt [M + σ]:      C = Enc(M + σ, Bob's Public Key)
③ Send C → Bob

Bob:
④ Decrypt:              M + σ = Dec(C, Bob's Private Key)
⑤ Verify signature:     Verify(σ, Alice's Public Key) → ✅ Alice confirmed

Scenario D — TLS Handshake Key Exchange (Simplified)

① Server sends Certificate (contains Server's Public Key)
② Client verifies Certificate (via CA signature)
③ Client generates Premaster Secret
④ Client encrypts it:   Enc(Premaster Secret, Server's Public Key)
⑤ Server decrypts:      Dec(..., Server's Private Key) = Premaster Secret
⑥ Both compute:
   Session Key = f(Client Random, Server Random, Premaster Secret)
⑦ All data encrypted with Session Key (AES) from now on ✅

7. Quick Reference Summary

Encrypt for Bob→Bob’s PUBLIC key Decrypt as Bob→Bob’s PRIVATE key Sign as Alice→Alice’s PRIVATE key Verify Alice’s sig→Alice’s PUBLIC key Bulk data encryption→Symmetric (AES) with shared key Key exchange→Asymmetric (RSA/DH/ECDHE) \boxed{ \begin{array}{ll} \text{Encrypt for Bob} & \rightarrow \text{Bob's PUBLIC key} \ \text{Decrypt as Bob} & \rightarrow \text{Bob's PRIVATE key} \ \text{Sign as Alice} & \rightarrow \text{Alice's PRIVATE key} \ \text{Verify Alice's sig} & \rightarrow \text{Alice's PUBLIC key} \ \text{Bulk data encryption} & \rightarrow \text{Symmetric (AES) with shared key} \ \text{Key exchange} & \rightarrow \text{Asymmetric (RSA/DH/ECDHE)} \ \end{array} }

"I want to…"Use
Send a secret to BobEncrypt with Bob's public key
Read a secret sent to meDecrypt with my private key
Prove this message is from meSign with my private key
Check if message is really from AliceVerify with Alice's public key
Encrypt lots of data fastSymmetric AES with shared key
Securely agree on a symmetric keyDH / ECDHE / RSA key exchange
Check data hasn't been modifiedHash (SHA-256) comparison