Cryptography and Computer Security - Exercise 5
Subject: Modern Public-Key Encryption: RSA
Submission deadline: 29/12/2010
- Programming
Generate your own 31- or 32-bit RSA public and private keys:
- Pick 2 secret primes p, q, in the range [10000-65535]: Try a
few numbers at random and test for primality. You will find a
prime very quickly. You can test a number x for primality by
checking whether all the odd numbers
y <
do not divide x.
- Compute your public modulus nz = pq.
- Compute the secret
= (p - 1)(q - 1).
- Pick a value for your public exponent ez such that
gcd (
, ez) = 1. Any value that works is OK.
- Compute the secret exponent
dz = (ez)-1(mod
)
using the extended Euclid algorithm.
- Tip: Test your key pair (nz, ez):
compute
t = 2ez(mod nz)
and check whether
tdz(mod nz) = 2.
- Tip: use unsigned 64-bit variables in your program to avoid
integer overflows in intermediate values.
- Tip: make sure to pick p and q so n is larger than your TZ number
Once you have a working RSA system
(nz, ez, dz), sign your
Teudat Zehut number (seen as a 9-digit integer): that is, compute
SIG = (TZ)dz(mod nz).
Send the results by email according to the instructions below.
- Consider an RSA system with a public key (n, e), with
n = pq.
- Show an algorithm to find the factors of
n if the secret
(n) is leaked. Hint: write and solve a
quadratic equation. Justify why your solution works on integers.
- What is the time complexity of your algorithm (order of
magnitude as a function of n)? take into account the complexity of
computing integer square roots.
- What is the probability that a randomly chosen number a
would not
be relatively prime to a given RSA modulus n?
- Estimate this probability in terms of n for
p
q
and for
p
q3.
- What threat would such a number a pose ?
- In a given RSA system with public (n, e), prove that there
exist more than one posible secret exponent d that works. In
other words, show that there exists
d' <
(n),
d'
e-1 mod
(n), which
correctly decrypts every message
C = me mod n.
- Hand in questions 2-4 on paper.
- Send question 1 via email to
- The subject should be: ex5. Do NOT put a dash ("-")
between the "x" and the "5" as it confuses the mailer.
- The body of the email should contain 4 lines, including the leading
keywords and the ":=" symbols:
TZ := your "Teudat Zehut" number (9 digits)
NZ := the public modulus nz from q.1
EZ := the public exponent ez from q.1
SIG := the signature from q.2,
(TZ)dz(mod nz) from q.1.
Note that these are all PUBLIC values. Do NOT send your secret keys!
- Send plain ASCII email.
Avishai Wool
2010-12-19