Introduction to Cryptography#
Unit I: Introduction to Cyber Security & Cryptography#
Lecture 7: The Science of Secret Communication#
Course: Cyber Security (4353204) | Semester V | Diploma ICT | Author: Milav Dabgar
layout: default#
What is Cryptography?#
๐ Definition#
Cryptography is the science of protecting information by transforming it into an unreadable format for unauthorized users, while allowing authorized users to access the original information.
๐ฏ Core Objectives#
- Confidentiality - Keep information secret
- Integrity - Ensure data hasn’t been altered
- Authentication - Verify identity of sender
- Non-repudiation - Prevent denial of actions
๐ Etymology#
- Crypto (Greek) = Hidden, Secret
- Graphy (Greek) = Writing
- Cryptography = Secret Writing
๐ Cryptographic Process#
graph LR
A[Plaintext] --> B[Encryption Algorithm]
B --> C[Ciphertext]
C --> D[Decryption Algorithm]
D --> E[Plaintext]
F[Key] --> B
G[Key] --> D
style A fill:#e8f5e8
style C fill:#fff3e0
style E fill:#e8f5e8
style F fill:#f3e5f5
style G fill:#f3e5f5
๐ Key Components#
- Plaintext - Original readable message
- Ciphertext - Encrypted unreadable message
- Algorithm - Mathematical process
- Key - Secret parameter that controls encryption
- Keyspace - Set of all possible keys
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Historical Cryptography#
๐๏ธ Ancient Cryptography#
Caesar Cipher (50 BC)#
Plaintext: HELLO WORLD
Key: 3 (shift by 3)
Ciphertext: KHOOR ZRUOG
A B C D E F G H I J K L M
โ โ โ โ โ โ โ โ โ โ โ โ โ
D E F G H I J K L M N O P
Atbash Cipher#
- Hebrew origin - reverse alphabet
- AโZ, BโY, CโX…
- Used in Biblical texts
Scytale (Ancient Greece)#
- Physical device - rod with leather strip
- Transposition cipher
- Military communications
๐ฐ๏ธ Evolution Timeline#
Middle Ages (500-1500 AD)#
- Polyalphabetic ciphers
- Vigenรจre cipher (1553)
- Frequency analysis attacks
Renaissance (1400-1600)#
- Diplomatic cryptography
- Cipher wheels and devices
- Code breaking emergence
Modern Era (1900-1950)#
- Mechanical devices (Enigma)
- World War cryptography
- Breaking Enigma - Turing’s work
Computer Age (1950+)#
- DES (1976) - Data Encryption Standard
- Public key cryptography (1976)
- AES (2001) - Advanced Encryption Standard
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Types of Cryptographic Systems#
๐ Symmetric Cryptography#
๐ฏ Characteristics#
- Same key for encryption and decryption
- Fast and efficient
- Shared secret required
- Key distribution problem
๐ Process Flow#
graph LR
A[Alice] --> B[Message + Shared Key]
B --> C[Encryption]
C --> D[Ciphertext]
D --> E[Network/Storage]
E --> F[Ciphertext]
F --> G[Decryption]
G --> H[Message + Shared Key]
H --> I[Bob]
style A fill:#e3f2fd
style I fill:#e3f2fd
style C fill:#f3e5f5
style G fill:#f3e5f5
๐ง Common Algorithms#
- AES (Advanced Encryption Standard)
- 3DES (Triple Data Encryption Standard)
- ChaCha20 (Stream cipher)
- Blowfish (Block cipher)
๐ Asymmetric Cryptography#
๐ฏ Characteristics#
- Different keys (public/private pair)
- Slower than symmetric
- No shared secret needed
- Solves key distribution problem
๐ Process Flow#
graph LR
A[Alice] --> B[Message + Bob's Public Key]
B --> C[Encryption]
C --> D[Ciphertext]
D --> E[Network]
E --> F[Ciphertext]
F --> G[Decryption]
G --> H[Message + Bob's Private Key]
H --> I[Bob]
style A fill:#e3f2fd
style I fill:#e3f2fd
style C fill:#e8f5e8
style G fill:#e8f5e8
๐ง Common Algorithms#
- RSA (Rivest-Shamir-Adleman)
- ECC (Elliptic Curve Cryptography)
- DSA (Digital Signature Algorithm)
- Diffie-Hellman (Key exchange)
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Symmetric Encryption: AES Algorithm#
๐ AES Overview#
๐ Specifications#
- Block size: 128 bits
- Key sizes: 128, 192, 256 bits
- Rounds: 10, 12, 14 (based on key size)
- Standard: NIST FIPS 197
๐ AES Operations#
- SubBytes - Byte substitution using S-box
- ShiftRows - Cyclic shift of rows
- MixColumns - Linear transformation
- AddRoundKey - XOR with round key
๐ AES Structure#
Round 1-9: SubBytes โ ShiftRows โ MixColumns โ AddRoundKey
Round 10: SubBytes โ ShiftRows โ AddRoundKey
๐ง AES Implementation Example#
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
import os
# AES encryption example
def aes_encrypt(plaintext, key):
# Generate random IV
iv = os.urandom(16)
# Create cipher object
cipher = Cipher(
algorithms.AES(key),
modes.CBC(iv),
backend=default_backend()
)
encryptor = cipher.encryptor()
# Pad plaintext to block size
padded_text = pad(plaintext.encode(), 16)
# Encrypt
ciphertext = encryptor.update(padded_text) + encryptor.finalize()
return iv + ciphertext
# Key generation
key = os.urandom(32) # 256-bit key
๐ก๏ธ Security Features#
- Proven security through extensive analysis
- Resistant to known attacks
- Hardware optimization available
- Government approved (FIPS 140-2)
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Asymmetric Encryption: RSA Algorithm#
๐ข RSA Mathematical Foundation#
๐ฏ Key Generation Process#
- Choose two large prime numbers p and q
- Compute n = p ร q (modulus)
- Compute ฯ(n) = (p-1)(q-1)
- Choose e such that gcd(e, ฯ(n)) = 1
- Compute d such that e ร d โก 1 (mod ฯ(n))
๐ Keys#
- Public Key: (n, e)
- Private Key: (n, d)
๐ RSA Operations#
Encryption: C = M^e mod n
Decryption: M = C^d mod n
Where:
- M = Message (plaintext)
- C = Ciphertext
- e = Public exponent
- d = Private exponent
- n = Modulus
๐ RSA Security & Applications#
๐ก๏ธ Security Basis#
- Integer factorization problem
- Large prime factorization difficulty
- Computational complexity theory
โก Performance Considerations#
- Slow compared to symmetric encryption
- Key size affects performance (1024, 2048, 4096 bits)
- Hybrid cryptography common approach
๐ง RSA Applications#
- Digital signatures
- Key exchange protocols
- Certificate authorities
- Secure communications (TLS/SSL)
๐ Hybrid Cryptography Example#
1. Generate random AES key
2. Encrypt data with AES (fast)
3. Encrypt AES key with RSA (secure)
4. Send both encrypted data and encrypted key
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Digital Signatures#
โ๏ธ Digital Signature Concept#
๐ฏ Purpose#
- Authentication - Verify sender identity
- Integrity - Detect message tampering
- Non-repudiation - Prevent denial of signing
๐ Signature Process#
graph TB
A[Message] --> B[Hash Function]
B --> C[Message Digest]
C --> D[Sign with Private Key]
D --> E[Digital Signature]
F[Message + Signature] --> G[Hash Function]
G --> H[Message Digest]
E --> I[Verify with Public Key]
I --> J[Original Digest]
H --> K{Compare}
J --> K
K --> L[Valid/Invalid]
style A fill:#e8f5e8
style E fill:#f3e5f5
style L fill:#fff3e0
๐ง Digital Signature Implementation#
๐ Common Algorithms#
- RSA signatures
- DSA (Digital Signature Algorithm)
- ECDSA (Elliptic Curve DSA)
- EdDSA (Edwards-curve DSA)
๐ป Example: RSA Signature#
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
# Generate key pair
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048
)
public_key = private_key.public_key()
# Sign message
message = b"Important document content"
signature = private_key.sign(
message,
padding.PSS(
mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.MAX_LENGTH
),
hashes.SHA256()
)
# Verify signature
try:
public_key.verify(signature, message, ...)
print("Signature valid")
except:
print("Signature invalid")
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Key Management#
๐๏ธ Key Management Lifecycle#
๐ Key Lifecycle Phases#
- Generation - Create cryptographic keys
- Distribution - Securely share keys
- Storage - Protect keys at rest
- Usage - Apply keys for cryptographic operations
- Rotation - Replace keys periodically
- Revocation - Invalidate compromised keys
- Destruction - Securely delete old keys
โก Key Generation Requirements#
- True randomness (entropy)
- Sufficient length
- Proper algorithms
- Secure random generators
๐ Key Storage Options#
- Hardware Security Modules (HSM)
- Key management systems
- Secure software storage
- Cloud key management
๐ก๏ธ Key Management Best Practices#
๐ Security Principles#
- Separation of duties in key handling
- Least privilege access
- Key escrow for recovery
- Audit trails for key operations
- Regular key rotation
๐ง Key Distribution Methods#
- Public Key Infrastructure (PKI)
- Key exchange protocols
- Symmetric key pre-distribution
- Key derivation functions
๐ Key Management Challenges#
- Scalability - Managing thousands of keys
- Compliance - Meeting regulatory requirements
- Integration - Working with existing systems
- Cost - Hardware and operational expenses
- Availability - Ensuring key access when needed
๐ก Best Practice Example#
Key Management Policy:
Generation: FIPS 140-2 Level 3 HSM
Storage: Encrypted key vault with RBAC
Rotation: Every 90 days for signing keys
Backup: Encrypted offsite storage
Destruction: Crypto-shredding approved methods
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Cryptographic Applications#
๐ Modern Applications#
๐ณ E-Commerce Security#
- Payment card encryption (PCI DSS)
- Transaction integrity
- Customer data protection
- Secure communications (TLS)
๐ฑ Mobile Security#
- Device encryption (full disk)
- App data protection
- Secure messaging
- Mobile payments (Apple Pay, Google Pay)
โ๏ธ Cloud Security#
- Data at rest encryption
- Data in transit protection
- Key management as a service
- Homomorphic encryption (future)
๐ฆ Financial Services#
- Banking transactions
- ATM communications
- Trading systems
- Regulatory compliance
๐ฎ Emerging Cryptography#
๐งฎ Quantum Cryptography#
- Quantum key distribution (QKD)
- Post-quantum cryptography
- Quantum-resistant algorithms
- NIST standardization process
๐ Advanced Techniques#
- Zero-knowledge proofs
- Homomorphic encryption
- Multi-party computation
- Blockchain cryptography
๐ก๏ธ Cryptography Challenges#
- Quantum computing threat
- Implementation vulnerabilities
- Side-channel attacks
- Performance vs. security trade-offs
๐ Future Trends#
- Quantum-safe migration
- Lightweight cryptography for IoT
- Privacy-preserving technologies
- Automated key management
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Practical Exercise: Cryptographic Analysis#
๐ฏ Individual Activity (20 minutes)#
Scenario: Secure Communication System Design#
You’re designing a secure communication system for a healthcare organization that needs to:
- Exchange patient records between hospitals
- Store sensitive medical data
- Authenticate healthcare providers
- Ensure compliance with HIPAA regulations
- Support mobile devices for doctors
Task: Design Cryptographic Solution#
Address these requirements:
Data Protection:
- What encryption algorithms would you use?
- How would you protect data at rest vs. in transit?
- What key sizes are appropriate?
Authentication:
- How would you verify healthcare provider identities?
- What digital signature approach would you use?
- How would you handle user certificates?
Key Management:
- How would you generate and distribute keys?
- What key rotation schedule would you implement?
- How would you handle key recovery?
Implementation:
- Symmetric vs. asymmetric encryption usage
- Performance considerations
- Mobile device constraints
Deliverables:
- Cryptographic architecture diagram
- Algorithm selection justification
- Key management plan
- Security analysis
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Cryptography Best Practices#
โ Do’s#
๐ Algorithm Selection#
- Use proven algorithms (AES, RSA, ECC)
- Follow current standards (NIST, FIPS)
- Adequate key sizes (AES-256, RSA-2048+)
- Regular algorithm reviews
๐ Key Management#
- Strong key generation
- Secure key storage
- Regular key rotation
- Proper key disposal
๐ก๏ธ Implementation#
- Use established libraries
- Follow secure coding practices
- Regular security updates
- Proper error handling
โ Don’ts#
๐ซ Common Mistakes#
- Don’t create custom algorithms
- Don’t use deprecated algorithms (MD5, SHA-1, DES)
- Don’t hardcode keys in code
- Don’t ignore side-channel attacks
- Don’t implement crypto from scratch
โ ๏ธ Security Anti-patterns#
- Insufficient key lengths
- Poor random number generation
- Improper padding schemes
- Inadequate key storage
- Missing integrity checks
๐ก Success Factors#
- Security by design
- Regular security audits
- Compliance monitoring
- Incident response planning
- Continuous learning
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: default#
Next Lecture Preview#
๐ Lecture 8: Hash Algorithms#
๐ฏ Focus Topics:#
- Hash function properties and applications
- SHA family algorithms (SHA-1, SHA-2, SHA-3)
- Message authentication codes (MAC)
- Digital fingerprints and integrity checking
- Hash-based applications
- Collision attacks and resistance
๐ Preparation Tasks:#
- Review hash function mathematical properties
- Research recent hash algorithm developments
- Think about data integrity use cases
- Consider hash function security requirements
๐ Key Takeaways Today#
Cryptography Fundamentals#
- Cryptography is essential for modern security
- Symmetric encryption is fast and efficient
- Asymmetric encryption solves key distribution
- Digital signatures provide authentication and non-repudiation
Critical Concepts#
- Key management is crucial for security
- Algorithm selection impacts overall security
- Implementation quality matters as much as algorithms
- Regular updates and rotation are essential
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: center class: text-center#
Questions & Discussion#
๐ค Discussion Points:#
- What are the main challenges in implementing cryptography?
- How do you balance security and performance in encryption?
- What role will quantum computing play in future cryptography?
๐ก Exercise Review#
Share your cryptographic system designs for the healthcare scenario
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar
layout: center class: text-center#
Thank You!#
Next Lecture: Hash Algorithms#
Digital Fingerprints and Data Integrity#
Cyber Security (4353204) - Lecture 7 Complete
The art of keeping secrets! ๐โจ
Course: Cyber Security (4353204) | Unit I | Lecture 7 | Author: Milav Dabgar

