crypto
Class MyCryptoAgent

java.lang.Object
  extended by crypto.MyCryptoAgent
All Implemented Interfaces:
CryptoAgent

public class MyCryptoAgent
extends Object
implements CryptoAgent


Field Summary
 
Fields inherited from interface support.crypto.CryptoAgent
BIG_INT_SEED_BITS, E_VALUE, PRIME_CHECK_PRECISION
 
Constructor Summary
MyCryptoAgent()
          You should generate values for _p, _q, _phiN, and _d here.
 
Method Summary
 byte[] decrypt(byte[] cipher)
          Decrypt cipher using your private key (_d).
 byte[] encrypt(CryptoPublicKey key, byte[] message)
          Encrypt the given message using the provided public key.
 CryptoPublicKey getPublicKey()
          Return a CryptoPublicKey that contains your N and E values.
static void main(String[] argv)
          Since a visualizer for this assignment would be a little complicated to test we decided to provide this little text based driver instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyCryptoAgent

public MyCryptoAgent()
You should generate values for _p, _q, _phiN, and _d here. The value of e is stored in a the constant CryptoAgent.E_VALUE. See the lecture slides for the rest of the details.

Method Detail

getPublicKey

public CryptoPublicKey getPublicKey()
Return a CryptoPublicKey that contains your N and E values.

Specified by:
getPublicKey in interface CryptoAgent
Returns:
a public key containing this CryptoAgent's N and E values.

decrypt

public byte[] decrypt(byte[] cipher)
Decrypt cipher using your private key (_d).

Specified by:
decrypt in interface CryptoAgent
Parameters:
cipher - an array of bytes representing an encrypted message.
Returns:
an array of bytes storing the decrypted cipher.

encrypt

public byte[] encrypt(CryptoPublicKey key,
                      byte[] message)
Encrypt the given message using the provided public key.

Specified by:
encrypt in interface CryptoAgent
Parameters:
key - the public key to be used for the encryption.
message - the message to be encrypted.
Returns:
the encrypted message (cipher).

main

public static void main(String[] argv)
Since a visualizer for this assignment would be a little complicated to test we decided to provide this little text based driver instead. Feel free to modify it however you like. When we test your program we will not be using this main(...) function. Also note that, in the interest of keeping this short and easily understandable, there is very little error checking, As a result this will probably crash if, for example, one of your methods returns null.