Cyber Security Notes
Cyber Security Notes
RSA Algorithm
CS504-(A): Cyber Security
RSA Algorithm (Named after Rivest, Shamir and Adleman, who invented it
in 1977)
● RSA algorithm is asymmetric (Public key) cryptography algorithm.
● Asymmetric actually means that it works on two different keys i.e. Public
Key and Private Key.
● As the name describes that the Public Key is given to everyone and Private key
is kept private.
● The idea of RSA is based on the fact that it is difficult to factorize a large
integer. The public key consists of two numbers where one number is
multiplication of two large prime numbers. And private key is also derived from
the same two prime numbers. So if somebody can factorize the large number,
the private key is compromised. Therefore encryption strength totally lies on the
key size and if we double or triple the key size, the strength of encryption
increases exponentially. RSA keys can be typically 1024 or 2048 bits long, but
experts believe that 1024 bit keys could be broken in the near future. But till
now it seems to be an infeasible task.
RSA Algorithm
● Key Generation Algorithm
● Encryption
● Decryption
RSA Algorithm
● Key Generation Algorithm
1. Generate two large random primes, p and q, of approximately equal size such that their
product n = p x q. n is of the required bit length, e.g. 1024 bits.
2. Compute ϕ =(p−1) x (q−1). (ϕ is Euler totient)
3. Choose an integere, 1<e<ϕ, such that gcd( e, ϕ) = 1. (e shouldn’t be a factor of ϕ )
4. Compute the secret exponent d, 1<d<ϕ, such that e.d ≡1mod ϕ. (e.d mod ϕ = 1)
5. The public key is (n, e) and the private key (d, n).
6. n is known as the modulus.
7. e is known as the public exponent or encryption exponent or just the exponent.
8. d is known as the secret exponent or decryption exponent.
● Encryption : C=Me mod n
● Decryption: M=Cd mod n
RSA Algorithm
● Why the RSA algorithm is used
RSA derives its security from the difficulty of factoring large integers that are
the product of two large prime numbers. Multiplying these two numbers is
easy, but determining the original prime numbers from the total -- or
factoring -- is considered infeasible due to the time it would take using
even today's supercomputers.
`
RSA Algorithm Example
● Alice generates her RSA keys by selecting two primes: p=11 and q=13.
The modulus is n=p×q=143. The totient is ϕ(n)=(p−1)x(q−1)=120. She
chooses 7 for her RSA public key e (7)
● Calculates her RSA private key using the Extended Euclidean
algorithm, which gives her 103 (d).
d x e= 103x7 = 721, d x e mod ϕ = 721 mod 120 = 1
● Bob wants to send Alice an encrypted message, M, so he obtains her
RSA public key (n, e) which, in this example, is (143, 7). His message
is just the number 9 and is encrypted into the ciphertext C, as follows:
● Me mod n = 97 mod 143 = 48 = C
● When Alice receives Bob's message, she decrypts it by using her RSA
private key (d, n) =(143, 103) as follows:
● Cd mod n = 48103 mod 143 = 9 = M
Test Your Understanding
1. RSA is
A. Symmetric Algorithm
B. Asymmetric Algorithm
C. Hash Function
D. None of these
RSA Algorithm
Sources:
● Cyber Law Simplified – Vivek Sood, McGraw Hill Education Pvt. Ltd.
● https://www.cryptool.org
Disclaimer- Parts of the content of this course is based on the materials available from the Web sites and books listed above. The
materials that can be accessed from linked sites are not maintained by Acropolis Institute of Technology and we are not responsible
for the contents thereof. All trademarks, service marks, and trade names in this course are the marks of the respective owner(s).
Any Doubts/Questions
Acropolis Institute of Technology and Research, Indore
Thank You
11