Sei sulla pagina 1di 11

2509700

Mid Semester report

 The Mathematics of the RSA Public-Key Cryptosystem


 Full Name: Houmour ala eddine
 Student number: 2509700
 Word count: 2749
2509700

The Mathematics of the RSA Public-Key Cryptosystem


Abstract
discovered in 1977 by Rivest, Shamir and Adleman, the RSA cryptosystem has played a
significant role in the evolution of modern cryptography. RSA is one of the most algorithm used
in the world; its various application on the internet, banking, secure information transfer. This
papers explore the mathematics behind this famous invention RSA cryptosystem. We will start
by defining some mathematic facts and theories, Then use this data to propose the original RSA
public-key encryption scheme. The proposed RSA encryption scheme is based on prime
factorization, Diffie and Hellman approach, Euclidean division, and finally, some of Euler
accomplishments in mathematics. The rest of the paper proposes the encrypt/decrypt scheme and
keys implementation is provided in details.

1.Introduction
In the past, cryptography was based on symmetric keys, where the sender and the receiver share
identical key, the sender encrypts their message using a specific key, and the receiver decrypts
the message by using the same key.
In 1976 a new approach of the public-key cryptosystem was introduced by Diffie and Hellman, it
was the first revolutionary in public-key cryptography history. However, cryptography is a
technique to grantee the security of sensitive information (Nitaj,2016). This information can be
stored or transmitted across the network with the insurance that a third person cannot access to
this private information(George, Bonifus,2013). Cryptography is executed by several encryption/
decryption steps. It secures the transfer of message by using keys, and those keys are divided into
a symmetric and asymmetric key, the symmetric key is the public key. The asymmetric key is
knowing as a private key. Private key uses one key shared by both sender and the intended
receiver, and the Public key has two exponents, the first exponent is used for encryption and the
second for decryption (Kumar, Pradhan, 2011).
Diffie and Hellman have developed the concept of cryptography by using a number of
mathematical theories, they introduced a new method called Diffie-Hellman key agreement, the
idea is based on establishing secret keys by parties who don’t previously share a secret, yet
Diffie-hellman couldn’t identify a method with the public-key encryption/decryption
(Kaliski, n.d)

Since the Diffie and Hellman proposal, several public-key cryptosystems was proposed to realize
a better concept of public-key cryptography. At present, the best known and most extensively
used public-key system is RSA (Sonal, Parshant,Ravi, 2011), it was invented in 1977 by Ronald
Rivest, Adi Shamir and Leonard Adleman. A number of theories were used to invent the
asymmetric cryptosystem, in another aspect private key has a mathematical relationship with the
public key (Rivest, Shamir and Adleman, 1983). “The security of the RSA public key scheme is
based on the intractability of factoring the integer modulus which is the product of two large and
distinct prime numbers that is a difficult computational problem to find” (Aboud, Al-Fayoumi,
2509700

Jabbar,2008) For instance. web traffic, e-mail and bank security system are secured by the rsa
public-key cryptosytem .

This paper proposed an implementation of a detailed and practical RSA encrypt/decrypt solution
based on the study of the RSA public key algorithm.

2.Prime Generation and Integer Factorization


2.1 One-way function
One-way functions are easy to compute, but the inverse is not easy to compute their functions.
Thus, it is easy to calculate f(x)when you have x but, on the other side, having only the value
of f(x), it is problematic to calculate the value of x.
In terms of cryptography, the objective is to construct a special kind of one-way function, and
this function should be facile to calculate in one direction. However, the reverse is quite tricky,
except if the specific data are known, this data is called the trapdoor. For this, we have turned to
modular exponentiation, in the diff-Hellman key exchange, also called an exponential key
exchange (Joyner, 2000).
one way function is an encryption approach that adopts numbers raised to a precise power ( e in
our case ), to generate decryption keys based on components that are never directly shared. It is
about taking the original message, convert it to a number, raise it to some exponent, then all
divide by the modulus ( n in our case ) and save the remainder by using Euclidean division
(Joyner, 2000). This is an example that explains how to encrypt a message in an easy way:
1. Entity A wants to send a message, and this message is converted into a number, m
2. A multiplies the converted messages by itself e times, e is a public key
3. Then entity A divide the result by a random number, N, and save the remainder of the
division.
This result:
Modular exponentiation
Given m, n, and e, it’s easy to determine c
c=me mode n
Apparently, this computation is facile to perform, furthermore, having only c, e, and n, it is much
more challenging to compute which m was used, this is the one-way function that we can apply
to m, easy to implement, but the reverse is difficult, some piece of mathematical calculation that
makes the reverse of the encryption possible and secure, the following table shows the steps of
the reversing method:
2509700

 c=me mode n
