CIS 400/628 Homework #3 and #4: Implementing RSA Encryption and Decryption Algorithms, Assignments of Computer Science

Instructions for a computer science homework assignment in a cis 400/628 course, focusing on implementing rsa encryption and decryption algorithms. Students are required to write programs for randomly choosing numbers, selecting a 32-bit prime number, implementing euclid's extended algorithm, computing modular exponentiation, and combining these programs for rsa encryption and decryption. The assignment is due in february 2005.

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-y0v
koofers-user-y0v 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 400/628
Homework #3 & #4
Spring 2005
Due: 24 Feb 2005 & 3 Mar 2005
All of the following programs need only handle numbers that fit into long integers (64 bit quantities).
Real implementations of these algorithms must handle arbitrarily long integers.
You may work in teams of two for this assignment.
Homework #3 comprises items 1-3, and is due at 11:59 pm on 24 Feb 2005. Homework #4 comprises
items 4 & 5, and is due at 11:59 pm on 3 Mar 2005.
1. Write a program that takes two integers (a and b) and (pseudo-) randomly chooses a number be-
tween them (inclusive). For example, if I entered 1 and 100 as input, it would choose a number
between 1 and 100. If I entered 230 and (232 1), it would choose one in that range. You may use
whatever random number generator is available on your computer (note that this is too weak for a
real cryptosystem).
2. Write a program to choose a 32-bit (likely) prime number. Note that this is a fairly small prime, by
RSA standards, but will work for our purposes. Document what primality test you use.
3. Write a program that implements the extended version of Euclid’s algorithm. The output should
comprise the gcd of the two input values, d=gcd(a,b), and the values of sand tsuch that gcd(a,b)
=s·a+t·b. If you wish, you may include debugging output for each step of the algorithm.
4. Write a program to compute me(mod n). Note that ewill be a 32-bit number, and mwill be at most
6-ASCII characters long (i.e., it will fit in 48 bits of a 64-bit word). You should consider the “tricks”
from the HOW DO WE COMPUTE me(mod n) slide in the notes.
5. Graduate students: compose the above programs to implement RSA encryption and decryption. This
is not cryptanalysis, but rather building the basic key selection, encryption, and decryption blocks
for RSA. You should have write two programs: rsa keygen and rsa crypt.rsa keygen should
print out e,n,d,p,q,andφ(n). Note that normally, one would only publish eand n.rsa crypt takes
as inputs the message m(again, at most 48 bits), n, and either dor edepending on which way this
encryption is going. The result should be the en-/deciphered text, in hexadecimal characters (e.g,
0x04ab72c15d01).
Undergraduate students: Explain how you would combine the programs from steps 1-4 to implement
RSA. You do not have to write this program, only explain how you would.
We will distribute sample data for you to do some simple testing on your programs.

Partial preview of the text

Download CIS 400/628 Homework #3 and #4: Implementing RSA Encryption and Decryption Algorithms and more Assignments Computer Science in PDF only on Docsity!

CIS 400/

Homework #3 &

Spring 2005

Due: 24 Feb 2005 & 3 Mar 2005

All of the following programs need only handle numbers that fit into long integers (64 bit quantities). Real implementations of these algorithms must handle arbitrarily long integers. You may work in teams of two for this assignment. Homework #3 comprises items 1-3, and is due at 11:59 pm on 24 Feb 2005. Homework #4 comprises items 4 & 5, and is due at 11:59 pm on 3 Mar 2005.

  1. Write a program that takes two integers (a and b) and (pseudo-) randomly chooses a number be- tween them (inclusive). For example, if I entered 1 and 100 as input, it would choose a number between 1 and 100. If I entered 2^30 and ( 232 − 1 ), it would choose one in that range. You may use whatever random number generator is available on your computer (note that this is too weak for a real cryptosystem).
  2. Write a program to choose a 32-bit (likely) prime number. Note that this is a fairly small prime, by RSA standards, but will work for our purposes. Document what primality test you use.
  3. Write a program that implements the extended version of Euclid’s algorithm. The output should comprise the gcd of the two input values, d = gcd( a , b ), and the values of s and t such that gcd( a , b ) = s · a + t · b. If you wish, you may include debugging output for each step of the algorithm.
  4. Write a program to compute me^ (mod n ). Note that e will be a 32-bit number, and m will be at most 6-ASCII characters long (i.e., it will fit in 48 bits of a 64-bit word). You should consider the “tricks” from the “HOW DO WE COMPUTE me^ (mod n )” slide in the notes.
  5. Graduate students: compose the above programs to implement RSA encryption and decryption. This is not cryptanalysis, but rather building the basic key selection, encryption, and decryption blocks for RSA. You should have write two programs: rsa keygen and rsa crypt. rsa keygen should print out e , n , d , p , q , and φ( n ). Note that normally, one would only publish e and n. rsa crypt takes as inputs the message m (again, at most 48 bits), n , and either d or e depending on which way this encryption is going. The result should be the en-/deciphered text, in hexadecimal characters (e.g, 0x04ab72c15d01). Undergraduate students: Explain how you would combine the programs from steps 1-4 to implement RSA. You do not have to write this program, only explain how you would.

We will distribute sample data for you to do some simple testing on your programs.