cryptography sheet
cryptography sheet
Access control ensures only authorized users, processes, or systems access specific resources. In
cryptography, it uses encryption, authentication, and authorization to protect sensitive data.
Key Components:
Relation Between
Access Control and Availability
● Both are components of the CIA Triad (Confidentiality, Integrity, Availability) in cybersecurity
and cryptography.
● Access Control ensures confidentiality by restricting unauthorized access to data.
● Availability ensures that authorized users have uninterrupted access to data and
cryptographic services.
● Balance Needed: Excessive access control (e.g., strict authentication) may reduce
availability, causing access difficulties.
The Diffie-Hellman (DH) key exchange is a cryptographic protocol that allows two parties to
securely establish a shared secret key over an insecure channel without prior knowledge of each
other. This shared key can be used for symmetric encryption.
Algorithm Steps:
1. Public Parameters Selection: Choose a large prime number ppp and a primitive root ggg of
ppp.
2. Key Generation:
○ Alice selects a private key aaa and computes her public key A=gamod pA = g^a \mod
pA=gamodp.
○ Bob selects a private key bbb and computes his public key B=gbmod pB = g^b \mod
pB=gbmodp.
3. Public Key Exchange: Alice and Bob exchange their public keys AAA and BBB over the
insecure channel.
4. Shared Secret Computation:
○ Alice computes S=Bamod p=gabmod pS = B^a \mod p = g^{ab} \mod
pS=Bamodp=gabmodp.
○ Bob computes S=Abmod p=gabmod pS = A^b \mod p = g^{ab} \mod
pS=Abmodp=gabmodp.
Since exponentiation is commutative, both derive the same shared secret SSS, used for
encryption.
Limitations:
Triple DES (3DES) is a symmetric encryption algorithm that enhances the original DES by applying
it three times to each data block. It uses three different keying options with varying security levels.
3DES can reuse keys in certain modes, affecting its overall security.
1. 3-Key Triple DES (3TDEA): Uses three independent 56-bit keys (K1,K2,K3K_1, K_2,
K_3K1,K2,K3), providing the highest security with a 168-bit key space.
2. 2-Key Triple DES (2TDEA): Uses two keys (K1=K3K_1 = K_3K1=K3) but K2K_2K2is
different, providing moderate security (112-bit key space). Vulnerable to Meet-in-the-Middle (MitM)
attacks.
3. 1-Key Triple DES: All keys are the same (K1=K2=K3K_1 = K_2 = K_3K1=K2=K3), reducing
security to the same level as single DES, with a 56-bit key space. This is considered weak and not
recommended.
How Key Reuse Works in 3DES:
1. 2-Key Triple DES: The same key K1K_1K1is used for both the first and third encryption
steps, reducing the effective key strength to 112 bits:
C=EK1(DK2(EK1(P)))C = E_{K_1} ( D_{K_2} ( E_{K_1} (P) ) )C=EK1(DK2(EK1(P)))
2. 1-Key Triple DES: All three keys are the same, effectively making 3DES equivalent to DES:
C=EK1(DK1(EK1(P)))C = E_{K_1} ( D_{K_1} ( E_{K_1} (P) ) )C=EK1(DK1(EK1(P)))
This provides no additional security, making it as vulnerable as single DES.
Security Implications:
● 2-Key Triple DES: Reduced to 112 bits of effective security, vulnerable to MitM attacks.
● 1-Key Triple DES: Equivalent to DES with a 56-bit key, susceptible to brute-force attacks.
● 3-Key Triple DES: Offers 168-bit security, but is now deprecated due to quantum threats.
Current Status:
What is RSA?
RSA (Rivest-Shamir-Adleman) is an asymmetric cryptographic algorithm used for secure key
exchange, encryption, and digital signatures. It ensures confidentiality and authenticity by
leveraging the difficulty of factoring large prime numbers.
Example:
● Choose p=3p = 3p=3, q=11q = 11q=11, n=33n = 33n=33, and ϕ(n)=20\phi(n) = 20ϕ(n)=20.
● Choose e=7e = 7e=7, and compute d=3d = 3d=3.
● Public Key: (7,33)(7, 33)(7,33), Private Key: (3,33)(3, 33)(3,33).
● Encrypt message M=4M = 4M=4: C=47 (mod 33)=16C = 4^7 \ (\text{mod} \ 33) = 16C=47
(mod 33)=16.
● Decrypt ciphertext C=16C = 16C=16: M=163 (mod 33)=4M = 16^3 \ (\text{mod} \ 33) =
4M=163 (mod 33)=4.
Limitations:
How It Works:
1. Hashing:
The message is processed through a hash function (e.g., SHA-256) to produce a fixed-size hash.
Any change in the message results in a different hash.
2. Signing:
The hash is encrypted using the sender’s private key, creating the digital signature.
3. Verification:
The recipient decrypts the signature using the sender’s public key and hashes the original
message again. If the hashes match, the signature is valid.
Use Cases:Secure Emails: Used in PGP and S/MIME.Software Code Signing: Verifies
authenticity of software.Blockchain Transactions: Provides ownership proof.Legal/Financial
Documents: Secures contracts and banking transactions.SSL/TLS Certificates: Verifies website
authenticity.
There are several types of attacks that can target digital signatures. These attacks aim to
compromise the authenticity, integrity, or non-repudiation of a signed message. Here are the key
types of attacks:
1. Forgery Attack: In this type of attack, an attacker tries to create a fraudulent digital
signature. If the signature scheme is weak, attackers may generate a valid signature for a
message without the private key. Forgery is possible if the attacker can exploit weaknesses in the
cryptographic algorithm or the signature generation process.
2. Replay Attack: A replay attack occurs when an attacker intercepts a signed message and
replays it to the recipient, pretending it is a new message. Although the signature is valid, the
attacker does not alter the message, but instead tries to deceive the recipient into believing it is a
fresh communication. To mitigate this, timestamps and nonces are often used to make each
signature unique.
3. Collision Attack: A collision attack involves finding two different messages that result in the
same hash value. If an attacker can find such a collision in the hash function used for the digital
signature, they could create two different messages with identical signatures. This could cause a
valid signature to be used for a message other than the one intended. A strong hash function like
SHA-256 helps prevent such attacks.
4. Key Substitution Attack: In this type of attack, an attacker manages to replace the public
key of a legitimate signer with a counterfeit key, thus redirecting verification to their own public key.
This would allow them to forge signatures that appear valid to the recipient. Public key
infrastructures (PKIs) and certificate authorities (CAs) are used to prevent this by ensuring proper
public key validation.
5. Man-in-the-Middle (MITM) Attack: In a MITM attack, an attacker intercepts and alters the
communication between the sender and the receiver. The attacker could change the signed
message or replace the public key used for signature verification. Though this attack can be
mitigated using encryption for the entire communication and verifying the integrity of the signature
with a trusted third party, it remains a significant risk.
Write down limitations of Caesar Cipher Technique. How can we overcome it?
The Caesar Cipher is a substitution cipher where each letter in the plaintext is shifted by a certain
number of positions down or up the alphabet. While it is simple and easy to use, it has several
limitations:
Transform the plain text "UNIVERSITY" into cipher text using Modified Caesar Cipher
Technique
To transform the plaintext "UNIVERSITY" into ciphertext using the Modified Caesar Cipher
technique, let's assume a simple variation of the Caesar Cipher where a shift key is chosen (e.g.,
shifting by 3 positions). The Modified Caesar Cipher works by shifting each letter in the plaintext by
a certain number of positions in the alphabet.
Steps:
Write the alphabet for reference:
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
Shift each letter of the plaintext by 3 positions forward:
So, the plaintext "UNIVERSITY" is encrypted to "XQLYHUVWLB" using the Modified Caesar
Cipher with a shift of 3.
This is a simple example, and the "Modified" version of the Caesar Cipher could involve varying
the shift for each letter or using a more complex mechanism (e.g., a keyword), depending on the
specific modification used.
Explain continuous encryption principle
ChatGPT said:
The continuous encryption principle is a concept in cryptography where data is encrypted and
decrypted continuously throughout its lifecycle, ensuring that the data remains protected at all
times. This principle aims to provide real-time security for sensitive information while minimizing
the potential for unauthorized access.
ChatGPT said:
Key Points:
1. Encryption: SSL encrypts data to make it unreadable to unauthorized third parties, ensuring
that sensitive information (e.g., passwords, credit card numbers) remains private.
2. Authentication: SSL uses digital certificates to authenticate the server to the client, ensuring
the client is connecting to the correct server. These certificates are issued by trusted Certificate
Authorities (CAs).
3. Integrity: SSL ensures data integrity by using message authentication codes (MACs),
preventing tampering of the data during transmission.
4. SSL Handshake: During the SSL handshake, the client and server agree on encryption
algorithms and generate session keys to securely encrypt the data being transferred.
5. Secure Communication: Once the session is established, SSL allows secure data
exchange, maintaining privacy and trust between parties, and providing protection from attacks like
man-in-the-middle.
SSL is essential for secure online transactions, ensuring privacy and security on websites that use
HTTPS.
ChatGPT said:
Secure Hashing Algorithm (SHA) is a family of cryptographic hash functions designed to provide
a secure method for generating a fixed-size output (hash) from an input of arbitrary size. SHA is
primarily used for ensuring data integrity, authentication, and digital signatures.
Key Points:
1. Hash Function: SHA takes an input (message) and produces a fixed-size string of
characters, typically represented as a hexadecimal value. This hash is unique to the input data.
2. Data Integrity: It ensures data integrity by producing a unique hash value for a given input.
Even a small change in the input will result in a drastically different hash, which helps detect
alterations in the data.
3. Types of SHA: The SHA family includes several versions, with SHA-1, SHA-256, and
SHA-512 being the most widely used. SHA-256 and SHA-512 are part of the SHA-2 family and are
considered more secure than SHA-1, which is no longer recommended due to vulnerabilities.
4. Fixed Length Output: Regardless of the input size, the output hash produced by SHA has a
fixed length. For example, SHA-256 produces a 256-bit hash, while SHA-512 produces a 512-bit
hash.
5. Applications: SHA is widely used in digital signatures, certificate generation, password
hashing, and blockchain technology, ensuring the authenticity and integrity of data.
SHA plays a vital role in modern cryptography by ensuring that data remains unaltered and secure
throughout its transmission.
ChatGPT said:
Hill Cipher is a polygraphic substitution cipher that encrypts data in blocks of letters using linear
algebra. It is based on the use of matrix multiplication, which allows multiple plaintext letters to be
encrypted simultaneously.
Key Points:
1. Matrix-based Cipher: The Hill cipher uses an n x n matrix as the key, where n is the size of
the block (usually 2x2 or 3x3 matrices). Each letter of the plaintext is represented by a number,
and the encryption process involves multiplying the matrix by a column vector representing the
plaintext.
2. Encryption Process:
○ The plaintext is divided into blocks of size n (e.g., 2 letters for a 2x2 matrix).
○ Each block is represented as a column vector of numbers corresponding to the plaintext
letters.
○ The plaintext vector is then multiplied by the key matrix and taken modulo 26 to produce the
ciphertext.
3. Key Matrix: The key matrix must be invertible, meaning its determinant should not be zero,
to ensure that the ciphertext can be decrypted properly. The matrix entries correspond to numbers
representing the letters of the alphabet.
4. Decryption Process: To decrypt the ciphertext, the inverse of the key matrix is used. The
inverse matrix is multiplied by the ciphertext vector to retrieve the original plaintext.
5. Security Considerations: The Hill cipher is relatively more secure than simple substitution
ciphers because it encrypts multiple letters at once. However, it can still be vulnerable to frequency
analysis and requires careful key management.
Example:
The plaintext "HI" (which corresponds to [7, 8] in numeric form) would be encrypted using matrix
multiplication with K, resulting in the ciphertext.
The Hill cipher's strength lies in the use of linear transformations, making it a notable algorithm for
encrypting multiple letters at a time.
ChatGPT said:
Key Exchange Algorithm in cryptography is a method by which two parties can securely
exchange cryptographic keys over a public channel without anyone else being able to intercept or
decipher the key. It forms the basis for secure communication in various cryptographic systems,
allowing parties to agree on a shared secret key for encryption or digital signatures.
Key Points:
1. Purpose: The primary purpose of key exchange algorithms is to enable two parties (e.g.,
Alice and Bob) to securely share a secret key, which can later be used for symmetric encryption or
other cryptographic operations, even if the communication channel is insecure.
2. Public Key Cryptography: Key exchange often involves asymmetric (public-key)
cryptography, where each party has a public key (which is shared) and a private key (which is
kept secret). This allows secure communication without needing to meet in person or exchange a
secret key beforehand.
3. Diffie-Hellman Key Exchange:
○ One of the most famous and widely used key exchange protocols is the Diffie-Hellman
algorithm.
○ Both parties agree on a large prime number and a base (both public).
○ They each select a private key, compute their public key by raising the base to the power of
their private key modulo the prime, and exchange their public keys.
○ Finally, each party combines their private key with the other party’s public key to compute the
shared secret key.
4. Elliptic Curve Diffie-Hellman (ECDH):
○ This is a variant of Diffie-Hellman that uses elliptic curve cryptography (ECC) to generate
keys.
○ ECDH provides the same level of security as Diffie-Hellman with much smaller key sizes,
making it more efficient and faster.
5. Security: The security of key exchange algorithms is based on the mathematical difficulty
of certain problems (like discrete logarithms in Diffie-Hellman), which makes it hard for an
eavesdropper to compute the shared key even if they can intercept the public keys.
Example:
In the Diffie-Hellman key exchange, let’s assume Alice and Bob agree on a prime number ppp and
a base ggg. Alice and Bob then choose private keys aaa and bbb, respectively. They calculate
their public keys, exchange them, and then compute the shared secret key:
Even though an eavesdropper might intercept the values AAA and BBB, they cannot easily
compute the shared secret key.
Conclusion:
Key exchange algorithms are critical for enabling secure communication over insecure channels.
By using mathematical techniques such as Diffie-Hellman and elliptic curve methods, these
algorithms provide a way to establish a shared secret key securely, which can then be used for
encrypted communication.
How It Works:
Summary:
The Caesar Cipher works by shifting each letter of the plaintext by a fixed number (key). It is
simple to implement but insecure because there are only 25 possible keys, making it vulnerable to
brute force attacks. The formulas for encryption and decryption are as follows:
Conventional encryption, or symmetric-key encryption, is based on the use of the same key for
both the encryption and decryption processes. The key is shared between the sender and the
receiver, and its secrecy is essential to ensure secure communication. The working of conventional
encryption can be explained through a simple example.
Working Example:
● Plaintext: "HELLO"
● Key: 3 (Each letter will be shifted by 3 positions)
Step 1: Encryption
Using the Caesar Cipher encryption algorithm, we shift each letter of the plaintext by 3 positions in
the alphabet
H → K, E → H, L → O, L → O, O → R,
Step 2: Decryption
To decrypt the ciphertext, the receiver uses the same key (3) and shifts each letter of the ciphertext
back by 3 positions:
Conventional encryption algorithms, also known as symmetric-key encryption algorithms, use the
same key for both encryption and decryption of data. The security of these algorithms relies on the
secrecy of the key. The main goal is to convert plaintext into ciphertext and vice versa, ensuring
confidentiality. Here are some widely used conventional encryption algorithms:
1. Caesar Cipher
● Working: The Caesar Cipher is a substitution cipher where each letter in the plaintext is
shifted by a fixed number (key) positions in the alphabet.
● Example: For a key of 3, the letter 'A' becomes 'D', 'B' becomes 'E', etc.
● Encryption: Each character of the plaintext is replaced by a letter a fixed number of positions
ahead in the alphabet.
● Decryption: The same key is used to reverse the shift.
● Limitations: Very basic and insecure due to the small key space (only 25 possible keys).
2. Monoalphabetic Cipher
3. Vigenère Cipher
● Working: The Vigenère Cipher is a more advanced form of the Caesar Cipher that uses a
keyword. The key is repeated to match the length of the plaintext. Each letter of the plaintext is
shifted according to the corresponding letter of the keyword.
● Encryption: For a given key, the plaintext letter is shifted by a number equal to the
alphabetical position of the key letter.
● Decryption: The ciphertext is decrypted by reversing the shift using the same key.
● Example: Plaintext: "HELLO", Key: "KEY" → Encrypted as "RIJVS".
● Limitations: The key must remain secret, and short keys are vulnerable to cryptanalysis.
● Working: DES is a block cipher that encrypts data in 64-bit blocks using a 56-bit key. It uses
a series of complex transformations and substitutions to encrypt the data.
● Rounds: The algorithm operates in 16 rounds of substitution and permutation, using an initial
permutation, a series of rounds, and a final permutation.
● Decryption: Decryption is the reverse of encryption, using the same key.
● Limitations: DES is considered insecure due to the small key size (56 bits), making it
vulnerable to brute-force attacks.
● Working: AES is a symmetric block cipher that operates on 128-bit blocks of data with key
sizes of 128, 192, or 256 bits. It uses a series of substitutions, permutations, and XOR operations
to transform the plaintext into ciphertext.
● Rounds: AES performs 10 rounds of encryption for a 128-bit key, 12 rounds for a 192-bit key,
and 14 rounds for a 256-bit key.
● Decryption: The decryption process is the reverse of encryption.
● Strength: AES is considered highly secure and is widely used for data encryption in
government, banking, and secure communications.
● Working: Triple DES enhances the security of DES by applying the DES algorithm three
times using either two or three different keys.
● Modes: 3DES operates in three modes: encryption with three keys (3TDEA), encryption with
two keys (2TDEA), and encryption with a single key (which reverts to single DES).
● Decryption: The decryption process is similar to encryption but is performed with the reverse
order of keys.
● Limitations: 3DES is slower compared to AES, and while more secure than DES, it is being
phased out due to its vulnerability to modern cryptographic attacks.
● Working: RC4 is a stream cipher that generates a keystream (a sequence of random bits)
using a variable-length key. The keystream is XORed with the plaintext to produce ciphertext.
● Decryption: The same key is used to generate the same keystream, which is XORed with the
ciphertext to obtain the original plaintext.
● Limitations: RC4 is known to have vulnerabilities and weaknesses that make it less secure
for modern use, especially in SSL/TLS protocols.