Principle of RSA algorithm (II.)

Source: Internet
Author: User
Tags integer

Last time, I introduced some knowledge of number theory.

With this knowledge, we can read the RSA algorithm. This is the most important encryption algorithm on Earth at present.

Vi. Steps for key generation

We use an example to understand the RSA algorithm. Suppose Alice wants to encrypt the communication with Bob, how does she generate the public and private key?

The first step is to randomly select two unequal prime numbers p and Q.

Alice chose 61 and 53. (In practical applications, the larger the two primes, the harder it is to crack.) )

The second step is to compute the product N of P and Q.

Alice multiplies 61 and 53.

n = 61x53 = 3233

The length of n is the key length. 3233 Write binary is 110010100001, a total of 12 bits, so this key is 12 bits. In practical application, RSA key is usually 1024 digits, and 2048 bits in important occasion.

The third step is to compute the Euler function φ (n) of N.

According to the formula:

φ (n) = (p-1) (q-1)

Alice calculates that φ (3233) equals 60x52, or 3120.

The fourth step, randomly selects an integer e, the condition is 1< e <φ (n), and E and φ (n) coprime.

Alice is between 1 and 3120 and randomly chooses 17. (In practical applications, 65537 is often selected.) )

The fifth step is to compute the modulo inverse element d of E for φ (n).

The so-called "modulo inverse element" means that there is an integer d that makes the remainder of Ed by φ (n) 1.

Ed≡1 (modφ (n))

This equation is equivalent to

Ed-1 = kφ (n)

So, we find the modulo inverse element D, which is essentially the solution to the two-dollar equation below.

Ex +φ (n) y = 1

Known e=17,φ (n) = 3120,

17x + 3120y = 1

This equation can be solved with the "extended Euclidean algorithm", where the specific process is omitted. In short, Alice calculates a set of integer solutions (x,y) = (2753,-15), that is, d=2753.

All calculations have been completed thus far.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.