Transcript
Page 1: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Rennes, 02/10/2014

Cristina Onete

[email protected]

Attacks on RSA. Safe modes.

Page 2: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

From the previous lecture…

p, q, n:=pq

πœ‘ (𝑛) ,𝑛 ,𝑒 ,𝑑

B

𝑛 ,𝑒

Secret π‘š 𝑐=π‘šπ‘’(π‘šπ‘œπ‘‘π‘›) π‘š=𝑐𝑑(π‘šπ‘œπ‘‘π‘›)

Cristina Onete || 25/09/2014 || 2

𝑛 ,𝑒

Page 3: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Textbook RSA (V)

Security:

β€’ Is encryption secure?

𝑐=π‘šπ‘’(π‘šπ‘œπ‘‘π‘›)

β€’ Can we recover the secret key ?Key recovery as hard as factorizing

β€’ Can we recover in any other way ?

Values are long-term

Each maps to unique Deterministic

Cristina Onete || 25/09/2014 || 3

Page 4: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Textbook RSA (VI)

Security:

β€’ Plaintext recovery: can’t find from

β€’ IND-CPA/IND-CCA: can’t say anything about

Encryption is deterministic:Can always distinguish m from m’

Not guaranteed if few possible messagesTry out all alternatives – find plaintext

OK if chosen at random from large set

β€’ Not very secure; but we can improve it

Cristina Onete || 25/09/2014 || 4

Page 5: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Textbook RSA ++

Improving Textbook RSA:

Secret pre-processing RSAencryption

pre-processing

Security will depend on this step

Cristina Onete || 25/09/2014 || 5

Page 6: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

PKCS and Bleichenbacher

Preprocessing with PKCS1, mode 2

β€’ Pad with random number (make it probabilistic)

02 random pad FF message

1024 bits

β€’ Bleichenbacher ’98: use the regularity of the ciphertext (they must start with β€œ00|02”) to recover plaintext!

00

Cristina Onete || 25/09/2014 || 6

Page 7: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

PKCS and Bleichenbacher (II)

Core idea

Ciphertext

DecryptDoes m start with β€œ00|02”?

Continue

ERROR!

Attacker starts with ciphertext β€’ Re-randomize it: β€’ Is it PKCS? Repeat until you know rM starts with 00|02 β€’ Move to next part of message ciphertexts

Cristina Onete || 25/09/2014 || 7

Page 8: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 8

Contents

Pre-processingβ€’ How OAEP works

β€’ Improvements on OAEPβ€’ Hash Functions; Random Oracles (brief)

Attacks on factoring – genericβ€’ Pollard’s β€’ Pollard-

Unsafe modes for RSA

β€’ Small sk: Wiener’s attackSome physical attacks

β€’ Small pk and related ciphertexts

Page 9: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

The OAEP Function

A new pre-processing function: OAEPβ€’ OAEP = Optimal Asymmetric Encryption Paddingβ€’ By Bellare & Rogaway, 1994; in RFC 2437

Cristina Onete || 25/09/2014 || 9

m pad r

G

H

YX

bits bits bits

K = size of n=pq

= parameters (to be set)G,H = hash functions

= bit XOR

Page 10: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 10

The OAEP Function

In detail: OAEP

m pad r

G

Hash functions

β€’ A box with input of any size, and output of fixed sizeIn this case: input is bits, output is

β€’ Collision-resistance: can’t find with β€’ Random oracles: always outputs new string

Outputs consistently: consistent

Page 11: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 11

The OAEP Function

In detail: OAEP

m pad r

G

How it works:

r

bits

G 𝐼 0

m pad 𝐼 0 𝑋=

bitsrandom

Page 12: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 12

The OAEP Function

In detail: OAEP

How it works:

bits

H 𝐼 1

bits

𝐼 1 π‘Œ=

H

r𝑋

𝑋

r

random

Page 13: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 13

RSA-OAEP Decryption

are random oracles Hard to invert

How do we decrypt?Go in reverse: receive

Decrypt:

m pad r

G

H

YX

Page 14: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 14

RSA-OAEP Decryption

are random oracles Hard to invert

How do we decrypt?Go in reverse: receive

H 𝐼 1

𝐼 1 π‘Œ=

𝑋

r

𝐻 ( 𝑋 )=𝐼 1

π‘Ÿ 𝐼 1=π‘Œ

π‘Ÿ 𝐻 (𝑋 )=π‘Œ

Decrypt:

π‘Ÿ=𝐻 ( 𝑋 )π‘Œ

Page 15: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 15

RSA-OAEP Decryption

are random oracles Hard to invertHow do we decrypt?Go in reverse: receive

Decrypt: Recover:

m pad r

G

H

YX

Page 16: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 16

RSA-OAEP Decryption

are random oracles Hard to invert

How do we decrypt?Go in reverse: receive

Decrypt: Recover:

r G 𝐼 0

m pad 𝐼 0 𝑋=

𝐺 (π‘Ÿ )=𝐼 0

π‘šβˆ¨π‘π‘Žπ‘‘ 𝐼 0=𝑋

π‘šβˆ¨π‘π‘Žπ‘‘πΊ (π‘Ÿ )=π‘‹π‘šβˆ¨π‘π‘Žπ‘‘=𝐺 (π‘Ÿ ) 𝑋

Page 17: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 17

RSA-OAEP Decryption

are random oracles Hard to invert

How do we decrypt?Go in reverse: receive

Decrypt: Recover:

Retrieve:

Check: pad has the right format

Page 18: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 18

The OAEP Function

In detail: OAEP

β€’ Functions are random oracles: that is, they give random output. In practice: use SHA-1

β€’ Randomness chosen freshly every timeβ€’ How about the padding?

m pad r

β€’ Original OAEP: ([BR94])β€’ OAEP+: with W a random oracle ([S01])

Page 19: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 19

Improving OAEP: SAEP

m W(m,r) r

H

YX

bits bits bits

β€’ No need for function β€’ Function is random oracle. Input size: bits. Output

size: bits

Page 20: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 20

Contents

Pre-processingβ€’ How OAEP works

β€’ Improvements on OAEPβ€’ Hash Functions; Random Oracles (brief)

Generic attacks on factoringβ€’ Small Small or β€’ Pollard-

Unsafe modes for RSA

β€’ Small sk: Wiener’s attackSome physical attacks

β€’ Small pk and related ciphertexts

Page 21: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 21

Attacks on RSA

For the remainder of this lecture

We =

1st goal:

β€’ Given something of the form , find Strategies:β€’ Generic: factor . Given , easy to recover β€’ Specific: retrieve plaintext without factoring

Page 22: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 22

Small

Easy case: we are given and

β€’ If are prime, then β€’ Given and

Calculate: This gives:

Also:

So:

and: ΒΏβˆ“βˆš(π‘›βˆ’πœ‘ (𝑛)+1)2βˆ’4𝑛

Factorization: and

Page 23: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 23

Small

Hard case: we are given only Try to guess Use: Then:

Algorithm SmallDiff: Input Complexity parameter Write Let .

Note: are odd. Thus: and are even

IF is a square (it is equal to for a positive integer )

THEN: if and are prime, Output and

ELSE:

While DO

Page 24: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 24

Small or : Pollard’s

Attack on factoring – bad (p-1)

β€’ Vulnerability: with one small prime β€’ Pollard’s-(p-1) factors in steps if smallest factor

If is small, then this method is fast

β€’ Idea: if is prime, then is not

Since all are odd (impair), is even

We are hoping has only small factors and we will try to retrieve them all

Obviously will have 2 as a factor

All in the same set

Page 25: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 25

Small or : Pollard’s

Attack on factoring – bad (p-1)

β€’ Vulnerability: with one small prime β€’ Supposition:

β€’ How large can be for each ?

Well, for any , so

β€’ Start with definite upper bound:

As , any divides . So divides

1β‰€π‘Ž<𝑝 :π‘Žπ‘βˆ’ 1=1(π‘šπ‘œπ‘‘π‘) So

Page 26: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 26

Small or : Pollard’s

Attack on factoring – bad (p-1)

β€’ Vulnerability: with one small prime

As , any divides . So divides

1β‰€π‘Ž<𝑝 :π‘Žπ‘βˆ’ 1=1(π‘šπ‘œπ‘‘π‘) So

Pick random Check that

𝑝 dividesπ‘Žπ‘…βˆ’1

β€’ If : then . Hooray!

β€’ If and With high probability

Then Else, pick a new a

Page 27: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 27

Exercise time!

Write pseudocode for Pollard’s

Page 28: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 28

So far

Small

β€’ Given and : calculate Take:

Factorization: and

β€’ Given : verify values of for integer

For each check if is integer

If so, if are prime then:Output

Else, next and repeat procedure

Page 29: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 29

So far

Small

Pick random Check that β€’ If : then . Hooray!

β€’ If and With high probability

Then

Else, pick a new a and repeat

Page 30: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 30

Pollard’s

General factorization attack (are we lucky?)

β€’ Strategy: find specific small such that Most likely then,

β€’ Imagine we could calculate Say we had:

β€’ Suppose we find such that , then:

π‘Žπ‘’βˆ’π‘Žπ‘£=0(π‘šπ‘œπ‘‘π‘) divides

Then with high probability

β€’ But, we don’t know . We do this .

Page 31: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 31

Pollard’s

β€’ Strategy: we compute:

β€’ Choice: speed vs. storage

β€’ Find: such that β€’ With high probability

β€’ Storage: method as above. Need to store all β€’ Speed: Floyd’s cycle finding algorithm:

