Message Authentication and Hash Functions Chapter 11.

47
Message Authentication and Hash Functions Chapter 11

Transcript of Message Authentication and Hash Functions Chapter 11.

Page 1: Message Authentication and Hash Functions Chapter 11.

Message Authentication and Hash Functions

Chapter 11

Page 2: Message Authentication and Hash Functions Chapter 11.

2

Contents

Authentication Requirements

Authentication Functions Message Encryption Message Authentication Code Hash Function

Message Authentication Codes

Hash Functions

Security of Hash Functions and MACs

Page 3: Message Authentication and Hash Functions Chapter 11.

3

Authentication Requirements

Attacks

Disclosure Release of message contents

Traffic analysis Discovery of the pattern of traffic between parties.

Masquerade Insertion of messages into the network from a fraudulent

source.

Content modification Changes to the contents of a message.

Page 4: Message Authentication and Hash Functions Chapter 11.

4

Authentication Requirements

Sequence modification Any modification to a sequence of messages between

parties.

Timing modification Delay or replay of messages.

Source repudiation Denial of transmission of message by source.

Destination repudiation Denial of receipt of message by destination.

Page 5: Message Authentication and Hash Functions Chapter 11.

5

Authentication Requirements

Disclosure and traffic analysis can be prevented by providing message confidentiality.

Masquerade, content / sequence / timing modification can be prevented by providing message authentication.

Source repudiation can be prevented by providing digital signatures.

Destination repudiation can be prevented by a combined use of digital signatures and a protocol designed to counter this attack.

Page 6: Message Authentication and Hash Functions Chapter 11.

6

Authentication Requirements

Message authentication is a procedure to verify that received messages come from the alleged source and have not been altered.

Message authentication also verify sequencing and timeliness.

Digital signature is an authentication technique that also includes measures to counter source repudiation.

Page 7: Message Authentication and Hash Functions Chapter 11.

7

Authentication Functions

Authentication functions that produce an authenticator.

Message encryption Symmetric encryption Public-key encryption

Message authentication code (MAC)

Hash function

Page 8: Message Authentication and Hash Functions Chapter 11.

8

Message Encryption: Symmetric Encryption

Symmetric encryption A message M transmitted from A to B is encrypted using

a secret key K shared by A and B. If no other party knows the key, then confidentiality is

provided. In addition, B is assured that the message was generated

by A. Because A is the only other party that possesses K.

So, symmetric encryption provides authentication as well as confidentiality.

Page 9: Message Authentication and Hash Functions Chapter 11.

9

Message Encryption: Symmetric Encryption

Authentication of a message at destination B. B decrypts the incoming message X (Y = DK(X)). If X is the ciphertext of a legitimate message, Y will be a meaning

ful plaintext M. Otherwise, Y will likely be a meaningless bit sequence.

If the message M can be any arbitrary bit pattern, the previous authentication cannot work. If M can be any bit pattern, then regardless of the value X,

Y = DK(X) is some bit pattern. Therefore it must be accepted as authentic plaintext.

Page 10: Message Authentication and Hash Functions Chapter 11.

10

Message Encryption: Symmetric Encryption

Thus, in general, only a small subset of all possible bit patterns be considered legitimate plaintext. Suppose that only one bit pattern in 106 is legitimate plaintext. Th

en, the probability that any randomly chosen bit pattern will be decrypted to a legitimate plaintext mesasge is only 10-6.

For example, suppose that we are transmitting English-lauguage messages using a Caesar cipher with K = 1. nbsftfbupbutboeepftf…. mareseatoatsanddoes… We are assured the message is legitimate because it is readable.

Page 11: Message Authentication and Hash Functions Chapter 11.

11

Message Encryption: Symmetric Encryption

However, readability check is not easy to be automated.

So, there may need to be some automated means of determining at B whether Y is legitimate plaintext.

A simple frequency analysis can be automated.

However, if the plaintext is binary string, automatic plaintext check is difficult.

Page 12: Message Authentication and Hash Functions Chapter 11.

12

