Chapter4
Chapter4
Chapter4
2
Outline
• Secure Hash Algorithms
• Message Authentication Code
3
Review of symmetric cryptography
• Confidentiality:
– Block ciphers using encryption modes.
– Stream ciphers using pseudo-random number
generators.
• Limitations:
– Secure channel for key distribution.
– Many keys for n users.
• Solution: public key cryptography.
4
Motivation
• Alice wants to send a secret message (m) to Bob using his public key.
• Oscar intercepts and replaces the message with his own data (m*).
• Bob encrypts the response with Oscar’s public key.
• Oscar decrypts the message and gets the secret data!
• Confidentiality is not enough!
5
Hash function
• Takes as input a variable-length message and produces a
fixed-length hash value (a.k.a message digest) based on a
compression function.
• It is defined by the following expression:
h : {0, 1}∗ → {0, 1}n
• For example, hello world →
b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
• It has the following properties:
– Computation of the hash value should be easy
– Inversion of the hash value should be difficult (preimage
resistant)
– Collision-resistant
6
Avalanche effect
• It is an important property for the design of
cryptographic algorithms, typically block
ciphers and hash functions.
• Refers to changing one bit of the plaintext or
the key should change half of the bits in the
ciphertext.
• A good cryptographic algorithm should satisfy
an avalanche effect > 50%
7
Applications
• Message integrity verification.
• Password verification (database).
• Message authentication code (MAC).
• Digital signatures.
• Pseudo-random number generators (PRNG).
• Blockchain (proof of work).
8
Common examples
• MD-x family:
– MD4 : 1990, Broken
– MD5 : 1992, Broken
• SHA-x family:
– SHA-0 , 1993, Broken
– SHA-1 , 1995, Theoretically Broken in 2005
– SHA-2 , 2002
– SHA-3, 2015, still have to test
9
Merkle-Damgard construction
• How do we build a hash function?
• Maps a compression function into a
cryptographic hash function by:
– Applying padding to the original message.
– Dividing the padded message to fixed size blocks.
– Iterating a compression function over each block
starting from an initial value.
10
Compression function
12
SHA-1
13
Message authentication code
• It is a keyed hash function that takes a
variable-length message and a fixed-size
secret key and produces a fixed message
digest.
• It can be defined by the following expression:
y = h(m, k)
• It aims to ensure both the source of the
message and its integrity.
14
15