public key encryption dan fleck cs 469: security engineering these slides are modified with...

33
Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public Key Encryption 1 1

Upload: cornelius-stapley

Post on 15-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Public Key Encryption

Public Key EncryptionDan FleckCS 469: Security Engineering

These slides are modified with permission from Bill Young (Univ of Texas)

11

Page 2: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Public Key Encryption

Public Key Encryption

• In 1976, Whitfield Diffie and Martin Hellman proposed public key encryption (asymmetric encryption) in which different keys are used for encryption and decryption.

• In 1997, it was disclosed that asymmetric key algorithms had been developed in the early 1970’s by the British Government’s Communication Headquarters (GCHQ). They referred to the technique as non-secret encryption.

22

Page 3: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Public Key Systems

Public Key Encryption

Use a publicly disclosed key to encrypt and a secret key to decrypt.

The requisite relationship is:

We’ll denote the public key for principal A by Ka and the private key will be denoted Ka

−1

33

Page 4: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Public Key Systems

Public Key Systems

Also, for some public key systems, RSA in particular, encryption and decryption commute and either key can be used in either function. That is:

This is crucial in some uses of RSA. But is not true for most public key cryptosystems.

44

Page 5: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: E ciency of Encryptionffi

Public Key Systems

The basis of any public key system is the identification of a one-way function: easily computed, but difficult to invert without additional information.

Example: It is easy to multiply two large primes p1 and p2. However, it is very difficult to factor p1p2 to recover p1 and p2. But, given p1p2 and either of p1 or p2, it is straightforward to recover the other, simply by dividing.

55

Page 6: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Lessons

E ciency of Encryptionffi

Public key systems largely solve the key distribution problem.Why?

A public key encryption may take 10,000 times as long to perform as a symmetric encryption; the computation depends on more complex operations, not on simple bit-wise operations.

Symmetric encryption remains the work horse of commercial cryptography, with asymmetric encryption playing some important special functions.

66

Page 7: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: RSA Algorithm

Lessons

• Devising an asymmetric encryption algorithm depends on identifying a one-way function, easy to compute but hard to invert.

• Public key systems largely solve the key distribution problem.

• Asymmetric algorithms are generally much less efficient than symmetric algorithms.

77

Page 8: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Other Public Key Algorithms

RSA AlgorithmThe Rivest-Shamir-Adelman (RSA) algorithm relies on the difficulty of factoring large numbers.

Two keys, e and d, are used for encryption and decryption. The algorithm is such that:

A plaintext block P is encrypted as (Pe mod n). d is chosen so that:

An interceptor would have to factor Pe to recover the plaintext. The legitimate receiver knows d and merely computes,

which is much easier. 88

Page 9: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Elliptic Curve Cryptography

Other Public Key Algorithms

A public key system can be based on any one-way function. A rich source is the set of NP-complete problems. These are infeasible to solve, but a solution can be checked in polynomial time.

Merkle and Hellman proposed a public key system based on the knapsack problem: given a set of integers and a target sum, find a subset of the integers that sum to the target.

The algorithm is theoretically very secure, but has practical weaknesses.

99

Page 10: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Authentication with Public Keys

Elliptic Curve Cryptography

• Elliptical Curve Cryptography (ECC) is a newer public key encryption system (1985) using elliptic curves instead of prime numbers

• Some say 164 bit key is equivalent to other systems 1024 bit key (another say 256 bit = 3076 RSA bits)

• 112-bit key ECC broken using 200 Playstation 3s running continuously for 3.5 months.

• G=start point per curve• k=random private key, public key=kG

Source:http://en.wikipedia.org/wiki/Elliptic_curve_cryptography#Cryptographic_schemes

10

Page 11: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Authentication with Public Keys

Authentication with Public Keys

Assume Ka is A’s public key. Suppose B sends the following message to A: {M}Ka . What assurances does A have?

1. No-one intercepting the message could read it. Why?2. He can’t be sure it actually came from B. Why not?

Thus, encryption with the public key is a privacy transformation, but not an authenticity transformation.

1011

Page 12: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Lessons

Authentication with Public Keys

Using RSA, B send to A. If A can decrypt it using Kb, what assurance is gained?1. A is sure it originated with B. Why?2. But someone intercepting the message might read it. Why?

Thus, encryption with private key is an authenticity transformation, not a privacy transformation.

Note this only works in RSA, because:

In other public key systems, you typically need two pairs of keys: one pair for privacy and the other pair for “signing” (authenticity).

1112

Page 13: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Cryptographic Hash Functions

Lessons

• RSA is the most widely used public key cryptosystem.

• RSA is symmetric in the use of keys; most public key schemes are not.

• A public key encryption can be used for authenticity or for privacy but not both at once.

1213

Page 14: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Hash Functions

Cryptographic Hash FunctionsDan FleckCS 469: Security Engineering

These slides are modified with permission from Bill Young (Univ of Texas)

1314

Page 15: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Vocabulary

Hash Functions

• A hash function is a function that converts variable-sized text into a small datum, usually a fixed size integer.

A cryptographic hash function has the additional qualities:• it is difficult to construct a text that has a given hash,• it is difficult to modify a given text without changing its hash,• it is unlikely that two different messages will have the same

hash.

The hash value is sometimes called a message digest.Cryptographic hash functions are used to protect integrity.

1415

Page 16: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Birthday Attacks

Vocabulary

A function f is preimage resistant if, given h, it is hard to find any m such that h = f (m).

A function f is second preimage resistant if, given an input m1, it is hard to find m2 ≠ m1 such that f (m1) = f (m2). This is sometimes called weak collision resistance.

A function f is (strong) collision resistant if it is hard to find two messages m1 and m2 such that f (m1) = f (m2).

1516

Page 17: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Cryptographic Hash Functions

Birthday Attacks

If a function f(x) yields any of H different outputs with equal probability and H is sufficiently large, then we expect to obtain a pair of different arguments x1 and x2 with f (x1) = f (x2) after

evaluating the function for about different arguments on average.

What does this mean for a hash value of 128 bits? for 160 bits?

1617

Page 18: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Using a Hash Function

Cryptographic Hash Functions

Hash functions usually are used for integrity, not confidentiality.

• In a document retrieval system containing legal records, it may be important to know that the copy retrieved is identical to that stored.

• In a secure communications system, the correct transmission of messages may override confidentiality concerns.

A cryptographic hash function “binds” the bytes of a file together in a way that makes seal any alterations to the file apparent. We say that we the file to make it tamper-proof (actually tamper-resistant).

1718

Page 19: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Common Hash Algorithms

Using a Hash Function

The process is as follows:

• Given a sensitive file f , compute the hash function h(f ) and store the result securely.

• Each time the file is used or accessed, recompute the hash. • Compare it to the stored value.

If the two values match, it is likely that no changes have occurred to the file.

1819

Page 20: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Lessons

Common Hash Algorithms

Two widely used cryptographic hash functions are:

MD5: (Message Digest 5) invented by Ron Rivest and RSA Labs;

SHA-1/SHA-2/SHS: (Secure Hash Algorithm or Standard) similar to MD5.

MD5 hashes a message of any size to a 128-bit digest. SHA/SHS produce a 160-bit digest.

1920

Page 21: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Key Exchange

Lessons

• A cryptographic hash function takes an arbitrary text and produces a fixed size bit string that depends on each value of the text.

• It should be difficult to find collisions—values that hash to the same result.

• A hash can be used to show with high probability that a text has not changed.

2021

Page 22: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: The Key Exchange Problem

Key ExchangeDan FleckCS 469: Security Engineering

These slides are modified with permission from Bill Young (Univ of Texas)

2122

Page 23: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Key Exchange: Attempt 1

The Key Exchange Problem

Suppose you want to establish a secure communication channel with someone you don’t know. We call this a situation of mutual suspicion. This is extremely common.

• You submit your income tax on-line.• You send your credit card information to a shopping website.• You wish to exchange encrypted email with another party.

