chapter 6 the rsa algorithm - weebly

34
Chapter 6 The RSA Algorithm

Upload: others

Post on 19-Oct-2021

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 6 The RSA Algorithm - Weebly

Chapter 6 The RSA Algorithm

Page 2: Chapter 6 The RSA Algorithm - Weebly

Introduction

The development of public-key cryptography is the greatest andperhaps the only true revolution in the entire history ofcryptography.

Previously, virtually all cryptosystems have been based on theelementary tools of substitution and permutation.

A major advance in symmetric cryptography occurred with thedevelopment of the rotor encryption/decryption machine.

With the availability of computers, even more complex systemswere devised (most prominently, LUCIFER which led to DES)

Both the rotor machines and DES, although representingsignificant advances, still relied on the tools of substitution andpermutation.

Page 3: Chapter 6 The RSA Algorithm - Weebly

Public-Key Encryption

Public-key algorithms are based on mathematical functionsrather than substitution and permutations.

Public-key cryptography is asymmetric, involving the use of twoseparate keys.

The use of two keys has profound consequences in the area ofconfidentiality, key distribution and authentication.

Page 4: Chapter 6 The RSA Algorithm - Weebly

Misconceptions

Public-key encryption is more secure from cryptoanalysis than issymmetric encryption.

depends on length of the keydepends on how much computational work is required

Public-key encryption is a general purpose technique that hasmade symmetric encryption obsolete.

because of the computational overhead of current public-keyencryption schemes, there seems to be no foreseeable likelihoodthat symmetric encryption will be abandoned‘the restrictions on public-key cryptography to key managementand signature applications is almost universally accepted’

Key distribution is trivial when using public-key encryption,compared to the rather cumbersome hand-shaking involved withkey distribution centers for symmetric encryption.

some form of protocol is needed, generally involving a centralagentthe procedures involved are not simpler nor any more efficientthan those required for symmetric encryption

Page 5: Chapter 6 The RSA Algorithm - Weebly

Misconceptions

Public-key encryption is more secure from cryptoanalysis than issymmetric encryption.

depends on length of the keydepends on how much computational work is required

Public-key encryption is a general purpose technique that hasmade symmetric encryption obsolete.

because of the computational overhead of current public-keyencryption schemes, there seems to be no foreseeable likelihoodthat symmetric encryption will be abandoned‘the restrictions on public-key cryptography to key managementand signature applications is almost universally accepted’

Key distribution is trivial when using public-key encryption,compared to the rather cumbersome hand-shaking involved withkey distribution centers for symmetric encryption.

some form of protocol is needed, generally involving a centralagentthe procedures involved are not simpler nor any more efficientthan those required for symmetric encryption

Page 6: Chapter 6 The RSA Algorithm - Weebly

Key Terms

DefinitionAsymmetric KeysTwo related keys, a public key and a private key, that are used toperform complementary operations, such as encryption anddecryption or signature generation and signature verification.

DefinitionPublic Key CertificateA digital document issued and digitally signed by the private key of acertification authority that binds the name of the subscriber to a publickey. The certificate indicates that the subscriber identified in thecertificate has sole control and access to the corresponding private key.

Page 7: Chapter 6 The RSA Algorithm - Weebly

Key Terms

DefinitionPublic Key (Asymmetric) Cryptographic AlgorithmA cryptographic algorithm that uses two related keys, a public and aprivate key. The two keys have the property that deriving the privatekey from the public key is computationally infeasible.

DefinitionPublic Key Infrastructure (PKI)A set of policies, processes, server platforms, software and workstations used the purpose of administering certificates andpublic-private key pairs, including the ability to issue, maintain andrevoke public key certificates.

Page 8: Chapter 6 The RSA Algorithm - Weebly

Principles of Public-Key Cryptosystems

The concept of public-key cryptography evolved from an attempt toattack two of the most difficult problems with symmetric encryption.

The first problem is key distribution. Key distribution undersymmetric encryption requires either

(1) that communicants already share a key, which has somehow beendistributed to them; or

(2) the use of a key distribution center

Whitfield Diffie (who discovered public-key encryption along withMartin Hellman while both were at Stanford) reasoned that thissecond requirement negated the very essence of cryptography; theability to maintain total secrecy over your own communications.

Page 9: Chapter 6 The RSA Algorithm - Weebly

Principles of Public-Key Cryptosystems

The second problem was that of digital signatures.

Wanted widespread use, not just military

Needed electronic signatures to be equivalent of those ondocuments

Needed to be sure signature was sent by a particular person andsatisfactory to both parties

Page 10: Chapter 6 The RSA Algorithm - Weebly

Diffie and Hellman

Diffie and Hellman achieve an astounding breakthrough in 1976 bycoming up with a method that addressed both problems and wasradically different from all previous approaches to cryptography.

