org.eclipse.higgins.sts.utilities
Class X931KeyGenerator

java.lang.Object
  extended byorg.eclipse.higgins.sts.utilities.X931KeyGenerator

public class X931KeyGenerator
extends Object

Generate keys for self signed keys in Higgins according to the X9.31 specifications. Requirements as obtained from the "Identity Selector Interoperability Profile V1.0" (Arun Nanda) and the X9 specification "Digital Signatures Using Reversible Public Key Cryptography for the Financial Services Industry (rDSA)".


Constructor Summary
X931KeyGenerator(byte[] xp1, byte[] xp2, byte[] xq1, byte[] xq2, byte[] xp, byte[] xq)
           
 
Method Summary
static BigInteger findSmallPrimeSequential(BigInteger startFrom)
          Successively searches for the smallest odd number starting from the given parameter till it finds a probable prime.
static BigInteger findX931KeyPrime(BigInteger startFrom, BigInteger factorOfPMinus1, BigInteger factorOfPPlus1, BigInteger publicExponent)
          Finds prime P which is the next largest prime after startFrom which satisfies the following conditions a.
 KeyPair GenerateKeyPair(RSAKeyGenParameterSpec params)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

X931KeyGenerator

public X931KeyGenerator(byte[] xp1,
                        byte[] xp2,
                        byte[] xq1,
                        byte[] xq2,
                        byte[] xp,
                        byte[] xq)
                 throws InvalidRandomParameterException
Parameters:
xq1 -
xq2 -
xp1 -
xp2 -
xp -
xq -
Method Detail

findSmallPrimeSequential

public static BigInteger findSmallPrimeSequential(BigInteger startFrom)
Successively searches for the smallest odd number starting from the given parameter till it finds a probable prime. If the input number is not odd it returns false.

Parameters:
startFrom - the bigInteger to start searching from
Returns:
a probable prime number greater than the given number

findX931KeyPrime

public static BigInteger findX931KeyPrime(BigInteger startFrom,
                                          BigInteger factorOfPMinus1,
                                          BigInteger factorOfPPlus1,
                                          BigInteger publicExponent)
                                   throws UnsupportedOptionException
Finds prime P which is the next largest prime after startFrom which satisfies the following conditions a. P - 1 has the factor factorOfPMinus1 b. P + 1 has th factor factorOfPPlus1 c. e and p - 1 are relatively prime NOTE: this does NO size checking on either the startFrom or the factors. It also assumes that the factors are indeed primes.

Parameters:
startFrom - Integer to start search from
factorOfPMinus1 - requested factor of P - 1
factorOfPPlus1 - requested factor of P + 1
publicExponent - the public exponent for the key being generated. Note that this is required so that the generated prime has the property that e and p-1 are relatively prime. This exponent is ASSUMED to be ODD. If this parameter is even it returns NULL
Returns:
The prime P found with these features.
Throws:
UnsupportedOptionException

GenerateKeyPair

public KeyPair GenerateKeyPair(RSAKeyGenParameterSpec params)
                        throws UnsupportedOptionException,
                               InvalidRandomParameterException
Parameters:
params -
Returns:
The generated key which is an object implementing the interface
Throws:
UnsupportedOptionException
InvalidRandomParameterException
See Also:
. The private key of this keypair is a @see java.security.interfaces.RSAPrivateCrtKey . Note that the interface, doesnt let you specify the primes P and Q so we use the Crt Key. Throws exceptions if the requested options are not supported(currently only odd exponents are supported) OR if the initially supplied parameters used in constructing this generator do not match the requested keygen parameters

main

public static void main(String[] args)