β€’ and β€’ Mod n:

Only checking pairs at a time

Page 32: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 32

Floyd’s Cycle-Finding Alg.

Source:http://home.online.no/~vlaenen/

Page 33: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 33

Exercise time!

Put the method (with Floyd’s cycle-finding algorithm) in pseudocode/algorithm form!

Page 34: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 34

Contents

Pre-processingβ€’ How OAEP works

β€’ Improvements on OAEPβ€’ Hash Functions; Random Oracles (brief)

Generic attacks on factoringβ€’ Small Small or β€’ Pollard-

Unsafe modes for RSA

β€’ Small sk: Wiener’s attackSome physical attacks

β€’ Small pk and related ciphertexts

Page 35: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 35

Unsafe Modes for RSA

Small public keyβ€’ More receivers with same small (different )β€’ Same plaintext is sent to users

π‘šπ‘’

π‘šπ‘’(π‘šπ‘œπ‘‘π‘ 1)

π‘šπ‘’(π‘šπ‘œπ‘‘π‘ 2)

π‘šπ‘’(π‘šπ‘œπ‘‘π‘ 1)

π‘šπ‘’(π‘šπ‘œπ‘‘π‘ 1)

π‘š

Page 36: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 36

Unsafe Modes for RSA

Small public keyβ€’ One receiver with small (different )β€’ Two related plaintexts: and

β€’ If knows the relationship of the messages,

she can use polynomial multiplication to find

Recommended

β€’ e =

β€’ This leads to fast encryption

Page 37: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 37

More Unsafe Modes

Small secret keyβ€’ Better for decryption: makes it more efficient

𝑒𝑑=1(π‘šπ‘œπ‘‘πœ‘ (𝑁 )) 𝑒𝑑=1(π‘šπ‘œπ‘‘(𝐿𝐢𝑀 (π‘βˆ’1 ,π‘žβˆ’1)))

Math β€œmagic”

β†’β€’ Use: least common multiple LCM

𝐿𝐢𝑀 (π‘βˆ’1 ,π‘žβˆ’1 )= (π‘βˆ’1)(π‘žβˆ’1)𝐺𝐢𝐷(π‘βˆ’1 ,π‘žβˆ’1) 𝐺

𝑒𝑑=1+𝐾𝐺

(π‘π‘žβˆ’π‘βˆ’π‘ž+1)β†’

Divide by dpq

π‘’π‘π‘ž

=1

π‘‘π‘π‘ž+𝐾𝑑𝐺

βˆ’πΎ

π‘‘πΊπ‘žβˆ’

𝐾𝑑𝐺𝑝

+𝐾

π‘‘πΊπ‘π‘ž

π‘’π‘π‘žβˆ’

1π‘‘π‘π‘ž

+ 𝐾𝑑𝐺 ( 1π‘ž + 1

π‘βˆ’1π‘π‘ž )= 𝐾

𝑑𝐺

Page 38: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 38

More Unsafe Modes

Small secret keyβ€’ If is small, then .

𝐾𝑑𝐺

= π‘’π‘π‘žβˆ’

1π‘‘π‘π‘ž

+ 𝐾𝑑𝐺 ( 1π‘ž + 1

π‘βˆ’1π‘π‘ž )

β€’ If is small, then .Tend to 0

≅𝑒𝑛≅ 1

| πΎπ‘‘πΊβˆ’ π‘’π‘π‘ž|=| 𝐾𝑑𝐺 ( 1π‘ž+ 1

π‘βˆ’1π‘π‘ž )βˆ’ 1

π‘‘π‘π‘ž|≀ 1

βˆšπ‘π‘ž< 1

2(𝑑𝐺)2

β€’ This means that converges towards

β€’ Continued fractions and some trial and error gives d

Page 39: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 39

Physical Attacks

Implementation: Square and Multiply

π‘š=𝑐𝑑(π‘šπ‘œπ‘‘π‘›)β€’ Standard way to do exponentiation

β€’ Write in binary []. Set For DO:

β€’ If then set β€’ Else, set

Square AND Multiply

Square

β€’ Example:

i 7 6 5 4 3 2 1 0

m

Page 40: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

Cristina Onete || 25/09/2014 || 40

Physical Attacks

Implementation: Square and Multiply

π‘š=𝑐𝑑(π‘šπ‘œπ‘‘π‘›)

β€’ Time the operation and write out the order of ops

Timing attack: multiply takes longer than square

M, Sq, Sq, M, Sq, Sq, M, Sq, M, Sq, Sq, M

β€’ Retrieve key from inverse Square and Multiply

Power attack: multiply burns more than square

β€’ Retrieve for smartcards

Source: http://www.dbs.com.hk/

Page 41: Rennes, 02/10/2014 Cristina Onete maria-cristina.onete@irisa.fr Attacks on RSA. Safe modes

CIDRE

Thanks!


Recommended