Rivest–Shamir–Adleman (RSA) Cryptosystem
RSA is a public-key scheme that turns a pair of large primes into a trapdoor for modular exponentiation.
Let and be distinct 512-bit (or larger) primes that are kept secret and set . Also, let be any number that is relatively prime to , such that . Then the public key is the tuple , and the private key is the inverse . Note that is guaranteed to exist since and are coprime.
With the keys in place, RSA communication reduces to two mirror-image steps:
- The sender encrypts a message as the ciphertext .
- The receiver decrypts by computing .
The security of RSA hinges upon the fact that and are kept private by the correspondents. Given only , and , there is no efficient algorithm to compute .
Correctness
The premise of RSA boils down to one simple fact:
- For every possible message , it holds that .
We will now go ahead and prove this fact using Fermat’s Little Theorem, described in 4.2. We restate it here for convenience: - Fermat’ Little Theorem: For all primes , if , and for all .
Examples
(Very Easy) RSA Warm-Up
Consider an RSA scheme with modulus , where and are distinct prime numbers larger than .
What is wrong with using the exponent in an RSA public key? A value will not be relatively prime to , which is necessarily even for all , and therefore an inverse will not exist for the private key.
Now suppose that , , and .
What is the public key and private key? . Then, the public key is , whereas we find private key using a quick application of EGCD, such that .
We have
Alice wants to send a message to Bob. What is the encrypted message she sends using the public key? We have that .
Suppose Bob receives the message from Alice. What equation would he use to decrypt the message? What is the decrypted message? He would use .
In RSA, we rely on the hardness of two different problems in order to guarantee the security of the scheme. Which two problems are these? If their hardness is not guaranteed, what goes wrong?
(Easy) RSA Security with Multiple Keys
A secret society repeatedly sends the same secret (with ) using RSA keys that all share the same exponent but have pair-wise distinct moduli . Eve hears every ciphertext and the public keys; she knows the RSA setup but cannot factor large numbers.
Eve observes two keys and and their own distinct messages and , where are 1024-bit primes.
Can this information alone let her recover ? Since Eve knows that is a factor in both and , she computes . Then she divides both moduli by , such that and . Knowing the primes, she can construct the private keys and and recovers the secret.
The secret society sniffs Eve out and switches to a new word and to three keys , , with six distinct primes and three distinct messages .
Explain briefly why Eve’s previous method no longer works. ) such that , since all primes are distinct and therefore no pair shares a common factor. As such, Eve's method no longer works.
For all pairs (
Now, assume the secret stays the same and the public exponent is still .
The group keeps using the three public keys from part (b) but sends only that single repeated ciphertext. Explain how Eve can recover . Eve observes the following system of equations: She must find , and use CRT to compute . Since , then , and therefore she can simply take the cube root to recover .
(Medium) RSA for Concert Tickets
Alice’s concert ticket number is an integer . She wishes to tell Bob this number over an insecure channel that Eve can monitor, but she does not want Eve to learn .
Bob first announces his RSA public key, which consists of a 512-bit modulus and an exponent . Alice encrypts her ticket number with and transmits the resulting ciphertext to Bob. Eve sees the encrypted message, and she is able to deduce .
Explain the method that allows Eve to recover under these conditions. Eve uses brute force to find a number in the small interval that, paired with the public key , results in .
Alice now adopts a more elaborate approach. She chooses a random 256-bit integer that is coprime to . She then sends Bob two separate ciphertexts, both encrypted with the same public key as before . The first ciphertext is , and the second ciphertext is . Eve knows the protocol in use and can observe both and but she does not know the value of .
Describe how Eve can nevertheless determine the ticket number . Eve can define . In other words, , and since there exists a modular inverse such that . Then, Eve can use the brute force method explained in the previous part to deduce .
(Hard) RSA with CRT Optimization
Alice wants to decrypt faster, so after generating an ordinary RSA key with private exponent , she pre-computes the reduced exponents:
Given a ciphertext from Bob, she also forms the expressions:
Show that this algorithm is correct, i.e. that is the only solution to the modular system.
a
Example
a
Assuming , demonstrate how anyone with access to the private key can recover and .
Start out by expressing , and per CRT there is a unique such that and .
Similarly, we can express which is recovered using , and per CRT this becomes and ,
Now, to evaluate and , notice that
RSA with Just One Prime