demo
Class RSACryptoManager

java.lang.Object
  |
  +--demo.RSACryptoManager

public class RSACryptoManager
extends java.lang.Object

A collection of purpose built methods for encrypting secret shares and commitment values and signing messages.

The RSA CryptoManager requires the cryptix provider, version 3.2 or later. In order to run the ShareDemo, you must have cryptix installed properly in your classpath or specified on the command line.

Version:
.2
Author:
Brice Daniels
See Also:
Cryptix

Constructor Summary
RSACryptoManager(Client client, java.security.PrivateKey priv, java.security.PublicKey[] pubs)
          Creates a new instance of RSACryptoManager
 
Method Summary
protected  java.math.BigInteger[] decrypt(byte[] cipherText)
          Decrypts the ciphertext into two BigIntegers using the local private key and places them into an array.
 byte[] encrypt(Share share, int shareNumber)
          Encrypts the secret share and the commitment value from the supplied share with the specified public key using RSA encryption.
static java.security.KeyPair generateKeyPair()
          Generates an RSA key pair.
protected  byte[] sign(byte[] data)
          Signs the data usa SHA-1 and RSA following PKCS#1 using the local private key.
protected  byte[] validate(byte[] messageBytes, int senderShareNumber)
          Verifies the signature with an attached message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSACryptoManager

public RSACryptoManager(Client client,
                        java.security.PrivateKey priv,
                        java.security.PublicKey[] pubs)
Creates a new instance of RSACryptoManager

Parameters:
client - The parent client.
priv - The private key of the client.
pubs - An array of public keys for all clients
Method Detail

encrypt

public byte[] encrypt(Share share,
                      int shareNumber)
               throws CryptoException

Encrypts the secret share and the commitment value from the supplied share with the specified public key using RSA encryption.

Parameters:
share - The share with the secret share and commitment values that are to be encrypted.
shareNumber - The share number of the client whose public key should be used in the encryption.
Returns:
a byte array containing the encrypted version of the secret share and commitment value.
Throws:
CryptoException - An indication of an error encrypting the information.

decrypt

protected java.math.BigInteger[] decrypt(byte[] cipherText)
                                  throws MalformedCryptoException,
                                         CryptoException

Decrypts the ciphertext into two BigIntegers using the local private key and places them into an array.

Parameters:
cipherText - The ciphertext created by encrypt().
Returns:
The secret share and commitment value as a BigInteger array.
Throws:
MalformedCryptoException - An indication of invalid ciphertext.
CryptoException - An indication of error during the decryption process.

sign

protected byte[] sign(byte[] data)
               throws CryptoException

Signs the data usa SHA-1 and RSA following PKCS#1 using the local private key.

Parameters:
data - The message data in a byte array.
Returns:
A byte array containing the serialized data and the digital signature.
Throws:
CryptoException - An indication of an error during the signing process.

validate

protected byte[] validate(byte[] messageBytes,
                          int senderShareNumber)
                   throws CryptoException,
                          MalformedCryptoException

Verifies the signature with an attached message.

Parameters:
messageBytes - The message.
senderShareNumber - The share number of the sender
Returns:
The message bytes.
Throws:
CryptoException - An indication of an error during the verification process.
MalformedCryptoException - An indication that the message has an invalid signature.

generateKeyPair

public static java.security.KeyPair generateKeyPair()

Generates an RSA key pair.

Returns:
An RSA public/private key pair.