RSA algorithm
To generate a key pair, you can start by creating two large prime numbers named P and Q. Multiply these two numbers, and the result is called N. because both P and Q are prime numbers, the full factor of n is 1, p, Q, and N.
If only the number less than n is considered, the number of numbers with n Inma (that is, no common factor with N) equals (p-1) (q-1).
Now, select a number e, which is calculated with a value of Inma. the public key is represented as {e, n}.
To create a private key, you must calculate D, which is a number that satisfies (d) (e) mod n = 1. According to the Euclidean algorithm, the private key is {d, n}.
the encryption of plain text m to cipher text C is defined as C = (m ^ e) mod N. decryption is defined as m = (c ^ d) mod N.
Field Summary
The PKCS #1 on the RSA Laboratories website: The a.1.2 section of the RSA Cryptography Standard (PKCS #1: RSA encryption Standards) defines the format of the RSA private key.
The following table summarizes the fields of the rsaparameters structure. The third column provides the corresponding fields in the a.1.2 section of the PKCS #1: RSA Cryptography Standard (PKCS #1: RSA encryption standards).
RSAParameters Field |
Contains |
Corresponding PKCS #1 fields |
D |
D, private key index |
Privateexponent |
Dp |
d MoD (p-1) |
Exponent1 |
Dq |
d MoD (q-1) |
Exponent2 |
Exponent |
E, public key index |
Publicexponent |
Inverseq |
(INVERSEQ) (q) = 1 mod p |
Coefficient |
Modulus |
N |
Modulus |
P |
P |
Prime1 |
Q |
Q |
Prime2 |
The security of RSA is based on the fact that given the public key {e, n}, whether it is calculated directly or by factoring N to p and Q, it is not feasible to calculate d. Therefore, any key part related to D, p, or Q must be kept confidential.
RSA Algorithm-MSDN Documentation