0% found this document useful (0 votes)
27 views14 pages

Crypto Module 2

Module 2 covers Public-Key Cryptography and RSA, detailing the principles of asymmetric cryptography, including key exchange and trust problems. It explains the RSA algorithm, its security requirements, and the Diffie-Hellman key exchange method, alongside potential vulnerabilities like brute-force and man-in-the-middle attacks. The module emphasizes the importance of public and private keys in ensuring confidentiality and authentication in digital communications.

Uploaded by

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

Crypto Module 2

Module 2 covers Public-Key Cryptography and RSA, detailing the principles of asymmetric cryptography, including key exchange and trust problems. It explains the RSA algorithm, its security requirements, and the Diffie-Hellman key exchange method, alongside potential vulnerabilities like brute-force and man-in-the-middle attacks. The module emphasizes the importance of public and private keys in ensuring confidentiality and authentication in digital communications.

Uploaded by

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

Module – 2 Public-Key Cryptography and RSA

MODULE 2- Public Key Cryptography and RSA


Introduction to Public key Cryptography:
 Public key cryptography also called as asymmetric cryptography.
 It was invented by whitfield Diffie and Martin Hellman in 1976. Sometimes this
cryptography also called as Diffie-Helman Encryption.
 Public key algorithms are based on mathematical problems which admit no efficient
solution that are inherent in certain integer factorization, discrete logarithm and
Elliptic curve relations.

Public key Cryptosystem Principles:

 The concept of public key cryptography in invented for two most difficult problems
of Symmetric key encryption.

 The Key Exchange Problem


 The Trust Problem
The Key Exchange Problem: The key exchange problem arises from the fact
that communicating parties must somehow share a secret key before any secure
communication can be initiated, and both parties must then ensure that the key
remains secret. Of course, direct key exchange is not always feasible due to risk,
inconvenience, and cost factors.

The Trust Problem: Ensuring the integrity of received data and verifying the
identity of the source of that data can be very important. Means in the symmetric
key cryptography system, receiver doesn’t know whether the message is coming
for particular sender.
 This public key cryptosystem uses two keys as pair for encryption of plain text and
Decryption of cipher text.
 These two keys are names as “Public key” and “Private key”. The private key is kept
secret where as public key is distributed widely.
 A message or text data which is encrypted with the public key can be decrypted only
with the corresponding private-key
 This two key system very useful in the areas of confidentiality (secure) and
authentication

A public-key encryption scheme has six ingredients


1 Plaintext This is the readable message or data that is fed into the algorithm as input.
Encryption
2 The encryption algorithm performs various transformations on the plaintext.
algorithm
3 Public key This is a pair of keys that have been selected so that if one is used for encryption, the
other is used for decryption. The exact transformations performed by the algorithm
4 Private key depend on the public or private key that is provided as input
This is the scrambled message produced as output. It depends on the plaintext and
5 Ciphertext the key. For a given message, two different keys will produce two different
ciphertexts.
Decryption This algorithm accepts the ciphertext and the matching key and produces the original
6
algorithm plaintext.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 1
Module – 2 Public-Key Cryptography and RSA

Public key cryptography for providing confidentiality (secrecy)

The essential steps are the following.


1. Each user generates a pair of keys to be used for the encryption and decryption of
messages.
2. Each user places one of the two keys in a public register or other accessible file. This
is the public key.The companion key is kept private.As Figure 9.1a suggests, each
user maintains a collection of public keys obtained from others.
3. If Bob wishes to send a confidential message to Alice, Bob encrypts the message
using Alice’s public key.
4. When Alice receives the message, she decrypts it using her private key. No other
recipient can decrypt the message because only Alice knows Alice’s private key.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 2
Module – 2 Public-Key Cryptography and RSA

There is some source A that produces a message in plaintext X = [X1, X2, . . . ,XM].

The M elements of X are letters in some finite alphabet. The message is intended for
destination B.
B generates a related pair of keys: a public key, PU b, and a private key, PRb.

PRb is known only to B, whereas PUb is publicly available and therefore accessible by A.
With the message X and the encryption key PUb as input, A forms the ciphertext Y = [Y1, Y2,
. . . , YN]:

The intended receiver, in possession of the matching private key, is able to invert the transformation:

Public key cryptography for proving Authentication:

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 3
Module – 2 Public-Key Cryptography and RSA

The above diagrams show the use of public-key encryption to provide authentication:

 In this case,A prepares a message to B and encrypts it using A’s private key before
