GD32W51x User Manual
970
Figure 29-2. Flow chart of RSA algorithm
Bob
Generate
key pairs
Alice
Save public
key from Bob
encryption
algorithm
message
ciphertext
decryption
algorithm
message
ciphertext
Private key
from Bob
Public key
from Bob
A complete public key crypto system includes key pairs (public and private keys), encryption
algorithms and decryption algorithms.
Generate key pairs of RSA
1.
Select two large primes p and q (p≠q);
2.
Calculate n=p×q, n is the modulus of public and private keys;
3.
Calculate L=
∅
(
n
)
=(p-1)(q-1),
∅
(
n
)
is euler function;
4.
Select e, 1<e<L, e and L must be relatively prime;
5.
Calculate d, 1<d<L and e*d mod L = 1.
The parameters show in
Table 29-1. Parameters of RSA algorithm
can be obtained by the
above calculation.
Table 29-1. Parameters of RSA algorithm
Param eters
Description
n
modulus
e
public exponent
d
private exponent
(n,e)
public key
(n,d)
private key
RSA encryption
Bob generates a key pair that conforms to RSA algorithm standard, including public key and
private key. Bob sends the public key to Alice, and holds the private key. Alice can encrypt the
message m through the public key from Bob and obtain the ciphertext c. Then Alice sends
the ciphertext to Bob. The ciphertext is c
=
m
e
mod n.