1 / 9

Basic Cryptography Concepts

Understanding Modern Encryption

Exploring symmetric and asymmetric encryption with real-world applications

šŸ” Symmetric Encryption

AES and shared key systems

šŸ”‘ Asymmetric Encryption

Public-private key pairs

🌐 Real-World Examples

SSH, PKI, and TLS/SSL

What is Cryptography?

Basic Encryption Process

šŸ“„ Plaintext
"Hello World"
šŸ”
šŸ”‘ Key
Secret Key
→
šŸ”’ Ciphertext
"X7#$mK9@1z"
šŸ”“
šŸ“„ Plaintext
"Hello World"

Confidentiality

Ensuring data is only readable by authorized parties

Integrity

Verifying data hasn't been tampered with

Authentication

Confirming the identity of communicating parties

Symmetric Encryption

One Key for Both Encryption and Decryption

Symmetric Encryption Diagram

šŸ‘¤ Alice
šŸ”‘ K
Shared Key
šŸ“¤
šŸ” Encrypted
E(K, message)
Secure Channel
šŸ“„
šŸ‘¤ Bob
šŸ”‘ K
Same Key

Both parties must have the same secret key

āœ… Advantages

• Fast encryption/decryption
• Low computational overhead
• Efficient for large data

āŒ Challenges

• Key distribution problem
• Key management complexity
• Scalability issues

AES (Advanced Encryption Standard)

The Gold Standard of Symmetric Encryption

AES Block Cipher Process

šŸ“„ Input
128-bit block
"Hello World....."
+
šŸ”‘ Key
128/192/256-bit
AES Key
→
āš™ļø Rounds
10/12/14 rounds
SubBytes, ShiftRows, MixColumns
→
šŸ”’ Output
128-bit block
Encrypted data

Key Sizes

• AES-128: 128-bit key
• AES-192: 192-bit key
• AES-256: 256-bit key

Applications

• File encryption
• Database encryption
• VPN tunnels
• WiFi security (WPA2/3)

Security

• NIST approved
• Quantum resistant (larger keys)
• No known practical attacks

Asymmetric Encryption

Public-Private Key Pairs

Asymmetric Encryption Process

šŸ‘¤ Alice
šŸ”“ Public
šŸ” Private
šŸ“¤
🌐 Public Directory
šŸ”“ Alice's Public Key
Anyone can access
šŸ“„
šŸ‘¤ Bob
Encrypts with
šŸ”“ Alice's Public
šŸ”’ Encrypted Message
Only Alice can decrypt
šŸ“¤
šŸ‘¤ Alice
Decrypts with
šŸ” Private Key
Advantages
Disadvantages
• No key distribution problem
• Scalable
• Digital signatures
• Key exchange
• Slower than symmetric
• Higher computational cost
• Larger key sizes needed

Diffie-Hellman Key Exchange

Securely Sharing Keys Over Insecure Channels

The Color Mixing Analogy

šŸŽØ Public Color
Yellow
(Known to everyone)
šŸ‘¤ Alice
šŸ”“ Red (secret)
🟔 + šŸ”“ = 🟠
Sends Orange
⟷
šŸ‘¤ Bob
šŸ”µ Blue (secret)
🟔 + šŸ”µ = 🟢
Sends Green
šŸ‘¤ Alice
🟢 + šŸ”“ = 🟤
Final shared color
šŸ¤
šŸ‘¤ Bob
🟠 + šŸ”µ = 🟤
Same shared color!
Mathematical Formula:
g^(aƗb) mod p = g^(bƗa) mod p

TLS/SSL in Action

Hybrid Encryption System

TLS Handshake Process

1. Client Hello

Supported protocols

2. Server Hello

Certificate + chosen protocol

3. Key Exchange

Diffie-Hellman or RSA

4. Secure Channel

AES symmetric encryption

🌐 Browser
RSA Public
Encrypts session key
šŸ”
šŸ“” Server
RSA Private
Decrypts session key
→
šŸ”„ Both
AES Session Key
Fast symmetric encryption

Why Hybrid?

Combines the key distribution advantages of asymmetric encryption with the speed of symmetric encryption

Real-World Usage

• HTTPS websites
• Email encryption
• VPN connections
• API security

SSH (Secure Shell)

Secure Remote Access

SSH Connection Process

1. Connection

Client connects to server

2. Key Exchange

Diffie-Hellman protocol

3. Authentication

Password or key-based

4. Encrypted Session

AES symmetric encryption

šŸ’» Client
Private Key
~/.ssh/id_rsa
šŸ”
šŸ”’ SSH Protocol
Encrypted tunnel
Port 22
šŸ”“
šŸ–„ļø Server
Public Key
~/.ssh/authorized_keys

SSH Key Authentication

• Generate public/private key pair
• Install public key on server
• Use private key for authentication
• No password needed

Security Benefits

• Encrypted communication
• Strong authentication
• Port forwarding/tunneling
• File transfer (SCP/SFTP)

PKI (Public Key Infrastructure)

Trust and Certificate Management

Root CA

šŸ›ļø Trusted Authority

ā¬‡ļø

Intermediate CA

šŸ”— Chain of Trust

ā¬‡ļø

End Entity

šŸ“„ Digital Certificate

Digital Certificates

• Bind public keys to identities
• Signed by trusted CA
• Include validity periods
• Enable trust verification

PKI Applications

• HTTPS/TLS certificates
• Email signing (S/MIME)
• Code signing
• VPN authentication
• Smart card authentication

Certificate Lifecycle

• Generation
• Distribution
• Validation
• Revocation
• Renewal