0% found this document useful (0 votes)
50 views36 pages

Week 6 - Cryptography - RSA

RSA is a widely used public-key cryptosystem. It uses a public key and private key pair generated from large prime numbers. The public key is used to encrypt messages, while the private key is used to decrypt messages. RSA provides both confidentiality through encryption with the public key and authentication through digital signatures with the private key. Its security relies on the difficulty of factoring large numbers.

Uploaded by

Tahir Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views36 pages

Week 6 - Cryptography - RSA

RSA is a widely used public-key cryptosystem. It uses a public key and private key pair generated from large prime numbers. The public key is used to encrypt messages, while the private key is used to decrypt messages. RSA provides both confidentiality through encryption with the public key and authentication through digital signatures with the private key. Its security relies on the difficulty of factoring large numbers.

Uploaded by

Tahir Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Cryptography

Public key cryptography and RSA


Week 6
Chapter 9 – Public Key Cryptography and
RSA

Every Egyptian received two names, which were


known respectively as the true name and the
good name, or the great name and the little
name; and while the good or little name was
made public, the true or great name appears to
have been carefully concealed.
—The Golden Bough, Sir James George Frazer
Private-Key Cryptography
• traditional private/secret/single key
cryptography uses one key
• Key is shared by both sender and
receiver
• if the key is disclosed
communications are compromised
• also known as symmetric, both
parties are equal
• hence does not protect sender from
receiver forging a message & claiming
is sent by sender
Symmetric Cryptography:
Analogy

K K

Safe with a strong lock, only Alice and Bob have a copy of the key
• Alice encrypts  locks message in the safe with her key
• Bob decrypts  uses his copy of the key to open the safe
Public-Key Cryptography
• probably most significant advance in
the 3000 year history of
cryptography
• uses two keys – a public key and a
private key
• asymmetric since parties are not
equal
• uses clever application of number
theory concepts to function
• complements rather than replaces
private key cryptography
Idea behind Asymmetric
Cryptography
New Idea:

Use the „good old mailbox“ principle:

Everyone can drop a letter

But: Only the owner has the


correct key to open the box

1976: first publication of such an algorithm by Whitfield Diffie and Martin Hellman,and
also by Ralph Merkle.
Asymmetric Cryptography:
Analogy
Safe with public lock and private lock:

(Kpub) (Kpr)

• Alice deposits (encrypts) a message with the - not secret - public key Kpub
• Only Bob has the - secret - private key Kpr to retrieve (decrypt) the message
Public-Key Cryptography
• public-key/two-key/asymmetric
cryptography involves the use of
two keys:
• a public-key, which may be known by
anybody, and can be used to encrypt
messages, and verify signatures
• a private-key, known only to the
recipient, used to decrypt messages,
and sign (create) signatures
• is asymmetric because
• those who encrypt messages or verify
signatures cannot decrypt messages
or create signatures
Public-Key Cryptography
Why Public-Key Cryptography?
• developed to address two key issues:
• key distribution – how to have secure
communications in general without
having to trust a KDC with your key
• digital signatures – how to verify a
message comes intact from the claimed
sender
• public invention due to Whitfield Diffie &
Martin Hellman at Stanford U. in 1976
• known earlier in classified community
Public-Key Characteristics
• Public-Key algorithms rely on two keys
with the characteristics that it is:
• computationally infeasible to find
decryption key knowing only algorithm
& encryption key
• computationally easy to en/decrypt
messages when the relevant
(en/decrypt) key is known
• either of the two related keys can be
used for encryption, with the other used
for decryption (in some schemes)
A breakthrough idea
• Rather than having a secret key that the two
users must share, each users has two keys.
• One key is secret and he is the only one
who knows it
• The other key is public and anyone who
wishes to send him a message uses that
key to encrypt the message
• Diffie and Hellman first (publicly)
introduced the idea in 1976 – this was
radically different than all previous efforts
A word of warning
Public-key cryptography complements
rather than replaces symmetric
cryptography
• There is nothing in principle to make public-key
crypto more secure than symmetric crypto
• Public-key crypto does not make symmetric crypto
obsolete: it has its advantages but also its (major)
drawbacks such as speed
• Due to its low speed, it is mostly confined to key
management and digital signatures

• Some algorithms (such as RSA) satisfy
also the following useful characteristic:
• Either one of the two keys can be used for
encryption – the other one should then be
used to decrypt the message
Essential steps in public-key
encryption
• Each user generates a pair of keys to be
used for encryption and decryption
• Each user places one of the two keys in a
public register and the other key is kept
private
• If B wants to send a confidential message
to A, B encrypts the message using A’s
public key

• When A receives the message, she
decrypts it using her private key
• Nobody else can decrypt the message
because that can only be done using A’s
private key
• Deducing a private key should be
infeasible
• If a user wishes to change his keys –
generate another pair of keys and publish
the public one: no interaction with other
users is needed
Bob sends an encrypted
message to Alice
Some notation

• The public key of user A will be denoted


PUA
• The private key of user A will be denoted
PRA
• Encryption method will be a function E
• Decryption method will be a function D
• If B wishes to send a plain message X to
A, then he sends the cryptotext
Y=E(PUA,X)
• The intended receiver A will decrypt the
message: D(PRA,Y)=X
A first attack on the public-key
scheme – authenticity
• Immediate attack on this scheme:
• An attacker may impersonate user B: he
sends a message E(PUA,X) and claims in
the message to be B – A has no guarantee
this is so
• This was guaranteed in classical
cryptosystems simply through knowing the
key (only A and B are supposed to know
the symmetric key)
The authenticity of user B can be
established as follows:
• B will encrypt the message using his
private key: Y=E(PRB,X)
• This shows the authenticity of the sender
because (supposedly) he is the only one
who knows the private key
• The entire encrypted message serves as a
digital signature
A scheme to authenticate the
sender of the message
Encryption and authenticity

