+ All Categories
Home > Documents > Rennes, 02/10/2014 Cristina Onete [email protected] Attacks on RSA. Safe modes.

Rennes, 02/10/2014 Cristina Onete [email protected] Attacks on RSA. Safe modes.

Date post: 05-Jan-2016
Category:
Upload: sabrina-hines
View: 217 times
Download: 3 times
Share this document with a friend
41
Rennes, 02/10/2014 Cristina Onete maria- [email protected] Attacks on RSA. Safe modes.
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