0% found this document useful (0 votes)
35 views31 pages

7 Ch07

The document discusses private-key and public-key cryptography, highlighting the differences between symmetric and asymmetric encryption. It details the RSA encryption algorithm, including key generation, encryption, and decryption processes, as well as potential security threats like brute force and timing attacks. The document concludes by summarizing the principles of public-key cryptography and the RSA algorithm's implementation and security considerations.

Uploaded by

hussen16337
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)
35 views31 pages

7 Ch07

The document discusses private-key and public-key cryptography, highlighting the differences between symmetric and asymmetric encryption. It details the RSA encryption algorithm, including key generation, encryption, and decryption processes, as well as potential security threats like brute force and timing attacks. The document concludes by summarizing the principles of public-key cryptography and the RSA algorithm's implementation and security considerations.

Uploaded by

hussen16337
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/ 31

Cryptography and Network

Security
Chapter 9

Fourth Edition
by William Stallings

Lecture slides by Lawrie Brown


Private-Key Cryptography
• traditional private/secret/single key
cryptography uses one key
• shared by both sender and receiver
• if this key is disclosed communications are
compromised
• also is symmetric, parties are equal
• hence does not protect sender from receiver
forging a message & claiming is sent by sender
Public-Key Cryptography
• probably most significant advance in the 3000
year history of cryptography
• uses two keys – a public & a private key
• asymmetric since parties are not equal
• uses clever application of number theoretic
concepts to function
• complements rather than replaces private key
crypto
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
Public-Key Characteristics
• Public-Key algorithms rely on two keys where:
– it is computationally infeasible to find decryption key
knowing only algorithm & encryption key
– it is 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 (for some algorithms)
Public-Key Cryptosystems

Secrecy and Authentication


RSA Encryption Algorithm
• RSA encryption algorithm is a type of public-
key encryption algorithm.
• Public Key encryption algorithm is also called
the Asymmetric algorithm. Asymmetric
algorithms are those algorithms in which
sender and receiver use different keys for
encryption and decryption. Each sender is
assigned a pair of keys:
RSA Encryption Algorithm
• The Public key is used for encryption, and the Private
Key is used for decryption. Decryption cannot be
done using a public key. The two keys are linked, but
the private key cannot be derived from the public
key. The public key is well known, but the private key
is secret and it is known only to the user who owns
the key. It means that everybody can send a message
to the user using user's public key. But only the user
can decrypt the message using his private key.
RSA Encryption Algorithm

• The data to be sent is encrypted by sender A using the public key of


the intended receiver
• B decrypts the received ciphertext using its private key, which is known
only to B. B replies to A encrypting its message using A's public key.
• A decrypts the received ciphertext using its private key, which is known
only to him.
RSA Encryption Algorithm

Public d
• RSA algorithm uses the following procedure to generate public and private keys:
• Select two large prime numbers, p and q.
• Multiply these numbers to find n = p x q, where n is called the modulus for
encryption and decryption.

• Choose a number e less than φ (n), such that e is relatively prime to (p - 1) x (q -


1). It means that e and (p - 1) x (q - 1) have no common factor except 1. Choose
"e" such that 1<e < φ (n), e is prime to φ (n), gcd (e, φ (n)) =1

• If n = p x q, then the public key is <e, n>. A plaintext message m is encrypted using
public key <e, n>. To find ciphertext from the plain text following formula is used to
get ciphertext C.
• C = me mod n. Here, m must be less than n.

• To determine the private key, we use the following formula to calculate the d such
that: e D mod {(p - 1) x (q - 1)} = 1 Or e D mod φ (n) = 1
• The private key is <d, n>. A ciphertext message c is decrypted using private key <d,
n>. To calculate plain text m from the ciphertext c following formula is used to get
plain text m.
m = cd mod n
RSA Example
• Step 1: Select two large prime numbers, p,
and q.
• p=7
• q = 11
• Step 2: Multiply these numbers to find n = p x
q, where n is called the modulus for
encryption and decryption.
• First, we calculate n = p x q
• n = 7 x 11
• n = 77
RSA Example
• Step 3 (find public key): Choose a number e less
than n, such that n is relatively prime to (p - 1) x (q -
1). It means that e and (p - 1) x (q - 1) have no
common factor except 1. Choose "e" such that 1<e <
φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
• Second, we calculate
• φ (n) = (p - 1) x (q-1)
• φ (n) = (7 - 1) x (11 - 1)
• φ (n) = 6 x 10 φ (n) = 60
• Let us now choose relative prime e of 60 as 7.
• Thus the public key is <e, n> = (7, 77)
• Step 4: A plaintext message m is encrypted
using public key <e, n>.

• To find ciphertext from the plain text following


