SlideShare una empresa de Scribd logo
1 de 59
Descargar para leer sin conexión
CNIT 141
Cryptography for Computer Networks
10.RSA
Topics
• The Math Behind RSA
• The RSA Trapdoor Permutation
• RSA Key Generation and Security
• Encrypting with RSA
• Signing with RSA
• RSA Implementations
• How Things Can Go Wrong
The Math Behind RSA
The Group ZN*
• If N is prime, Zp* contains {1,2, 3, ... p-1}
• So Z5* contains {1,2,3,4}
• 0 is excluded because it has no inverse
• But Z4* contains {1,3}
• 2 has no inverse
• Because 4 is a multiple of 2
N = 10
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

0
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

1
N = 10
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

2
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

3
N = 10
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

4
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

5
N = 10
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

6
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

7
N = 10
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

8
0
5
1
4
3
2
9
6
7
8 Multiples 

of 

9
The Group Z10*
• Z10* contains {1, 3, 7, 9}
• 0, 2, 4, 5, 6, 8 are excluded
• Because they have no inverse
• Because they have a common factor with 10
• They aren't co-prime with 10
Euler's Totient
• How many elements are in the group Zn*?
• When n is not prime, but the product of
several prime numbers
• n = p1 ✖ p2 ✖ ... ✖ pm
• ϕ(n) = (p1 - 1) ✖ (p2 - 1) ✖ ... ✖ (pm - 1)
• For Z10*
• n = 10 = 2 ✖ 5
• ϕ(10) = 1 ✖ 4 : 4 elements in Z10*
The RSA Trapdoor
Permutation
RSA Parameters
• n is the modulus
• Product of two primes p and q
• e is the public exponent
• In practice, usually 65537
• Public key: (n, e)
• Private key: p and other values easily derived
from it
Trapdoor Permutation
• x is the plaintext message
• y is the ciphertext
Encryption: y = xe mod n
Decryption: x = yd mod n
• d is the decryption key
• calculated from p and q
Calculating d
• ed = 1 mod ϕ(n)
• Decryption: x = yd mod n

= (xe)d mod n

= xed mod n

= x mod n

= x
Example: n=10
n=10; x=3
0
5
1
4
3
2
9
6
7
8
0
5
1
4
3
2
9
6
7
8
31 = 3 32 = 9
0
5
1
4
3
2
9
6
7
8
0
5
1
4
3
2
9
6
7
8
n=10; x=3
33 = 27 34 = 81
• Z10* contains {1, 3, 7, 9}
• 4 elements
• 3 is a generator of the group
• Although n is 10, the powers of 3 repeat with a
cycle of 4 (ϕ(n) )
• Encrypt by raising x to a power, forming y
• Decrypt by raising y to a power, returning x
Powers of 3 31 mod 10 = 3

32 mod 10 = 9

33 mod 10 = 7

34 mod 10 = 1
35 mod 10 = 3
• Z10* contains {1, 3, 7, 9}
• 4 elements
• p = 2 and q = 5
• ϕ(n) = (p-1)(q-1) = 1x4 = 4
• ed = 1 mod ϕ(n)
• For e = 3, d = 3
Finding d
n=10; x=3; e=3
3x1 mod 4 = 3

3x2 mod 4 = 2

3x3 mod 4 = 1
• x is the plaintext message (3)
• y is the ciphertext
Encryption: y = xe mod n 

= 33 mod 10 = 7
Decryption: x = yd mod n 

= 73 mod 10 

= 343 mod 10 

= 3
n=10; x=3; e=3; d=7
Example: n=14
2
n=14; x=3
0
31 = 3
1
3
4
5
67
13
8
12
9
11
10
2
0
32 = 9
1
3
4
5
67
13
8
12
9
11
10
2
n=14; x=3
0
33 = 27
1
3
4
5
67
13
8
12
9
11
10
2
0
34 = 81
1
3
4
5
67
13
8
12
9
11
10
2
n=14; x=3
0
35 = 243
1
3
4
5
67
13
8
12
9
11
10
2
0
36 = 729
1
3
4
5
67
13
8
12
9
11
10
• Z14* contains 

