Skip to content

MohamedHashim/RSA_Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RSA Algorithm

Simple implementation of RSA algorithm, asymmetric cryptography algorithm

The concept of RSA Algorithm is generating public and private keys in 512 bits.

Screenshot

The Algorithm theory:

1- Key Generation

β€’ Choose two random prime numbers p & q using Miller-Rabin Test
β€’ Compute n =p*q
β€’ Compute euler phi = (p-1) (q-1)
β€’ Choose e, random prime number in specific range
β€’ Then get the key of (n,e)

2- Message Encryption using EEA (Extended Euclidean algorithm)

β€’ C = m^e mod n

3- Message Decryption using CRT

β€’ C^d mod n
β€’ e^-1 mod phi

β€’ Miller-Rabin Test

1- Get U & R from the prime number
2- Use Square and multiply algorithm to allow fast exponentiaition

β€’ CRT

1- Modular representation of y into p and q

𝑦𝑝=𝑦 π‘šπ‘œπ‘‘ 𝑝 
π‘¦π‘ž=𝑦 π‘šπ‘œπ‘‘ π‘ž 

2- Compute exponents

𝑑𝑝=𝑑 π‘šπ‘œπ‘‘ (π‘βˆ’1) 
π‘‘π‘ž=𝑑 π‘šπ‘œπ‘‘ (π‘žβˆ’1) 

3- Compute exponentiation

π‘₯𝑝=𝑦𝑝𝑑𝑝 π‘šπ‘œπ‘‘ 𝑝
π‘₯π‘ž=π‘¦π‘žπ‘‘π‘ž π‘šπ‘œπ‘‘ π‘ž

4- Compute C:

𝐢𝑝=π‘žβˆ’1 π‘šπ‘œπ‘‘ 𝑝 
πΆπ‘ž=π‘βˆ’1 π‘šπ‘œπ‘‘ π‘ž 

5- Compute X

𝑋 = {(π‘ž.𝐢𝑝)𝑋𝑝 + (𝑝.πΆπ‘ž) π‘‹π‘ž} π‘šπ‘œπ‘‘ 𝑛 

About

Simple implementation of RSA algorithm, asymmetric cryptography algorithm

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages