0% found this document useful (0 votes)
53 views30 pages

IT Security - Hash

The document discusses message authentication and integrity checks. It describes different types of network attacks and explains how message encryption, hash functions, and keyed hash functions can be used for authentication and integrity. It also discusses properties like collision resistance and provides examples of hash functions like MD4, MD5, SHA-1, and RIPEMD-160.

Uploaded by

pupu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views30 pages

IT Security - Hash

The document discusses message authentication and integrity checks. It describes different types of network attacks and explains how message encryption, hash functions, and keyed hash functions can be used for authentication and integrity. It also discusses properties like collision resistance and provides examples of hash functions like MD4, MD5, SHA-1, and RIPEMD-160.

Uploaded by

pupu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Message Authentication

and Integrity Check

1
Network Attacks
1. Disclosure
2. Traffic analysis
3. Masquerade
4. Content modification
5. Sequence modification
6. Timing modification
7. Source repudiation
8. Destination repudiation

2
Integrity, not secrecy
n First two concern the protection of message content
(secrecy) dealt with by encrypting the message.
n Points 3-6 refer to modifications: how to prevent
message modification without noticing (integrity),
and to confirm the identity of the sender.
n Generically this is the problem of message
authentication
n in some applications (e.g.; e-commerce) it is arguably more
important than secrecy, to which it is orthogonal.
n 7 is solved with digital signatures
n 8 with combination of signatures and protocol design

3
Message Authentication
n message authentication is concerned with:
n verifying the integrity of a message
n validating the identity of the originator
n non-repudiation of origin (dispute resolution)
n three alternative approaches used:
1. message encryption (as for secrecy)
2. hash function
3. keyed hash functions (also called MAC)

4
1. Message Encryption
n message encryption, used mainly for
confidentiality, also provides a measure of
authentication
n if symmetric encryption is used then:
n receiver knows sender must have created it since
only sender and receiver know the key used
n content cannot have been altered by party not
knowing key
n if message has suitable structure, redundancy or a
checksum used to detect any changes
5
1. Message Encryption (cont.)

n if public-key encryption is used:


n encryption provides no confidence in the sender since
anyone potentially knows public key (public !)
n however if
n sender signs (encrypts) message using his/her private-key
n then encrypts result with recipient’s public key
n have both secrecy (by public) and authentication (by private)
n again need to recognize corrupted messages
n but at cost of two public-key uses on message

6
2. Cryptographic Checksums
n Also known as hash functions
n Mathematical function to generate a set of k
bits from a set of n (>=k) bits (in general,
from arbitrary length to fixed length, hence
necessarily non-injective).
n Example: ASCII parity bit
n ASCII has 7 bits; 8th bit is “parity”
n Even parity: even number of 1 bits
n Odd parity: odd number of 1 bits

7
Checksums
n The result of applying a hash function is called
hash value, message digest, or checksum.
n The last term creates frequent confusion because
in communications, checksums often refer to error
correcting codes, typically a cyclic redundancy
check (CRC).
n Checksums used by anti-virus products, on the
other hand, are not computed with a CRC but with
a cryptographic hash function.

8
Definition
Cryptographic checksum h: A®B :
1. For any x Î A, h(x) is easy to compute
2. For any y Î B, it is computationally infeasible
to find x Î A such that h(x) = y [one-way]
3. It is computationally infeasible to find two
inputs x, x¢ Î A such that x ≠ x¢ and h(x) =
h(x¢)
– Alternate form (stronger): Given any x Î A, it is
computationally infeasible to find a different x¢ Î A
such that h(x) = h(x¢).

9
Example: Integrity Protection

n To protect a program p, compute its hash h(p) in a


clean environment and store it in a place where it
cannot be modified, e.g. on CD-ROM.
n Protection of the hash value is important; computing
the hash value requires no secret information, so
anybody can create a valid hash for a given file.
n To check whether the program has been modified,
re-compute the hash value and compare it with the
value stored.

