How is the RSA public key calculated?

In the first step, two unequal prime numbers p and q are randomly selected.
Alice chose 61 and 53. (In practice, the larger these two prime numbers are, the harder it is to decipher.)
 
The second step is to calculate n, the product of p and q.
Alice multiplied 61 and 53.
n = 61×53 = 3233
The length of n is the key length. 3233 written in binary is 110010100001, a total of 12 bits, so the key is 12 bits. (In practical applications, the RSA key is generally 1024 bits, and in important cases, it is 2048 bits.)
 
The third step is to calculate the Euler function φ(n) of n.
According to the formula:
φ(n) = (p-1)(q-1)
Alice calculates that φ(n) is equal to 60×52=3120.
 
The fourth step is to randomly select an integer e, provided that 1 < e < φ(n), and e and φ(n) are relatively prime.
Alice is just between 1 and 3120, with e=17 chosen at random. (In practical applications, 65537 is often chosen.)
 
The fifth step is to calculate the modulo inverse element d of e for φ(n).
The so-called "modular inverse element" means that there is an integer d, which can make the remainder of ed divided by φ(n) to be 1.
ed ≡ 1 (mod φ (n))
This formula is equivalent to
ed - 1 = kφ(n)
In essence, it is to solve the following binary equation.
ed + φ(n)k = 1
Known e=17, φ(n)=3120,
17d + 3120k = 1
This equation can be solved by the "Extended Euclidean Algorithm", and the specific process is omitted here.
In short, Alice calculates a set of integer solutions as (d,k)=(2753,-15), that is, d=2753.
So far all calculations are completed.
 
The sixth step is to encapsulate n and e into a public key, and n and d into a private key.
In Alice's example, n=3233, e=17, d=2753, so the public key is (3233,17) and the private key is (3233,2753).
 
Step 7: Send the public key and keep the private key. This message is in centificate.
Alice sends the public key (3233, 17) to Bob, and keeps the private key (3233, 2753).
 The certificate public key is shown in the following packet capture

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326365486&siteId=291194637
Recommended