Message Authentication

advertisement
Network Security Essentials
Chapter 3
Fourth Edition
by William Stallings
(Based on Lecture slides by
Lawrie Brown)
Public Key Cryptography and
RSA
Every Egyptian received two names, which were
known respectively as the true name and the
good name, or the great name and the little
name; and while the good or little name was
made public, the true or great name appears to
have been carefully concealed.
—The Golden Bough, Sir James George Frazer
Outline
 Message
authentication (Ref. Chap.12)
 Secure hash functions (Ref. Chap.11)
 Message authentication codes (Ref.
Chap.12)
 Public-key cryptography (Ref. Chap.9)
 Digital signatures (Ref. Chap.13)
Message Authentication
 To

Encryption
 To

protect against passive attacks
protect against active attacks
Message authentication
Message Authentication

Message authentication is concerned with:




Protecting the integrity of a message
Validating identity of originator
Non-repudiation of origin (dispute resolution)
The three alternative functions used:



Message encryption
Hash function
Message authentication code (MAC)
 Authentication
using conventional
encryption

Not suitable, e.g. block reordering in ECB
mode
 Authentication



without encryption
Broadcast
Heavy loads
Authentication of a program in plaintext
Message Authentication Code
 MACM=F(KAB,



Message not altered
The alleged sender confirmed
The proper sequence of messages assured
 Similar


M)
to encryption
NIST recommends the use of DES
One difference: authentication algorithm need
not be reversible, less vulnerable
Hash Functions
 Condenses
arbitrary message to fixed size
h = H(M)
 No secret key needed
 Usually assume hash function is public
 Hash used to detect changes to message
 We


want a cryptographic hash function
Computationally infeasible to find data mapping
to specific hash (one-way property)
Computationally infeasible to find two data to the
same hash (collision-free property)
Message authentication using
a one-way hash function



Using conventional encryption (Fig.3.2a)
Using public-key encryption (Fig.3.2b)
Using secret value (Fig.3.2c)



MDM=H(SAB||M), then send [M||MDM]
E.g. HMAC adopted for IP security
Reasons for avoiding encryption




Encryption software quite slow
Encryption hardware costs nonnegligible
Encryption hardware optimized for large data sizes
Encryption algorithm protected by a patent
Two Simple Insecure Hash
Functions
 Consider
two simple insecure hash functions
 Bit-by-bit exclusive-OR (XOR) of every block



Ci = bi1 xor bi2 xor . . . xor bim
A longitudinal redundancy check
Reasonably effective as data integrity check
 One-bit

circular shift on hash value
For each successive n-bit block
• Rotate current hash value to left by 1bit and XOR
block

Good for data integrity but useless for security
Simple Hash Function Using
Bitwise XOR
Hash Function Requirements
Attacks on Hash Functions
 Have
brute-force attacks and cryptanalysis
 A preimage or second preimage attack

Find y s.t. H(y) equals a given hash value
 Collision


resistance
Find two messages x & y with the same hash
H(x) = H(y)
Protection against birthday attack
value 2m/2 determines strength of
hash code against brute-force attacks
 Hence

128-bits inadequate, 160-bits suspect
Secure Hash Algorithm

SHA originally designed by NIST & NSA in 1993
 Was revised in 1995 as SHA-1
 US standard for use with DSA signature scheme



Standard is FIPS 180-1 1995, also Internet RFC3174
nb. the algorithm is SHA, the standard is SHS
Based on design of MD4 with key differences
 Produces 160-bit hash values
 Recent 2005 results on security of SHA-1 have
raised concerns on its use in future applications
Revised Secure Hash
Standard

NIST issued revision FIPS 180-2 in 2002





Adds 3 additional versions of SHA:
SHA-256, SHA-384, SHA-512
Designed for compatibility with increased security
provided by the AES cipher
Structure & detail is similar to SHA-1
Hence analysis should be similar, but security levels
are rather higher
NIST FIPS 180-3 (in 2008) adds SHA-224
 RFC 4634 details SHA-224, -256, -384, -512
SHA Versions
SHA-1
Message
digest size
SHA-224 SHA-256 SHA-384 SHA-512
160
224
256
384
512
< 264
< 264
< 264
< 2128
< 2128
Block size
512
512
512
1024
1024
Word size
32
32
32
64
64
Number of
steps
80
64
64
80
80
Message
size
SHA-512 Overview
SHA-512 Compression
Function
 Heart
of the algorithm
 Processing message in 1024-bit blocks
 Consists of 80 rounds



Updating a 512-bit buffer
Using a 64-bit value Wt derived from the
current message block
And a round constant Kt based on cube roots
of the first 80 prime numbers
Keyed Hash Functions as MACs
 Want


a MAC based on a hash function
Because hash functions are generally faster
Crypto hash function code is widely available
 Hash
