Principles of Cryptography and Network Security
Principles of Cryptography and Network Security
1. Confidentiality: This ensures that sensitive information is only accessible to authorized users. It
prevents unauthorized access by encrypting data, so even if an attacker intercepts the message, they
cannot understand its contents. Encryption algorithms like AES (Advanced Encryption Standard) help
maintain confidentiality.
2. Integrity: Integrity ensures that data is not altered, modified, or tampered with during
transmission or storage. Even a small change in data should be detectable. Hash functions like SHA
(Secure Hash Algorithm) are used to maintain integrity by generating a fixed-length hash value from
the original data.
3. Availability: This ensures that data and services are accessible when needed. Attacks like
Distributed Denial-of-Service (DDoS) can disrupt service availability by overwhelming a system with
traffic. Security mechanisms like firewalls, redundancy, and load balancing help maintain availability.
5. Non-Repudiation: This prevents an entity from denying their actions. Digital signatures and
cryptographic techniques provide proof that a message was sent and received, preventing fraud or
disputes in transactions.
2. Cryptographic Attacks
Cryptographic systems face various types of attacks that attempt to break encryption and gain
unauthorized access. Some common cryptographic attacks include:
1. Brute Force Attack: This is the simplest type of attack where an attacker tries all possible key
combinations to decrypt an encrypted message. The longer the encryption key, the harder it is to
crack using brute force.
2. Ciphertext-Only Attack (COA): The attacker only has access to the ciphertext (the encrypted
message) and tries to deduce the plaintext (original message) without knowing the encryption key.
3. Known-Plaintext Attack (KPA): The attacker has access to both the plaintext and the
corresponding ciphertext. They analyze this information to derive the encryption key and use it to
decrypt other messages.
4. Chosen-Plaintext Attack (CPA): The attacker can choose plaintext messages and obtain their
corresponding ciphertexts. This helps them understand the encryption process and derive the key
5. Man-in-the-Middle Attack (MITM): In this attack, an attacker secretly intercepts and possibly
alters communication between two parties without them knowing. Secure protocols like TLS
(Transport Layer Security) help prevent MITM attacks.
6. Side-Channel Attacks: These attacks exploit physical properties of cryptographic implementations,
such as power consumption, timing, and electromagnetic leaks, to extract sensitive data.
Security Services:
1. Confidentiality Service: Ensures that information is only accessible to authorized individuals.
Encryption techniques like AES and RSA are used.
2. Integrity Service: Ensures that data has not been modified. Hash functions like SHA-256 are used.
3. Authentication Service: Verifies the identity of users. Digital certificates and passwords help with
authentication.
4. Access Control: Restricts access to resources based on predefined policies. Role-Based Access
Control (RBAC) is an example.
Security Mechanisms:
1. Encryption: Transforms readable data into an unreadable format using algorithms like AES or RSA.
4. Intrusion Detection Systems (IDS): Detects malicious activities and alerts administrators.
4. Mathematics of Cryptography
Cryptography relies heavily on mathematical principles. Some fundamental mathematical concepts
used in cryptography include:
1. Modulo Arithmetic: Many encryption algorithms use modular arithmetic, where numbers wrap
around after reaching a certain value (modulus). Example:
10 \mod 3 = 1
3. Discrete Logarithms: Used in asymmetric encryption methods like the Diffie-Hellman key
exchange.
5. Symmetric Encryption
Symmetric encryption uses the same key for both encryption and decryption. The key must be kept
secret; otherwise, anyone with access to the key can decrypt the data.
Let’s say we use a shift cipher where each letter is replaced by the letter three positions ahead in the
alphabet (A → D, B → E, etc.).
Plaintext: HELLO
While simple ciphers like the shift cipher are easy to break, modern symmetric encryption
algorithms use complex transformations that make decryption without the key extremely difficult.
1. Block Ciphers: Encrypt fixed-size blocks of data at a time. Example: AES, DES.
Uses a 56-bit key (which is now considered weak due to advances in computing).
Due to its small key size, DES is no longer secure and has been replaced by AES.
AES is widely used in applications like SSL/TLS (for secure web browsing), VPNs, and secure
communications.
UNIT II: Asymmetric Encryption
Asymmetric encryption, also known as public-key cryptography, uses two different keys:
This eliminates the key distribution problem of symmetric encryption since the public key can be
shared openly, while only the private key holder can decrypt the message.
Asymmetric encryption relies on complex mathematical problems that are computationally hard to
solve. Some fundamental concepts include:
a) Prime Numbers
Prime numbers play a key role in asymmetric encryption. A prime number is a number that has only
two divisors: 1 and itself. Examples: 2, 3, 5, 7, 11, 13, 17...
b) Primality Testing
To generate secure encryption keys, cryptographic systems must check whether a number is prime.
Some common primality testing algorithms are:
c) Factorization
Many encryption systems, such as RSA, rely on the fact that factoring a large number into two prime
factors is computationally hard.
For example, if you are given N = 91, finding that N = 7 × 13 is easy. But for a 2048-bit number, it
would take thousands of years to factor with current technology.
a) RSA Cryptosystem
The Rivest-Shamir-Adleman (RSA) algorithm is the most widely used public-key encryption system. It
is based on the difficulty of factoring large prime numbers.
RSA Encryption:
RSA Decryption:
Example:
Choose p = 3, q = 11 → N = 3 × 11 = 33
ϕ(N) = (3 - 1) × (11 - 1) = 2 × 10 = 20
b) Rabin Cryptosystem
The Rabin cryptosystem is similar to RSA but is based on the difficulty of computing square roots
modulo N.
Key Steps:
2. Compute N = p × q
3. Encryption: C = M² mod N
4. Decryption: Finding the square root of C mod N is hard, which makes Rabin encryption highly
secure.
c) ElGamal Cryptosystem
ElGamal encryption is based on the Discrete Logarithm Problem, which is computationally difficult.
Key Generation:
Encryption:
Decryption:
ECC is an advanced public-key cryptosystem that offers strong security with shorter key lengths. It is
based on the mathematics of elliptic curves.
Advantages of ECC:
Requires smaller key sizes compared to RSA for the same level of security
y^2 = x^3 + ax + b
1. Deterministic: The same input will always produce the same output.
3. Pre-Image Resistance: Given a hash value, it should be computationally hard to determine the
original input.
4. Small Change in Input → Large Change in Output: Also known as the avalanche effect.
5. Collision Resistance: It should be hard to find two different inputs with the same hash value.
2. Data Integrity Checks: Hashes are used in digital signatures to verify that data has not been
altered.
3. Blockchain Technology: Cryptographic hash functions are the backbone of blockchain security.
Though simple, such functions are weak because they do not meet collision resistance and security
requirements.
SHA Variants:
1. SHA-1 (160-bit output, insecure) – No longer recommended due to vulnerabilities.
SHA-256: Produces a 256-bit (32-byte) hash and is widely used in security protocols.
3. SHA-3: The latest standard, based on the Keccak algorithm, offering improved security over SHA-2.
Plaintext: "Hello"
SHA-256 Hash:
185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969
6. Digital Signatures
A digital signature is a cryptographic mechanism that verifies the authenticity and integrity of digital
messages or documents. It provides:
1. Hashing: The message is first hashed using a hash function (SHA-256, SHA-3).
2. Encryption with Private Key: The sender encrypts the hash using their private key (e.g., using RSA).
3. Signature Transmission: The digital signature (encrypted hash) is sent along with the message.