{1, 3, 5, 9, 11, 13}
• 6 elements (ϕ(n) )
• 3 is a generator of the group
Powers of 3
31 mod 14 = 3

32 mod 14 = 9

33 mod 14 = 13

34 mod 14 = 11
35 mod 14 = 5
36 mod 14 = 1
• Z14* contains 

{1, 3, 5, 9, 11, 13}
• 6 elements
• p = 2 and q = 7
• ϕ(n) = (p-1)(q-1) = 1x6 = 6
• ed = 1 mod ϕ(n)
• For e = 5, d = 5
Finding d
n=14; x=3; e=5
5x1 mod 6 = 5

5x2 mod 6 = 4

5x3 mod 6 = 3

5x4 mod 6 = 2

5x5 mod 6 = 1
• x is the plaintext message (3)
• y is the ciphertext
Encryption: y = xe mod n 

= 35 mod 14 = 5
Decryption: x = yd mod n 

= 55 mod 14 

= 3125 mod 14 

= 3
n=14; x=3; e=5; d=5
RSA Key Generation and
Security
Key Generation
• Pick random primes p and q
• Calculate ϕ(n) from p and q
• Pick e
• Calculate d (inverse of e)
RSA Encryption in Python
RSA Decryption in Python
Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl"32
Speed of Calculations
• Encryption is fastest
• Decryption is much slower
• Key generation is slowest
Encrypting with RSA
Used with AES
• RSA typically not used to encrypt plaintext
directly
• RSA is used to encrypt an AES private key
Textbook RSA
• Plaintext converted to ASCII bytes
• Placed in x
• RSA used to compute y = xe mod n
Malleability
• Encrypt two plaintext messages x1 and x2
• y1 = x1e mod n
• y2 = x2e mod n
• Consider the plaintext (x1)(x2)
• Multiplying x1 and x2 together
• y = (x1e mod n)(x2e mod n) = (y1)(y2)
• An attacker can create valid ciphertext without
the key
Strong RSA Encryption:
OAEP
• Optimal Asymmetric Encryption Padding
• Padded plaintext is as long as n
• Includes extra data and randomness
PKCS#1 v1.5
• An old method created by RSA
• Much less secure than OAEP
• Used in many systems
Signing with RSA
Digital Signatures
• Sign a message x with y = xd mod n
• No one can forge the signature because d is
secret
• Everyone can verify the signature using e
• x = ye mod n
• Notice that x is not secret
• Signatures prevent forgeries, they don't
provide confidentiality
Signing a Hash
• Signing long messages is slow and
uncommon
• Typically the message is hashed
• Then the hash is signed
Textbook RSA Signatures
• Sign a message x with y = xd mod n
• Attacker can forge signatures
• For x =0, 1, or n - 1
Blinding Attack
• You want to get the signature for message M
• Which the targeted user would never
willingly sign
• Find a value R such that ReM mod n
• Is a message the user will sign
• That signature S is (ReM)d mod n
• = RedMd mod n = RMd mod n
• The signature we want is Md mod n = S/R
The PSS Signature Standard
• Makes signatures more secure, the way OAEP
makes encryption more secure
• Combines the message with random and fixed bits
Full Domain Hash
Signatures (FDH)
• x = Hash(message)
• Signature y = xe mod n
FDH v. PSS
• PSS came later
• More proof of theoretical security
• Because of added randomness
• But in practice they are similar in secuity
• But PS is safer against fault attacks
RSA Implementations
Just Use Libraries
• Much easier and safer than writing your own
implementation
Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl
Square-and-Multiply
• Consider RSA with a 1024-bit key
• We need to calculate xe where e is 1024
bits long
• x * x * x * x .... 21024 multiplications
• Competely impossible -- we can't even
crack a 72-bit key yet (272 calculations)
"50
Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl
Square-and-Multiply
• Use memory to save time
• Do these ten multiplications
• x2 = x * x
• x4 = x2 * x2
• x8 = x4 * x4
• x16 = x8 * x8
• ...
• x1024 = x512 * x512
• ...
• Combine the results to make any
exponent
"51
Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl
Square-and-Multiply
• With this trick, a 1024-bit exponent can be
calculated with only 1536 multiplications
• But each number being multiplied is 1024
bits long, so it still takes a lot of CPU
"52
Side-Channel Attacks
• The speedup from square-and-multiply means
that exponent bits of 1 take more time than
exponent bits of 0
• Measuring power consumption or timing can
leak out information about the key
• Few libraries are protected from such attacks
• EverCrypt -- a library immune to timing attacks
• From Microsoft research
• Link Ch 10b
Small e for Faster
Encryption
• Encryption: y = xe mod n
• Decryption: x = yd mod n
• Choosing small e makes encryption faster, but
decryption slower
Chinese Remainder
Theorem
• Replaces one operation mod n
• Encryption: y = xe mod n
• With two operations mod p and q
• Making RSA four times faster
How Things Can Go
Wrong
Bellecore Attack on 