10
Collisions
n The Integrity protection example described needs
more than the one-way property of h.
n not concerned about an attacker reconstructing the
program from the hash, but concerned about
attackers who can change a program p to p’ so that
h(p’) = h(p).
n Then, our integrity protection mechanism would fail
to detect the change.
n there is a collision when two inputs x and x’ map to
the same hash value.

11
Collisions
n If x ≠ x¢ and h(x) = h(x¢), x and x¢ are a
collision
n Pigeonhole principle: if there are n containers

for n+1 objects, then at least one container


will have 2 objects in it.
n Application: if there are 25 files and 8 possible
cryptographic checksum values, at least one value
corresponds to at least 4 files

12
Collision Resistance
n Integrity protection requires collision-resistant hash
functions
n distinguish between:
n 2nd pre-image resistance (weak collision resistance):
given a value h(x), it is computationally infeasible to
find another input x’, x ≠ x’’, with h(x) = h(x’).
n Collision resistance (strong collision resistance): it is
computationally infeasible to find any two inputs x and
x’, x ≠ x’, with h(x) = h(x’).

13
Properties of One-way Functions

x ? x x’ x ? ? ?

h(x) h(.) h(x) h(x) h(.)

ease of pre-image collision 2nd pre-image collision


computation resistance resistance resistance

14
Birthday Paradox
n How difficult is it to find collisions?
n It depends on the bit-length of the hash
n Given an n-bit hash y, the expected number of tries before
an x with h(x) = y is found is 2n-1.
n Given n-bit hash values, a set of 2n/2 inputs is likely to
contain a pair causing a collision.
n Birthday paradox:
n put m balls numbered 1 to m into an urn;
n draw a ball, list its number, put it back;
n repeat;
n for m® ¥, the expected number of draws before a previously
drawn number appears is sqrt(pm/2).
15
Chances of Success
n Given a hash function which generates 64-bit digest (n = 264),
randomly distributed and diffused
n Chance that a randomly chosen message maps to a given hash value
is 1 in n or 2-64 : seems secure
n but by birthday attack it is not: (digest of size m)
m/
n opponent generates 2 2 variations of a valid message, all with

essentially the same meaning


m/
n opponent also generates 2 2 variations of a desired fraudulent

message
n two sets of messages are compared to find pair with same hash

(probability > 0.5 by birthday paradox)


n have user sign the valid message, then substitute the forgery

which will have a valid signature


16
Manipulation Detection Codes
n Manipulation detection code (MDC, also modification
detection code, message integrity code) is used to detect
changes to a document.
n Two types:
n One-way hash function (OWHF): ease-of-computation,
compression, pre-image resistance, and 2nd pre-image
resistance.
n Collision resistant hash function (CRHF): compression,
ease-of-computation, 2nd pre-image resistance, and
collision resistance.

17
Block Ciphers as Hash Functions
n can use block ciphers as hash functions
n using h0=0 and zero-pad of final block
n compute: hi = Exi [hi-1]
n and use final block as the hash value
n similar to DES-CBC but without a key
n resulting hash is too small (64-bit)
n due to direct birthday attack
n other variants also susceptible to attack

18
Construction

x1 x2 xm

h0 h1 h2 … hm-1 hm
f f f

initial hm=h(x)
value
19
Frequently Used Hash Functions

n MD4: weak, it is computationally feasible to find


meaningful collisions.
n MD5: (early 90s) standard choice in Internet
protocols, broken and no longer recommended.
n 128 bit message digest
n 64 bits birthday attack
n RIPEMD-160: (late 90s) hash function
frequently used by European cryptographic
service providers.
20
MD4 family of hash functions
MD4

MD5 SHA HAVAL RIPEMD

SHA-1 RIPEMD-128 RIPEMD-160

SHA-224 SHA-256 SHA-384 SHA-512

