Introduction to Cryptography
Cryptography is the art and science of concealing meaning, derived from the Greek words "kryptos" (hidden) and "graphein" (writing). It is the foundation of modern information security, enabling confidentiality, integrity, and authentication of digital communications.
Cryptology is the broader study of cryptography (creating codes) and cryptanalysis (breaking codes). Together, they form the science of secure communication.
Cryptographic Terminology
Basic Terms
- Plaintext: The original, readable message or data
- Ciphertext: The encrypted, unreadable message
- Cipher: The algorithm used for encryption/decryption
- Key: The secret parameter used in encryption
- Encryption: Converting plaintext to ciphertext
- Decryption: Converting ciphertext back to plaintext
A Cryptosystem
A cryptosystem is formally defined as a 5-tuple (E, D, M, K, C):
- E: Encryption function
- D: Decryption function
- M: Message space (all possible plaintexts)
- K: Key space (all possible keys)
- C: Ciphertext space (all possible ciphertexts)
Classical Ciphers
The Caesar cipher is a simple substitution cipher where letters are shifted by a fixed number (the key):
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
With key = 3: "HELLO" → "KHOOR"
Symmetric Encryption
Also known as secret-key or shared-key encryption, symmetric encryption uses the same key for both encryption and decryption.
Symmetric Encryption Process
Plaintext
Encrypt
Ciphertext
Decrypt
Plaintext
Types of Symmetric Ciphers
Block Ciphers
- Encrypt data in fixed-size blocks (typically 64 or 128 bits)
- Modes: ECB, CBC, CTR, GCM
- Examples: DES, AES, Blowfish
Stream Ciphers
- Encrypt data one byte or bit at a time
- Generate a keystream combined with plaintext
- Examples: RC4, ChaCha20, Salsa20
Advantages & Disadvantages
| Advantages | Disadvantages |
|---|---|
| Very fast | Key distribution problem |
| Can encrypt large amounts of data | Requires secure channel for key exchange |
| Low computational requirements | Number of keys grows with users |
Asymmetric Encryption
Also known as public-key cryptography, asymmetric encryption uses a pair of mathematically related keys: a public key and a private key.
Key Pair Concept:
• Public Key: Shared with everyone, used for encryption
• Private Key: Kept secret, used for decryption
• What is encrypted with the public key can only be decrypted with the private key, and vice versa.
Key Uses
- Encryption: Encrypt messages using recipient's public key
- Digital Signatures: Sign messages using sender's private key
- Key Exchange: Securely exchange symmetric keys
Advantages & Disadvantages
| Advantages | Disadvantages |
|---|---|
| Solves key distribution problem | Much slower than symmetric |
| Enables digital signatures | Higher computational requirements |
| Supports authentication | Key sizes are larger |
Common Encryption Algorithms
Symmetric Algorithms
DES (Data Encryption Standard)
- 56-bit key, 64-bit block size
- Developed by IBM and NSA in 1977
- Now considered insecure (brute-forceable)
- 3DES (Triple DES) uses three rounds for better security
AES (Advanced Encryption Standard)
- 128, 192, or 256-bit key sizes
- 128-bit block size
- Selected as the standard in 2001
- Used worldwide, considered secure
Asymmetric Algorithms
RSA (Rivest-Shamir-Adleman)
- Based on difficulty of factoring large primes
- Typical key sizes: 2048, 4096 bits
- Most widely used public-key algorithm
- Used for encryption, digital signatures, key exchange
Elliptic Curve Cryptography (ECC)
- Based on elliptic curve discrete logarithm problem
- Smaller keys than RSA for equivalent security
- Used in mobile devices due to efficiency
- Examples: ECDSA, ECDH
Algorithm
Type
Key Size
Status
DES
Symmetric
56 bits
Insecure
3DES
Symmetric
168 bits
Legacy
AES
Symmetric
128/192/256
Secure
RSA
Asymmetric
2048+ bits
Secure
ECC
Asymmetric
256 bits
Secure
| Algorithm | Type | Key Size | Status |
|---|---|---|---|
| DES | Symmetric | 56 bits | Insecure |
| 3DES | Symmetric | 168 bits | Legacy |
| AES | Symmetric | 128/192/256 | Secure |
| RSA | Asymmetric | 2048+ bits | Secure |
| ECC | Asymmetric | 256 bits | Secure |
Key Distribution
Key distribution is one of the most challenging problems in cryptography. How do you securely share a secret key with someone you can't meet in person?
Symmetric Key Distribution Methods
- Manual Distribution: Physically meeting to exchange keys
- Key Distribution Centers (KDC): Trusted third party distributes keys
- Key Encapsulation: Encrypt key with recipient's public key
Hybrid Approach
Most practical systems use both symmetric and asymmetric encryption:
- Use asymmetric encryption to securely exchange a symmetric key
- Use symmetric encryption for the actual data (for speed)
Hybrid Encryption
Generate Session Key
Encrypt with RSA
Send Encrypted Key
AES Encrypt Data