transmitting it. B can decrypt the message using A’s public key. Because the message
was encrypted using A’s private key, only A could have prepared the message.
Therefore, the entire encrypted message serves as a digital signature.

 It is impossible to alter the message without access to A’s private key, so the message
is authenticated both in terms of source and in terms of data integrity.

Public key cryptography for both authentication and confidentiality (Secrecy)

It is, however, possible to provide both the authentication function and confidentiality by a
double use of the public-key scheme (above figure):

In this case, we begin as before by encrypting a message, using the sender’s private key. This
provides the digital signature. Next, we encrypt again, using the receiver’s public key. The
final ciphertext can be decrypted only by the intended receiver, who alone has the matching
private key. Thus, confidentiality is provided.

Applications for Public-Key Cryptosystems


Public-key systems are characterized by
the use of a cryptographic algorithm with two keys, one held private and one available
publicly. Depending on the application, the sender uses either the sender’s
private key or the receiver’s public key, or both, to perform some type of cryptographic
function.
the use of public-key cryptosystems

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 4
Module – 2 Public-Key Cryptography and RSA

into three categories


• Encryption /decryption: The sender encrypts a message with the recipient’s
public key.
• Digital signature: The sender “signs” a message with its private key. Signing is
achieved by a cryptographic algorithm applied to the message or to a small
block of data that is a function of the message.
• Key exchange: Two sides cooperate to exchange a session key. Several different
approaches are possible, involving the private key(s) of one or both parties.

Applications for Public-Key Cryptosystems


Algorithm Encryption/Decryption Digital Signature Key Exchange
RSA Yes Yes Yes
Elliptic Curve Yes Yes Yes
Diffie-Hellman No No Yes
DSS No Yes No

Public-Key Cryptanalysis
As with symmetric encryption, a public-key encryption scheme is vulnerable to a brute-force
attack. The countermeasure is the same: Use large keys. However, there is a tradeoff to be
considered. Public-key systems depend on the use of some sort of invertible mathematical
function. The complexity of calculating these functions may not scale linearly with the
number of bits in the key but grow more rapidly than that. Thus, the key size must be large
enough to make brute-force attack impractical but small enough for practical encryption and
decryption. In practice, the key sizes that have been proposed do make brute-force attack
impractical but result in encryption/decryption speeds that are too slow for general-purpose
use. Instead, as was mentioned earlier, public-key encryption is currently confined to key
management and signature applications.

RSA

 It is the most common public key algorithm.


 This RSA name is get from its inventors first letter (Rivest (R), Shamir (S) and
Adleman (A)) in the year 1977.
 The RSA scheme is a block cipher in which the plaintext & ciphertext are integers
between 0 and n-1 for some ‘n’.
 A typical size for ‘n’ is 1024 bits or 309 decimal digits. That is, n is less than 2 1024

Description of the Algorithm:


 RSA algorithm uses an expression with exponentials.
 In RSA plaintext is encrypted in blocks, with each block having a binary value less
than some number n. that is, the block size must be less than or equal to log 2(n)
 RSA uses two exponents ‘e’ and ‘d’ where epublic and dprivate.
 Encryption and decryption are of following form, for some PlainText ‘M’ and
CipherText block ‘C’

M=Cd mod = (Me mod n) d mon n =(Me)d mod n= Med mod n

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 5
Module – 2 Public-Key Cryptography and RSA

Both sender and receiver must know the value of n.


The sender knows the value of ‘e’ & only the reviver knows the value of ‘d’ thus this
is a public key encryption algorithm with a
Public key PU={e, n}
Private key PR={d, n}

Requirements:
The RSA algorithm to be satisfactory for public key encryption, the following requirements
must be met:
1. It is possible to find values of e, d n such that “ M ed mod n =M ” for all M<n
2. It is relatively easy to calculate “ M e mod n “ and “ Cd mod n “for M<n
3. It is infeasible to determine “d” given ‘e’ & ‘n’. The “ M ed mod n =M ” relationship
holds if ‘e’ & ‘d’ are multiplicative inverses modulo Ø(n).
Ø(n) Euler Totient function
For p,q primes where p*q and p≠q.
Ø(n)= Ø(pq)=(p-1)(q-1)

Then the relation between ‘e’ & ‘d’ can be expressed as “ “


this is equivalent to saying

That is ‘e’ and ‘d’ are multiplicative inverses mod Ø(n).


Note: according to the rules of modular arithmetic, this is true only if ‘d’ (and ‘e’) is
relatively prime to Ø(n).
Equivalently gcd(Ø(n), d)=1.

