These tasks are due as part of the next homework.
Task 1:
Using your modexp
function from before, verify
my RSA digital signature sig
of my message m
listed in my code above.
Task 2:
Write a function findprime(k)
that finds a random (pseudo)prime of at least k digits.
You may use the randint
function, and your choice
of primality test from Lab 6. Test this a couple of times for k=2.
Task 3:
Write a function inv(a,n)
that efficiently computes a inverse mod n. If a is not invertible
mod n, print an error message to that effect, and return -1.
Test this for (a,n) = (2,7) and (6,15).
Task 4:
Write a function RSAprivatekey(p,q,e=65537)
which generates the RSA private key d for n=pq and public
key e.
Task 5: Using the above functions, generate your own random primes p and q which are both 10-15 digit numbers. Generate a public key (n,e) and private key d. Test encryption and decryption on the message 'rsa'.
Task 6:
Exchange your public key with one other person in the class.
(a) Encrypt a short text message of your choice with their RSA public key
and send them (only) the encrypted message (as a number, or as a
sequence of numbers if your message is longer than the block size for
their n).
(b) Decrypt the encrypted message you receive from your partner.