1. Modular exponentiation
2. Raise c to the exponent d  m=cd moden
3. Which undo the first operation
applied to m and return the original
message m.  m=me∗d mode n
4. By combining the first and second
operation, the combination gave us
m to the power of e, to the power of
d.
5. The result is m to the power of e
times d, (e is used for encryption,
while d for encryption)

2.1.1 Result:

the reverse of modular exponentiation


 Given n, e, c, and the prime factors p and q, it’s easy to recover the value m such that
c=me mode n

 The value m can be recovered from c by a modular exponentiation operation with


another odd integer d between 3 and n-1.
m=me∗d mode n
(Kaliski, n.d)

2.2 prime factorization vs multiplying numbers


thus, the problem is how to find a way for the receiver to generate e and d, in a way that makes it
very difficult for an unauthorized person to find d. in order to make the transfer of information
safer. it requires a second one-way function, which is used for generating d
In mathematics prime factorization was always a hard problem in mathematics comparing to
multiplying numbers, even with the aid of the computer, we all know that computers can perform
much faster than a human can, but when it’s come to prime factorization, computers face some
difficulties.
The vertical axis shows the time needed for a computer to multiply numbers in red and to factor
prime numbers in bleu. The vertical axis shows the size of bits(numbers)
2509700

Figure 1: less than 50 bits figure 2: less than 100 bits figure 3: more than 100 bits
(cruise, 2015)
2.2.1 Observation
the time necessary to find the answer increases as the numbers increase, multiplication requires
more time to compute than prime factorization when the numbers are small.
Now, compare this to prime factorization, the time needed to perform the calculations increases
rapidly, as the size of the number increase, the computer needs more time (minutes then hours,
years. However, the time needed for multiplication remains constant, less than one second
“Multiplication can be computed in polynomial time, whereas factoring time can grow
exponentially proportional to the size of the number” (Sharma, Sharma, Dhakar,2011).
2.2.2 Result
Multiplication
Given p and q, it’s easy to find the product of n, n = p*q.

Prime factorization
Given integer n, it appears to be quite hard to recover the prime factors p and q.

From the previous observation, Prime factorization is the solution to build the trap door and to
make the transfer operation much more complicated
1. The receiver generates two large prime numbers, p and q
2. Multiplying p and q together, to get the composite number, n
3. The receiver takes the factorization of n and saves it.
However, it is required to find a function which depends on knowing the factorization of N, for
this, Leonhard Euler, a swiss mathematician, has worked on prime numbers, and discovered some
mathematical theories and facts, they are useful in RSA cryptography
2509700

2.3 Leonhard Euler


2.3.1 Introduction to Euler’s Totient Function ϕ(n)
Euler has investigated in properties of prime numbers, one of his inventions is called Euler’s phi
function. Phi function gives a count of how many numbers in the set {1,2,3…. n}, which is less
than or equal to n, and do not share any common factor with N (Clay,2008), the following table
shows the function values for several natural
n  φ(n)  numbers
1 1 1 numbers:
2 1 1
3 2 1, 2
4 2 1,3 Method of calculation
5 4 1,2,3,4 1. to find φ (10),
6 2 1,5
2. we check all numbers from one to
7 6 1,2,3,4,5,6
ten,
8 4 1,3,5,7
3. we count the number of integers
9 6 1,2,4,5,7,8
that do not share any common
1 4 1,3,7,9
factor with n
0
1 10 1,2,3,4,5,6,7,8,9,10 4. we found that 1, 3, 7and 9 shares
1 only a factor of one
1 4 1,5,7,11 5. φ (10) = 4
2
1 12 1,2,3,4,5,6,7,8,9,10,11,1
3 2
1 6 1,3,5,9,11,13
4
1 8 1,2,4,7,8,11,13,14 (table 1: phi function)
5
2.3.2. Interesting Pattern
furthermore, if we look at the next graph, which represents the values of phi, over integers from
one to 5000. the straight line along the top represent all the prime numbers, and since the greatest
common divisor of prime number with any number equal to one, we conclude that the phi
function of any prime number is the number it self mince one
eurler came up with an interesting result based on the fact that the φ function is multiplicative
(weaving,2016)
2509700

Figure 4: ϕ(n) for n less than 5000 (weaving,2016)


2.3.3 Result
phi function is multiplicative
Relatively Prime Integers

. Two integers p and q are said to be Given p and q, p<q, n=p*q


relatively prime or coprime if gcd(p; q) = 1. φ(n) = (p - 1) *(q - 1)

3.RSA public-key cryptosystem


3.1 indtroduction
The recent observations including theories and mathematical fact, which encouraged Ronald
Rivest, Adi Shamir and Leonard Adelman to invent the first asymmetric public-key cryptosystem
in 1977 at MIT, their invention is called RSA after their names. RSA is based on the principle
that some mathematical operations (difficulty of integer factoring) are facile to do in one
direction, but without extra data the inverse is impossible.

Furthermore, RSA is the most widely used public-key cryptosystem. The conception behind RSA
public-key cryptography is that a public key (n, e) is used to encrypt a message, which is known
as ’plain text’. The encrypted plain text is called’ cypher text’ and can be sent to the designated
person without the need for a secure connection. The cypher text cannot then be decrypted except
if the private key (n, d) is known; this private key is kept secret and known only by the intended
recipient (weaving,2016).

(weaving,2016)
2509700

3.2 RSA Scheme


RSA consist of three steps, the first step is a key generation these keys are used to encrypt and
decrypt the message, step two is encryption, plaintext convert to ciphertext third step is
decryption, where the encrypted message is converted into the original message plain text
 3.2.1 Key Generation Process:
1. Generate two vast primes, p and q, p and q should have approximately the same size
2. Calculate n = p x q and φ(n) = (p-1) x (q-1). (Euler équation)
3. Choose an number e, satisfying 1 < e < φ, gcd (e, φ) = 1.
4. calculate the private exponent d, 1 < d < φ, e x d ≡ 1 (mod φ). (Euler theory)
5. The public key is (n, e) and the private key is (n, d). save all the values d, p, q and φ
secret.
6. The modulus is n.
7. e is the encryption exponent, e is also known as the public exponent.
8. d is the private exponent or decryption exponent.
The public key (n, e) is published for everyone, and private key (p, q, d) must be stored secretly.
 3.2.2 Encryption Process:
1. Obtain the recipient public key (n, e)
2. Convert the plaintext message as a positive integer m
3. Calculate the cypher text c=me mod n
4. Send the ciphertext c to the sender
 3.2.3 Decryption process
1. Obtain the cypher text from the sender
2. Use privet key (n, d) to compute m=cd mod n
3. Extract the plaintext from the message, which represents m the original message
3.3 Simple Example of RSA:
Small prime numbers are used to keep the example clear. However, In a secure situation, it is
recommended to use large prime numbers.
3.3.1 Key Generation Process:

1. The receiver generates randomly two prime numbers, p = 5 and q = 11.


2. calculate n= p *q =5*11=55 and φ(n)= (11-1) *(5-1) =40.
3. chose e=7 which represent public key, which satisfy 1 < e < φ, gcd (e, φ) = 1.
4. Now d*e = 1*mod (40) => d=7, 1 < d < φ, e x d ≡ 1 (mod φ).
5. public key is the s pair (n=55, e= 3), shared with the sender.
6. private key is, (φ= 40, d=7), known only by the intended receiver.
3.3.2 Encryption:
1. the sender obtains from the intended receiver public key, which is (n = 55, e = 3)
2. the sender determines a message m to be encrypted
3. compute c=me mod n , c=63 mod 55
2509700

4. then send c = 51 to the receiver


3.3.3 Decryption:
To get the original message m, the intended receiver should the following:
1. Obtain the ciphertext c=51 from the sender
2. then compute the original message m=cd mod n=517 mod 55,
3. m=6

table 2: gives a small example showing the encryption of some messages, which we will
represent it as numbers m from 0 to 9 as well as decryptions of the resulting ciphertexts
Key Pair Key Pair Generation
Public key (n = 55, e = 3) Two Prime numbers: p = 5, q = 11
Private key (n = 55, d = 7) Modulos : n = p*q = 5*11=55
Encryption exponent : e = 3
decryption exponent: d= 7
Message Encryption c = m3 mod Decryption m = c7 mod n
n
m m3 mod n c7 mod n
0 0 0
1 1 1
2 8 2
3 27 3
4 9 4
5 15 5
6 51 6
7 13 7
8 17 8
9 14 9

3.4 Elementary attacks on RSA


Every system has its own weakness. Pirates spent too much time looking for these gaps. “It is
well known that most successful attacks on RSA, are not based on factoring the modulus N.
Rather, they exploit the mathematical weakness of the RSA algorithm or the improper use of the
RSA system, such as lower exponents, common modulus, and knowledge of parts of the private
exponent”(nitaj,2016). By knowing the phi(n) and n the pirate can quickly compute p and q.
In more details given the modulus n and eurler tuition function φ(n)
1 N =p*q ……..(1)
2 Φ(n) = (p-1)*(q-1)
2509700

3 p = N/q
4 Φ(n) = ((N/q)-1)*(q-1)
5 q2 − (N + 1 − φ(N))q + N = 0……….(2)
Is second a quadratic equation, by solving this equation we can find q and then we will use (1) to
find p
The solution is :
2
N +1−φ ( N)+ √ ( N +1−φ ( N ) ) −4 N ,
q=
2
2
N +1−φ ( N )−√ ( N +1−φ ( N )) −4 N ,
p=
2
(nitaj,2016)
4. Conclusion
This report aims to explore the original version of the RSA cryptosystem. It relies on facts of
mathematics that prove that given a vast number, it is quite challenging in today’s aspect to
conclude two prime numbers whose product is the given number. If the size of the number gets
larger, the possibility for factoring the given number decline, the secret of RSA it in prime
number complexity. However, in the suggested scheme, it is quite challenging to find the
public/privet exponents when the given number is vast, also a method to lunch attacks on the
RSA cryptosystem. Even though RSA was the first asymmetric proposal in cryptography, it
creates new directions in cryptography, it became an indispensable part of modern world
information security, by improving the security of the virtual world.
2509700

References

1 D. George and P. L. Bonifus, "RSA encryption system using an encoded multiplier and
Vedic mathematics," 2013 International Conference on Advanced Computing and
Communication Systems, Coimbatore, 2013, pp. 1-4.

2 S. J. Aboud, M. A. AL-Fayoumi, M. Al-Fayoumi and H. S. Jabbar, "An Efficient RSA


Public Key Encryption Scheme," Fifth International Conference on Information
Technology: New Generations (itng 2008), Las Vegas, NV, 2008, pp. 127-130.

3 S. Sharma, P. Sharma and R. S. Dhakar, "RSA algorithm using modified subset-sum


cryptosystem," 2011 2nd International Conference on Computer and Communication
Technology (ICCCT-2011), Allahabad, 2011, pp. 457-461.

4 Clay S. Turner, ‘Euler’s Totient Function and Public Key Cryptography Clay S’. Nov 7,
2008, available at <http://www.claysturner.com/dsp/totient.pdf>

5 Weaving, T., 2020. Euler’S Theorem And RSA Public Key Cryptography. Available at:
<https://vknight.org/Computing_for_mathematics/Assessment/IndividualCoursework/PastC
ourseWorks/2015-2016/weaving2015-2016.pdf>

6 Sushanta Kumar Sahu and Manoranjan Pradhan, “FPGA Implementation of RSA


Encryption System”, International Journal of Computer Applications (0975-8887) volume
19-N0.9, April 2011.

7 R.L. Rivest, A. Shamir, and L. Adleman, A method for obtaining digital signatures and
public-key cryptosystems, Commun. ACM, Feb. 1978,21(2): 120-126.

8 Joyner, D., 2000. Coding Theory And Cryptography. Berlin: Springer.

9 Kaliski, B., n.d. [online] Mathaware.org. Available at:


<http://www.mathaware.org/mam/06/Kaliski.pdf> [Accessed 16 March 2020].

10 cruise, b., 2015. Time Complexity (Exploration). [online] Khan Academy. Available at:
<https://www.khanacademy.org/computer-programming/time-complexity-
exploration/1466763719> [Accessed 20 March 2020].

Potrebbero piacerti anche