21
Non-keyed Message Digest Algorithms
n SHA-1 (Secure Hash Algorithm) by NIST
n 160 bit message digest
n used for US Digital Signature Standard (DSA);
n 80 bits birthday attack (65K longer time)(broken Feb 2005, with
collision in 2**69 instead of 2**80)
n After 2010 usable only for HMACs, KDFs and RNGs
n SHA-2 Family by NIST (2006) , block cipher based, not
used much
n SHA-3 winner of competition in 2012, NIST standard in
2015, permutation based
n BLAKE (-2) another finalist in 2012, 256 and 512 output
n SHA-256 -384 or -512 when longer hash values are
advisable.
22
3. MAC and its Properties
n a MAC is the value of a keyed cryptographic checksum
n condenses a variable-length message M to a fixed-
sized “authenticator” using a secret key K
n Since a cryptographic checksum is a many-to-one
function, potentially many messages may have the same
MAC but finding these needs to be very difficult
n needs satisfy the following:
§ knowing a message and MAC, it is unfeasible to find
another message with same MAC
§ MAC values should be uniformly distributed
§ MAC should depend equally on all bits of the message
23
Definition: authentication
n Authentication algorithm - A
n Verification algorithm - V (“accept” / ”reject”)
n Authentication key - k
n Message space - usually binary strings
n Messages between Alice and Bob are pairs (m,
Ak(m)) consisting of a message m (to be
authenticated) and an authentication tag Ak(m)
for m

24
Definition (cont.)
n Requirement - Vk(m, Ak(m)) = “accept”
n The verification consists of applying the

authentication algorithm to m and comparing the


result to Ak(m)
n The authentication algorithm is sometimes called

MAC (Message Authentication Code)


n Ak(m) is often denoted by MACk(m)

n In the context of public key, the function A uses a


private key and the function V the corresponding
public key Vkpub(m, Akpriv(m)) = “accept”
25
Symmetric Ciphers for MACs
n can use any block cipher in chaining mode and use
the final block as a MAC
n Data Authentication Algorithm (DAA) was a
widely used MAC based on DES-CBC
n using IV=0 and zero-pad of final block
n encrypt message using DES in CBC mode
n and send just the final block as the MAC
n or the leftmost M bits (16≤M≤64) of final block
n but final MAC is (again) too small for security
n Idea can be used with any symmetric block cipher
26
Symmetric Ciphers to combine
Secrecy and Integrity
Given a message M consisting of n blocks M1, M2, …Mn,
n use CBC with secret key k1 to produce MACk1(M) as
the final block
n using CBC with a different key k2, produce the
ciphertext blocks C1, C2, …, Cn
n Send the blocks C1, C2, …, Cn and the authentication
tag MACk1(M)

Question: why is it necessary to use two different keys?


What could happen if the same key were used for
both? (Exercise)

27
Current Generation MAC
n HMAC-MD5, HMAC-SHA
n IETF standard
n general technique for constructing a MAC from a
message digest (unkeyed) algorithm
n Older MACs are based on secret key
encryption algorithms (notably DES) and are
still in use
n DES based MACs are 64 bit and not considered
strong enough anymore

28
HMAC (proposed late 90s)
n Make keyed cryptographic checksums using keyless
cryptographic checksums
n h keyless cryptographic checksum function that takes data
in blocks of b bytes and outputs blocks of l bytes. k¢ is
cryptographic key of length b bytes
n If short, pad with 0 bytes; if long, hash to length b

n ipad is 00110110 repeated b times

n opad is 01011100 repeated b times

n HMAC-h(k, m) = h(k¢ Å opad || h(k¢ Å ipad || m))


n Å exclusive or, || concatenation

29
Security of HMAC
n Depends heavily on size of secret key
n Most common attack brute force
n Simpler version MAC-h(k, m) = h(k || m) suffers from
collision attacks
n Unless the function h is SHA-3
n Same for MAC-h(k, m) = h(k || m || k)
n Values of ipad and opad not critical but chosen for their
large Hamming distance (few bits in common between
outer and inner key)
n HMAC-MD5 does not suffer from shortcomings of MD5

30

You might also like