How is RSA Algorithm Calculated?

Information SecuritySafe & SecurityData Structure

RSA is a cryptosystem for public-key encryption, and it is broadly used for securing sensitive information, specifically when being sent over an insecure network including the Internet.

RSA algorithm is the most popular asymmetric key cryptographic algorithm depends on the mathematical fact that it is simply to discover and multiply large prime numbers but complex to factor their product. It needs both private and public key.

Example of RSA Algorithm

Let us take an example of this procedure to learn the concepts. For ease of reading, it can write the example values along with the algorithm steps.

  • Choose two large prime numbers P and Q

    Let P = 47, Q = 17

  • Calculate N = P x Q

    We have, N = 7 x 17 = 119.

  • Choose the public key (i.e., the encryption key) E such that it is not an element of (P -1) x (Q – 1)

    • Let us find (7 - 1) x (17 -1) = 6 x 16 = 96

    • The factors of 96 are 2, 2, 2, 2, 2, and 3 (because 96 = 2 x 2 x 2 x 2 x 2 x 3).

    • Therefore, it can select E such that none of the factors of E is 2 and 3. We cannot choose E as 4 (because it has 2 as a factor), 15 (because it has 3 as a factor) and 6 (because it has 2 and 3 both as factors).

    • Let us choose E as 5 (it can have been any other number that does not its factors as 2 and 3).

  • Choose the private key (i.e., the decryption key) D including the following equation is true:

    (D x E) mod (P – 1) x (Q – 1) = 1

    • Let us substitute the values of E, P, and Q in the equation.

    • We have (D x 5) mod (7 – 1) x (17 – 1) = 1.

    • That is, (D x 5) mod (6) x (16) = 1.

    • That is, (D x 5) mod (96) = 1

    • After some calculations, let us take D = 77. Then the following is true: (77 x 5) mod (96) = 385 mod 96 = 1 which is what we wanted.

  • For encryption, calculate the cipher text (CT) from the plain text (PT) as follows:

    CT = PTE mod N

    Let us assume that we want to encrypt plain text 10. Then, we have

    CT = 105 mod 119 = 100000 mod 119 = 40.

  • Send CT as the cipher text to the receiver.

    Send 40 as the cipher text to the receiver.

  • For decryption, calculate the plain text (PT) from the cipher text (CT) as follows:

    PT = CTD mod N

    It perform the following:

    PT = CTDmod N

    That is,

    PT = 4077mod 119 = 10, which was the original plaintext of step5.

raja
Updated on 16-Mar-2022 10:06:24

Advertisements