Cryptography and Network Security – Unit 1 Notes
Cryptography is the science of protecting information from unauthorized access. It converts readable information into a protected form and allows an authorized receiver to recover the original information.
1. Basic Terms in Cryptography
- Plaintext: The original readable message.
- Ciphertext: The transformed or encrypted message.
- Encryption: The process of converting plaintext into ciphertext.
- Decryption: The process of recovering plaintext from ciphertext.
- Key: A value used by the cryptographic algorithm to control encryption and decryption.
C = E(K, P)
P = D(K, C)
Here, P is plaintext, C is ciphertext, K is the key, E is encryption and D is decryption.
2. Security Attacks
A security attack is an attempt to obtain information, modify information, impersonate an authorized user or disturb the normal operation of a system.
2.1 Passive Attacks
In a passive attack, the attacker observes communication but does not normally change the transmitted information. The main purpose is to obtain information without being noticed.
- Release of message contents: Unauthorized reading of confidential information.
- Traffic analysis: Studying message timing, size, frequency or communication patterns.
2.2 Active Attacks
In an active attack, the attacker changes communication, inserts false information or interferes with normal operation.
- Masquerade: An attacker pretends to be an authorized user.
- Replay: A valid message is captured and transmitted again later.
- Modification of messages: The contents of a message are changed.
- Denial of Service (DoS): A service is made unavailable to legitimate users.
3. Security Services
Security services are functions provided by a system to protect information and communication against security attacks.
3.1 Authentication
Authentication verifies the identity of a user, device or system.
3.2 Access Control
Access control ensures that only authorized users can access protected resources.
3.3 Data Confidentiality
Confidentiality prevents unauthorized disclosure of information. Encryption is an important mechanism for providing confidentiality.
3.4 Data Integrity
Integrity ensures that information has not been changed, deleted or inserted without authorization.
3.5 Non-Repudiation
Non-repudiation provides evidence about an action or communication so that a party cannot easily deny having performed it.
4. Security Mechanisms
Security mechanisms are techniques used to implement security services.
- Encryption: Protects information by converting plaintext into ciphertext.
- Digital signature: Supports authentication, integrity and non-repudiation.
- Authentication exchange: Verifies the identity of communicating parties.
- Access control: Restricts access to authorized users.
- Data integrity mechanism: Helps detect unauthorized changes.
- Traffic padding: Adds extra traffic to make traffic analysis more difficult.
- Routing control: Selects communication paths according to security requirements.
5. Classical Encryption Techniques
Classical encryption techniques are traditional methods used to protect messages. They are mainly divided into substitution and transposition techniques.
6. Substitution Ciphers
In a substitution cipher, plaintext symbols are replaced by other symbols according to a defined rule. The positions of the characters are generally retained, but the characters themselves are changed.
6.1 Caesar Cipher
The Caesar cipher shifts every alphabetic character by a fixed number of positions. For example, with a shift of 3, A becomes D, B becomes E and so on.
C = (P + K) mod 26
Example: With a shift of 3, HELLO becomes KHOOR.
6.2 Monoalphabetic Substitution Cipher
In a monoalphabetic cipher, every plaintext letter is mapped to one fixed ciphertext letter. The same substitution is used throughout the message. Frequency analysis can be used against this type of cipher because normal languages have recognizable letter frequencies.
6.3 Playfair Cipher
The Playfair cipher encrypts two letters at a time using a 5 × 5 matrix. Usually I and J share one position.
| M | O | N | A | R |
|---|---|---|---|---|
| C | H | Y | B | D |
| E | F | G | I/J | K |
| L | P | Q | S | T |
| U | V | W | X | Z |
Rules: Letters in the same row are replaced by the letters to their right. Letters in the same column are replaced by the letters below them. Otherwise, the two letters form a rectangle and the letters at the opposite corners are used.
6.4 Hill Cipher
The Hill cipher is a polygraphic substitution cipher based on matrix multiplication. Plaintext letters are converted into numbers and processed in groups using a key matrix.
C = K × P mod 26
P = K⁻¹ × C mod 26
The key matrix must have a modular inverse modulo 26 for decryption.
6.5 Vigenère Cipher
The Vigenère cipher uses a keyword. Each key character produces a different Caesar shift, so the same plaintext letter can be encrypted differently at different positions.
Cᵢ = (Pᵢ + Kᵢ) mod 26
7. Transposition Ciphers
In a transposition cipher, the characters are not replaced. Their positions are rearranged according to a specified rule.
7.1 Rail Fence Cipher
The plaintext is written in a zig-zag pattern across a fixed number of rails. The ciphertext is then obtained by reading the rails from top to bottom.
Rail 1: H L O
Rail 2: E L W R
Rail 3: L O
7.2 Columnar Transposition Cipher
The plaintext is written in rows under a keyword. The columns are then read according to the alphabetical order of the keyword.
8. Cryptanalysis
Cryptanalysis is the study of methods used to analyze cryptographic systems and recover plaintext, key information or other useful information without authorized knowledge of the secret key.
8.1 Major Cryptanalytic Attacks
- Ciphertext-only attack: Only ciphertext is available.
- Known-plaintext attack: Some plaintext and its corresponding ciphertext are known.
- Chosen-plaintext attack: The attacker chooses plaintext and obtains its ciphertext.
- Chosen-ciphertext attack: The attacker chooses ciphertext and obtains its plaintext.
- Brute-force attack: Possible keys are tried until the correct key is found.
For a key of k bits, there can be up to 2ᵏ possible key values.
9. Steganography
Steganography is the technique of hiding secret information inside another apparently normal medium such as an image, audio file, video or text. Its main purpose is to hide the existence of the secret information.
Cryptography vs Steganography
| Cryptography | Steganography |
|---|---|
| Changes plaintext into ciphertext. | Hides information inside another medium. |
| Main purpose is to protect the meaning of information. | Main purpose is to hide the presence of information. |
10. Stream and Block Ciphers
10.1 Stream Cipher
A stream cipher processes data one bit or one byte at a time. It generates a keystream which is combined with plaintext, commonly using XOR.
Cᵢ = Pᵢ XOR Kᵢ
Pᵢ = Cᵢ XOR Kᵢ
Example: RC4 is a historical example of a stream cipher.
10.2 Block Cipher
A block cipher processes plaintext in fixed-size blocks. A key and a mode of operation determine how the blocks are encrypted.
Examples: DES, Triple DES and AES.
Stream Cipher vs Block Cipher
| Stream Cipher | Block Cipher |
|---|---|
| Processes data as a stream of bits or bytes. | Processes fixed-size blocks. |
| Uses a keystream. | Uses a block transformation. |
| Example: RC4. | Examples: DES, 3DES, AES. |
Important Points
- Cryptography protects information from unauthorized access.
- Passive attacks observe information; active attacks modify or disrupt communication.
- Authentication verifies identity.
- Confidentiality protects information from unauthorized disclosure.
- Integrity protects information from unauthorized modification.
- Substitution changes symbols; transposition changes their positions.
- Cryptanalysis attempts to obtain useful information from a cryptosystem.
- Steganography hides the existence of secret information.
- Stream ciphers process data as a stream; block ciphers process fixed-size blocks.