Message Encryption: Symmetric Encryption

One solution to this problem is append an error-detecting code, to each message before encryption. Known as a frame check sequence (FCS) or checksum.

A prepares a plaintext message M. Then A provides this as input to a function F that produces

an FCS. The FCS is appended to M and the entire block is then

encrypted. B decrypts the incoming block. Then B applies the same function F to attempt to reproduce

the FCS. If the calculated FCS is equal to the incoming FCS, then the

message is considered authentic.

Page 13: Message Authentication and Hash Functions Chapter 11.

13

Message Encryption: Symmetric Encryption

The order of the FCS and encryption functions is critical. With internal error control, an opponent would have difficulty gener

ating ciphertext that, when decrypted, would have valid error control bits.

With external error control, an opponent can construct messages with valid error-control code. Although the opponent cannot know what the decrypted plaintext will

be, he or she can still hope to create confusion and disrupt operations.

Page 14: Message Authentication and Hash Functions Chapter 11.

14

Message Encryption: Symmetric Encryption

Another example is the structure of messages transmitted using the TCP/IP protocol architecture. One could simply encrypt the datagram except the IP

header. If an opponent substituted some arbitrary bit pattern for

the encrypted TCP segment, the resulting plaintext would not include a meaningful header.

Page 15: Message Authentication and Hash Functions Chapter 11.

15

Message Encryption: Symmetric Encryption

The header includes a checksum and the sequence number. Because TCP segments are numbered sequentially, encryption as

sures that an opponent does not delay, misorder, or delete any segments.

Page 16: Message Authentication and Hash Functions Chapter 11.

16

Message Encryption: Public-key Encryption

Public-key encryption A uses the public key KUb of B to encrypt M. This scheme provides no authentication because any opponent co

uld also use B’s public key to encrypt a message, claiming to be A.

This scheme provides confidentiality.

Page 17: Message Authentication and Hash Functions Chapter 11.

17

Message Encryption: Public-key Encryption

To provide authentication, A uses its private key to encrypt the message, and B uses A’s public key to decrypt. The message must have come from A because A is the only party

that possesses KRa. As before, there must be some internal structure to the plaintext

so that the receiver can distinguish between well-formed plaintext and random bits.

Page 18: Message Authentication and Hash Functions Chapter 11.

18

Message Encryption: Public-key Encryption

It also provides what is known as digital signature. Only A could have constructed the ciphertext because only A poss

esses KRa. Not even B (the recipient) could have constructed the ciphertext. In effect, A has “signed” the message by using its private key to e

ncrypt.

This scheme does not provide confidentiality. Anyone in possession of A’s public key can decrypt the ciphertext.

Page 19: Message Authentication and Hash Functions Chapter 11.

19

Message Encryption: Public-key Encryption

To provide both confidentiality and authentication, A can encrypt M first using its private key and then using B’s public key.

Disadvantage This public-key algorithm must be exercised four times

rather than two in each communication.

Page 20: Message Authentication and Hash Functions Chapter 11.

20

Authentication Functions

Authentication functions that produce an authenticator. Message encryption

Symmetric encryption Public-key encryption

Message authentication code (MAC) Hash function

Page 21: Message Authentication and Hash Functions Chapter 11.

21

Message Authentication Code

An alternative authentication technique involves the use of a secret key to generate a small fixed-size block of data, known as a cryptographic checksum or MAC that is appended to the message.

This technique assumes that two communicating parties share a common secret key K.

When A has a message to send to B, it calculates the MAC as a function of the message.

Page 22: Message Authentication and Hash Functions Chapter 11.

22

Message Authentication Code

The message plus MAC are transmitted to B.

B performs the same calculation on the received message, using the same secret key, to generate a new MAC.

The received MAC is compared to the calculated MAC.

Page 23: Message Authentication and Hash Functions Chapter 11.

23

Message Authentication Code

Since only the receiver and sender know the secret key, if the received MAC matches the calculated MAC,

The receiver is assured that the message has not been altered.

The receiver is assured that the message is from the alleged sender.