• Still a drawback: the scheme on the


previous slide authenticate but does not
ensure security: anybody can decrypt the
message using B’s public key
One can provide both authentication and
confidentiality using the public-key scheme
twice:
• B encrypts X with his private key:
Y=E(PRB,X)
• B encrypts Y with A’s public key:
Z=E(PUA,Y)
• A will decrypt Z (and she is the only one
capable of doing it): Y=D(PRA,Z)
• A can now get the plaintext and ensure
that it comes from B (he is the only one
who knows his private key): decrypt Y
using B’s public key: X=E(PUB,Y)
Secrecy and authentication using
public-key schemes.
Applications for public-key
cryptosystems
• Encryption/decryption: sender encrypts
the message with the receiver’s public key
• Digital signature: sender “signs” the
message (or a representative part of the
message) using his private key
• Key exchange: two sides cooperate to
exchange a secret key for later use in a
secret-key cryptosystem
Security of Public Key Schemes
• like private key schemes brute force exhaustive
search attack is always theoretically possible
• but keys used are too large (>512bits)
• security relies on a large enough difference in
difficulty between easy (en/decrypt) and hard
(cryptanalyse) problems
• more generally the hard problem is known, its
just made too hard to do in practise
• requires the use of very large numbers
• hence is slow compared to private key schemes
RSA
 by Rivest, Shamir & Adleman of MIT in 1977
 best known & widely used public-key scheme
 based on exponentiation in a finite (Galois) field
over integers modulo a prime
 uses large integers eg. 1024 bits.(309 decimal
digits)
 security due to cost of factoring large numbers
Encryption and Decryption
• RSA operations are done over the integer ring Zn (i.e., arithmetic
modulo n), where n = p * q, with p, q being large primes
• Encryption and decryption are simply exponentiations in the ring
Definition
Given the public key (n,e) = kpub and the private key d = kpr we write

y = ekpub(x) ≡ xe mod n

x = dkpr(y) ≡ yd mod n

where x, y ε Zn.

We call ekpub() the encryption and dkpr() the decryption operation.


• In practice x, y, n and d are very long integer numbers (≥ 1024 bits)
• The security of the scheme relies on the fact that it is hard to derive
the „private exponent“ d given the public-key (n, e)

Chapter 7 of Understanding Cryptography by


Christof Paar and Jan Pelzl
Key Generation
• Like all asymmetric schemes, RSA has set-up phase during which
the private and public keys are computed
Algorithm: RSA Key Generation
Output: public key: kpub = (n, e) and private key kpr = d
1. Choose two large primes p, q
2. Compute n = p * q
3. Compute Φ(n) = (p-1) * (q-1)
4. Select the public exponent e ε {1, 2, …, Φ(n)-1} such that
gcd(e, Φ(n) ) = 1
5. Compute the private key d such that d * e ≡ 1 mod Φ(n)
6. RETURN kpub = (n, e), kpr = d

Remarks:
• Choosing two large, distinct primes p, q (in Step 1) is non-trivial
• gcd(e, Φ(n)) = 1 ensures that e has an inverse and, thus, that there
is always a private key d
Chapter 7 of Understanding Cryptography by
Christof Paar and Jan Pelzl
Example: RSA with small numbers
ALICE BOB
Message x = 4 1. Choose p = 3 and q = 11
2. Compute n = p * q = 33
3. Φ(n) = (3-1) * (11-1) = 20
4. Choose e = 3

Kpub = (33,3)
5. d ≡ e-1 ≡7 mod 20

y = xe ≡ 43 ≡ 31 mod 33
y = 31

yd = 317 ≡ 4 = x mod 33

Chapter 7 of Understanding Cryptography by


Christof Paar and Jan Pelzl
Using the Euclidean algorithm
• If we need to find d = e-1 mod n and we
can find integers x and y such that 
ex + ny = 1
then the inverse d is the value of x.
•  find d = 3-1 mod 20, we first obtain
 gcd(20, 3) and check that it's 1 (otherwise
the inverse doesn't exist)
20 = 3 x 6 + 2
3=2x1+1
• giving gcd(20, 3) = 1
• nx + ey = 1,
1=3-1x2
= 3 - 1 x (20 - 6 x 3)
= -1 x 20 + 7 x 3
• The value of x (the coefficient of 3) is 7,
so the inverse is 7.
RSA example:
Bob chooses p=5, q=7. Then n=35, z=24.
e=5 (so e, ø(n) relatively prime).
d=29 (so ed-1 exactly divisible by ø(n) or
d * e ≡ 1 mod Φ(n).

letter m me c = me mod n
encrypt:
l 12 1524832 17

d
decrypt:
c c m = cd mod n letter
17 481968572106750915091411825223071697 12 l
RSA Security
• possible approaches to attacking RSA are:
• brute force key search - infeasible given
size of numbers
• mathematical attacks - based on
difficulty of computing ø(n) , by
factoring modulus n
• timing attacks - on running of
decryption
• chosen ciphertext attacks - given
properties of RSA
References and further readings
• Book: cryptography and network security
by William Stalling 5th edition chapter 9
• Book:Understanding cryptography by
christof Paar chapter 6 & 7

You might also like