Network Security Essentials Chapter 3 Fourth Edition by William - - PowerPoint PPT Presentation

network security essentials chapter 3
SMART_READER_LITE
LIVE PREVIEW

Network Security Essentials Chapter 3 Fourth Edition by William - - PowerPoint PPT Presentation

Network Security Essentials Chapter 3 Fourth Edition by William Stallings Lecture slides by Lawrie Brown Chapter 9 Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the


slide-1
SLIDE 1

Network Security Essentials Chapter 3

Fourth Edition by William Stallings Lecture slides by Lawrie Brown

slide-2
SLIDE 2

Chapter 9 – 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

slide-3
SLIDE 3

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:

  • hash function
  • message encryption
  • message authentication code (MAC)
slide-4
SLIDE 4

Hash Functions

➢ condenses arbitrary message to fixed size

h = H(M)

➢ usually assume hash function is public ➢ hash used to detect changes to message ➢ want a cryptographic hash function

  • computationally infeasible to find data mapping

to specific hash (one-way property)

  • computationally infeasible to find two data to

same hash (collision-free property)

slide-5
SLIDE 5

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 by1bit and XOR block
  • good for data integrity but useless for security
slide-6
SLIDE 6

Hash Function Requirements

slide-7
SLIDE 7

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 same hash so

H(x) = H(y)

➢ hence value 2m/2 determines strength of

hash code against brute-force attacks

  • 128-bits inadequate, 160-bits suspect
slide-8
SLIDE 8

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

slide-9
SLIDE 9

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

slide-10
SLIDE 10

SHA Versions

slide-11
SLIDE 11

SHA-512 Overview

slide-12
SLIDE 12

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 based on cube root of

first 80 prime numbers

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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

  • f authentication mechanism strength
slide-15
SLIDE 15

HMAC : Okay but why though?

➢ Suppose you have some secret key ➢ You want to ensure it hasn’t been modified

by someone who doesn’t know that key

slide-16
SLIDE 16

HMAC

➢ specified as Internet standard RFC2104 ➢ uses hash function on the message:

HMACK(M)= Hash[(K+ XOR opad) || Hash[(K+ XOR ipad) || M)] ]

  • where K+ is the key padded out to size
  • opad, ipad are specified padding constants

➢ overhead is just 3 more hash calculations than

the message needs alone

➢ any hash function can be used

  • eg. MD5, SHA-1, RIPEMD-160, Whirlpool
slide-17
SLIDE 17

HMAC Overview

slide-18
SLIDE 18

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
  • bserve a very large number of messages)

➢ choose hash function used based on

speed versus security constraints

slide-19
SLIDE 19

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

slide-20
SLIDE 20

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 key used for both encryption & MAC

slide-21
SLIDE 21

CCM Operation

slide-22
SLIDE 22

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

slide-23
SLIDE 23

Public-Key Cryptography

➢ probably 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 crypto

slide-24
SLIDE 24

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 Uni in 1976

  • known earlier in classified community
slide-25
SLIDE 25

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

slide-26
SLIDE 26

Public-Key Cryptography

slide-27
SLIDE 27

Symmetric vs Public-Key

slide-28
SLIDE 28

RSA

➢ by Rivest, Shamir & Adleman of MIT in 1977 ➢ best known & widely used public-key scheme ➢ based on exponentiation in a finite (Galois) field

  • ver 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)
slide-29
SLIDE 29

RSA En/decryption

➢ to encrypt a message M the sender:

  • obtains public key of recipient PU={e,n}
  • computes: C = Me mod n, where 0≤M<n

➢ to 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)

slide-30
SLIDE 30

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}

slide-31
SLIDE 31

Why RSA Works

➢ because of Euler's Theorem:

  • aø(n)mod n = 1 where gcd(a,n)=1

➢ in RSA have:

  • 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

slide-32
SLIDE 32

RSA Example - Key Setup

1.

Select primes: p=17 & q=11

2.

Calculate n = pq =17 x 11=187

3.

Calculate ø(n)=(p–1)(q-1)=16x10=160

4.

Select e: gcd(e,160)=1; choose e=7

5.

Determine d: de=1 mod 160 and d < 160 Value is d=23 since 23x7=161= 10x160+1

6.

Publish public key PU={7,187}

7.

Keep secret private key PR={23,187}

slide-33
SLIDE 33

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

slide-34
SLIDE 34

Diffie-Hellman Key Exchange

➢ first public-key type scheme proposed ➢ by Diffie & Hellman in 1976 along with the

exposition of public key concepts

  • note: now know that Williamson (UK CESG)

secretly proposed the concept in 1970

➢ is a practical method for public exchange

  • f a secret key

➢ used in a number of commercial products

slide-35
SLIDE 35

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

slide-36
SLIDE 36

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
  • compute their public key: yA = axA mod q

➢ each user makes public that key yA

slide-37
SLIDE 37

Diffie-Hellman Key Exchange

➢ shared session key for users A & B is KAB:

KAB = axA.xB mod q = yA

xB mod q (which B can compute)

= yB

xA 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

slide-38
SLIDE 38

Diffie-Hellman Example

➢ users Alice & Bob who wish to swap keys: ➢ agree on prime q=353 and a=3 ➢ select random secret keys:

  • A chooses xA=97, B chooses xB=233

➢ compute respective public keys:

  • yA=397 mod 353 = 40

(Alice)

  • yB=3233 mod 353 = 248

(Bob)

➢ compute shared session key as:

  • KAB= yB

xA mod 353 = 24897 = 160

(Alice)

  • KAB= yA

xB mod 353 = 40233 = 160(Bob)

slide-39
SLIDE 39

Key Exchange Protocols

➢ users could create random private/public

D-H keys each time they communicate

➢ 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-in-the-Middle Attack

➢ authentication of the keys is needed

slide-40
SLIDE 40

Man-in-the-Middle Attack

1.

Darth prepares by creating two private / public keys

2.

Alice transmits her public key to Bob

3.

Darth intercepts this and transmits his first public key to

  • Bob. Darth also calculates a shared key with Alice

4.

Bob receives the public key and calculates the shared key (with Darth instead of Alice)

5.

Bob transmits his public key to Alice

6.

Darth intercepts this and transmits his second public key to Alice. Darth calculates a shared key with Bob

7.

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

slide-41
SLIDE 41

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

slide-42
SLIDE 42

Digital Signature Model

slide-43
SLIDE 43

Digital Signature Model

slide-44
SLIDE 44

Key Management and Distribution

➢ topics of cryptographic key management /

key distribution are complex

  • cryptographic, protocol, & management issues

➢ symmetric schemes require both parties to

share a common secret key

➢ public key schemes require parties to

acquire valid public keys

➢ have concerns with doing both

slide-45
SLIDE 45

Key Distribution

➢ symmetric schemes require both parties to

share a common secret key

➢ issue is how to securely distribute this key ➢ whilst protecting it from others ➢ frequent key changes can be desirable ➢ often secure system failure due to a break

in the key distribution scheme

slide-46
SLIDE 46

Key Distribution

given parties A and B have various key distribution alternatives:

1.

A can select key and physically deliver to B

2.

third party can select & deliver key to A & B

3.

if A & B have communicated previously can use previous key to encrypt a new key

4.

if A & B have secure communications with a third party C, C can relay key between A & B

slide-47
SLIDE 47

X.509 Certificate Use

slide-48
SLIDE 48

X.509 Certificates

➢ issued by a Certification Authority (CA), containing:

  • version V (1, 2, or 3)
  • serial number SN (unique within CA) identifying certificate
  • signature algorithm identifier AI
  • issuer X.500 name CA)
  • period of validity TA (from - to dates)
  • subject X.500 name A (name of owner)
  • subject public-key info Ap (algorithm, parameters, key)
  • issuer unique identifier (v2+)
  • subject unique identifier (v2+)
  • extension fields (v3)
  • signature (of hash of all fields in certificate)