If the message includes a sequence number, then the receiver can be assured of the proper sequence because an attacker cannot alter the sequence number.

Page 24: Message Authentication and Hash Functions Chapter 11.

24

Message Authentication Code

A MAC function is similar to encryption except that the MAC algorithm need not be reversible. Decryption is not required.

So, the MAC function is usually a many-to-one function. The domain is the set of messages of some arbitrary length. The range is the set of MACs of a fixed-length. For example, messages can be of arbitrary length and we have onl

y 10-bit MAC.

Page 25: Message Authentication and Hash Functions Chapter 11.

25

Message Authentication Code

Confidentiality can be provided by performing message encryption either after or before the MAC algorithm. Two separate keys are needed, each of which is shared

by the sender and the receiver. Authenticating the plaintext is preferable.

Page 26: Message Authentication and Hash Functions Chapter 11.

26

Message Authentication Code

Because symmetric encryption will provide authentication and it is widely used with readily available products, why not simply use this instead of a separate message authentication code?

In general, MAC checking is faster than decryption. So, if confidentiality is not necessary, MAC is preferred.

MAC checking can be bypassed for efficiency while decryption cannot.

The MAC does not provide a digital signature because both sender and receiver share the same key.

Page 27: Message Authentication and Hash Functions Chapter 11.

27

Hash Function

Hash function Input: A variable-size message M Output: A fixed-size bit string, referred to as a hash code

H(M). The hash code is also referred to as a message digest or

hash value.

Unlike a MAC, a hash code does not use a key.

A change to any bit or bits in the message results in a change to the hash code.

Page 28: Message Authentication and Hash Functions Chapter 11.

28

Hash Function

Message authentication by hash function The message plus concatenated hash code is

encrypted using symmetric encryption. Because only A and B share the secret key, the message

must have come from A and has not been altered. Because encryption is applied to the entire message plus

hash code, confidentiality is also provided.

Page 29: Message Authentication and Hash Functions Chapter 11.

29

Hash Function

Only the has code is encrypted, using symmetric encryption. This reduces the processing burden for those

applications that do not require confidentiality. Note that the combination of hashing and encryption

results in a MAC. Because EK[H(M)] is a fixed-size output that is secure against an opponent who does not know the secret key.

Page 30: Message Authentication and Hash Functions Chapter 11.

30

Hash Function

Only the has code is encrypted, using public-key encryption and using the sender’s private key. This provides authentication. It also provides a digital signature, because only the

sender could have produced the encrypted hash code. This is the essence of the digital signature technique.

Page 31: Message Authentication and Hash Functions Chapter 11.

31

Hash Function

If confidentiality as well as a digital signature is desired, then the message plus the private-key-encrypted hash code can be encrypted using a symmetric secret key.

Page 32: Message Authentication and Hash Functions Chapter 11.

32

Hash Function

It is possible to use a hash function without encryption. Assume that the two communicating parties share a

common secret value S. A computes the hash value over the concatenation of M

and S and appends the resulting hash value to M. B can verify the hash value because it knows S but an

opponent cannot modify a message and cannot generate a false message.

Page 33: Message Authentication and Hash Functions Chapter 11.

33

Hash Function

Confidentiality can be added to the approach of (e) by encrypting the entire message plus the hash code.

Page 34: Message Authentication and Hash Functions Chapter 11.

34

Contents

Authentication Requirements

Authentication Functions Message Encryption Message Authentication Code Hash Function

Message Authentication Codes

Hash Functions

Security of Hash Functions and MACs

Page 35: Message Authentication and Hash Functions Chapter 11.

35

Message Authentication Codes

A MAC is generated by a function C of the form

M is a variable-length message. K is a secret key shared only by sender and receiver. CK(M) is the fixed-length authenticator.

A MAC is a many-to-one function. Potentially many messages have same MAC . But finding these needs to be very difficult.

MAC = CK(M)

Page 36: Message Authentication and Hash Functions Chapter 11.

36

Requirements for MACs

Need the MAC to satisfy the following: Knowing a message and MAC, is infeasible to find another mess

age with same MAC MACs should be uniformly distributed MAC should depend equally on all bits of the message

Page 37: Message Authentication and Hash Functions Chapter 11.

37

Message Authentication Code Based on DES

One of the most widely used MACs, referred to as the Data Authentication Algorithm, is based on DES.

Using the cipher block chaining (CBC) mode of operation of DES with an initialization vector of zero.

The data to be authenticated are grouped into contiguous 64-bit blocks : D1, D2, … , DN. If necessary, the final block is padded on the right with zeroes to f

orm a full 64-bit block.

Page 38: Message Authentication and Hash Functions Chapter 11.

38

Message Authentication Code Based on DES

Using the DES encryption algorithm, E, and a secret key, K, a data authentication code (DAC) is calculated as follow.

)(

...

)(

)(

)(

1

233

122

11

NNKN

K

K

K

ODEO

ODEO

ODEO

DEO

Page 39: Message Authentication and Hash Functions Chapter 11.

39

Message Authentication Code Based on DES

Data Authentication Algorithm.

Page 40: Message Authentication and Hash Functions Chapter 11.

40

Hash Function

A hash value h is generated by a function H of the form

M is a variable-length message and H(M) is the fixed-length hash value.

)(MHh

Page 41: Message Authentication and Hash Functions Chapter 11.

41

Hash Function

The purpose of a hash function is to produce a “fingerprint” of a file, message, or other block of data.Properties H can be applied to a block of data of any size. H produces a fixed-length output. H(x) is easy to compute for any given x, making both hardware and softw

are implementations practical. For any given value h, it is infeasible to find x such that H(x) = h.

The one-way property For any given block x, it is infeasible to find y ≠ x with H(y) = H(x).

Weak collision resistance It is infeasible to find any pair (x, y) such that H(x) = H(y).

Strong collision resistance

Page 42: Message Authentication and Hash Functions Chapter 11.

42

Simple Hash Function

One of the simplest hash functions is the bit-by-bit XOR of every block.

Ci = i th bit of the hash code, 1 ≤ i ≤ n. m = number of n-bit blocks in the input. bij = i th bit in j th block. XOR operation.

imiii bbbC ...21

Page 43: Message Authentication and Hash Functions Chapter 11.

43

Simple Hash Function

Simple hash function using bitwise XOR.

Page 44: Message Authentication and Hash Functions Chapter 11.

44

Simple Hash Function

For example, in most normal text files, the high-order bit of each octet is always zero.

So if a 128-bit hash value is used, instead of an effectiveness of 2-128, the hash function on this type of data has an effectiveness of 2-112.

Page 45: Message Authentication and Hash Functions Chapter 11.

45

Simple Hash Function

A simple way to improve matters is to perform a one-bit circular shift, or rotation, on the hash value after each block is processed.

Page 46: Message Authentication and Hash Functions Chapter 11.

46

Simple Hash Function

Although a simple XOR or rotated XOR is insufficient if only the hash code is encrypted, you may still feel that such a simple function could be useful when the message as well as the hash code are encrypted. But be careful.

We define the scheme as follows Used the simple XOR applied to 64-bit blocks of the message

and then an encryption of the entire message that used the CBC mode.

Given a message consisting of a sequence of 64-bit blocks X1, X2, … , XN.

Define the hash code C as the block-by-block XOR of all blocks. Append the hash code as the final block.

NN XXXXC ...211

Page 47: Message Authentication and Hash Functions Chapter 11.

47

Simple Hash Function

Next, encrypt the entire message plus hash code, using CBC mode to produce the encrypted message Y1, Y2, … , YN+1.

By the definition of CBC

But XN+1 is the hash code

Because the terms in the preceding equation can be XORed in any order, it follows that the hash code would not change if the ciphertext blocks were permuted.

)(

)(

)(

11

1

11

NKNN

iKii

K

YDYX

YDYX

YDIVX

))((...))(())((

...

1211

211

NKNKK

NN

YDYYDYYDIV

XXXX