org.bouncycastle.crypto.generators
Class NaccacheSternKeyPairGenerator

java.lang.Object
  extended by org.bouncycastle.crypto.generators.NaccacheSternKeyPairGenerator
All Implemented Interfaces:
AsymmetricCipherKeyPairGenerator

public class NaccacheSternKeyPairGenerator
extends java.lang.Object
implements AsymmetricCipherKeyPairGenerator

Key generation parameters for NaccacheStern cipher. For details on this cipher, please see http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf


Field Summary
private static java.math.BigInteger ONE
           
private  NaccacheSternKeyGenerationParameters param
           
private static int[] smallPrimes
           
 
Constructor Summary
NaccacheSternKeyPairGenerator()
           
 
Method Summary
private static java.util.Vector findFirstPrimes(int count)
          Finds the first 'count' primes starting with 3
 AsymmetricCipherKeyPair generateKeyPair()
          return an AsymmetricCipherKeyPair containing the generated keys.
private static java.math.BigInteger generatePrime(int bitLength, int certainty, java.security.SecureRandom rand)
           
private static int getInt(java.security.SecureRandom rand, int n)
           
 void init(KeyGenerationParameters param)
          intialise the key pair generator.
private static java.util.Vector permuteList(java.util.Vector arr, java.security.SecureRandom rand)
          Generates a permuted ArrayList from the original one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

smallPrimes

private static int[] smallPrimes

param

private NaccacheSternKeyGenerationParameters param

ONE

private static final java.math.BigInteger ONE
Constructor Detail

NaccacheSternKeyPairGenerator

public NaccacheSternKeyPairGenerator()
Method Detail

init

public void init(KeyGenerationParameters param)
Description copied from interface: AsymmetricCipherKeyPairGenerator
intialise the key pair generator.

Specified by:
init in interface AsymmetricCipherKeyPairGenerator
Parameters:
param - the parameters the key pair is to be initialised with.

generateKeyPair

public AsymmetricCipherKeyPair generateKeyPair()
Description copied from interface: AsymmetricCipherKeyPairGenerator
return an AsymmetricCipherKeyPair containing the generated keys.

Specified by:
generateKeyPair in interface AsymmetricCipherKeyPairGenerator
Returns:
an AsymmetricCipherKeyPair containing the generated keys.

generatePrime

private static java.math.BigInteger generatePrime(int bitLength,
                                                  int certainty,
                                                  java.security.SecureRandom rand)

permuteList

private static java.util.Vector permuteList(java.util.Vector arr,
                                            java.security.SecureRandom rand)
Generates a permuted ArrayList from the original one. The original List is not modified

Parameters:
arr - the ArrayList to be permuted
rand - the source of Randomness for permutation
Returns:
a new ArrayList with the permuted elements.

getInt

private static int getInt(java.security.SecureRandom rand,
                          int n)

findFirstPrimes

private static java.util.Vector findFirstPrimes(int count)
Finds the first 'count' primes starting with 3

Parameters:
count - the number of primes to find
Returns:
a vector containing the found primes as Integer