➢ notation CA<<A>> denotes certificate for A signed by CA

slide-49
SLIDE 49

X.509 Certificates

slide-50
SLIDE 50

Obtaining a Certificate

➢ any user with access to CA can get any

certificate from it

➢ only the CA can modify a certificate ➢ because cannot be forged, certificates can

be placed in a public directory

slide-51
SLIDE 51

CA Hierarchy

➢ if both users share a common CA then they are

assumed to know its public key

➢ otherwise CA's must form a hierarchy ➢ use certificates linking members of hierarchy to

validate other CA's

  • each CA has certificates for clients (forward) and

parent (backward)

➢ each client trusts parents certificates ➢ enable verification of any certificate from one CA

by users of all other CAs in hierarchy

slide-52
SLIDE 52

CA Hierarchy Use

slide-53
SLIDE 53

Certificate Revocation

certificates have a period of validity

may need to revoke before expiry, eg:

1.

user's private key is compromised

2.

user is no longer certified by this CA

3.

CA's certificate is compromised

CA’s maintain list of revoked certificates

  • the Certificate Revocation List (CRL)

users should check certificates with CA’s CRL

slide-54
SLIDE 54

X.509 Version 3

➢ has been recognised that additional

information is needed in a certificate

  • email/URL, policy details, usage constraints

➢ rather than explicitly naming new fields

defined a general extension method

➢ extensions consist of:

  • extension identifier
  • criticality indicator
  • extension value
slide-55
SLIDE 55

Certificate Extensions

➢ key and policy information

  • convey info about subject & issuer keys, plus

indicators of certificate policy

➢ certificate subject and issuer attributes

  • support alternative names, in alternative

formats for certificate subject and/or issuer

➢ certificate path constraints

  • allow constraints on use of certificates by
  • ther CA’s
slide-56
SLIDE 56

Email Security

➢ email is one of the most widely used and

regarded network services

➢ currently message contents are not secure

  • may be inspected either in transit
  • or by suitably privileged users on destination

system

slide-57
SLIDE 57

Email Security Enhancements

➢ confidentiality

  • protection from disclosure

➢ authentication

  • of sender of message

➢ message integrity

  • protection from modification

➢ non-repudiation of origin

  • protection from denial by sender
slide-58
SLIDE 58

Pretty Good Privacy (PGP)

➢ widely used de facto secure email ➢ developed by Phil Zimmermann ➢ selected best available crypto algs to use ➢ integrated into a single program ➢ on Unix, PC, Macintosh and other systems ➢ originally free, now also have commercial

versions available

slide-59
SLIDE 59

PGP Operation – Authentication

  • 1. sender creates message
  • 2. make SHA-1160-bit hash of message
  • 3. attached RSA signed hash to message
  • 4. receiver decrypts & recovers hash code
  • 5. receiver verifies received message hash
slide-60
SLIDE 60

PGP Operation – Confidentiality

  • 1. sender forms 128-bit random session key
  • 2. encrypts message with session key
  • 3. attaches session key encrypted with RSA
  • 4. receiver decrypts & recovers session key
  • 5. session key is used to decrypt message
slide-61
SLIDE 61

PGP Operation – Confidentiality & Authentication

➢ can use both services on same message

  • create signature & attach to message
  • encrypt both message & signature
  • attach RSA/ElGamal encrypted session key
slide-62
SLIDE 62

PGP Operation – Compression

➢ by default PGP compresses message

after signing but before encrypting

  • so can store uncompressed message &

signature for later verification

  • & because compression is non deterministic

➢ uses ZIP compression algorithm

slide-63
SLIDE 63

PGP Operation – Email Compatibility

➢ when using PGP will have binary data to send

(encrypted message etc)

➢ however email was designed only for text ➢ hence PGP must encode raw binary data into

