|
IAIK ECC version 2.18 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.security.ecc.math.field.PrimeFieldFactory
Abstract base class for all prime field factories. Subclasses provide factory methods to obtain concrete field implementations for specific prime moduli.
Use the static getInstance
method to obtain an instance of the prime field factory. The used
factory for a specific prime modulus can be set by the setDefaultFactory
method. There will
be one instance of a prime field factory for each modulus.
BigInteger p192 = ECCParameters.PRIME_P[0]; BigInteger prime = BigInteger.probablePrime(192, new Random()); // set the default factory to be used for every modulus without // a specific implementation: Class cDefault = PrimeFieldFactory.class.getClassLoader().loadClass( "iaik.security.ecc.math.field.FastPrimeFieldFactory"); PrimeFieldFactory.setDefaultFactory(cDefault, null); // set the factory used for the P-192 prime modulus Class cP192 = PrimeFieldFactory.class.getClassLoader().loadClass( "iaik.security.ecc.math.field.P192FieldFactory"); PrimeFieldFactory.setDefaultFactory(cP192, p192); PrimeFieldFactory p192Factory = PrimeFieldFactory.getInstance(p192); PrimeField p192Field = p192Factory.getField(); PrimeFieldFactory primeFactory = PrimeFieldFactory.getInstance(prime); PrimeField primeField = primeFactory.getField();A default factory with field implementations for the NIST primes P-192, P-224, P-256, P-384 and P-521, and a fast default implementation for all other moduli is set by the static constructor.
Field Summary | |
protected java.math.BigInteger |
modulus_
This is the modulus for which this prime field factory creates prime fields. |
protected static java.math.BigInteger |
p192_
Define the modulus for the P-192 curve. |
protected static java.math.BigInteger |
p224_
Define the modulus for the P-224 curve. |
protected static java.math.BigInteger |
p256_
Define the modulus for the P-256 curve. |
protected static java.math.BigInteger |
p384_
Define the modulus for the P-384 curve. |
protected static java.math.BigInteger |
p521_
Define the modulus for the P-521 curve. |
Constructor Summary | |
PrimeFieldFactory()
|
Method Summary | |
abstract Field |
getField()
Creates a new (factory specific) implementation of a prime field. |
static FieldFactory |
getInstance(java.math.BigInteger modulus)
Use this method to get a concrete instance of a PrimeFieldFactory for a specific modulus. |
static void |
setDefaultFactory(java.lang.Class c,
java.math.BigInteger modulus)
Set the prime field factory to be used for a specific modulus. |
protected void |
setModulus(java.math.BigInteger modulus)
This method is used to set the modulus after creating an instance of a PrimeFieldFactory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.math.BigInteger p192_
protected static final java.math.BigInteger p224_
protected static final java.math.BigInteger p256_
protected static final java.math.BigInteger p384_
protected static final java.math.BigInteger p521_
protected java.math.BigInteger modulus_
Constructor Detail |
public PrimeFieldFactory()
Method Detail |
public static FieldFactory getInstance(java.math.BigInteger modulus) throws FieldException
FieldException
- if the irreducible polynomial is null
or the factory cannot be found.public static void setDefaultFactory(java.lang.Class c, java.math.BigInteger modulus) throws FieldException
c
- the class of the field factory that should be used for a specific modulus. If factory is
null
the factory defined for modulus is removed.modulus
- the modulus that is used by the factory. If modulus is null
the default
factory will be set by factory .
FieldException
public abstract Field getField()
getField
in interface FieldFactory
FieldElement
protected void setModulus(java.math.BigInteger modulus)
modulus
- the modulus that the factory should use.
|
IAIK ECC version 2.18 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |