Unit 2
1) Define Asymmetric Key Encryption with a proper Diagram.
Asymmetric key encryption, also known as public-key cryptography, utilizes a pair of keys—a public key and a private key—to secure data. The public key is openly shared and used for encryption, while the private key remains confidential and is used for decryption. This method ensures that only the intended recipient, who possesses the private key, can access the encrypted information.
Process:
- The sender obtains the recipient’s public key.
- Using this public key, the sender encrypts the message.
- The encrypted message is transmitted to the recipient.
- The recipient uses their private key to decrypt and read the message.
This approach eliminates the need for sharing secret keys beforehand, addressing key distribution challenges inherent in symmetric encryption systems. Asymmetric encryption is widely used in applications such as secure email communication, digital signatures, and SSL/TLS protocols.
Diagram:
In the diagram above, the sender encrypts the plaintext message using the recipient’s public key. The ciphertext is then sent over the network. Upon receiving it, the recipient decrypts the ciphertext using their private key, retrieving the original plaintext message.
This mechanism ensures that even if the encrypted message is intercepted during transmission, it cannot be decrypted without the corresponding private key, thereby maintaining confidentiality and security.
2) Explain RSA public key cryptography with all steps.
RSA (Rivest-Shamir-Adleman) is an asymmetric cryptographic algorithm that uses a pair of keys—a public key for encryption and a private key for decryption—to securely transmit data. The security of RSA relies on the computational difficulty of factoring large composite numbers.
Key Generation Steps:
-
Select Two Large Prime Numbers (p and q): Choose two distinct large prime numbers,
p
andq
. These should be kept secret to ensure security. -
Compute n: Calculate the product of
p
andq
:n
serves as the modulus for both the public and private keys. -
Calculate Euler’s Totient Function (φ(n)): Determine the totient function: This value is used in the key generation process.
-
Choose Public Exponent (e): Select an integer
e
such that:e
is coprime with φ(n) (i.e., gcd(e, φ(n)) = 1) Common choices fore
include 3, 17, or 65537.
-
Compute Private Exponent (d): Determine
d
as the modular multiplicative inverse ofe
modulo φ(n): This means:
The public key consists of (n, e)
, and the private key consists of (n, d)
.
Encryption Process:
-
Obtain Recipient’s Public Key: Retrieve the recipient’s public key
(n, e)
. -
Convert Plaintext to Integer (m): Transform the plaintext message into an integer
m
such that . This is typically done using a reversible encoding scheme. -
Compute Ciphertext (c): Encrypt the message using the public key:
Decryption Process:
-
Use Private Key: Utilize the private key
(n, d)
for decryption. -
Compute Original Message (m): Decrypt the ciphertext:
-
Revert Integer to Plaintext: Convert the integer
m
back to the original plaintext message using the appropriate decoding scheme.
Example:
-
Key Generation:
- Select primes:
p = 61
,q = 53
- Compute
n
: - Calculate φ(n):
- Choose
e
: - Compute
d
:
- Select primes:
-
Encryption:
- Message:
m = 65
- Compute ciphertext:
- Message:
-
Decryption:
- Compute original message:
This example demonstrates the RSA algorithm’s process of key generation, encryption, and decryption.
Diagram:
In the diagram, the sender encrypts the plaintext message using the recipient’s public key, resulting in ciphertext. The recipient then decrypts this ciphertext using their private key to retrieve the original plaintext message.
3) Explain Diffie Hellman Key Exchange with all steps.
The Diffie-Hellman key exchange algorithm allows two parties to securely establish a shared secret over an insecure communication channel. This shared secret can then be used for symmetric encryption to ensure confidentiality.
Steps of the Diffie-Hellman Key Exchange:
-
Agree on Public Parameters:
- Both parties select a large prime number and a primitive root modulo , denoted as . These values are public and can be known to anyone.
-
Select Private Keys:
- Each party chooses a private key:
- Alice selects a private key , where .
- Bob selects a private key , where .
- These private keys are kept secret.
- Each party chooses a private key:
-
Compute Public Keys:
- Using their private keys, both parties compute their respective public keys:
- Alice computes .
- Bob computes .
- These public keys are then exchanged between the parties.
- Using their private keys, both parties compute their respective public keys:
-
Compute Shared Secret:
- After exchanging public keys, each party computes the shared secret using their private key and the other party’s public key:
- Alice computes .
- Bob computes .
- Both computations result in the same shared secret due to the properties of modular arithmetic.
- After exchanging public keys, each party computes the shared secret using their private key and the other party’s public key:
Example:
-
Agree on Public Parameters:
- Choose a prime number and a primitive root .
-
Select Private Keys:
- Alice selects .
- Bob selects .
-
Compute Public Keys:
- Alice computes .
- Bob computes .
-
Exchange Public Keys:
- Alice and Bob exchange their public keys: and .
-
Compute Shared Secret:
- Alice computes .
- Bob computes .
- Both arrive at the shared secret .
This shared secret can now be used as a key for symmetric encryption algorithms to securely transmit data between Alice and Bob.
Diagram:
In this diagram, both Alice and Bob agree on public parameters and , exchange their computed public keys and , and independently compute the shared secret .
Security Considerations:
The security of the Diffie-Hellman key exchange relies on the difficulty of solving the discrete logarithm problem. An eavesdropper, even if they know , , , and , cannot feasibly compute the shared secret without knowing the private keys or .
Note: In practical applications, much larger values of (typically 2048 bits or more) and corresponding are used to ensure security against modern computational capabilities.
4) Justify Diffie Hellman Key Exchange vulnerable to Man in Middle Attack.
The Diffie-Hellman key exchange protocol allows two parties to establish a shared secret over an insecure channel. However, it is susceptible to a Man-in-the-Middle (MitM) attack due to the absence of authentication mechanisms.
How the Man-in-the-Middle Attack Works:
-
Initial Setup:
- Alice and Bob agree on public parameters: a large prime number and a base .
- Alice selects a private key and computes her public value .
- Bob selects a private key and computes his public value .
-
Interception by the Attacker (Mallory):
- Mallory intercepts Alice’s public value intended for Bob and replaces it with her own public value , where is Mallory’s private key.
- Mallory sends to Bob, who assumes it’s Alice’s public value.
- Similarly, Mallory intercepts Bob’s public value intended for Alice and replaces it with her own public value , where is another private key chosen by Mallory.
- Mallory sends to Alice, who assumes it’s Bob’s public value.
-
Establishment of Separate Shared Secrets:
- Alice computes the shared secret using the received value :
- Bob computes the shared secret using the received value :
- Mallory computes both shared secrets:
-
Communication Compromise:
- Alice encrypts messages using , believing it’s the shared secret with Bob.
- Mallory decrypts these messages using , reads or alters them, re-encrypts using , and forwards them to Bob.
- Bob decrypts messages using , believing they’re from Alice.
Throughout this process, Mallory maintains separate shared secrets with both Alice and Bob, effectively controlling and monitoring their communication without their knowledge.
Diagram Illustrating the Attack:
Reason for Vulnerability:
The core issue is the lack of authentication in the basic Diffie-Hellman protocol. Without verifying the identities of the parties involved, there’s no assurance that the public keys exchanged haven’t been tampered with by an attacker.
Mitigation Measures:
To prevent MitM attacks, it’s essential to incorporate authentication mechanisms into the key exchange process:
-
Digital Signatures: Alice and Bob can sign their public values using their private keys. The recipient can then verify the signature using the sender’s public key, ensuring the integrity and authenticity of the public values.
-
Public Key Infrastructure (PKI): Utilizing certificates issued by trusted Certificate Authorities (CAs) binds public keys to their respective owners, allowing parties to authenticate each other during the exchange.
By integrating these authentication methods, the Diffie-Hellman key exchange can be secured against Man-in-the-Middle attacks.
5) P and Q are two prime numbers. P=7, and Q=17. Take public key E=5. If the plaintext value is 6, then what will be the cipher text value according to the RSA algorithm? Explain in detail.
Let’s work through the steps:
-
Compute :
Given and , we have: -
Encryption Formula:
The RSA encryption formula is:where:
- is the plaintext
- is the public key exponent
- is the product of the two primes
-
Substitute the Given Values:
Here, , , and . So, we compute: -
Calculate :
-
Compute :
Divide 7776 by 119. The quotient is 65 (since ) and the remainder is:Thus,
Final Answer:
The ciphertext value is 41.
This detailed computation shows how the RSA encryption formula is applied using the given primes and public key exponent.
6) Solve this example Using Knapsack algorithm
Super Increasing sequence={1, 2, 4, 10, 20, 40} Do necessary calculation to solve.
Let’s solve an example of the Merkle–Hellman Knapsack Cryptosystem using the superincreasing sequence
For this example, we will illustrate both the encryption and decryption processes. (Since the problem doesn’t specify a plaintext, we’ll assume a 6‐bit message; here we choose the plaintext bits as “101101”.)
Step 1. Key Generation
-
Private (Superincreasing) Sequence:
This is given as -
Choose a Modulus :
must be greater than the sum of the sequence.For example, choose
-
Choose a Multiplier :
Choose such that and .
For instance, let -
Compute the Public Key Sequence:
For each in , computeCalculation for each component:
So, the public key is:
Step 2. Encryption
Assume the plaintext message is the 6-bit binary string “101101”. Label the bits corresponding to the private sequence (ordered as given):
Encryption Formula:
The ciphertext is the sum of the public key components corresponding to the 1’s in the plaintext:
Plug in the values:
Now calculate:
Thus, the ciphertext is 223.
Step 3. Decryption
To decrypt, the receiver (who knows the private key) performs the following steps:
-
Compute the Modular Inverse of modulo :
We need such that:With and , using the Extended Euclidean Algorithm we find:
so
-
Multiply the Ciphertext by mod :
Compute:First, . Then,
So, .
-
Solve the Superincreasing Knapsack Problem:
We now use the superincreasing sequence to determine which subset sums to .
Decryption Process (working backward):- Start with the largest number:
is less than or equal to , so include it.
Remainder: . - Next, is greater than so skip it.
- is less than or equal to ; include it.
Remainder: . - is less than or equal to ; include it.
Remainder: . - is greater than ; skip it.
- is equal to the remainder; include it.
Remainder: .
Mapping to Bit Positions:
The sequence corresponds to bit positions from the smallest weight to the largest. Inclusion means the bit is 1:- (included) → bit1 = 1
- (skipped) → bit2 = 0
- (included) → bit3 = 1
- (included) → bit4 = 1
- (skipped) → bit5 = 0
- (included) → bit6 = 1
Thus, the decrypted bit string is:
which matches the original plaintext.
- Start with the largest number:
Summary
- Private Key (Superincreasing sequence):
- Modulus :
- Multiplier :
- Public Key:
- Plaintext (assumed): “101101”
- Ciphertext:
- Decrypted Message: “101101”
This complete example demonstrates the steps involved in the Merkle–Hellman knapsack cryptosystem using the given superincreasing sequence.
7) Explain in detail about Elliptic Curve Architecture.
Elliptic Curve Architecture
Elliptic Curve Cryptography (ECC) is a modern cryptographic approach based on the algebraic structure of elliptic curves over finite fields. It provides high security with smaller key sizes, making it efficient for constrained environments like IoT and mobile devices.
1. Introduction to Elliptic Curves
An elliptic curve is a set of points that satisfy the equation:
where:
- are coordinates in a finite field (prime field) or (binary field),
- and are constants satisfying (to ensure a valid curve).
A graphical representation of an elliptic curve is a symmetric curve about the x-axis.
2. Key Components of Elliptic Curve Architecture
ECC relies on the mathematical properties of elliptic curves for encryption, key exchange, and digital signatures. The architecture consists of:
a) Curve Definition
- Defined by parameters .
- Prime Field : The curve is defined over integers modulo a prime number .
- Binary Field : Used in certain applications where numbers are represented in binary.
b) Elliptic Curve Points
- The set of points on the curve satisfying .
- Includes a special point called the point at infinity (denoted as ), acting as the identity element in addition.
c) Point Addition and Doubling
ECC operations are defined using point addition and point doubling, which form the basis of ECC cryptographic algorithms.
-
Point Addition: Given two points and , the sum is computed using:
where (the slope) is:
-
Point Doubling: If , the doubling formula is:
where:
d) Scalar Multiplication
- ECC uses scalar multiplication, which involves computing (adding to itself times).
- It is the fundamental operation in ECC-based encryption and key exchange.
3. ECC in Cryptographic Applications
ECC is used in:
a) Key Exchange (Elliptic Curve Diffie-Hellman - ECDH)
- Both parties agree on an elliptic curve and a public base point .
- Each party selects a private key ().
- Public keys: , .
- Shared secret: , ensuring secure key exchange.
b) Digital Signatures (Elliptic Curve Digital Signature Algorithm - ECDSA)
- Private key: .
- Public key: .
- Signature generation and verification involve elliptic curve operations for authentication.
c) Encryption (Elliptic Curve Integrated Encryption Scheme - ECIES)
- Uses ECC to encrypt messages securely.
- More efficient than RSA due to smaller key sizes.
4. Advantages of ECC Architecture
- Stronger Security with Smaller Keys: ECC provides the same security as RSA but with much smaller key sizes.
- 256-bit ECC key ≈ 3072-bit RSA key.
- Efficient Performance: Faster computations and lower memory usage.
- Energy-Efficient: Ideal for IoT, mobile, and embedded devices.
- Scalability: Works well in distributed and resource-limited environments.
5. Comparison with RSA
Feature | ECC | RSA |
---|---|---|
Key Size | Small (256-bit) | Large (2048-bit) |
Speed | Faster | Slower |
Security | High | Requires larger keys |
Resource Usage | Low | High |
Conclusion
ECC is a highly efficient cryptographic system that provides strong security with smaller keys, making it ideal for modern security applications like secure communications, blockchain, and IoT security.
8) Write a short note on Man in the Middle Attack.
Man-in-the-Middle (MITM) Attack
A Man-in-the-Middle (MITM) attack is a cyberattack where an attacker secretly intercepts and alters communication between two parties without their knowledge. The attacker positions themselves between the sender and receiver to eavesdrop, modify, or inject malicious data.
How MITM Works:
- Interception: The attacker intercepts communication between two parties (e.g., user and website).
- Modification: The attacker can alter the messages, steal sensitive data (passwords, financial details), or inject malicious content.
- Forwarding: The manipulated data is sent to the intended recipient, making it appear as a legitimate conversation.
Types of MITM Attacks:
- Eavesdropping: Listening to unencrypted communication.
- Session Hijacking: Stealing active session cookies.
- SSL Stripping: Downgrading HTTPS to HTTP to intercept secure traffic.
- Wi-Fi Spoofing: Creating fake Wi-Fi networks to capture data.
Prevention Methods:
- Use end-to-end encryption (e.g., HTTPS, VPN).
- Implement public key infrastructure (PKI) and digital certificates.
- Avoid connecting to unsecured public Wi-Fi without VPN.
- Use multi-factor authentication (MFA) for extra security.
MITM attacks are dangerous as they compromise confidentiality and integrity, making secure communication essential.
9) Write a short note on Key Distribution and also define Master and Session Key.
Key Distribution
Key distribution is the process of securely delivering cryptographic keys to parties that need to communicate securely. Since encryption relies on keys, securely sharing them is crucial to prevent unauthorized access.
Methods of Key Distribution:
- Manual Key Exchange: Physically delivering keys (e.g., USB drives).
- Public Key Cryptography: Using asymmetric encryption (e.g., RSA, Diffie-Hellman).
- Key Distribution Center (KDC): A trusted third party that provides session keys.
- Kerberos Protocol: Uses a Ticket Granting System for authentication and key distribution.
Master Key vs. Session Key
Master Key:
- A long-term key used to establish a secure connection and generate session keys.
- Shared between two parties in advance.
- Less frequently changed to avoid security risks.
- Example: A pre-shared key (PSK) in a VPN.
Session Key:
- A temporary key used for a single session of communication.
- Generated dynamically and discarded after use.
- Improves security by reducing key exposure.
- Example: The key used in TLS/SSL during HTTPS communication.
Efficient key distribution and management are essential for ensuring secure communication in cryptographic systems.
10) 10.List four general categories of schemes for the distribution of public keys.
Four General Categories of Public Key Distribution Schemes:
-
Publicly Available Directory:
- A trusted directory maintains a list of public keys associated with user identities.
- Users retrieve public keys when needed.
- Requires authentication and regular updates to prevent unauthorized modifications.
-
Public-Key Authority:
- A central trusted entity (like a Certification Authority, CA) verifies and provides public keys.
- Users contact the authority to obtain verified public keys.
- More secure than a public directory but requires trust in the authority.
-
Public-Key Certificates:
- A trusted authority issues digital certificates containing a user’s public key, identity, and a digital signature.
- Certificates can be shared over untrusted networks while ensuring authenticity.
- Used in PKI (Public Key Infrastructure) and SSL/TLS security.
-
Peer-to-Peer Exchange:
- Users exchange public keys directly without relying on a central authority.
- Often used in small or private networks.
- Vulnerable to Man-in-the-Middle (MITM) attacks without proper authentication.
Each method has its strengths and weaknesses, with Public-Key Certificates and Public-Key Authorities being the most widely used in modern secure communications.
11) Write a note on simple secret key distribution.
Simple Secret Key Distribution
Secret key distribution is the process of securely sharing a symmetric encryption key between two communicating parties. Since symmetric encryption uses the same key for both encryption and decryption, protecting the key during transmission is crucial to prevent unauthorized access.
Basic Methods of Secret Key Distribution:
-
Manual Key Exchange:
- The secret key is physically shared using a secure channel (e.g., USB, paper, face-to-face).
- Secure but impractical for large-scale networks.
-
Using a Trusted Third Party (Key Distribution Center - KDC):
- A KDC generates and distributes session keys to communicating parties.
- Used in protocols like Kerberos to authenticate users and distribute keys securely.
-
Diffie-Hellman Key Exchange:
- A cryptographic method where two parties securely generate a shared secret over an insecure channel.
- Vulnerable to Man-in-the-Middle (MITM) attacks without authentication.
-
Public Key Cryptography (Hybrid Approach):
- A public key algorithm (e.g., RSA) encrypts the secret key before sending it.
- Once exchanged, symmetric encryption (e.g., AES) is used for faster communication.
Efficient secret key distribution is essential for secure communication, ensuring confidentiality and preventing unauthorized access.
12) Draw a neat sketch showing the key distribution scenario.
13) Specify the application of public key cryptography.
Applications of Public Key Cryptography
Public Key Cryptography (PKC) is widely used for secure communication and authentication. Some key applications include:
-
Secure Communication (Encryption & Decryption)
- Used in SSL/TLS protocols for encrypting web traffic (HTTPS).
- Ensures confidentiality in emails (PGP, S/MIME).
-
Digital Signatures
- Used in digital certificates to verify sender authenticity (e.g., ECDSA, RSA).
- Prevents message tampering and ensures non-repudiation.
-
Key Exchange (Key Distribution)
- Securely shares symmetric keys using algorithms like Diffie-Hellman.
- Essential for secure messaging apps (e.g., Signal, WhatsApp).
-
Authentication & Identity Verification
- Used in digital certificates for user authentication in systems like PKI.
- Enables passwordless logins with public-private key pairs (e.g., SSH authentication).
-
Blockchain & Cryptocurrencies
- Used in Bitcoin and Ethereum for wallet security and transactions.
- Ensures ownership and verification through cryptographic hashing.
-
Secure Email Communication
- PGP (Pretty Good Privacy) and S/MIME (Secure/Multipurpose Internet Mail Extensions) use PKC for email encryption and signing.
-
Software Security (Code Signing)
- Verifies software integrity using digital signatures before installation.
- Prevents tampering and malware injection.
Public key cryptography is fundamental to modern cybersecurity, enabling secure data exchange, authentication, and digital trust across various applications.