formula is used to get ciphertext C.
• C = me mod n
• C = 97 mod 77
• C = 37
• Step 5 (find private key): The private key is <d, n>. To
determine the private key, we use the following
formula d such that:
• E d mod {(p - 1) x (q - 1)} = 1
• 7d mod 60 = 1, which gives d = 43
• The private key is <d, n> = (43, 77)
• Step 6: A ciphertext message c is decrypted using
private key <d, n>. To calculate plain text m from the
ciphertext c following formula is used to get plain
text m.
• m = cd mod n
• m = 3743 mod 77
• m=9
• In this example, Plain text = 9 and the ciphertext = 37
RSA Key Setup
• each user generates a public/private key pair by:
• selecting two large primes at random - p, q
• computing their system modulus n=p.q
– note ø(n)=(p-1)(q-1)
• selecting at random the encryption key e
• where 1<e<ø(n), gcd(e,ø(n))=1
• solve following equation to find decryption key d
– e.d=1 mod ø(n) and 0≤d≤n
• publish their public encryption key: PU={e,n}
• keep secret private decryption key: PR={d,n}
RSA Use
• to encrypt a message M the sender:
– obtains public key of recipient PU={e,n}
– computes: C = Me mod n, where 0≤M<n
• to decrypt the ciphertext C the owner:
– uses their private key PR={d,n}
– computes: M = Cd mod n
• note that the message M must be smaller
than the modulus n (block if needed)
RSA Example - Key Setup
1. Select primes: p=17 & q=11
2. Compute n = pq =17 x 11=187
3. Compute ø(n)=(p–1)(q-1)=16 x 10=160
4. Select e: gcd(e,160)=1; choose e=7
5. Determine d: de=1 mod 160 and d < 160
Value is d=23 since 23x7=161= 10x160+1
6. Publish public key PU={7,187}
7. Keep secret private key PR={23,187}
RSA Example - En/Decryption
• sample RSA encryption/decryption is:
• given message M = 88 (nb. 88<187)
• encryption:
C = 887 mod 187 = 11
• decryption:
M = 1123 mod 187 = 88
The rest of slides are
self-reading
Exponentiation
• can use the Square and Multiply Algorithm
• a fast, efficient algorithm for exponentiation
• concept is based on repeatedly squaring base
• and multiplying in the ones that are needed to
compute the result
• look at binary representation of exponent
• only takes O(log2 n) multiples for number n
– eg. 75 = 74.71 = 3.7 = 10 mod 11
– eg. 3129 = 3128.31 = 5.3 = 4 mod 11
Exponentiation
c = 0; f = 1
for i = k downto 0
do c = 2 x c
f = (f x f) mod n
if bi == 1 then
c = c + 1
f = (f x a) mod n
return f
Efficient Encryption
• encryption uses exponentiation to power e
• hence if e small, this will be faster
– often choose e=65537 (216-1)
– also see choices of e=3 or e=17
• but if e too small (eg e=3) can attack
– using Chinese remainder theorem & 3 messages
with different modulii
• if e fixed must ensure gcd(e,ø(n))=1
– ie reject any p or q not relatively prime to e
Efficient Decryption
• decryption uses exponentiation to power d
– this is likely large, insecure if not
• can use the Chinese Remainder Theorem
(CRT) to compute mod p & q separately. then
combine to get desired answer
– approx 4 times faster than doing directly
• only owner of private key who knows values of
p & q can use this technique
RSA Key Generation
• users of RSA must:
– determine two primes at random - p, q
– select either e or d and compute the other
• primes p,q must not be easily derived from
modulus n=p.q
– means must be sufficiently large
– typically guess and use probabilistic test
• exponents e, d are inverses, so use Inverse
algorithm to compute the other
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)
Factoring Problem
• mathematical approach takes 3 forms:
– factor n=p.q, hence compute ø(n) and then d
– determine ø(n) directly and compute d
– find d directly
• currently believe all equivalent to factoring
– have seen slow improvements over the years
• as of May-05 best is 200 decimal digits (663) bit with LS
– biggest improvement comes from improved algorithm
• cf QS to GHFS to LS
– currently assume 1024-2048 bit RSA is secure
• ensure p, q of similar size and matching other constraints
Timing Attacks
• developed by Paul Kocher in mid-1990’s
• exploit timing variations in operations
– eg. multiplying by small vs large number
– or IF's varying which instructions executed
• infer operand size based on time taken
• RSA exploits time taken in exponentiation
• countermeasures
– use constant exponentiation time
– add random delays
– blind values used in calculations
Chosen Ciphertext Attacks
• RSA is vulnerable to a Chosen
Ciphertext Attack (CCA)
• attackers chooses ciphertexts & gets
decrypted plaintext back
• choose ciphertext to exploit
properties of RSA to provide info to
help cryptanalysis
• can counter with random pad of
plaintext
• or use Optimal Asymmetric
Encryption Padding (OASP)
Summary
• have considered:
– principles of public-key cryptography
– RSA algorithm, implementation, security

You might also like