Hash functions
A message's digest, the three resistances (preimage, second preimage, collisions), the avalanche effect, the birthday paradox and digest size, broken and recommended functions, file integrity and HMAC.
- 35 cards
- 6 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- The numbers
- Scenarios
- Understand
A few cards from the deck
Cryptographic hash function: what is it?
Show the answer
A public function that turns a message of any size into a fixed-size digest, easy to compute but infeasible to invert in practice.
No key is involved: anyone computes the same digest from the same message. SHA-256 always gives 256 bits, whether the input is one byte or one gigabyte.
What size is the digest of these two messages?
```python
import hashlib
a = hashlib.sha256(b"a").hexdigest()
b = hashlib.sha256(b"a" * 1000000).hexdigest()
print(len(a), len(b))`64 641 1000000256 25632 32
Show the answer
64 64SHA-256 always gives 256 bits, that is 32 bytes, which
hexdigest()writes as 64 hexadecimal characters (4 bits each), whatever the input size. With MD5 it would be 32 characters.A cryptographic hash function is …: the same message always gives the same digest, and its size is ….
Show the answer
A cryptographic hash function is deterministic: the same message always gives the same digest, and its size is fixed.
Otherwise two digests could not be compared to check a file. SHA-256 digests are always 256 bits.
Preimage resistance: what is it?
Show the answer
A property of a hash function: given a digest, it is out of reach to find any message that produces it.
Against an n-bit digest, the generic attack tries about 2 to the power n messages. For SHA-256, that is 2 to the power 256 tries.