RSA This algorithm is used in cryptography Technique in that RSA is added along with it. These are procedures followed
Key generation
RSA involves a public key and a private key. The public key can be known to everyone and is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. The keys for the RSA algorithm are generated the following way:
1. Choose two distinct prime numbers p and q.
* For security purposes, the integers p and q should be chosen uniformly at random and should be of similar bit-length. Prime integers can be efficiently found using a primality test.
2. Compute n = pq.
* n is used as the modulus for both the public and private keys
3. Compute φ(pq) = (p − 1)(q − 1). (φ is Euler's totient function).
4. Choose an integer e such that 1 < e < φ(pq), and e and φ(pq) share no divisors other than 1 (i.e., e and φ(pq) are coprime).
* e is released as the public key exponent.
* e having a short bit-length and small Hamming weight results in more efficient encryption. However, small values of e (such as e = 3) have been shown to be less secure in some settings.[4]
5. Determine d (using modular arithmetic) which satisfies the congruence relation d e \equiv 1\pmod{\varphi(pq)}.
* Stated differently, ed − 1 can be evenly divided by the totient (p − 1)(q − 1).
* This is often computed using the extended Euclidean algorithm.
* d is kept as the private key exponent.
The public key consists of the modulus n and the public (or encryption) exponent e. The private key consists of the private (or decryption) exponent d which must be kept secret.
Note:
[edit] Encryption
Alice transmits her public key (n,e) to Bob and keeps the private key secret. Bob then wishes to send message M to Alice.
He first turns M into an integer 0 < m < n by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext c corresponding to:
This can be done quickly using the method of exponentiation by squaring. Bob then transmits c to Alice.
[edit] Decryption
Alice can recover m from c by using her private key exponent d by the following computation:
Given m, she can recover the original message M by reversing the padding scheme.
(In practice, there are more efficient methods of calculating cd using the pre computed values above.)
[edit] A worked example
Here is an example of RSA encryption and decryption. The parameters used here are artificially small, but one can also use OpenSSL to generate and examine a real keypair.
1. Choose two prime numbers
2. Compute n = pq
3. Compute the totients of product. For primes the totient is
maximal and equals the prime minus one. Therefore \varphi(pq) =
(p-1)(q-1) \,
4. Choose any number e > 1 that is coprime to 3120. Choosing a
prime number for e leaves you with a single check: that e is not a
divisor of 3120.
5. Compute d such that d e \equiv 1\pmod{\varphi(pq)}\, e.g., by
computing the modular multiplicative inverse of e modulo \varphi(pq)\,:
d = 2753
since 17 · 2753 = 46801 and 46801 mod 3120 = 1, this is the correct answer.
(iterating finds (15 times 3120)+1 divided by 17 is 2753, an integer, whereas other values in place of 15 do not produce an integer. The extended euclidean algorithm finds the solution to Bézout's identity of 3120x2 + 17x-367=1, and -367 mod 3120 is 2753)
The public key is (n = 3233, e = 17). For a padded message m the encryption function is m^{17} \mod {3233} or abstractly:
The private key is (n = 3233, d = 2753). The decryption function is c^{2753} \mod {3233} or in its general form:
For instance, in order to encrypt m = 65, we calculate
Both of these calculations can be computed efficiently using the
square-and-multiply algorithm for modular exponentiation. In real life
situations the primes selected would be much larger; in our example it
would be relatively trivial to factor n, 3233, obtained from the freely
available public key back to the primes p and q. Given e, also from the
public key, we could then compute d and so acquire the private key.
Key generation
RSA involves a public key and a private key. The public key can be known to everyone and is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. The keys for the RSA algorithm are generated the following way:
1. Choose two distinct prime numbers p and q.
* For security purposes, the integers p and q should be chosen uniformly at random and should be of similar bit-length. Prime integers can be efficiently found using a primality test.
2. Compute n = pq.
* n is used as the modulus for both the public and private keys
3. Compute φ(pq) = (p − 1)(q − 1). (φ is Euler's totient function).
4. Choose an integer e such that 1 < e < φ(pq), and e and φ(pq) share no divisors other than 1 (i.e., e and φ(pq) are coprime).
* e is released as the public key exponent.
* e having a short bit-length and small Hamming weight results in more efficient encryption. However, small values of e (such as e = 3) have been shown to be less secure in some settings.[4]
5. Determine d (using modular arithmetic) which satisfies the congruence relation d e \equiv 1\pmod{\varphi(pq)}.
* Stated differently, ed − 1 can be evenly divided by the totient (p − 1)(q − 1).
* This is often computed using the extended Euclidean algorithm.
* d is kept as the private key exponent.
The public key consists of the modulus n and the public (or encryption) exponent e. The private key consists of the private (or decryption) exponent d which must be kept secret.
Note:
Alice transmits her public key (n,e) to Bob and keeps the private key secret. Bob then wishes to send message M to Alice.
He first turns M into an integer 0 < m < n by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext c corresponding to:
[edit] Decryption
Alice can recover m from c by using her private key exponent d by the following computation:
(In practice, there are more efficient methods of calculating cd using the pre computed values above.)
[edit] A worked example
Here is an example of RSA encryption and decryption. The parameters used here are artificially small, but one can also use OpenSSL to generate and examine a real keypair.
1. Choose two prime numbers
d = 2753
since 17 · 2753 = 46801 and 46801 mod 3120 = 1, this is the correct answer.
(iterating finds (15 times 3120)+1 divided by 17 is 2753, an integer, whereas other values in place of 15 do not produce an integer. The extended euclidean algorithm finds the solution to Bézout's identity of 3120x2 + 17x-367=1, and -367 mod 3120 is 2753)
The public key is (n = 3233, e = 17). For a padded message m the encryption function is m^{17} \mod {3233} or abstractly:
No comments:
Post a Comment