RSA-CRT
• Fault injection
• Alter the power supply
• or hit chips with a laser pulse
• Can break deterministic schemes like CRT
• But not ones including randomness like PSS
CNIT 141: 10. RSA

Más contenido relacionado

La actualidad más candente

CNIT 141 12. Elliptic Curves
CNIT 141 12. Elliptic CurvesCNIT 141 12. Elliptic Curves
CNIT 141 12. Elliptic CurvesSam Bowne
 
CNIT 141: 14. Quantum and Post-Quantum
CNIT 141: 14. Quantum and Post-Quantum CNIT 141: 14. Quantum and Post-Quantum
CNIT 141: 14. Quantum and Post-Quantum Sam Bowne
 
An Analysis of RSA Public Exponent e
An Analysis of RSA Public Exponent eAn Analysis of RSA Public Exponent e
An Analysis of RSA Public Exponent eDharmalingam Ganesan
 
Homomorphic Encryption
Homomorphic EncryptionHomomorphic Encryption
Homomorphic EncryptionGöktuğ Serez
 
CNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsCNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsSam Bowne
 
CNIT 141: 11. Diffie-Hellman
CNIT 141: 11. Diffie-HellmanCNIT 141: 11. Diffie-Hellman
CNIT 141: 11. Diffie-HellmanSam Bowne
 
CRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYCRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
Cyclic Attacks on the RSA Trapdoor Function
Cyclic Attacks on the RSA Trapdoor FunctionCyclic Attacks on the RSA Trapdoor Function
Cyclic Attacks on the RSA Trapdoor FunctionDharmalingam Ganesan
 
An Analysis of Secure Remote Password (SRP)
An Analysis of Secure Remote Password (SRP)An Analysis of Secure Remote Password (SRP)
An Analysis of Secure Remote Password (SRP)Dharmalingam Ganesan
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryptionsecurityxploded
 
Security Attacks on RSA
Security Attacks on RSASecurity Attacks on RSA
Security Attacks on RSAPratik Poddar
 
RSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyRSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyMd. Shafiul Alam Sagor
 

La actualidad más candente (20)

CNIT 141 12. Elliptic Curves
CNIT 141 12. Elliptic CurvesCNIT 141 12. Elliptic Curves
CNIT 141 12. Elliptic Curves
 
CNIT 141: 14. Quantum and Post-Quantum
CNIT 141: 14. Quantum and Post-Quantum CNIT 141: 14. Quantum and Post-Quantum
CNIT 141: 14. Quantum and Post-Quantum
 
同態加密
同態加密同態加密
同態加密
 
An Analysis of RSA Public Exponent e
An Analysis of RSA Public Exponent eAn Analysis of RSA Public Exponent e
An Analysis of RSA Public Exponent e
 
Homomorphic Encryption
Homomorphic EncryptionHomomorphic Encryption
Homomorphic Encryption
 
CNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsCNIT 141 6. Hash Functions
CNIT 141 6. Hash Functions
 
Rsa
RsaRsa
Rsa
 
CNIT 141: 11. Diffie-Hellman
CNIT 141: 11. Diffie-HellmanCNIT 141: 11. Diffie-Hellman
CNIT 141: 11. Diffie-Hellman
 
CRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYCRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITY
 
The rsa algorithm JooSeok Song
The rsa algorithm JooSeok SongThe rsa algorithm JooSeok Song
The rsa algorithm JooSeok Song
 
Cyclic Attacks on the RSA Trapdoor Function
Cyclic Attacks on the RSA Trapdoor FunctionCyclic Attacks on the RSA Trapdoor Function
Cyclic Attacks on the RSA Trapdoor Function
 
Analysis of Shared RSA Modulus
Analysis of Shared RSA ModulusAnalysis of Shared RSA Modulus
Analysis of Shared RSA Modulus
 
An Analysis of Secure Remote Password (SRP)
An Analysis of Secure Remote Password (SRP)An Analysis of Secure Remote Password (SRP)
An Analysis of Secure Remote Password (SRP)
 
PKC&RSA
PKC&RSAPKC&RSA
PKC&RSA
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
 
RSA ALGORITHM
RSA ALGORITHMRSA ALGORITHM
RSA ALGORITHM
 
Security Attacks on RSA
Security Attacks on RSASecurity Attacks on RSA
Security Attacks on RSA
 
RSA Algorithm
RSA AlgorithmRSA Algorithm
RSA Algorithm
 
RSA
RSARSA
RSA
 
RSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyRSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key Cryptography
 

Similar a CNIT 141: 10. RSA

CNIT 141 10. RSA
CNIT 141 10. RSACNIT 141 10. RSA
CNIT 141 10. RSASam Bowne
 
Cybersecurity cyberlab3
Cybersecurity cyberlab3Cybersecurity cyberlab3
Cybersecurity cyberlab3rayborg
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithmVaibhav Khanna
 
Public_Key_Cryptography in crypto analysis.ppt
Public_Key_Cryptography in crypto analysis.pptPublic_Key_Cryptography in crypto analysis.ppt
Public_Key_Cryptography in crypto analysis.pptImmanImman6
 
Cryptography using rsa cryptosystem
Cryptography using rsa cryptosystemCryptography using rsa cryptosystem
Cryptography using rsa cryptosystemSamdish Arora
 
Introduction to cryptography part2-final
Introduction to cryptography  part2-finalIntroduction to cryptography  part2-final
Introduction to cryptography part2-finalTaymoor Nazmy
 
Simple Overview Caesar and RSA Encryption_by_Tarek_Gaber
Simple Overview Caesar and RSA Encryption_by_Tarek_GaberSimple Overview Caesar and RSA Encryption_by_Tarek_Gaber
Simple Overview Caesar and RSA Encryption_by_Tarek_GaberTarek Gaber
 
Broadcasting and low exponent rsa attack
Broadcasting and low exponent rsa attackBroadcasting and low exponent rsa attack
Broadcasting and low exponent rsa attackAnkita Kapratwar
 
Ch12 Encryption
Ch12 EncryptionCh12 Encryption
Ch12 Encryptionphanleson
 
Cryptography and applications
Cryptography and applicationsCryptography and applications
Cryptography and applicationsthai
 
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptx
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptxRivest Shamir Adleman Algorithm and its variant : DRSA.pptx
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptxwerip98386
 

Similar a CNIT 141: 10. RSA (20)

