Skip to content

Implementing RSA Algorithm using MR Test, FME Test, EA and EEA

License

Notifications You must be signed in to change notification settings

abhi-agrawl/rsa-algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RSA Algorithm

  • Generating Key value pair with a multiple options for number of bits to choose from.
  • Option to store Public and Private Key in .txt file.
  • Encrypts a message (also gives option to import key stored by the same program)
  • Option to store Encrypted Message in .txt file.
  • Decrypts a message (also gives option to import key stored by the same program)

Implementation

I. Key Generation

Using CreateRandom Class

  • Get two different large prime numbers p and q
    • Using Miller-Rabin Test

Using GenerateKeys Class

  • Let n = p * q

  • Let φ(n) = (p-1) * (q-1)

  • Choose a small, odd integer number e, where 1 < e < φ(n) and e is a co-prime to φ(n).

    • Using Euclidean Algorithm
    • Check calculateEncryptionExponent() method
  • Calculate the integer number d, where ed ≡ 1 mod φ(n) and 1 < d < φ(n).

    • Using Extended Euclidean Algorithm
    • Check calculateDecryptionExponent() method
  • The public key of the RSA is the pair PK = (n, e)

  • The secret key of the RSA is the pair SK = (n, e)

II. Encryption

Using FME Class

  • To encrypt the message m (where m < n) using the public key PK = (n, e) following formula is used: (Fast Modular Exponent)

    c := EncPK(m) = m^e (mod n).
    

III. Decryption

Using FME Class

  • To decrypt the secret message c using the secret key d following formula is used: (Fast Modular Exponent)

    m := DecSK(c) = c^d (mod n).