Lec 23-26 Hash Functions
Lec 23-26 Hash Functions
2. Fast Computation: Computing the hash value for any data should be efficient.
Hash functions vary based on design, complexity, and use cases. Some
of the most common cryptographic hash functions include
• MD5 (Message Digest Algorithm 5): Produces a 128-bit hash, but due to
vulnerabilities, it is not considered secure today.
• BLAKE2: Designed to be faster than MD5, SHA-1, and SHA-2, and it's efficient
in software.
Applications of Hash Functions
1. Data Integrity Verification: Hash values can verify that data hasn’t been altered
during transmission. For instance, file downloads often come with hash values to
check if the file is corrupted or tampered with.
2. Digital Signatures: In public key cryptography, hash functions are used to create
digital signatures. The message is hashed, and the hash is then encrypted with the
sender’s private key, ensuring the message’s authenticity.
• Birthday Attacks: Based on the birthday paradox, this attack exploits the
probability of finding two inputs with the same hash value.
• Length Extension Attacks: This applies to certain hash functions (like MD5 and
SHA-1) when used inappropriately. It allows an attacker to predict the hash of a
concatenated message if the hash and message length are known.
Practical Example in Python
• import hashlib
• hash_object = hashlib.sha256(message.encode())
• hash_hex = hash_object.hexdigest()
• SHA-256 hash of a message with the avalanche effect – small changes to input drastically change output
Practical Example in Python (Output)
• Original Message: Hello, Info Security Class
• SHA-256 Hash:
1db9ceeabc0c845441ed419ef1f7f9a47f2df7bcf8a7adf3d299d577a52ec15d
Summary
• Hash functions are crucial for security and data integrity.
• Used across applications in cryptography, blockchain, password
security, and digital signatures.
• Choosing secure hash functions and using them properly is essential to
avoid vulnerabilities.
Summary
• Hash functions are crucial for security and data integrity.
• Used across applications in cryptography, blockchain, password
security, and digital signatures.
• Choosing secure hash functions and using them properly is essential to
avoid vulnerabilities.
SHA-1 (Secure Hash Algorithm 1)
• SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by
the National Security Agency (NSA) and published by the National Institute of
Standards and Technology (NIST) in 1993.
• SHA-1 was widely adopted and used for secure communications, data integrity,
and digital certificates until vulnerabilities were discovered.
Properties of SHA-1
• SHA-1 was initially favored due to the following properties:
1. Fixed Output: Produces a 160-bit (20-byte) hash regardless of input size.
2. Deterministic: The same input will always result in the same hash.
3. Fast and Efficient: Designed for speed and low computational requirements.
4. Avalanche Effect: A small change in input results in a significantly different
hash output.
• However, these properties are now overshadowed by its vulnerabilities to collision
attacks.
Working of SHA-1
1. Input Padding:
o The input message is padded to ensure its length is a multiple of 512 bits. Padding adds a "1" bit
followed by zeros and the message length as a 64-bit integer.
2. Initialization:
3. Processing:
o The algorithm processes data in blocks of 512 bits (64 bytes) in 80 rounds. Each round uses bitwise
operations, shifts, and constants to modify the variables.
4. Output:
• After processing, the variables A, B, C, D, and E are combined to produce a final 160-bit hash output.
SHA-1 Use Cases
1. Digital Signatures and Certificates:
o SHA-1 was commonly used in digital certificates to verify the authenticity of public keys.
2. Birthday Attack:
o This attack exploits the probability that, with enough attempts, two different
inputs will produce the same hash due to the birthday paradox. In SHA-1, a
collision can be found with a complexity of 2632^{63}263 operations.
Vulnerabilities and Attacks on SHA-1
3. SHAttered Attack (2017):
o Google and the CWI Institute in Amsterdam announced a successful collision
attack on SHA-1, known as SHAttered.
o This attack demonstrated that two different PDF files could produce the same
SHA-1 hash, undermining the algorithm’s reliability in practical applications.
SHA-1 Deprecation and Transition to Secure
Alternatives
Due to its vulnerabilities, major standards bodies, software companies, and security protocols have
deprecated SHA-1:
1. Digital Certificates:
o In 2014, web browsers and certificate authorities (CAs) began deprecating SHA-1 for digital
certificates. SHA-2 and SHA-3 are now the standard.
• SHA-3:
o Designed by a third party, SHA-3 uses a different structure (Keccak) and is less vulnerable to
the types of attacks affecting SHA-1 and SHA-2.
• Summary
• SHA-1 was a widely used hash function that provided security for
years, but its collision vulnerabilities have led to its deprecation.
• Modern cryptographic applications have transitioned to SHA-2 and
SHA-3, which are more secure against modern computational attacks.