Cryptography 10
Cryptography 10
Spring 2006
http://www.abo.fi/~ipetre/crypto/
Ion Petre
Academy of Finland and
Department of IT, Åbo Akademi University
Goal here: having received a message one would like to make sure that the
message has not been altered on the way
Produce a short sequence of bits that depends on the message and on a secret key
To authenticate the message, the partner will compute the same bit pattern, assuming
he shares the same secret key
This does not necessarily includes encrypting or signing the message
The message can be sent in plain, with the authenticator appended
This is not a digital signature: the receiver can produce the same MAC
One may encrypt the authenticator with his private key to produce a digital signature
One may encrypt both the message and the authenticator
Possible attacks on message authentication:
Content modification
Sequence modification – modifications to a sequence of messages, including
insertion, deletion, reordering
Timing modification – delay or replay messages
Main idea here: the message must have come from A because the ciphertext can be
decrypted using his (secret or public) key
Also, none of the bits in the message have been altered because an opponent does not
know how to manipulate the bits of the ciphertext to induce meaningful changes to the
plaintext
Conclusion: encryption (either symmetric or public-key) provides authentication as well
as confidentiality
To generate the MAC of a message M, Alice gives M and the secret key K to a MAC
function C: MAC=CK(M)
Alice will send M plus the MAC to Bob
Bob has the same secret key K and generates the MAC himself to check the match
Typical attacks on MACs
Produce an illegitimate message with the same signature as a given (or chosen) legitimate one
Produce a valid MAC for an illegitimate message
Requirements for MACs
The MAC function is in general many-to-one – messages are arbitrarily long and the MAC has
fixed length, thus there will be more than one message with the same MAC
Computationally easy to compute the MAC
Knowing M and CK(M) it is computationally infeasible to construct another message M’ with
CK(M’)= CK(M)
CK(M) is uniformly distributed – if the attacker chooses a random bit pattern of length n, the
chances of it being the correct signature is 2-n
If M’ is obtained from M by certain transformations (even switching one bit), then the probability
that the two have the same MAC is 2-n
One of the most widely used MACs – ANSI standard X9.17, also FIPS
PUB 113
Cipher block chaining mode of DES with an initialization vector of zero
Message to be authenticated is grouped into 64-bit blocks, last block padded
with 0: D1,D2, …, DN
O1=EK(D1), O2=EK(D2⊕O1), O3=EK(D3⊕O2), …, ON=EK(DN⊕ON-1)
MAC is ON or a part of it, e.g., its 32 leftmost bits
a. Classical encryption
of message+hash
d. Hash is encrypted
with an asymmetric
system, then a second
encryption is applied
e. No encryption here
but the hash is
applied to a message
where a secret text S
has been appended
Suppose a hash value on 64 bits is used (as the one based on DES)
In principle this is secure: to find a message M’ with H(M)=H(M’), one apparently has
to generate in average 263 messages M’
A different much more effective attack is possible
A is prepared to sign the document by appending its hash value (on m bits) and then
encrypting the hash code with its private key
E will generate 2m/2 variations of the message M and computes the hash values for
all of them
E also generates 2m/2 variations of the message M’ that she would really like to have
A authenticating and computes the hash values for all of them
By the birthday paradox, the probability that the two sets of hash values have one
element in common is more than 0.5 – she finds M and M’ with the same hash values
(messages expressing totally different things!)
E will offer M to A for hashing and then signing
E will send instead M’ with the signature A has produced
E breaks the protocol although she does not know A’s private key!
Level of effort for the hash based on DES: 233
MD5
SHA-1
Most popular hash algorithm until very recently – concerns for its
security were raised and was proposed to be replaced by SHA-1
Developed by Rivest at MIT
For a message of arbitrary length produces an output of 128 bits
Processes the input in blocks of 512 bits
Idea:
Start by padding the message to a length of 448 bits modulo 512 –
padding is always added even if the message is of required length; the
length of the message is added on 64 bits so that altogether the length
is a multiple of 512 bits
Several rounds, each round takes a block of 512 bits from the message
and mixes it thoroughly with a 128 bit buffer that was the result of the
previous round
The last content of the buffer is the hash value
Idea: append a secret key to the message and compute the hash value
To avoid a brute-force attack, apply the hash twice to mangle thoroughly the bits of the
key with those of the message
H=embedded hash function
IV=initial value to the has function
M=message input to HMAC (including the padding specific to the hash function)
Yi=i-th block of M
L=number of blocks in M
b=number of bit sin a block
n=length of the hash code
K=secret key, if its length is greater than b – will be given as input to the hash
function to produce n-bit key
K+=K padded with 0 on the left to make a b-bit key, if the original length of K is
smaller than b
ipad=0x36 repeated b/8 times
opad=0x5C repeated b/8 times
HMACK(M)=H[ (K+⊕ opad) || H[(K+⊕ ipad) || M] ]