Aïkido  |  Members  |  Other
Sitemap  |  Links  |  Homepage
 
   
Mask calculator
RSA encryption
AES encryption
Man In the Middle
The RSA algorithm was invented in 1978 by Ron Rivest, Adi Shamir, and Leonard Adleman.

Public Key
n   product of two primes, p and q (p and q must remain secret)
e   relatively prime to (p - 1)(q - 1)
Private Key
d = e-1 mod ((p - 1)(q - 1))
Public operation (for encipherment and signature verification)
c = me mod n
Secret operation (for decipherment and signature generation)
m = cd mod n
Methodology
  1. Find p and q, two large prime numbers (e.g., 1024-bit).

  2. Choose e such that e is less than pq, and such that 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 encrypt(m) = (m^e) mod pq, where m is the plaintext (a positive integer) and ^ indicates exponentiation. The message being encrypted, m, must be less than the modulus, pq.

  5. The decryption function is decrypt(c) = (c^d) mod pq, where c is the ciphertext (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 computers presently in existence can factor your modulus into p and q.
Example
p  = 5    first prime number (destroy this after computing e and d)
q  = 3    second prime number (destroy this after computing e and d)
pq = 15   modulus (give this to others)
e  = 11   public exponent (give this to others)
d  = 3    private exponent (keep this secret!)

Your public key is (pq, e).
Your private key is d.

The encryption function is: encrypt(m) = (m^e) mod pq
                                       = (m^11) mod 15

The decryption function is: decrypt(c) = (c^d) mod pq
                                       = (c^3) mod 15

To encrypt the plaintext value 12, do this:

encrypt(12) = (12^11) mod 15
            = 743008370688 mod 15
            = 3

To decrypt the ciphertext value 3, do this:

decrypt(3)  = (3^3) mod 15
            = 27 mod 15
            = 12

Creative Commons License
This page is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 France License.

Last update 15 janvier, 2011
Copyright © 2008-2012,  All rights reserved.
Questions? Contact ktana.eu.