Monday, April 02, 2007

RSA -- A public-key encryption algorithm

What is RSA ? and why named like that ?

RSA is an algorithm for public-key encryption. The RSA algorithm was invented in 1978 by Ron Rivest, Adi Shamir, and Leonard Adleman and was named after them.

How RSA works ?

Here's the relatively easy to understand math behind RSA public key encryption.

1. Find P and Q, two large (e.g., 1024-bit) prime numbers.

2. Choose E such that E is greater than 1, E is less than PQ, and E and (P-1)(Q-1) are relatively prime, which means they have no prime factors in common. E does not have to be prime, but it must be odd. (P-1)(Q-1) can't be prime because it's an even number.

3. Compute D such that (DE - 1) is evenly divisible by (P-1)(Q-1). Mathematicians write this as DE = 1 (mod (P-1)(Q-1)), and they call D the multiplicative inverse of E. This is easy to do -- simply find an integer X which causes D = (X(P-1)(Q-1) + 1)/E to be an integer, then use that value of D.

4. The encryption function is C = (T^E) mod PQ, where C is the ciphertext (a positive integer), T is the plaintext (a positive integer), and ^ indicates exponentiation. The message being encrypted, T, must be less than the modulus, PQ.

5. The decryption function is T = (C^D) mod PQ, where C is the ciphertext (a positive integer), T is the plaintext (a positive integer), and ^ indicates exponentiation.

Your public key is the pair (PQ, E). Your private key is the number D (reveal it to no one). The product PQ is the modulus (often called N in the literature). E is the public exponent. D is the secret exponent.

You can publish your public key freely, because there are no known easy methods of calculating D, P, or Q given only (PQ, E) (your public key). If P and Q are each 1024 bits long, the sun will burn out before the most powerful deterministic computers presently in existence can factor your modulus into P and Q.

An Example of the RSA Algorithm:

P = 61 <- first prime number
Q = 53 <- second prime number
PQ = 3233 <- modulus (give this to others)
E = 17 <- public exponent (give this to others)
D = 2753 <- private exponent (keep this secret!)

Your public key is (E,PQ).
Your private key is D.

The encryption function is:
encrypt(T) = (T^E) mod PQ = (T^17) mod 3233

The decryption function is:
decrypt(C) = (C^D) mod PQ = (C^2753) mod 3233

To encrypt the plaintext value 123, do this:
encrypt(123) = (123^17) mod 3233 = 337587917446653715596592958817679803 mod 3233 = 855

To decrypt the ciphertext value 855, do this:
decrypt(855) = (855^2753) mod 3233 = 123

Sources and more about RSA:

3 comments:

Anonymous said...

… Unbelievable , but I just found software which can do all hard work promoting your amr-magdy.blogspot.com website on complete autopilot - building backlinks and getting your website on top of Google and other search engines 1st pages, so your site finally can get laser targeted qualified traffic, and so you can get lot more visitors for your website.

YEP, that’s right, there’s this little known website which shows you how to get to the top 10 of Google and other search engines guaranteed.

I used it and in just 7 days… got floods of traffic to my site...

…Well check out the incredible results for yourself -
http://magic-traffic-software.com

I’m not trying to be rude here, but I believe when you find something that finally works you should share it…

…so that’s what I’m doing today, sharing it with you:

http://magic-traffic-software.com

Take care - your friend Jennifer

Anonymous said...

After getting more than 10000 visitors/day to my website I thought your amr-magdy.blogspot.com website also need unstoppable flow of traffic...

Use this BRAND NEW software and get all the traffic for your website you will ever need ...

= = > > http://get-massive-autopilot-traffic.com

In testing phase it generated 867,981 visitors and $540,340.

Then another $86,299.13 in 90 days to be exact. That's $958.88 a
day!!

And all it took was 10 minutes to set up and run.

But how does it work??

You just configure the system, click the mouse button a few
times, activate the software, copy and paste a few links and
you're done!!

Click the link BELOW as you're about to witness a software that
could be a MAJOR turning point to your success.

= = > > http://get-massive-autopilot-traffic.com

Unknown said...

This algorithm is very complex to understand and learn. I understood the logic behind it with the steps you have posted. Thank you.
electronic signature software