includes a key along with message
 Original proposal:
KeyedHash = Hash(Key|Message)

Some weaknesses were found with this
 Eventually
led to development of HMAC
HMAC Design Objectives
 Use,
without modifications, hash functions
 Allow for easy replaceability of embedded
hash function
 Preserve original performance of hash
function without significant degradation
 Use and handle keys in a simple way
 Have well understood cryptographic
analysis of authentication mechanism
strength
HMAC

Specified as Internet standard RFC2104
 Uses hash function on the message:
HMACK(M)= Hash[(K+ XOR opad) ||
Hash[(K+ XOR ipad) || M)] ]
+ is the key padded out to size
 where K
 opad, ipad are specified padding constants

Overhead is just 3 more hash calculations than
the message needs alone
 Any hash function can be used

E.g. MD5, SHA-1, RIPEMD-160, Whirlpool
HMAC
Overview
HMAC Security
 Proved
security of HMAC relates to that of
the underlying hash algorithm
 Attacking HMAC requires either:


Brute force attack on key used
Birthday attack (but since keyed would need
to observe a very large number of messages)
 Choose
hash function used based on
speed verses security constraints

MD5 vs. SHA-1
MACs based on Block
Ciphers
 CMAC
 CCM
CMAC
 Previously
saw the DAA (CBC-MAC)
 Widely used in govt & industry
 But has message size limitation
 Can overcome using 2 keys & padding
 Thus forming the Cipher-based Message
Authentication Code (CMAC)
 Adopted by NIST SP800-38B
CMAC Overview
Authenticated Encryption

Simultaneously protect confidentiality and
authenticity of communications


Often required but usually separate
Approaches




Hash-then-encrypt: E(K, (M || H(M))
MAC-then-encrypt: E(K2, (M || MAC(K1, M))
Encrypt-then-MAC: C=E(K2, M), T=MAC(K1, C)
Encrypt-and-MAC: C=E(K2, M), T=MAC(K1, M)

Decryption /verification straightforward
 But security vulnerabilities with all these

E.g. HtE used in WEP (Wired Equivalent Privacy)
Counter with Cipher Block
Chaining-Message
Authentication Code (CCM)
 NIST
standard SP 800-38C for WiFi
 Variation of encrypt-and-MAC approach
 Algorithmic ingredients



AES encryption algorithm
CTR mode of operation
CMAC authentication algorithm
 Single
MAC
key used for both encryption &
CCM
Operation
Private-Key Cryptography
 Traditional
private/secret/single key
cryptography uses one key
 Shared by both sender and receiver
 If this key is disclosed communications are
compromised
 Also is symmetric, parties are equal
 Hence does not protect sender from
receiver forging a message & claiming is
sent by sender
Public-Key Cryptography
 Probably
the most significant advance in
the 3000 year history of cryptography
 Uses two keys – a public & a private key
 Asymmetric since parties are not equal
 Uses clever application of number
theoretic concepts to function
 Complements rather than replaces
private key cryptography
Why Public-Key
Cryptography?
 Developed


to address two key issues:
Key distribution – how to have secure
communications in general without having to
trust a KDC with your key
Digital signatures – how to verify a message
comes intact from the claimed sender
 Public
invention due to Whitfield Diffie &
Martin Hellman at Stanford Univ. in 1976

Known earlier in classified community
Public-Key Cryptography

Public-key/two-key/asymmetric cryptography
involves the use of two keys:


A public-key, which may be known by anybody, and can
be used to encrypt messages, and verify signatures
A related private-key, known only to the recipient, used
to decrypt messages, and sign (create) signatures

Infeasible to determine private key from public
 Is asymmetric because

Those who encrypt messages or verify signatures
cannot decrypt messages or create signatures
Public-Key Cryptography
Symmetric vs Public-Key
RSA

By Rivest, Shamir & Adleman of MIT in 1977
 Best known & widely used public-key scheme
 Based on exponentiation in a finite (Galois) field
over integers modulo a prime

nb. exponentiation takes O((log n)3) operations (easy)

Uses large integers (eg. 1024 bits)
 Security due to cost of factoring large numbers

nb. factorization takes O(e log n log log n) operations (hard)
RSA En/decryption
 To


Obtains public key of recipient PU={e,n}
Computes: C = Me mod n, where 0≤M<n
 To


encrypt a message M the sender:
decrypt the ciphertext C the owner:
Uses their private key PR={d,n}
Computes: M = Cd mod n
 Note
that the message M must be smaller
than the modulus n (block if needed)
RSA Key Setup

Each user generates a public/private key pair by:
 Selecting two large primes at random: p, q
 Computing their system modulus n=p.q

note ø(n)=(p-1)(q-1)
Selecting at random the encryption key e
 where 1<e<ø(n), gcd(e,ø(n))=1
 Solve following equation to find decryption key d
 e.d=1 mod ø(n) and 0≤d≤n
 Publish their public encryption key: PU={e,n}
 Keep secret private decryption key: PR={d,n}

Why RSA Works

Because of Euler's Theorem:


In RSA have:





aø(n)mod n = 1 where gcd(a,n)=1
n=p.q
ø(n)=(p-1)(q-1)
Carefully chose e & d to be inverses mod ø(n)
Hence e.d=1+k.ø(n) for some k
Hence :
Cd = Me.d = M1+k.ø(n) = M1.(Mø(n))k
= M1.(1)k = M1 = M mod n
RSA Example - Key Setup
1.
2.
3.
4.
5.
6.
7.
Select primes: p=17 & q=11
Calculate
n = pq =17 x 11=187
Calculate
ø(n)=(p–1)(q-1)=16x10=160
Select e: gcd(e,160)=1; choose e=7
Determine d: de=1 mod 160 and d < 160
Value is d=23 since 23x7=161= 10x160+1
Publish public key PU={7,187}
Keep secret private key PR={23,187}
RSA Example - En/Decryption
 Sample
RSA encryption/decryption is:
 Given message M = 88 (nb. 88<187)
 Encryption:
C = 887 mod 187 = 11
 Decryption:
M = 1123 mod 187 = 88
Diffie-Hellman Key Exchange
 First
public-key type scheme proposed
 By Diffie & Hellman in 1976 along with the
exposition of public key concepts

 Is
Note: now know that Williamson (UK CESG)
secretly proposed the concept in 1970
a practical method for public exchange
of a secret key
 Used in a number of commercial products
Diffie-Hellman Key Exchange

A public-key distribution scheme




Cannot be used to exchange an arbitrary message
Rather it can establish a common key
Known only to the two participants
Value of key depends on the participants (and
their private and public key information)
 Based on exponentiation in a finite (Galois) field
(modulo a prime or a polynomial) - easy
 Security relies on the difficulty of computing
discrete logarithms (similar to factoring) – hard
Discrete Logarithm
 Ordinary


ax=b
x=loga(b)
 Discrete

logarithm:
logarithm:
b=ai mod p (0  i  p-1)
• a: primitive root of prime number p
• Can generate all integers from 1 to p-1
• i.e. a1 mod p, a2 mod p, ap-1 mod p are distinct

i=dloga,p(b)
Diffie-Hellman Setup
 All


users agree on global parameters:
Large prime integer or polynomial q
a being a primitive root mod q
 Each



user (eg. A) generates their key
Chooses a secret key (number): xA < q
xA
Compute their public key: yA = a mod q
Each user makes public that key yA
Diffie-Hellman Key Exchange

Shared session key for users A & B is KAB:
x
x
KAB = a A. B mod q
xB
= yA mod q (which B can compute)
xA
= yB mod q (which A can compute)

KAB is used as session key in private-key
encryption scheme between Alice and Bob
 If Alice and Bob subsequently communicate,
they will have the same key as before, unless
they choose new public-keys
 Attacker needs an x, must solve discrete log
from the corresponding y
Diffie-Hellman Example

Users Alice & Bob who wish to swap keys:
 Agree on prime q=353 and a=3
 Select random secret keys:


Compute respective public keys:
97



A chooses xA=97, B chooses xB=233
yA=3
mod 353 = 40 (Alice)
233
yB=3
mod 353 = 248 (Bob)
Compute shared session key as:


xA
97
KAB= yB mod 353 = 248 = 160
xB
233
KAB= yA mod 353 = 40
= 160
(Alice)
(Bob)
Key Exchange Protocols
 Users
could create random private/public
D-H keys each time they communicate

(Fig. 3.13)
 Users
could create a known private/public
D-H key and publish in a directory, then
consulted and used to securely
communicate with them
 Both of these are vulnerable to a meet-inthe-Middle Attack
 Authentication of the keys is needed
Man-in-the-Middle Attack
1.
2.
3.
4.
5.
6.
7.

Darth prepares by creating two private / public keys
Alice transmits her public key to Bob
Darth intercepts this and transmits his first public key to
Bob. Darth also calculates a shared key with Alice
Bob receives the public key and calculates the shared key
(with Darth instead of Alice)
Bob transmits his public key to Alice
Darth intercepts this and transmits his second public key
to Alice. Darth calculates a shared key with Bob
Alice receives the key and calculates the shared key (with
Darth instead of Bob)
Darth can then intercept, decrypt, re-encrypt, forward all
messages between Alice & Bob
Digital Signatures
 Have

looked at message authentication
But does not address issues of lack of trust
 Digital



signatures provide the ability to:
Verify author, date & time of signature
Authenticate message contents
Be verified by third parties to resolve disputes
 Hence
include authentication function with
additional capabilities
Digital Signature Model
Digital
Signature
Model
Download