Asymmetric algorithms, such as the RSA, rely on two different butrelated keys (one for encryption and one for decryption) and thesealgorithms have a very important characteristic: it is computationallyinfeasible to determine the decryption key given only the knowledgeof the cryptographical algorithm and the encryption key.

Another property is that either key can be used for encryption and theother for decryption.

Page 11: Chapter 6 The RSA Algorithm - Weebly

Ingredients

Plaintext

Encryption algorithm

Public and private keys

Ciphertext

Decryption algorithm

Page 12: Chapter 6 The RSA Algorithm - Weebly

Public-Key Encryption Scheme

1. Each user generates a pair of keys to be used for the encryption anddecryption of messages.

Page 13: Chapter 6 The RSA Algorithm - Weebly

Public-Key Encryption Scheme

2. Each of the users places one of the keys in a public key register orother accessible file. This is the public key. The companion key iskept private. Each user maintains a collection of public keys obtainedfrom others.

Page 14: Chapter 6 The RSA Algorithm - Weebly

Public-Key Encryption Scheme

3. If I want to send a confidential message to you, I encrypt with yourpublic key.

Page 15: Chapter 6 The RSA Algorithm - Weebly

Public-Key Encryption Scheme

4. When you receive the ciphertext, you decrypt with your privatekey. No other recipient can decrypt the message because only youknow your private key.

Page 16: Chapter 6 The RSA Algorithm - Weebly

Rivest, Shamir and Adleman

Each asymmetric (public-key) cipher depends on the practicalirreversibility of some process, usually referred to as a trapdoor.

The RSA cipher uses the fact that, while not hard to compute n = pqof two large primes p and q (perhaps ≈ 1080 or higher), to factor avery large integer n = 10160 into its prime factors is essentiallyimpossible.

The pioneering paper by Diffie and Hellman in effect challengedcryptologists to come up with a cryptographic algorithm that met therequirements for public-key systems.

One of the first successful attempts to the challenge was developed atMIT in 1977 by Rivest, Shamir and Adleman and was first publishedin 1978. Since that time, the RSA algorithm has reigned supreme asthe most widely accepted public-key scheme.

Page 17: Chapter 6 The RSA Algorithm - Weebly

RSA Scheme

The RSA scheme is a block cipher in which the plaintext andciphertext are integers between 0 and n− 1 for some n. A typical sizefor n is 1024 bits, or 309 decimal digits. That is, n is less than 21024.

RSA makes use of an expression with exponentials.Plaintext is encrypted in blocks having a binary value less thansome number n. (≤ log2(n) + 1)In practice, the block size is i bits, where 2i < n ≤ 2i+1.

Encryption and decryption are of the following form, for someplaintext block M and ciphertext block C.

C ≡ Me (mod n)

M ≡ Cd (mod n)

equiv(Me)d (mod n) ≡ Med (mod n)

Page 18: Chapter 6 The RSA Algorithm - Weebly

RSA Scheme

Both the sender and receiver must know the value of n.

Only the sender knows the value of e.

Only the receiver knows the value of d.

This is a public-key encryption algorithm with a public key ofPU = {e, n} and a private key of PR = {d, n}.

Page 19: Chapter 6 The RSA Algorithm - Weebly

Requirements

For this algorithm to be satisfactory for public-key encryption, thefollowing requirements must be met:

1 It is possible to find values of of e, d, n such thatMed (mod n) ≡ M for all M < n

2 It is relatively easy to calculate Me (mod n) and Cd (mod n) forall values of M < n

3 It is infeasible to determine d given e and n

Page 20: Chapter 6 The RSA Algorithm - Weebly

First Requirement

We need to find a relationship of the form

Med (mod n) ≡ M

The preceding relationship holds if d and e are multiplicative inversesof each other, modulo φ(n), where φ(n) is the Euler totient function.

Euler Totient Functionφ(n) of a positive integer n is defined to be the number of positiveintegers less than or equal to n that are relatively prime to n.

When p is prime, however, this reduces to

φ(p) = p(

1− 1p

)= p

(p− 1

p

)= p− 1

So, for our situation we have

n = pq⇒ φ(n) = φ(pq) = (p− 1)(q− 1)

Page 21: Chapter 6 The RSA Algorithm - Weebly

Euler Totient Function

Example

Find φ(10) = 4.

Page 22: Chapter 6 The RSA Algorithm - Weebly

Relationship between e and d

The relationship between e and d can be expressed as

ed (mod φ(n)) ≡ 1

ed ≡ 1 (mod φ(n))

d ≡ e−1 (mod φ(n))

Note that this is only true if d (and therefore e as well) are relativelyprime to φ(n). Equivalently, (φ(n), d) = 1.

Page 23: Chapter 6 The RSA Algorithm - Weebly

RSA Scheme

The ingredients are:

p, q, two private numbers that are private and chosen

n = pq, public and calculated

e, with (φ(n), e) = 1, 1 < e < φ(n)), public and chosen

d ≡ e−1 (mod φ(n)), private and calculated

The private key consists of {d, n} and the public key consists of{e, n}.

Suppose that User A has published its public key and that User Bwishes to send a message M to A. Then B calculatesC ≡ Me (mod φ(n)) and transmits C.

On receipt of this ciphertext, User A decrypts by calculatingM ≡ Cd (mod φ(n)).

Page 24: Chapter 6 The RSA Algorithm - Weebly

RSA Example

ExampleWe will show how the RSA Scheme works using p = 17 and q = 11.

Page 25: Chapter 6 The RSA Algorithm - Weebly

RSA Example - Encryption

So suppose we wanted to use these keys for a plaintext input ofM = 88.

Page 26: Chapter 6 The RSA Algorithm - Weebly

RSA Example - Decryption

Page 27: Chapter 6 The RSA Algorithm - Weebly

RSA Security

The security of RSA more or less depends upon the difficulty offactorization of integers into primes. This seems to be a genuinelydifficult problem.

More precisely, security of RSA depends on a much more specialproblem, the difficulty of factoring integers of the special form n = pqinto primes.

The reason that difficulty of factorization makes RSA secure is thatfor n the product of two big primes (with the primes being secret), itseems hard to compute φ(n) when only n is given.

Page 28: Chapter 6 The RSA Algorithm - Weebly

Finding p and q

If we know the factorization n = pq, it is easy to calculate φ(n) byφ(n) = φ(pq) = (p− 1)(q− 1).

If we know n and φ(n), we can find p and q as well.

Page 29: Chapter 6 The RSA Algorithm - Weebly

Key Generation and Management

To set up a modulus n = pq from secret primes p and q and todetermine a key pair e and d with ed ≡ 1 (mod φ(n)), requires first ofall two large primes p and q, each at least as large as 1080.

Since the security of RSA is based upon the intractability of factoring,it is very lucky that primality testing is much easier than factorizationinto primes. That is, we can obtain many ‘large’ primes cheaplydespite the fact that we can’t factor large n = pq.

The decryption key d (private) can be chosen first, after pq.

For there to be a corresponding encryption key e it must be that d isrelatively prime to (p− 1)(q− 1), and the Euclidean Algorithm givesan efficient means to compute e. If gcd > 1, we can guess another d.

Page 30: Chapter 6 The RSA Algorithm - Weebly

Notes

1 Sometimes the encryption exponent is taken to be 3 with p and qnot 1 (mod 3).

2 For technical reasons, some people have recently recommended216 + 1 = 65537 (prime) as the encryption exponent.

3 Both p− 1 and q− 1 should have at least one very large primefactor, since there are factorization attacks if p− 1 and q− 1have only smallish primes.

4 The primes p and q should not be ‘close’ to each other - there arefactorization attacks that succeed in this case.

5 The ratio pq should not be ‘close’ to a rational number with

smallish numerator and denominator since Lehmer’s ContinuousFraction Factorization attack on n = pq will succeed.

6 p and q should differ in length by only a few digits.7 gcd(p− 1, q− 1) should be small.

Page 31: Chapter 6 The RSA Algorithm - Weebly

Attacking RSA

At present, it seems that attacks on RSA will succeed only when RSAis improperly implemented, for example, with too small modulus.That is, there seems to be exploitable weaknesses when certainavoidable mistakes are made.

If the key size n = pq is too small, a brute force attack to factor n maysucceed in a smaller time than one would want.

Page 32: Chapter 6 The RSA Algorithm - Weebly

Mathematical Attacks

This is equivalent to factoring the product of two primes.

1 Factor n into p and q. This enables the calculation of φ(n), whichenables the determination of d ≡ e−1 (mod φ(n)).

2 Determine φ(n) directly without determining p or q.3 Determine d directly without first determining φ(n).

Page 33: Chapter 6 The RSA Algorithm - Weebly

Timing Attack

This is analagous to a burglar guessing a combination for a safe byobserving how long it takes for someone to turn the dial from numberto number. This would be a computer attack where we measure howlong it takes for exponentiation.

Steps against this kind of attack:1 Constant exponentiation time2 Random delay3 Blinding: multiply the ciphertext by a random number before

exponentiation. This prevents bit by bit analysis since theattacker won’t know the true cipher bits.

Page 34: Chapter 6 The RSA Algorithm - Weebly

Chosen Ciphertext Attack

An adversary chooses a number of ciphertexts and is givencorresponding plaintexts decrypted by the private key.

Not feasible if a real situation where a hacker is trying to defeat RSA.