printable ASCII characters

➢ uses radix-64 algorithm

  • maps 3 bytes to 4 printable chars
  • also appends a CRC

➢ PGP also segments messages if too big

slide-64
SLIDE 64

PGP Operation – Summary

slide-65
SLIDE 65

PGP Session Keys

➢ need a session key for each message

  • of varying sizes: 56-bit DES, 128-bit CAST or

IDEA, 168-bit Triple-DES

➢ generated using ANSI X12.17 mode ➢ uses random inputs taken from previous

uses and from keystroke timing of user

slide-66
SLIDE 66

PGP Public & Private Keys

➢ since many public/private keys may be in use,

need to identify which is actually used to encrypt session key in a message

  • could send full public-key with every message
  • but this is inefficient

➢ rather use a key identifier based on key

  • is least significant 64-bits of the key
  • will very likely be unique

➢ also use key ID in signatures

slide-67
SLIDE 67

PGP Message Format

slide-68
SLIDE 68

PGP Key Rings

➢ each PGP user has a pair of keyrings:

  • public-key ring contains all the public-keys of
  • ther PGP users known to this user, indexed

by key ID

  • private-key ring contains the public/private key

pair(s) for this user, indexed by key ID & encrypted keyed from a hashed passphrase

➢ security of private keys thus depends on

the pass-phrase security

slide-69
SLIDE 69

PGP Key Rings

slide-70
SLIDE 70

PGP Message Generation

slide-71
SLIDE 71

PGP Message Reception

slide-72
SLIDE 72

PGP Key Management

➢ rather than relying on certificate authorities ➢ in PGP every user is own CA

  • can sign keys for users they know directly

➢ forms a “web of trust”

  • trust keys have signed
  • can trust keys others have signed if have a chain of

signatures to them

➢ key ring includes trust indicators ➢ users can also revoke their keys

slide-73
SLIDE 73

PGP Trust Model Example

slide-74
SLIDE 74

If we haven’t discussed it yet

➢ PGP allows for a file to be encrypted, such

that multiple keys are necessary to decrypt

  • However, not all keys need to be necessary
  • e.g. three parties, each with a key; only two

parties needed to decrypt the document (but any two of them)

  • Do we understand how this is possible?
  • Would we like to?
slide-75
SLIDE 75

Domain Keys Identified Mail

➢ a specification for cryptographically

signing email messages

➢ so signing domain claims responsibility ➢ recipients / agents can verify signature ➢ proposed Internet Standard RFC 4871 ➢ has been widely adopted

slide-76
SLIDE 76

Internet Mail Architecture

slide-77
SLIDE 77

Email Threats

➢ see RFC 4684- Analysis of Threats

Motivating DomainKeys Identified Mail

➢ describes the problem space in terms of:

  • range: low end, spammers, fraudsters
  • capabilities in terms of where submitted,

signed, volume, routing naming etc

  • outside located attackers
slide-78
SLIDE 78

DKIM Strategy

➢ transparent

to user

  • MSA sign
  • MDA verify

➢ for pragmatic

reasons

slide-79
SLIDE 79

Afterthought

➢ To some extent, the same principle behind

DKIM is available to us for PGP

  • Consider how one might be able to share

public keys here in the COSC department

  • What are our options?
slide-80
SLIDE 80

Comment on OpenSSL

➢ Hopefully, we had a couple examples where we used the

  • penssl tool to simulate other encryption/authentication

tasks

  • But that’s not why so many distributions come with OpenSSL. If you

want the behaviour of PGP, you normally just use PGP

  • OpenSSL is included for actually handling and creating certificates,

signing, TSL/SSL, etc.

➢ That said, please try to avoid playing with that application

  • n sandcastle. You never want to risk somehow

accidentally giving the idea that the COSC department has signed something it hasn’t

slide-81
SLIDE 81

Questions?

➢ Next time:

  • On sneaky sneaks and the sneaking they do!