Steps of RSA algorithm:


Step 1Select 2 prime numbers p & q
Step 2Calculate n=pq
Step 3Calculate Ø(n)=(p-1)(q-1)
Step 4 Select or find integer e (public key) which is relatively prime to Ø(n).
ie., e with gcd (Ø(n), e)=1 where 1<e< Ø(n).
Step 5 Calculate “d” (private key) by using following condition.
d< Ø(n).

Step 6 Perform encryption by using

Step 7 perform Decryption by using

Example:
1. Select two prime numbers, p = 17 and q = 11.
2. Calculate n = pq = 17 × 11 = 187.
3. Calculate Ø(n) = (p - 1)(q - 1) = 16 × 10 = 160.
4. Select e such that e is relatively prime to Ø(n) = 160 and less than Ø (n); we choose e = 7.
5. Determine d such that de ≡1 (mod 160) and d < 160.The correct value is d = 23, because
23 * 7 = 161 = (1 × 160) + 1; d can be calculated using the extended Euclid’s algorithm

The resulting keys are public key PU = {7, 187} and private key PR = {23, 187}.
The example shows the use of these keys for a plaintext input of M= 88. For encryption,

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 6
Module – 2 Public-Key Cryptography and RSA

we need to calculate C = 887 mod 187. Exploiting the properties of modular arithmetic, we
can do this as follows.

The Security of RSA


Four possible approaches to attacking the RSA algorithm are
• Brute force: This involves trying all possible private keys.
• Mathematical attacks: There are several approaches, all equivalent in effort to factoring
the product of two primes.
• Timing attacks: These depend on the running time of the decryption algorithm.
• Chosen ciphertext attacks: This type of attack exploits properties of the RSA algorithm.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 7
Module – 2 Public-Key Cryptography and RSA

Diffie-Hellman Key Exchange:


 Diffie-Hellman key exchange is the first published public key algorithm
 This Diffie-Hellman key exchange protocol is also known as exponential key
agreement. And it is based on mathematical principles.
 The purpose of the algorithm is to enable two users to exchange a key securely that
can then be used for subsequent encryption of messages.
 This algorithm itself is limited to exchange of the keys.
 This algorithm depends for its effectiveness on the difficulty of computing discrete
logarithms.
 The discrete logarithms are defined in this algorithm in the way of define a primitive
root of a prime number.
 Primitive root: we define a primitive root of a prime number P as one whose
power generate all the integers form 1 to P-1 that is if ‘a’ is a primitive root of
the prime number P, then the numbers
are distinct and
consist of the integers form 1 through P-1 in some permutation.
For any integer ‘b’ and ‘a’, here ‘a’ is a primitive root of prime number P, then
b≡ ai mod P 0 ≤ i ≤ (P-1)
The exponent i  is refer as discrete logarithm or index of b for the base a, mod P.
The value denoted as ind a,p(b)

Algorithm for Diffie-Hellman Key Exchange:

Step 1 two public known numbers q, α


q Prime number
α primitive root of q and α< q.
Step 2  if A & B users wish to exchange a key
a) User A select a random integer X A<q and computes
b) User B independently select a random integer X B <q and computes
c) Each side keeps the X value private and Makes the Y value available publicly to
the outer side.

Step 3 User A Computes the key as

User B Computes the key as


Step 4 two calculation produce identical results

(We know that )

(We know that )


The result is that the two sides have exchanged a secret key.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 8
Module – 2 Public-Key Cryptography and RSA

Example:

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 9
Module – 2 Public-Key Cryptography and RSA

MAN-in the Middle Attack (MITM)

Definition: A man in the middle attack is a form of eavesdropping where communication


between two users is monitored and modified by an unauthorized party.

Generally the attacker actively eavesdrops by intercepting (stoping) a public key message
exchange.
The Diffie- Hellman key exchange is insecure against a “Man in the middle attack”.

Suppose user ‘A’ & ‘B’ wish to exchange keys, and D is the adversary (opponent). The attack
proceeds as follows.

1. ‘D’ prepares for the attack by generating two random private keys X D1 & XD2 and then
computing the corresponding public keys YD1 and YD2.
2. ‘A’ transmits ‘YA’ to ‘B’
3. ‘D’ intercepts YA and transmits YD1 to ‘B’. and D also calculates

4. ‘B’ receives YD1 & calculate


5. ‘B’ transmits ‘YB’ to ‘A”
6. ‘D’ intercepts ‘YB’ and transmits YD2 to ‘A’ and ‘D’ calculate K1

