
Internally, this method works only with numbers (no text), which are between 0 and n − 1.Ī message m (number) is encrypted with the public key ( n, e) by calculating:ĭecrypting with the private key ( n, d) is done analogously withĪs e and d were chosen appropriately, it is This d can always be determined (if e was chosen with the restriction described above) - for example with the extended Euclidean algorithm. It is x = y (mod z) if and only if there is an integer a with x − y = z × a.įor the chosen values of p, q, and e, we get d as: In this case, the mod expression means equality with regard to a residual class. The secret key also consists of a d with the property that e × d − 1 is a multiple of φ( n).Įxpressed in formulas, the following must apply: Only with the knowledge of p and q we can efficiently determine φ( n). To determine the value of φ( n), it is not enough to know n.

It is important for RSA that the value of the φ function is coprime to e (the largest common divisor must be 1).

Otherwise, the φ function would be calculated differently. The prerequisit here is that p and q are different. RSA uses the Euler φ function of n to calculate the secret key. This e may even be pre-selected and the same for all participants. E and φ(n) have a common divisor, they are not coprime.
