Nothing Special   »   [go: up one dir, main page]

Assignment No.8: 8.1 Title

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Lab Practices- Fourth Year Computer

III Engineering

Information and Cyber Security

Assignment No.8

W C D V T Total
Sign/Remark
(4) (4) (4) (4) (4) (20)

8.1 Title:

Implementation of RSA Algorithm


8.2 Problem Definition:

Implementation of RSA Algorithm

8.3 Prerequisite:

Basic of Python, Information security Algorithm

8.4 Software Requirements:

Python 3.7

8.5 Hardware Requirement:

2GB RAM, 500 GB HDD

8.6 Learning Objectives:

Learn RSA Algorithm

8.7 Outcomes:

After completion of this assignment students are able to understand the How to encrypt and
decrypt messages.

8.8 Theory Concepts:

8.8.1 RSA(Rivest, Shamir & Adleman )

RSA is an algorithm used by modern computers to encrypt and decrypt messages. It is an


asymmetric cryptographic algorithm. Asymmetric means that there are two different keys. This
is also called public key cryptography, because one of the keys can be given to anyone. The
other key must be kept private. The algorithm is based on the fact that finding the factors of a
Lab Practices- Fourth Year Computer
III Engineering
large composite number is difficult: when the integers are prime numbers, the problem is called
prime factorization. It is also a key pair (public and private key) generator.
• RSA makes the public and prívate keys by multiplying two large prime numbers p and
q
▫ It’s easy to find & multiply large prime No. (n=pq)
▫ It is very difficult to factor the number n to find p and q
▫ Finding the private key from the public key would require a factoring operation
▫ The real challenge is the selection & generation of keys.
• RSA is complex and slow, but secure
• 100 times slower than DES on s/w & 1000 times on h/w

The Rivest-Shamir-Adleman (RSA) algorithm is one of the most popular and secures public-
key encryption methods. The algorithm capitalizes on the fact that there is no efficient way to
factor very large (100-200 digit) numbers.

Using an encryption key (e,n), the algorithm is as follows:

1. Represent the message as an integer between 0 and (n-1). Large messages can be broken
up into a number of blocks. Each block would then be represented by an integer in the
same range.
2. Encrypt the message by raising it to the eth power modulo n. The result is a ciphertext
message C.
3. To decrypt ciphertext message C, raise it to another power d modulo n

The encryption key (e,n) is made public. The decryption key (d,n) is kept private by the user.

How to Determine Appropriate Values for e, d, and n

1. Choose two very large (100+ digit) prime numbers. Denote these numbers as p and q.
2. Set n equal to p * q.
3. Choose any large integer, d, such that GCD(d, ((p-1) * (q-1))) = 1
4. Find e such that e * d = 1 (mod ((p-1) * (q-1)))

Rivest, Shamir, and Adleman provide efficient algorithms for each required operation[4].

8.8.2. How secure is a communication using RSA?


Cryptographic methods cannot be proven secure. Instead, the only test is to see if someone can
figure out how to decipher a message without having direct knowledge of the decryption key.
The RSA method's security rests on the fact that it is extremely difficult to factor very large
numbers. If 100 digit numbers are used for p and q, the resulting n will be approximately 200
digits. The fastest known factoring algorithm would take far too long for an attacker to ever
break the code. Other methods for determining d without factoring n are equally as difficult.

Any cryptographic technique which can resist a concerted attack is regarded as secure. At this
point in time, the RSA algorithm is considered secure.

8.8.3. How Does RSA Works?

RSA is an asymmetric system, which means that a key pair will be generated (we will see how
soon) , a public key and a private key , obviously you keep your private key secure and pass
around the public one.

The algorithm was published in the 70’s by Ron Rivest, Adi Shamir, and Leonard Adleman,
hence RSA, and it sort of implement’s a trapdoor function such as Diffie’s one.

RSA is rather slow so it’s hardly used to encrypt data, more frequently it is used to encrypt and
pass around symmetric keys which can actually deal with encryption at a faster speed.

8.8.4. RSA Security:


• It uses prime number theory which makes it difficult to find out the key by reverse
engineering.
• Mathematical Research suggests that it would take more than 70 years to find P & Q if
N is a 100 digit number.

8.9. Algorithm

The RSA algorithm holds the following features −

 RSA algorithm is a popular exponentiation in a finite field over integers including prime
numbers.
 The integers used by this method are sufficiently large making it difficult to solve.
 There are two sets of keys in this algorithm: private key and public key.

You will have to go through the following steps to work on RSA algorithm −
Step 1: Generate the RSA modulus

The initial procedure begins with selection of two prime numbers namely p and q, and then
calculating their product N, as shown −

N=p*q

Here, let N be the specified large number.

Step 2: Derived Number (e)

Consider number e as a derived number which should be greater than 1 and less than (p-1) and
(q-1). The primary condition will be that there should be no common factor of (p-1) and (q-1)
except 1

Step 3: Public key

The specified pair of numbers n and e forms the RSA public key and it is made public.

Step 4: Private Key

Private Key d is calculated from the numbers p, q and e. The mathematical relationship between
the numbers is as follows −

ed = 1 mod (p-1) (q-1)

The above formula is the basic formula for Extended Euclidean Algorithm, which takes p and q
as the input parameters.

8.9.1. Encryption Formula

Consider a sender who sends the plain text message to someone whose public key is (n,e). To
encrypt the plain text message in the given scenario, use the following syntax −

C = Pe mod n

8.9.2. Decryption Formula


The decryption process is very straightforward and includes analytics for calculation in a
systematic approach. Considering receiver C has the private key d, the result modulus will be
calculated as −

Plaintext = Cd mod n

Example
1. P=7, Q=17
2. 119=7*17
3. (7-1)*(17-1)= 6*16 =96 factor 2 & 3, so E=5
4. (D*5) mod (7-1)*(17-1)=1, so D=77
5. CT=105 mod 119 =100000 mod 119 =40
6. Send 40
7. PT=4077 mod 119 = 10

8.10. Conclusion

Thus we learn that to how to Encrypt and Decrypt the message by using RSA
Algorithm.

References:-

1.Wikipedia
2.TutorialsPoint

Questions of RSA Algorithm

1. What is RSA Algorithm?


2. Write RSA Algorithm and explain with example
3. What is difference between DES and RSA?
4. How secure is RSA?
5. What are the Advantages and Disadvantages of RSA Algorithm?

You might also like