7. A receives YD2 and calculates

At this point, Bob and Alice think that they share a secret key, but instead Bob and Darth
share secret key K1 and Alice and Darth share secret key K2. All future communication
between Bob and Alice is compromised in the following way.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 10
Module – 2 Public-Key Cryptography and RSA

The key exchange protocol is vulnerable to such an attack because it does not authenticate the
participants. This vulnerability can be overcome with the use of digital signatures and public-
key certificates.

Elliptic Curve Cryptography


 Definition: Elliptic curve cryptography (ECC) is an approach to public-key
cryptography based on the algebraic structure of elliptic curves over finite fields.
These are analogy of existing public key cryptosystem in which modular arithmetic is
replaced by operations defined over elliptic curve.
 The use of elliptic curves in cryptography was suggested independently by Neal
Koblitz and Victor S. Miller in 1985.
 Elliptic curve cryptography (ECC) is one of the most powerful but least understood
types of cryptography in wide use today. An increasing number of websites make
extensive use of ECC to secure everything from customers' HTTPS connections to
how they pass data between data centers.

An elliptic curve is defined by an equation in two variables with coefficients. For


cryptography, the variables and coefficients are restricted to elements in a finite field,
which results in the definition of a finite abelian group.

Elliptic Curves over Real Numbers


Elliptic curves are not ellipses. They are so named because they are described by cubic equations,

is similar to equation of calculating


circumference of an ellipse.
Where
a,b,c,d and e  real numbers.
X and Y aretaken on values in the real numbers.

For utilization of this in cryptography

 EQ1, is sufficient.
Such equations are said to be cubic, or of degree 3, because the highest exponent they contain is a 3. Also
included in the definition of an elliptic curve is a single element denoted O and called the point at infinity or the
zero point. To plot such a curve, we need to compute

For given values of and, the plot consists of positive and negative values of for
each value of . Thus, each curve is symmetric about y = 0.

Two families of elliptic curves are used in cryptographic applications:


 Prime curves over Zp [it is Best for software application]
 Binary curves over GF(2m) [it is Best for software application]

Prime curves over Zp


In Prime curves over Zp , p referred to as a modulus.
we use a cubic equation in which the variables and coefficients all take on values in the set of
integers from 0 through p - 1 and in which calculations are performed modulo p.
from EQ1, in this case coefficients and variables limited to Z p.

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 11
Module – 2 Public-Key Cryptography and RSA

 eq2

Now consider the set Ep(a, b) consisting of all pairs of integers (x, y) that satisfy
Equation eq2 together with a point at infinity .The coefficients a and b and the variables x and
y are all elements of Zp.

For example, let p = 23 and consider the elliptic curve y2 = x3 + x + 1 In this case, a = b = 1
For the set E23(1, 1), we are only interested in the nonnegative integers in the quadrant from
(0, 0) through (p - 1, p - 1) that satisfy the equation mod p.

Elliptic Curves over GF(2 m):


A finite field GF(2m) consists of 2m elements, together with addition & multiplication
operations that can be defined over polynomials.

For elliptic Curves over GF(2m), we use a cubic equation in which the variables and
coefficients all take on values in GF(2 m), for some number m.
By this, the form of cubic equation appropriate for cryptographic application.

The form is  EQ3.

To form a cryptographic system using elliptic curves, we need to find a “hard problem”
corresponding to factoring the product of two primes or taking the discrete logarithm.

Consider the equation


It is relatively easy to calculate Q given k and P
But it is relatively hard to determine given Q and P.
This is called the discrete logarithm problem for elliptic curves.

ECC Diffie-Hellman Key Exchange:

ECC can do key exchange, that is analogous to Diffie Hellman.


Key exchange using elliptic curves can be done in the following manner.
First pick a large integer q , which is either a prime number P or an integer of the form 2 m and elliptic curve

parameters a & b for equation or

.
This define elliptic group of point E q(a,b).
Pick a base point G=(x1,y1) in Ep(a,b) whose order is a very large value n.
The order n of a point G on an elliptic curve is the smallest +ve integer n such that
nG=0.Eq(a,b)

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 12
Module – 2 Public-Key Cryptography and RSA

Elliptic Curve Encryption/Decryption:

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 13
Module – 2 Public-Key Cryptography and RSA

Availaible at VTU HUB (Android App)


Mr. Syed Matheen Pasha, Dept of CSE, SVIT. Page 14

You might also like