Title: Applied Cryptography
1Applied Cryptography
- Secure Hashes and their Uses
2Hash Functions
- Take an input from a large domain and return an
output in a smaller range - Easy to compute
3Hash Example
4Secure Hashes
- One-Way
- Given f(x), hard to find x.
- Collision-Free
- Hard to find x and y so that f(x)f(y)
- Hard to bias output
- Hard to generate a set xi so that we can
differentiate between f(xi) and f(U) where U is
a uniformly distributed input.
5Secure Hashes Example
- No proven secure hashes exist!
- Not even one-way functions are known to exist!
- If a one-way function exists P?NP
6Practical Secure Hashes
- Standards
- MD5(Message Digest)
- SHA-1(Secure Hash Algorithm)
Diagram of a SHA-1 round.
7Uses for Secure Hashes
- Message Authentication Checksums
- Prevent an attacker from changing messages
- Faster Digital Signatures
- Faster Bit-Commitment Schemes
- Pseudo-Random Number Generators
- (Not covered in this lecture)
8Simple Message Authentication
- Send a hash via another channel
10101001010101010101010101101010100010101010010
100011010010101010
Alice
Bob
Bulletin Board
SHA-1
100010010101100011
9Cryptographic Authentication
10101001010101010101010101101010100010101010010
100011010010101010
Alice
Bob
Shared Secret
SHA-1
100010010101100011
10Digital Signatures Problem
- Operations on big numbers are slow
- exponentiation
- multiplication
- RSA can only sign messages up to the keysize (a
few thousand bits) - To sign long messages using RSA we have divide
the message and sign many times - The signature is as long as the message
11Digital Signatures Solution
- Sign a secure hash of the message instead
- Advantages
- Hashing is fast
- We only have to perform RSA once
- The size of the signature is constant
12Digital Signatures Diagram
Message
101011101010101010
101011101010101010
SHA-1
010001
101011
101010
101010
RSA
RSA
RSA
RSA
010101
001010
001110
111001
010101001010001110
Signature
13Bit Commitment - Suggestion1
Commitment
SHA-1
Alice
Bob
01001
1
Unveiling
Alice
Bob
1
14Bit Commitment - Suggestion2
Commitment
Alice
Bob
Unveiling
101110100
Alice
Bob
1
15Bit Commitment - Assumptions
- Hash is one way and collision-free
- Alice is computationally bounded
- Hash doesnt leak information
- Example of a leaky hash
SHA-1
101110100
1001
1
1
16Bit Commitment - Protocol
- Due to Shai Halevi and Silvio Micali
- Requires only collision-free property
Universal Hash
SHA-1
Alice
Bob
01001
1
01001010001
11010101
17Using Secure Hashes in Java
- Java has a MessageDigest class
- import java.security.
- Implementations for MD5 and SHA-1 are included
18MessageDigest Class
- getInstance(String)
- Generates a MessageDigest object that implements
the specified digest algorithm. - update(byte)
- Updates the digest using the specified byte.
- update(byte)
- Updates the digest using the specified array of
bytes. - update(byte, int, int)
- Updates the digest using the specified array of
bytes, starting at the specified offset.
19- digest()
- Completes the hash computation by performing
final operations such as padding. - digest(byte)
- Performs a final update on the digest using the
specified array of bytes, then completes the
digest computation. - The DigestInputStream and DigestOutputStream can
also be used to update a MessageDigest object
while input is being read or written.
20DigestInputStream
public DigestInputStream(InputStream stream,
MessageDigest digest)
Creates a digest input stream, using the
specified input stream and message digest.
Parameters stream - the input stream.
digest - the message digest to associate
with this stream
- The read method can be used to read bytes from
the input stream. - The digest is automatically updated as bytes are
read. - The digest can be switched off if necessary.
21DigestOutputStream
- The DigestOutputStream is the analogous stream
for updating a digest as you write to an output
stream, using the write() methods. - The Documentation for the class is available on
line at - http//java.sun.com/products/jdk/1.1/docs/api/java
.security.DigestOutputStream.html - For more information on how input and output
streams work, look at - http//java.sun.com/docs/books/tutorial/essential/
io/index.html
22Available Digests
- SHA-1
- MessageDigest.getInstance(SHA)
- MD5
- MessageDigest.getInstance(MD5)
23Further Reading
- Bit-Commitment with Secure Hashes
- http//citeseer.nj.nec.com/halevi96practical.html
- SHA-1 Specification
- http//www.itl.nist.gov/fipspubs/fip180-1.htm
- MD5 Specification (rfc1321)
- http//andrew2.andrew.cmu.edu/rfc/rfc1321.html
- Keyed Hashes HMAC
- http//www-cse.ucsd.edu/users/mihir/papers/hmac.ht
ml