unit 3 and 4
unit 3 and 4
The RSA algorithm (Rivest-Shamir-Adleman) is one of the most widely used public-key
cryptosystems. It enables secure data transmission, ensuring both confidentiality and authentication.
RSA is based on the mathematical properties of large prime numbers, which makes it
computationally difficult to reverse the encryption without knowing the private key.
1. Key Generation: The first step in the RSA algorithm is generating the public and private keys.
These keys are used for encryption and decryption.
o Step 1: Choose two distinct large prime numbers, ppp and qqq.
▪ nnn is used as the modulus for both the public and private keys.
▪ ϕ(n)\phi(n)ϕ(n) represents the number of integers less than nnn that are
coprime with nnn.
o Step 4: Choose an integer eee such that 1<e<ϕ(n)1 < e < \phi(n)1<e<ϕ(n) and eee is
coprime to ϕ(n)\phi(n)ϕ(n) (i.e., gcd(e,ϕ(n))=1\gcd(e, \phi(n)) = 1gcd(e,ϕ(n))=1).
o nnn is part of both keys, while eee is used for encryption and ddd is used for
decryption. The private key ddd must be kept secret.
1. Convert the message MMM into an integer such that 0≤M<n0 \leq M < n0≤M<n.
2. Compute the ciphertext CCC using the public key (e,n)(e, n)(e,n): C=Me mod nC = M^e \
\text{mod} \ nC=Me mod n
3. The ciphertext CCC is then sent to the recipient.
To decrypt the ciphertext CCC, the recipient uses their private key (d,n)(d, n)(d,n):
1. Compute the original message MMM using: M=Cd mod nM = C^d \ \text{mod} \
nM=Cd mod n
1. Key Generation:
o Compute ddd such that 17×d≡1 (mod 3120)17 \times d \equiv 1 \ (\text{mod} \
3120)17×d≡1 (mod 3120). We find d=2753d = 2753d=2753.
2. Encryption:
3. Decryption:
• Asymmetric Encryption: RSA uses different keys for encryption (public) and decryption
(private), allowing secure communication without requiring the parties to share a secret key
beforehand.
• Security: The security of RSA relies on the difficulty of factoring large integers (specifically
the modulus nnn, which is the product of two large primes). As the size of nnn increases, the
difficulty of breaking RSA increases.
• Key Length: Common key sizes for RSA range from 1024 to 4096 bits. Larger key sizes provide
more security but require more computational power.
Applications of RSA
• Digital Signatures: RSA can be used to sign messages digitally. The sender uses their private
key to sign the message, and the recipient verifies the signature using the sender’s public
key.
• Secure Communication: RSA is commonly used in secure protocols like SSL/TLS (used for
HTTPS) to encrypt data during transmission.
• Key Exchange: RSA is often used in combination with symmetric encryption algorithms. RSA
encrypts the symmetric key, which is then used to encrypt the actual message (since
symmetric encryption is faster).
Conclusion
RSA is a powerful cryptographic algorithm used for secure data transmission and digital signatures.
Its security depends on the computational difficulty of factoring large numbers. Proper key
management and key length are critical to maintaining the security and effectiveness of RSA
encryption in modern applications.
The RSA (Rivest-Shamir-Adleman) algorithm is one of the first public-key cryptosystems and is widely
used for secure data transmission. The mathematical foundations of the RSA algorithm rely on
number theory concepts such as prime factorization, modular arithmetic, and the properties of
Euler's Totient function.
Here is a detailed step-by-step breakdown of the mathematical foundations of the RSA algorithm:
1. Prime Numbers:
RSA requires the selection of two large prime numbers for its security.
• The product of these two primes is used to calculate the modulus nnn: n=p×qn = p \times
qn=p×q This nnn is used as part of both the public and private keys.
2. Modulus nnn:
The modulus nnn is a key component of RSA. It is the product of the two primes and serves as the
base for the modulo operations in both the encryption and decryption processes.
The difficulty of factoring nnn into its prime components ppp and qqq underpins the security of RSA.
With large enough primes, factorization becomes computationally infeasible.
Euler's Totient function ϕ(n)\phi(n)ϕ(n) is a critical part of the RSA algorithm. It gives the number of
integers less than nnn that are relatively prime to nnn. For RSA, since nnn is the product of two
primes, we can compute ϕ(n)\phi(n)ϕ(n) as:
ϕ(n)=(p−1)(q−1)\phi(n) = (p-1)(q-1)ϕ(n)=(p−1)(q−1)
This is derived from the fact that for a prime number ppp, ϕ(p)=p−1\phi(p) = p-1ϕ(p)=p−1.
This ensures that eee has a multiplicative inverse modulo ϕ(n)\phi(n)ϕ(n), which is required for
decryption.
The private key exponent ddd is computed as the modular multiplicative inverse of eee modulo
ϕ(n)\phi(n)ϕ(n). That is, ddd satisfies the equation:
This can be calculated using the Extended Euclidean Algorithm, which finds the inverse of eee
modulo ϕ(n)\phi(n)ϕ(n).
6. Key Generation:
4. Choose eee such that 1<e<ϕ(n)1 < e < \phi(n)1<e<ϕ(n) and gcd(e,ϕ(n))=1\gcd(e, \phi(n)) =
1gcd(e,ϕ(n))=1.
The public key is (e,n)(e, n)(e,n), and the private key is (d,n)(d, n)(d,n).
7. Encryption:
Encryption in RSA is done using the public key. The plaintext message MMM is transformed into
ciphertext CCC using the formula:
Here, MMM is the numerical representation of the message (typically converted to an integer), eee
is the public key exponent, and nnn is the modulus.
8. Decryption:
Decryption is done using the private key. The ciphertext CCC is transformed back into the plaintext
message MMM using the formula:
The correctness of the RSA algorithm relies on the properties of modular arithmetic. Specifically, for
the RSA encryption and decryption process to work, the following condition must hold:
This is guaranteed by Euler's theorem, which states that for any integer MMM such that
gcd(M,n)=1\gcd(M, n) = 1gcd(M,n)=1:
Using the fact that ed≡1 (mod ϕ(n))ed \equiv 1 \ (\text{mod} \ \phi(n))ed≡1 (mod ϕ(n)), it follows
that:
This ensures that after encrypting with the public key and decrypting with the private key, we recover
the original message.
Key Generation:
• Compute ddd, the modular inverse of 17mod 6017 \mod 6017mod60, using the Extended
Euclidean Algorithm: d=53d = 53d=53
Encryption:
Decryption:
• Decrypt the ciphertext C=30C = 30C=30 using the private key d=53d = 53d=53,
• RSA relies on prime factorization, modular arithmetic, and Euler's Totient function.
• Private key ddd is the modular inverse of emod ϕ(n)e \mod \phi(n)emodϕ(n).
4o
The Diffie-Hellman key exchange allows two users, A and B, to securely share a secret key over an
insecure channel using the mathematical principles of modular arithmetic. Here, we will use the
provided values of q=11q = 11q=11 (the prime number) and α=7\alpha = 7α=7 (the primitive root).
Let's go through the steps to find the public keys for both users and compute the shared secret key.
Given:
• The public key of A, YAY_AYA, is computed as: YA=αXAmod q=73mod 11Y_A = \alpha^{X_A}
\mod q = 7^3 \mod 11YA=αXAmodq=73mod11 First, calculate 73=3437^3 = 34373=343, and
then: YA=343mod 11=2Y_A = 343 \mod 11 = 2YA=343mod11=2
• The public key of B, YBY_BYB, is computed as: YB=αXBmod q=76mod 11Y_B = \alpha^{X_B}
\mod q = 7^6 \mod 11YB=αXBmodq=76mod11 First, calculate 76=1176497^6 =
11764976=117649, and then: YB=117649mod 11=4Y_B = 117649 \mod 11 = 4YB
=117649mod11=4
• A uses B’s public key YB=4Y_B = 4YB=4 and A’s private key XA=3X_A = 3XA=3:
Shared Key for A=YBXAmod q=43mod 11\text{Shared Key for A} = Y_B^{X_A} \mod q = 4^3
\mod 11Shared Key for A=YBXAmodq=43mod11 First, calculate 43=644^3 = 6443=64, and
then: Shared Key for A=64mod 11=9\text{Shared Key for A} = 64 \mod 11 =
9Shared Key for A=64mod11=9
• B uses A’s public key YA=2Y_A = 2YA=2 and B’s private key XB=6X_B = 6XB=6:
Shared Key for B=YAXBmod q=26mod 11\text{Shared Key for B} = Y_A^{X_B} \mod q = 2^6
\mod 11Shared Key for B=YAXBmodq=26mod11 First, calculate 26=642^6 = 6426=64, and
then: Shared Key for B=64mod 11=9\text{Shared Key for B} = 64 \mod 11 =
9Shared Key for B=64mod11=9
Thus, the shared secret key is 9 for both User A and User B.
Final Results:
1. Select a large prime number qqq and a primitive root α\alphaα modulo qqq:
o User A computes their public key YA=αXAmod qY_A = \alpha^{X_A} \mod qYA=αXA
modq and sends it to User B.
o User B computes their public key YB=αXBmod qY_B = \alpha^{X_B} \mod qYB=αXB
modq and sends it to User A.
o User B computes the shared secret key as (YA)XBmod q(Y_A)^{X_B} \mod q(YA)XB
modq.
The result is the same for both users and becomes the shared secret key for secure communication.
The Diffie-Hellman algorithm is a secure way of establishing a shared secret key over an insecure
channel, which can then be used for encryption in symmetric key algorithms. The security comes
from the difficulty of solving the discrete logarithm problem.
ChatGPT
Introduction
The Diffie-Hellman key exchange is a foundational method in modern cryptography, enabling two
parties to securely share a secret key over an insecure communication channel. It is based on the
principles of modular arithmetic and the Discrete Logarithm Problem (DLP). This exchange allows
users to derive a common key for subsequent symmetric encryption, ensuring the confidentiality of
their communication.
Key Concepts
1. Modular Arithmetic: This mathematical operation involves numbers wrapping around upon
reaching a specified modulus. It is fundamental in cryptography, especially for operations
involving large primes.
2. Primitive Root: A number α\alphaα is a primitive root modulo qqq if it can generate all
integers from 111 to q−1q-1q−1 through exponentiation. The existence of such roots is
essential for the Diffie-Hellman process.
3. Discrete Logarithm Problem: Given a prime qqq and a primitive root α\alphaα, it is
computationally difficult to find XXX if you only know Y=αXmod qY = \alpha^X \mod
qY=αXmodq. This property underpins the security of the Diffie-Hellman exchange.
Given Parameters
User A computes:
User B computes:
Once the public keys are exchanged, both users compute the shared secret key.
1. For User A:
o A uses B's public key YBY_BYB and A's private key XAX_AXA:
2. For User B:
o B uses A's public key YAY_AYA and B's private key XBX_BXB:
Final Results
Conclusion
The Diffie-Hellman key exchange provides a secure method for two parties to establish a shared
secret key over an insecure channel. In this example, both users A and B successfully computed the
shared secret key K=9K = 9K=9 using their respective private keys and the exchanged public keys. This
process exemplifies the efficiency and security of the Diffie-Hellman algorithm, which remains a
fundamental technique in modern cryptographic systems.
Additional Notes:
This structured approach should cover the necessary details and be suitable for a 15-mark
assessment on the Diffie-Hellman key exchange technique, demonstrating an understanding of the
concepts, computations, and implications of the method.
4o mini
Unit4:
Hash algorithm:
https://www.geeksforgeeks.org/sha-1-hash-in-java/
- **Input Size**: Can accept an input of any length but processes data in blocks of 512 bits (64
bytes).
- **Deterministic**: The same input will always produce the same hash output.
- **Collision Resistance**: It should be infeasible to find two different inputs that produce the same
hash output.
- **Pre-image Resistance**: Given a hash value, it should be infeasible to find an input that hashes
to that value.
SHA-1 consists of several key steps: message padding, parsing the padded message into blocks,
initializing variables, processing the message blocks, and producing the final hash.
1. **Message Padding**:
- The original message is padded so that its length is congruent to 448 modulo 512. This ensures
that the message length is a multiple of 512 bits.
- Padding is done by adding a single '1' bit followed by the necessary number of '0' bits to make the
total length 448 bits. Finally, the original message length (in bits) is appended as a 64-bit integer.
2. **Message Parsing**:
- The padded message is divided into blocks of 512 bits (64 bytes), resulting in multiple 512-bit
blocks.
3. **Initialization**:
- SHA-1 uses five 32-bit variables, initialized to specific constant values (A, B, C, D, E):
- \( A = 0x67452301 \)
- \( B = 0xEFCDAB89 \)
- \( C = 0x98BADCFE \)
- \( D = 0x10325476 \)
- \( E = 0xC3D2E1F0 \)
- The words are expanded into eighty 32-bit words using bitwise operations.
- The core of SHA-1 consists of a series of logical functions and bitwise operations. Each of the 80
rounds applies specific transformations and updates the values of A, B, C, D, and E based on the
message words and constants.
- After processing all blocks, the final hash is obtained by concatenating the values of A, B, C, D, and
E, producing a 160-bit output.
```
+---------------------+
| Input Message |
+---------------------+
+---------------------+
| Message Padding |
+---------------------+
| Parse Message |
| into 512-bit |
| Blocks |
+---------------------+
+---------------------+
| Initialize Hash |
| Variables (A, B, |
| C, D, E) |
+---------------------+
+---------------------+
| (Update A, B, C, |
| D, E) |
+---------------------+
+---------------------+
| Final Hash |
| (A || B || C || D || E) |
+---------------------+
+---------------------+
| Output Hash |
+---------------------+
```
SHA-1 was widely used for many years, but it has been found to have significant vulnerabilities:
2. **Deprecation**: Due to its vulnerabilities, many organizations have moved to more secure hash
functions, such as SHA-256 or SHA-3. As of 2011, NIST has recommended transitioning away from
SHA-1.
### Conclusion
SHA-1 was a pioneering cryptographic hash function that played a significant role in various security
protocols and applications. However, due to its vulnerabilities and the emergence of more secure
alternatives, it is no longer considered safe for cryptographic purposes. Organizations are encouraged
to adopt stronger hash functions to ensure the integrity and security of their data.
### References
For further reading on SHA-1 and cryptographic hash functions, you can refer to:
Authentication functions are crucial components in ensuring the integrity and security of systems by
verifying the identity of users and devices. This analysis classifies authentication functions based on
several criteria, including type, method, principles, use cases, and protocols, providing a
comprehensive understanding of their roles in cybersecurity.
• Password-Based Authentication: This is the most traditional method where users create
passwords to verify their identities. It is widely used but can be susceptible to attacks like
brute-force and phishing.
b. Device Authentication
• Digital Certificates: Devices use digital certificates issued by a trusted Certificate Authority
(CA) to authenticate themselves. This method is common in SSL/TLS communications.
c. Data Authentication
• Message Authentication Codes (MAC): This method ensures both the integrity and
authenticity of a message. A secret key is combined with the message to produce a hash-like
value, which can be verified by the receiver.
a. Synchronous Authentication
• Users must provide the same credentials each time they authenticate. This includes
passwords, PINs, or biometric data. This method can be vulnerable to interception.
b. Asynchronous Authentication
• In this method, the user’s credentials are verified based on a challenge-response mechanism.
For example, the system sends a challenge, and the user responds with the correct answer,
such as a security question or a one-time password.
a. Symmetric Authentication
• Involves shared secret keys between the user and the system. Both parties must keep the key
confidential. Examples include using passwords and symmetric encryption for
authentication.
b. Asymmetric Authentication
• Utilizes a pair of keys: a public key (shared openly) and a private key (kept secret).
Authentication is achieved using digital signatures and certificates. The private key is used for
signing, while the public key is used for verification.
a. Authentication in Networks
• Used to authenticate users and devices in computer networks, such as Wi-Fi authentication
(WPA2), VPN connections, and network devices.
c. Authentication in APIs
• Involves verifying the identity of applications or services accessing an API. Common methods
include API keys, OAuth tokens, and JWT (JSON Web Tokens), which allow for secure
interactions between client and server.
5. Authentication Protocols
a. Challenge-Response Protocols
• Require the user to respond to a challenge issued by the system, preventing replay attacks.
The system generates a challenge that only the legitimate user can answer correctly.
• Protocols like EAP (Extensible Authentication Protocol) and RADIUS (Remote Authentication
Dial-In User Service) are designed to facilitate secure authentication in wireless
environments, ensuring that only authorized devices connect to the network.
• Involves a framework for managing digital certificates and public-key encryption, enabling
secure communication and authentication in distributed environments. PKI provides the
necessary trust model to ensure secure exchanges.
https://www.geeksforgeeks.org/hash-functions-system-security/
A hash function algorithm is designed to take an input (or message) and produce a fixed-size string of
bytes, typically a digest that is unique to each unique input. The design of a hash function focuses on
several key principles and requirements to ensure its effectiveness in various applications, such as
data integrity verification, digital signatures, and password storage. Below are the essential elements
in designing a hash function, along with its features and properties.
1. Deterministic: The same input should always produce the same output. This is essential for
consistency in hash calculations.
2. Fixed Output Size: Regardless of the input size, the output (hash value) should have a
consistent length. Common hash functions like SHA-256 produce a 256-bit (32-byte) output.
4. Pre-image Resistance: Given a hash value, it should be computationally infeasible to find any
input that hashes to that value. This ensures the security of the hash function against reverse
engineering.
5. Second Pre-image Resistance: Given an input and its hash value, it should be
computationally infeasible to find another input that produces the same hash value. This
prevents collisions, where two different inputs yield the same hash.
6. Collision Resistance: It should be computationally infeasible to find two distinct inputs that
produce the same hash output. This property is crucial for maintaining the integrity of data.
7. Avalanche Effect: A small change in the input (even a single bit) should produce a
significantly different hash output. This property ensures that similar inputs do not yield
similar hashes.
8. Uniform Distribution: Hash outputs should be uniformly distributed across the output space,
minimizing the chances of collisions and ensuring that the hash values are randomly spread.
• One-way Function: Hash functions are designed to be one-way, meaning that once data is
transformed into a hash value, it should not be easily reversible.
• Speed: Hash functions should be fast to compute, making them suitable for various
applications, including checksums, data retrieval, and cryptographic operations.
• Compact Representation: They provide a compact representation of the input data, which is
useful for data storage and transmission.
• Resistance to Length Extension: Modern hash functions (like SHA-256) are designed to resist
length extension attacks, ensuring that appending additional data does not compromise the
security of the hash.
1. Determinism: As mentioned earlier, for any given input, the output must be consistent every
time it is computed.
2. Compression: Hash functions compress input data of arbitrary size into a fixed-size hash
output. This makes it easier to handle large datasets.
3. Collision Resistance: This property ensures that it is difficult to find two different inputs that
hash to the same output. While not impossible (due to the pigeonhole principle), good hash
functions make finding such collisions computationally infeasible.
4. Pre-image and Second Pre-image Resistance: These properties safeguard against attempts
to reverse-engineer the input from its hash or find an alternative input with the same hash.
5. Avalanche Effect: The output should change dramatically with even the slightest change in
input, making it difficult to predict the output.
• MD5 (Message Digest Algorithm 5): Produces a 128-bit hash value. While it is fast and
widely used, it is no longer considered secure due to vulnerabilities and collision attacks.
• SHA-1 (Secure Hash Algorithm 1): Produces a 160-bit hash value. SHA-1 has been
deprecated for many applications due to security flaws that make it vulnerable to collision
attacks.
• SHA-2: A family of hash functions that includes SHA-224, SHA-256, SHA-384, and SHA-512.
SHA-256 is widely used in security protocols and is considered secure.
• SHA-3: The latest member of the Secure Hash Algorithm family, which uses a different
underlying structure (Keccak) and offers enhanced security.
Illustrate the steps involved in Signature generation and Verification functions of DSS.
The Digital Signature Standard (DSS) is a widely used method for creating digital signatures to ensure
the authenticity and integrity of messages. It relies on asymmetric cryptography, where a private key
is used for signing, and a public key is used for verification. The most common algorithm used in DSS
is the Digital Signature Algorithm (DSA). Below are the detailed steps involved in signature
generation and verification functions of DSS.
1. Key Generation
o Select Parameters: Choose a large prime number ppp and a prime divisor qqq of
p−1p-1p−1. The number qqq typically has 160 bits.
o Generate Private Key: Randomly select a private key xxx such that 0<x<q0 < x <
q0<x<q.
o Compute Public Key: Compute the public key yyy using the formula: y=gxmod py =
g^x \mod py=gxmodp
2. Message Hashing
o Hash the Message: Use a cryptographic hash function (like SHA-256) to compute the
hash of the message MMM: H(M)=hH(M) = hH(M)=h
3. Signature Generation
o Select Random Integer: Choose a random integer kkk such that 0<k<q0 < k <
q0<k<q. This value must be kept secret and should not be reused.
o Generate the Signature: The digital signature (r,s)(r, s)(r,s) is the pair of values
calculated above.
o The verifier receives the original message MMM and the digital signature (r,s)(r,
s)(r,s).
3. Signature Validation
o Check Signature Validity: Verify that rrr and sss are in the valid range, i.e., 0<r<q0 < r
< q0<r<q and 0<s<q0 < s < q0<s<q.
o Compute the Modular Inverse: Calculate the modular inverse of sss modulo qqq:
s−1mod qs^{-1} \mod qs−1modq
o Calculate vvv:
4. Compare Values
o The signature is valid if and only if: v≡rmod qv \equiv r \mod qv≡rmodq
o If vvv equals rrr, the signature is valid, confirming that the message was not altered
and was signed by the holder of the private key.
Summary
The steps involved in the signature generation and verification functions of DSS demonstrate how
digital signatures ensure message authenticity and integrity through the use of asymmetric
cryptography. The process includes key generation, message hashing, signature creation, and
verification, highlighting the mathematical operations that provide security and reliability in digital
communications.
https://www.geeksforgeeks.org/digital-signature-standard-dss/
Illustrate the approaches for Digital signature.
Digital signatures provide a means of ensuring the authenticity and integrity of digital messages or
documents. They rely on cryptographic techniques, specifically asymmetric cryptography, to validate
the identities of the signers and verify that the content has not been altered. There are several
approaches to implementing digital signatures, each with its unique methods and algorithms. Below
are the key approaches to digital signatures:
Description: PKI is a framework that uses asymmetric cryptography for creating digital signatures and
managing keys. It involves a trusted third party called a Certificate Authority (CA) that issues digital
certificates to users.
• Components:
o Public and Private Keys: Each user has a pair of keys. The private key is used to sign
the document, while the public key is used to verify the signature.
o Certificate Authority (CA): The CA issues digital certificates that bind the public keys
to user identities, ensuring trust.
• Process:
1. The signer generates a key pair and obtains a digital certificate from the CA.
2. The signer uses the private key to create a signature on the message.
3. The recipient uses the public key from the signer’s certificate to verify the signature.
• Example: Commonly used in secure web communications (HTTPS), email signing (S/MIME),
and document signing (PDF signing).
Description: This approach combines a cryptographic hash function with asymmetric encryption to
create a digital signature. The hash of the message is signed rather than the message itself.
• Components:
o Cryptographic Hash Function: A function that converts an input (or message) into a
fixed-size string of bytes. Common examples include SHA-256 and SHA-3.
• Process:
2. The hash is encrypted using the signer’s private key to create the digital signature.
3. The recipient computes the hash of the received message and decrypts the signature with
the signer’s public key.
Description: This approach allows specific computations to be performed on the signed data without
requiring access to the private key. Homomorphic signatures enable verifying computations on
encrypted data.
• Components:
o Signature Scheme: The digital signature is generated in such a way that it can be
verified even after computations have been performed on the signed data.
• Process:
2. The data can be manipulated while still being encrypted, and a new signature can be
generated for the results without needing the private key.
3. Verification of the resulting signature is possible without revealing the original data or keys.
• Example: Useful in cloud computing environments where data privacy must be maintained
while performing operations on that data.
Description: This scheme allows a group of users to jointly create a digital signature such that a
predefined threshold of participants is required to generate the signature.
• Components:
• Process:
1. Each participant generates their part of the private key and keeps it secret.
3. The resulting signature can be verified with the public key derived from the combined public
shares.
• Components:
• Process:
• Example: Ongoing research and standardization efforts are focused on developing post-
quantum digital signature algorithms to replace vulnerable systems.
• Message authentication functions are vital cryptographic techniques that ensure the
integrity and authenticity of a message by verifying that the data has not been altered and
comes from a legitimate sender. These functions are widely used in communication
protocols, digital transactions, and secure data transmissions to protect against
unauthorized tampering or forgery.
• Hash Functions
• Digital Signatures
•
• 1. Hash Functions
• Key Characteristics:
• Deterministic: For a given input, the hash function will always produce the same output.
• Fixed Output Size: Regardless of the input size, the output length (digest) is fixed (e.g., 128
bits, 256 bits).
• Collision Resistance: It should be hard to find two different inputs that produce the same
hash.
• Common Examples:
• MD5 (Message Digest Algorithm 5): Produces a 128-bit hash, but is no longer considered
secure.
• Hash functions are used in applications like checksums, data integrity verification, and
digital signatures.
•
• 2. Message Authentication Code (MAC)
• Working:
• Sender: Computes the MAC of the message using a shared secret key and sends both the
message and the MAC to the receiver.
• Receiver: Uses the same shared key to generate the MAC from the received message and
compares it to the transmitted MAC.
• If the MACs match, the message is authentic and unaltered. If they don't, the message may
have been tampered with.
• Types of MACs:
• HMAC (Hash-based Message Authentication Code): Uses a hash function (e.g., SHA-256) in
combination with a secret key. HMAC provides strong security properties and is resistant to
certain cryptographic attacks.
• CBC-MAC (Cipher Block Chaining MAC): Uses a block cipher (e.g., AES) in Cipher Block
Chaining (CBC) mode to generate the MAC.
• Example:
• HMAC-SHA256: Uses the SHA-256 hash algorithm to compute the MAC based on a secret
key and the message.
• MACs are used in authentication protocols, secure file transfers, banking transactions, and
VPNs.
•
• 3. Digital Signatures
• A Digital Signature is a cryptographic function that verifies the authenticity and integrity of
a message using asymmetric (public-key) cryptography. Unlike MACs, which use a shared
secret key, digital signatures use a pair of keys (public and private keys) to achieve non-
repudiation—the sender cannot deny having sent the message.
• Working:
• Signing: The sender generates a signature using their private key and the message (usually
by first hashing the message and then encrypting the hash with the private key).
• Verification: The receiver verifies the signature using the sender's public key. If the
signature is valid, the message is authentic and unaltered.
• Steps:
• The hash is encrypted with the sender's private key to form the signature.
• The receiver decrypts the signature using the sender's public key to retrieve the hash.
• The receiver hashes the received message and compares the two hashes. If they match,
the signature is valid.
• Common Algorithms:
• Digital signatures are widely used in secure email (PGP), digital certificates (SSL/TLS),
electronic voting, and blockchain technology.
•
• Comparison of Message Authentication Functions
• Hash
• Feature • MAC • Digital Signature
Function
• Uses
• No secret • Requires a shared
• Key Usage public/private key
key secret key
pair
• Non-
• No • No • Yes
repudiation
• Moderate
(asymmetric
• Efficiency • High • High
encryption is
slower)
Partc unit4:
1)
Here’s a detailed explanation of the SHA-512 algorithm, including its design, steps, features,
properties, and a diagram, suitable for a 20-mark question.
SHA-512 Overview
SHA-512 (Secure Hash Algorithm 512-bit) is part of the SHA-2 family designed by the National
Security Agency (NSA). It is a cryptographic hash function that produces a 512-bit (64-byte) hash
value from an input message of arbitrary length, providing integrity and authenticity for data.
• Security Level: Designed to be secure against preimage attacks, second preimage attacks,
and collision attacks.
1. Preprocessing
o The original message is padded to ensure its length is 896mod 1024896 \mod
1024896mod1024.
o Padding is done by appending a single '1' bit followed by enough '0' bits so that the
total length is 896896896 bits before the length encoding.
Example: For a message of length 448 bits, the padded message would be:
2. Initialization:
o Initialize eight hash values (H) using the first 64 bits of the fractional parts of the
square roots of the first 80 prime numbers.
H0=0x6a09e667f3bcc908,H1=0xbb67ae8584caa73b,H2=0x3c6ef372fe94f82b,H3=0xa54ff53a5f1d36f
1,H_0 = 0x6a09e667f3bcc908, H_1 = 0xbb67ae8584caa73b, H_2 = 0x3c6ef372fe94f82b, H_3 =
0xa54ff53a5f1d36f1,H0=0x6a09e667f3bcc908,H1=0xbb67ae8584caa73b,H2
=0x3c6ef372fe94f82b,H3=0xa54ff53a5f1d36f1,
H4=0x510e527fade682d1,H5=0x9b05688c2b3e6c1f,H6=0x1f83d9abfb41bd6b,H7=0x5be0cd19137e2
179H_4 = 0x510e527fade682d1, H_5 = 0x9b05688c2b3e6c1f, H_6 = 0x1f83d9abfb41bd6b, H_7 =
0x5be0cd19137e2179H4=0x510e527fade682d1,H5=0x9b05688c2b3e6c1f,H6
=0x1f83d9abfb41bd6b,H7=0x5be0cd19137e2179
3. Compression Function
1. Initialize Variables:
2. Main Loop:
o Where KtK_tKt are constants derived from the first 64 prime numbers and ChChCh
and MajMajMaj are:
• Concatenate the final hash values to produce the 512-bit message digest:
Below is a detailed diagram illustrating the main components and steps of the SHA-512 algorithm:
plaintext
Copy code
+-------------------------------+
| Input Message |
+-------------------------------+
+-------------------------------+
| Preprocessing |
+-------------------------------+
+-------------------------------+
+-------------------------------+
+-------------------------------+
+-------------------------------+
+-------------------------------+
| Message Schedule |
| (Extend to 80 words) |
+-------------------------------+
+-------------------------------+
| Compression Function |
| (80 Rounds) |
+-------------------------------+
+-------------------------------+
| (512-bit Hash) |
+-------------------------------+
Features of SHA-512
1. Collision Resistance: It is computationally infeasible to find two different inputs that produce
the same hash output.
2. Preimage Resistance: Given a hash output, it should be hard to find an input that hashes to
that output.
3. Second Preimage Resistance: Given an input and its hash output, it should be hard to find a
different input that produces the same hash output.