CNIT 141 10. RSA
CNIT 141 10. RSACNIT 141 10. RSA
CNIT 141 10. RSA
 
10 RSA
10 RSA10 RSA
10 RSA
 
Cybersecurity cyberlab3
Cybersecurity cyberlab3Cybersecurity cyberlab3
Cybersecurity cyberlab3
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithm
 
Public_Key_Cryptography in crypto analysis.ppt
Public_Key_Cryptography in crypto analysis.pptPublic_Key_Cryptography in crypto analysis.ppt
Public_Key_Cryptography in crypto analysis.ppt
 
Class3
Class3Class3
Class3
 
Cryptography using rsa cryptosystem
Cryptography using rsa cryptosystemCryptography using rsa cryptosystem
Cryptography using rsa cryptosystem
 
Introduction to cryptography part2-final
Introduction to cryptography  part2-finalIntroduction to cryptography  part2-final
Introduction to cryptography part2-final
 
Simple Overview Caesar and RSA Encryption_by_Tarek_Gaber
Simple Overview Caesar and RSA Encryption_by_Tarek_GaberSimple Overview Caesar and RSA Encryption_by_Tarek_Gaber
Simple Overview Caesar and RSA Encryption_by_Tarek_Gaber
 
3 pkc+rsa
3 pkc+rsa3 pkc+rsa
3 pkc+rsa
 
Broadcasting and low exponent rsa attack
Broadcasting and low exponent rsa attackBroadcasting and low exponent rsa attack
Broadcasting and low exponent rsa attack
 
RSA ALGORITHM
RSA ALGORITHMRSA ALGORITHM
RSA ALGORITHM
 
Ch9
Ch9Ch9
Ch9
 
Ch12 Encryption
Ch12 EncryptionCh12 Encryption
Ch12 Encryption
 
Prime numbers
Prime numbersPrime numbers
Prime numbers
 
Cryptography and applications
Cryptography and applicationsCryptography and applications
Cryptography and applications
 
Cryptography-101
Cryptography-101Cryptography-101
Cryptography-101
 
Cryptography - 101
Cryptography - 101Cryptography - 101
Cryptography - 101
 
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptx
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptxRivest Shamir Adleman Algorithm and its variant : DRSA.pptx
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptx
 
CNS.ppt
CNS.pptCNS.ppt
CNS.ppt
 

Más de Sam Bowne

3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 
4. Block Ciphers
4. Block Ciphers 4. Block Ciphers
4. Block Ciphers Sam Bowne
 

Más de Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 
4. Block Ciphers
4. Block Ciphers 4. Block Ciphers
4. Block Ciphers
 

Último

PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Último (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

CNIT 141: 10. RSA

  • 1. CNIT 141 Cryptography for Computer Networks 10.RSA
  • 2. Topics • The Math Behind RSA • The RSA Trapdoor Permutation • RSA Key Generation and Security • Encrypting with RSA • Signing with RSA • RSA Implementations • How Things Can Go Wrong
  • 4. The Group ZN* • If N is prime, Zp* contains {1,2, 3, ... p-1} • So Z5* contains {1,2,3,4} • 0 is excluded because it has no inverse • But Z4* contains {1,3} • 2 has no inverse • Because 4 is a multiple of 2
  • 5. N = 10 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 0 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 1
  • 6. N = 10 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 2 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 3
  • 7. N = 10 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 4 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 5
  • 8. N = 10 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 6 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 7
  • 9. N = 10 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 8 0 5 1 4 3 2 9 6 7 8 Multiples 
 of 
 9
  • 10. The Group Z10* • Z10* contains {1, 3, 7, 9} • 0, 2, 4, 5, 6, 8 are excluded • Because they have no inverse • Because they have a common factor with 10 • They aren't co-prime with 10
  • 11. Euler's Totient • How many elements are in the group Zn*? • When n is not prime, but the product of several prime numbers • n = p1 ✖ p2 ✖ ... ✖ pm • ϕ(n) = (p1 - 1) ✖ (p2 - 1) ✖ ... ✖ (pm - 1) • For Z10* • n = 10 = 2 ✖ 5 • ϕ(10) = 1 ✖ 4 : 4 elements in Z10*
  • 13. RSA Parameters • n is the modulus • Product of two primes p and q • e is the public exponent • In practice, usually 65537 • Public key: (n, e) • Private key: p and other values easily derived from it
  • 14. Trapdoor Permutation • x is the plaintext message • y is the ciphertext Encryption: y = xe mod n Decryption: x = yd mod n • d is the decryption key • calculated from p and q
  • 15. Calculating d • ed = 1 mod ϕ(n) • Decryption: x = yd mod n
 = (xe)d mod n
 = xed mod n
 = x mod n
 = x
  • 19. • Z10* contains {1, 3, 7, 9} • 4 elements • 3 is a generator of the group • Although n is 10, the powers of 3 repeat with a cycle of 4 (ϕ(n) ) • Encrypt by raising x to a power, forming y • Decrypt by raising y to a power, returning x Powers of 3 31 mod 10 = 3
 32 mod 10 = 9
 33 mod 10 = 7
 34 mod 10 = 1 35 mod 10 = 3
  • 20. • Z10* contains {1, 3, 7, 9} • 4 elements • p = 2 and q = 5 • ϕ(n) = (p-1)(q-1) = 1x4 = 4 • ed = 1 mod ϕ(n) • For e = 3, d = 3 Finding d n=10; x=3; e=3 3x1 mod 4 = 3
 3x2 mod 4 = 2
 3x3 mod 4 = 1
  • 21. • x is the plaintext message (3) • y is the ciphertext Encryption: y = xe mod n 
 = 33 mod 10 = 7 Decryption: x = yd mod n 
 = 73 mod 10 
 = 343 mod 10 
 = 3 n=10; x=3; e=3; d=7
  • 23. 2 n=14; x=3 0 31 = 3 1 3 4 5 67 13 8 12 9 11 10 2 0 32 = 9 1 3 4 5 67 13 8 12 9 11 10
  • 24. 2 n=14; x=3 0 33 = 27 1 3 4 5 67 13 8 12 9 11 10 2 0 34 = 81 1 3 4 5 67 13 8 12 9 11 10
  • 25. 2 n=14; x=3 0 35 = 243 1 3 4 5 67 13 8 12 9 11 10 2 0 36 = 729 1 3 4 5 67 13 8 12 9 11 10
  • 26. • Z14* contains 
 {1, 3, 5, 9, 11, 13} • 6 elements (ϕ(n) ) • 3 is a generator of the group Powers of 3 31 mod 14 = 3
 32 mod 14 = 9
 33 mod 14 = 13
 34 mod 14 = 11 35 mod 14 = 5 36 mod 14 = 1
  • 27. • Z14* contains 
 {1, 3, 5, 9, 11, 13} • 6 elements • p = 2 and q = 7 • ϕ(n) = (p-1)(q-1) = 1x6 = 6 • ed = 1 mod ϕ(n) • For e = 5, d = 5 Finding d n=14; x=3; e=5 5x1 mod 6 = 5
 5x2 mod 6 = 4
 5x3 mod 6 = 3
 5x4 mod 6 = 2
 5x5 mod 6 = 1
  • 28. • x is the plaintext message (3) • y is the ciphertext Encryption: y = xe mod n 
 = 35 mod 14 = 5 Decryption: x = yd mod n 
 = 55 mod 14 
 = 3125 mod 14 
 = 3 n=14; x=3; e=5; d=5
  • 29. RSA Key Generation and Security
  • 30. Key Generation • Pick random primes p and q • Calculate ϕ(n) from p and q • Pick e • Calculate d (inverse of e)
  • 31. RSA Encryption in Python RSA Decryption in Python
  • 32. Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl"32 Speed of Calculations • Encryption is fastest • Decryption is much slower • Key generation is slowest
  • 34. Used with AES • RSA typically not used to encrypt plaintext directly • RSA is used to encrypt an AES private key
  • 35. Textbook RSA • Plaintext converted to ASCII bytes • Placed in x • RSA used to compute y = xe mod n
  • 36. Malleability • Encrypt two plaintext messages x1 and x2 • y1 = x1e mod n • y2 = x2e mod n • Consider the plaintext (x1)(x2) • Multiplying x1 and x2 together • y = (x1e mod n)(x2e mod n) = (y1)(y2) • An attacker can create valid ciphertext without the key
  • 37. Strong RSA Encryption: OAEP • Optimal Asymmetric Encryption Padding • Padded plaintext is as long as n • Includes extra data and randomness
  • 38.
  • 39. PKCS#1 v1.5 • An old method created by RSA • Much less secure than OAEP • Used in many systems
  • 41. Digital Signatures • Sign a message x with y = xd mod n • No one can forge the signature because d is secret • Everyone can verify the signature using e • x = ye mod n • Notice that x is not secret • Signatures prevent forgeries, they don't provide confidentiality
  • 42. Signing a Hash • Signing long messages is slow and uncommon • Typically the message is hashed • Then the hash is signed
  • 43. Textbook RSA Signatures • Sign a message x with y = xd mod n • Attacker can forge signatures • For x =0, 1, or n - 1
  • 44. Blinding Attack • You want to get the signature for message M • Which the targeted user would never willingly sign • Find a value R such that ReM mod n • Is a message the user will sign • That signature S is (ReM)d mod n • = RedMd mod n = RMd mod n • The signature we want is Md mod n = S/R
  • 45. The PSS Signature Standard • Makes signatures more secure, the way OAEP makes encryption more secure • Combines the message with random and fixed bits
  • 46. Full Domain Hash Signatures (FDH) • x = Hash(message) • Signature y = xe mod n
  • 47. FDH v. PSS • PSS came later • More proof of theoretical security • Because of added randomness • But in practice they are similar in secuity • But PS is safer against fault attacks
  • 49. Just Use Libraries • Much easier and safer than writing your own implementation
  • 50. Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl Square-and-Multiply • Consider RSA with a 1024-bit key • We need to calculate xe where e is 1024 bits long • x * x * x * x .... 21024 multiplications • Competely impossible -- we can't even crack a 72-bit key yet (272 calculations) "50
  • 51. Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl Square-and-Multiply • Use memory to save time • Do these ten multiplications • x2 = x * x • x4 = x2 * x2 • x8 = x4 * x4 • x16 = x8 * x8 • ... • x1024 = x512 * x512 • ... • Combine the results to make any exponent "51
  • 52. Chapter 7 of Understanding Cryptography by Christof Paar and Jan Pelzl Square-and-Multiply • With this trick, a 1024-bit exponent can be calculated with only 1536 multiplications • But each number being multiplied is 1024 bits long, so it still takes a lot of CPU "52
  • 53. Side-Channel Attacks • The speedup from square-and-multiply means that exponent bits of 1 take more time than exponent bits of 0 • Measuring power consumption or timing can leak out information about the key • Few libraries are protected from such attacks
  • 54. • EverCrypt -- a library immune to timing attacks • From Microsoft research • Link Ch 10b
  • 55. Small e for Faster Encryption • Encryption: y = xe mod n • Decryption: x = yd mod n • Choosing small e makes encryption faster, but decryption slower
  • 56. Chinese Remainder Theorem • Replaces one operation mod n • Encryption: y = xe mod n • With two operations mod p and q • Making RSA four times faster
  • 57. How Things Can Go Wrong
  • 58. Bellecore Attack on 
 RSA-CRT • Fault injection • Alter the power supply • or hit chips with a laser pulse • Can break deterministic schemes like CRT • But not ones including randomness like PSS