Once you agree on a shared secret (key) the communication can proceed. But how do you exchange the key? This is the key exchange problem.

2223

Page 24: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Key Exchange: Attempt 2

Key Exchange: Attempt 1

Suppose both parties S and R have a public / private RSA key pair for asymmetric communication. Say S chooses a new symmetric key K and sends to R the following message:

R can decrypt the message using S’s public key to retrieve K. What is wrong with this scheme?

Answer: Any eavesdropper can intercept the message and decrypt it using S’s public key to retrieve K. 2324

Page 25: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Key Exchange (Cont.)

Key Exchange: Attempt 2

Instead, suppose S sends to R the following message:

Since only R can decrypt this message, confidentiality is assured. What’s wrong this time?

Now R doesn’t have any assurance that the message actually came from S. An intruder may be “spoofing” (pretending to be S) to obtain information that R intends only for S.

Can we preserve both confidentiality and authentication with one transaction? 2625

Page 26: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Lessons

Key Exchange (Cont.)

A third attempt is for S to send R the following:

How does R extract K? What assurances does this provide?1. Since, no one but R can decrypt the message, confidentiality

is assured.2. No one but S could have performed the inner encryption, so

authentication is accomplished.

This notion of nested encryptions is very useful in a variety of cryptographic protocols. Could you have done the encryptions in the other order? 2426

Page 27: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Diffie-Hellman Key Exchange

Lessons

• Public key cryptosystems can be used for key exchange, but you have to do it carefully.

• Key exchange requires both confidentiality and authentication.

2527

Page 28: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Di e-Hellman Key Exchangeffi

Diffie-Hellman Key ExchangeDan FleckCS 469: Security Engineering

These slides are modified with permission from Bill Young (Univ of Texas)

2728

Page 29: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Di e-Hellman Algorithmffi

Di e-Hellman Key Exchangeffi

• The question of key exchange was one of the first problems addressed by a cryptographic protocol. This was prior to the invention of public key cryptography.

• The Diffie-Hellman key agreement protocol (1976) was the first practical method for establishing a shared secret over an unsecured communication channel.

• The point is to agree on a key that two parties can use for a symmetric encryption, in such a way that an eavesdropper cannot obtain the key.

2829

Page 30: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Di e-Hellman Exampleffi

Di e-Hellman Algorithmffi

Steps in the algorithm:1. Alice and Bob agree on a prime number p and a base g.2. Alice chooses a secret number a, and sends Bob (ga mod p).3. Bob chooses a secret number b, and sends Alice (gb mod p).4. Alice computes ((gb mod p)a mod p).5. Bob computes ((ga mod p)b mod p).

Both Alice and Bob can use this number as their key. Notice that p and g need not be protected.

2930

Page 31: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Di e-Hellman Securityffi

Di e-Hellman Exampleffi

1. Alice and Bob agree on p = 23 and g = 5.2. Alice chooses a = 6 and sends 56 mod 23 = 8.3. Bob chooses b = 15 and sends 515 mod 23 = 19.4. Alice computes 196 mod 23 = 2.5. Bob computes 815 mod 23 = 2.

Then 2 is the shared secret

Clearly, much larger values of a, b, and p are required. An eavesdropper cannot discover this value even if she knows p and g and can obtain each of the messages.

3031

Page 32: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

Coming up: Lessons

Di e-Hellman Securityffi

Suppose p is a prime of around 300 digits, and a and b at least 100 digits each.

Discovering the shared secret given g, p, ga mod p and gb mod p would take longer than the lifetime of the universe, using the best known algorithm. This is called the discrete logarithm problem.

3132

Page 33: Public Key Encryption Dan Fleck CS 469: Security Engineering These slides are modified with permission from Bill Young (Univ of Texas) Coming up: Public

End of presentation

Lessons

• How can two parties agree on a secret value when all of their messages might be overheard by an eavesdropper?

• The Diffie-Hellman algorithm accomplishes this, and is still widely used.

• With sufficiently large inputs, Diffie-Hellman is very secure.

3233