Documentation for package rsm.rsa


Author : R. Scott McIntire

Version: 1.3

Overview:

This package provides RSA encryption functions.

REQUIRES: package rsm.mod.

Some of the functions use an rsa-keys structure that contains an RSA
encryption/decryption pair in the form of two slots. One slot contains the
encrypt-key structure and the other the decrypt-key structure. There is also a
key ring to store RSA encryption/decryption keys (rsa-keys structure).

Export Summary:

decrypt: RSA decryption of a message.
encrypt: RSA encryption of a message.

get-next-prob-prime: Get the next probable prime from a starting position.
get-rand-rel-prime : Generate a random number that is relatively prime.
generate-keys      : Forms the encryption and decryption keys given primes.
generate-prime-pair: Generates two primes of a given length.
prob-prime-p       : Return true if a number is very likely to be prime.

clear-key-ring : Clear the key ring.
remove-key-from-key-ring: Remove a key from the key ring.
key->key-ring  : Associate a name with an rsa-keys structure - add to key ring.
key-ring->file : Write the key ring out to a file.
file->key-ring : Load a key ring from a file.
make-new-keys  : Makes a new RSA encryption/decryption pair(rsa-keys structure).
find-keys      : Return an rsa-keys structure given its name.

find-encryption-key: Find the encryption key associated with a name.
find-decryption-key: Find the decryption key associated with a name.

clear-key-ring ()

Clear the key ring.

decrypt   (d-key encrypt-list)

Decrypt the list of numbers <encrypt-list> into a string. The key, <d-key>,
contains the numbers n and d which represent the RSA key decryption pair. It
also contains an Euler Phi number that is the value of the Euler Phi function 
of n.

encrypt   (e-key text)

Encrypt <text> into a list of numbers. Each number is formed by using the RSA
algorithm on a block of text. The key, <e-key>, contains the numbers n and e
which represent the RSA key encryption pair as well as the block size of the
text to encrypt.

file->key-ring   (file-name)

Load rsa-keys structures from file, <file-name>, and place on the key ring.

find-decryption-key   (name)

Get the rsa encryption structure associated with name, <name>.

find-encryption-key   (name)

Get the rsa encryption structure associated with name, <name>.

find-keys   (name)

Get an rsa-keys structure associated with name, <name>. This structure 
contains the encryption and decryption keys.

generate-keys   (p q name &key e)

Generate an rsa-key structure given the two primes, <p> and <q>.

generate-prime-pair   (len1 len2 &key (trials 100))

Generate two probable primes p,q, of lengths <len1> and <len2>. If used for
RSA encryption, the lengths should differ by a wide margin. This function will
choose p and q so that gcd(p-1, q-1) is small. Use a larger value for <trials>
for more probable primes. It should also (but does not) ensure 
that (p-1) and (q-1) both have large prime factors. This function can be  
time consuming. This function takes 15-20 seconds on a Pentium IV 1.8 GHZ 
when <len1> and <len2> are roughly 100. However, finding primes of lengths 
150 and 170 takes 45 seconds, while finding primes of lengths 250 and 270 
takes ever 3 minutes.

get-next-prob-prime   (p-start &key (trials 100))

Find a probable prime starting at <p-start> (p-start assumed odd) and
incrementing by 2 until a probable prime is found.  Test each value
using <trials> number of random values with the function prob-prime-p.

get-rand-rel-prime   (n)

Generate a random number relatively prime to <n> larger than a third of 
<n>, but less than a half of <n>.

key->key-ring   (rsa-keys)

Put key, <rsa-keys> on the key ring. That is, store (associate) the 
name of the rsa-keys structure, <rsa-keys>, with its name.

key-ring->file   (file-name)

Write out the key ring of rsa-keys structures to the file, <file-name>.

make-new-keys   (len1 len2 name &key (trials 100))

Make new RSA encryption/decryption pair returned as an rsa-keys structure.
The probable primes used will be randomly generated (use a larger value of
<trials> for more confidence in the primes) and have digit lengths of <len1> and
<len2> respectively. This function can be time consuming. 
This function takes 15-20 seconds on a Pentium IV 1.8 GHZ when <len1> and 
<len2> are roughly 100. However, finding primes of lengths 
150 and 170 takes 45 seconds, while finding primes of lengths 250 and 270 
takes ever 3 minutes.

prob-prime-p   (p &key (trials 100))

Use Fermat's little theorem: a^(p-1) = 1 mod p if p is prime. 
Raise <trials> random values to the (p-1) power and check that it is 1 mod <p>. 
If this is true of all values, then <p> is likely prime. The probability 
increases when the number of trials, <trials>, is larger.

remove-key-from-key-ring   (key-name)

Remove the key named, <key-name>, from the key-ring.

rsa-decrypt-key   (struct)

nil

rsa-encrypt-key   (struct)

nil