Networked and Distributed Operating Systems Project 8

advertisement
Networked and Distributed
Project 8 - Public Key Encryption
Operating Systems
Name _____________________________________________________ Score ________
In this laboratory exercise, we will experiment with a simplified version of the public-key
data encryption algorithm. - Notes and examples from http://mathforum.org/
In 1976, Rivest, Shamir and Adleman introduced a public key cryptosystem, known as
the RSA system. Since that time, there have been a number of variations in this algorithm
developed for secure public communication of critical information. The theoretical basis
for public-key encryption is the use of modular exponentiation and other integer
arithmetic algorithm in number theory to produce a pair of exponents. One of these
exponents is the public key which is transmitted to the message sender for encryption of
the plaintext message. The intended receiver hold the private key which is used to
decrypt the cypher text.
The plaintext message M is encrypted into the cypher text C using modular
exponentiation mod n, where n is the product of two values p and q, that are relatively
prime.
C  M e mod n
and we decrypt C back into M by,
M  C d mod n
The exponent e must exhibit the property,
gcd(e,(p-1)(q-1)) = 1.
Let's look at how to compute the values of e and d. We start with a pair of values p and q
that must be relatively prime (i.e. they have no common factors). For example
p = 47
q = 71
then, n = p*q = 3337 and, (p-1)(q-1) = 3220
Lets choose e to be 79. Now we can compute the decipher key, d = 79-1 mod 3220
The problem can be restated as follows:
Solve for d:
79*d = 1 mod 3220
First use the regular Euclidean Algorithm to find gcd(79,3220). The answer must be one
- otherwise we can't be sure that a solution exists, so we proceed as follows:
3220 = 40*79 + 60
79 = 1*60 + 19
60 = 3*19 + 3
19 = 6*3 + 1
3 = 3*1 + 0
The last nonzero remainder is the gcd. Thus gcd(79,3220) = 1 (as expected). Now write
this gcd (one) as a linear combination of 19 and 3220 by working back up the tree that
we just created:
The next to the last line gives:
1 = 19-6*3
= 19-6*(60-3*19)
= 19*19 - 6*60
= 19*(79-60) - 6*60
= 19*79 - 25*60
= 19*79 - 25*(3220-40*79)
= 1019*79 - 25*3220
Thus 1019*79 - 25*3220 = 1
Now do "mod 3220" on both sides to obtain:
1019*79 = 1 mod 3220
(the term that contains 3220 goes away because 3220 = 0 mod 3220).
Thus d = 1019.
So the inverse of 79 mod 3220 is 1019. Another way of saying this is that 79*1019 will
be one more than a multiple of 3220.
Experiment - In this laboratory experiment you are provided the following software
tools:
Crypto_GenKeyPair - helps to generate a public/private key pair
Crypto_Encoder - a demo program for public key encryption and decryption
Crypto_Cracker - extracts private key from the public key and the modulus
Limitations of these tools. In a real encryption system, very large numbers are used
which must be typed and maintained with special code. Number with hundreds or even
thousands of digits are common in public key encryption systems. In these tools we use
type long so values the sizes of the public and private key and the modulus are restricted
to this data type. As you work with these demo programs be alert for overflow errors.
Step 1: Run Crypto_GenKeyPair. Choose values for p and q. These can be primes or
numbers that are relatively prime.
p = __________________
q = ________________
Step 2: Select a candidate public key. Program will find the nearest acceptable public
key and then generate the corresponding private key.
e = _________________ (public key)
d = _________________ (private key)
n = ________________________ (this is the modulus)
Step 3: Run Crypto_Encoder. Enter a simple message.
Message = ___________________________________________________________
Step 4: Enter the public key and modulus. Note that the message is converted to integer
values and converted to a new set of integer values. Make sure that all conversions result
in non-negative values.
Step 5: Enter the private key. Did message message get converted back to original
message? Discuss.
_______________ _______________________________________________________
________________________________________________________________________
Step 6: Run Crypto_Cracker. Enter the public key and modulus. Did this program find
the private key? How many operations were necessary?
________________
_____________________
Questions:
1. Using the terms message sender and message receiver, answer the following:
a. Who generates the public key and private key pair? ___________________________
b. Who converts M to C? ________________________
c. Who converts C to M? ________________________
2. What value(s) is(are) sent to the sender? __________________________
3. What value(s) is(are) needed to decrypt the message? _________________________
4. Why is it more difficult for a third party eavesdropper to decrypt the message than it is
for the receiver?
________________________________________________________________________
________________________________________________________________________
5. Briefly describe what is needed in order to decrypt an encrypted message without
knowing the private key?
________________________________________________________________________
________________________________________________________________________
6. What is the runtime of the encoding and decoding algorithm as a function of the
message length and sizes of e and d?
________________________________________________________________________
7. Estimate the runtime of an algorithm used to find the value of d through a brute-force
search.
_______________________________________________________________________
Download