|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.DiffieHellman
public final class DiffieHellman
Implementation of the Diffie-Hellman public key agreement algorithm, as defined in PKCS#3.
Once a DiffieHellman
object has been instantiated, use the myValue()
method to obtain the value to send to the peer (g^x). The method getKey(java.math.BigInteger)
is used to compute the shared Diffie-Hellman key value.
Constructor Summary | |
---|---|
DiffieHellman() Creates a new, uninitialized DiffieHellman instance. |
|
DiffieHellman(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs) Constructs a DiffieHellman object with the specified values for the prime (p) and generator (g), and creates a random value for x. |
|
DiffieHellman(RandomBitsSource rbs, int len) Constructs a DiffieHellman object, creating a random prime (p) of the given bit length, and a random value x; the generator (g) is set to 4. |
Method Summary | |
---|---|
void |
erase() Erases the values for this key agreement. |
void |
finalize() Finalizes this instance by erasing all sensitive data. |
protected void |
generatePandG(RandomBitsSource rbs, int len) Generates a random prime (p) of the given bit length for this DiffieHellman and sets the generator (g) to 4. |
protected void |
generateValues(RandomBitsSource rbs) Generates a large random integer (x) for this DiffieHellman , and uses its prime (p) and generator (g) to compute the value g^x. |
java.math.BigInteger |
getGen() Returns the generator (g). |
static DiffieHellman |
getInstance() Returns an uninitialized DiffieHellman instance. |
static DiffieHellman |
getInstance(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs) Returns an initialized DiffieHellman instance. |
static DiffieHellman |
getInstance(RandomBitsSource rbs, int len) Returns an initialized DiffieHellman instance. |
java.math.BigInteger |
getKey(java.math.BigInteger gy) Computes the shared DH key value g^(xy). |
java.math.BigInteger |
getPrime() Returns the prime (p). |
void |
initialize(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs) Sets the prime (p) and generator (g) for this DiffieHellman , and invokes generateValues(oracle.security.crypto.core.RandomBitsSource) . |
void |
initialize(RandomBitsSource rbs, int len) Generates the prime (p), generator (g) and values (x and g^x) by invoking generatePandG(oracle.security.crypto.core.RandomBitsSource, int) and generateValues(oracle.security.crypto.core.RandomBitsSource) . |
java.math.BigInteger |
myValue() Returns the generated value g^x. |
java.lang.String |
toString() Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DiffieHellman()
DiffieHellman
instance.public DiffieHellman(RandomBitsSource rbs, int len) throws java.lang.IllegalArgumentException
DiffieHellman
object, creating a random prime (p) of the given bit length, and a random value x; the generator (g) is set to 4.
java.lang.IllegalArgumentException
public DiffieHellman(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs)
DiffieHellman
object with the specified values for the prime (p) and generator (g), and creates a random value for x.Method Detail |
---|
public static DiffieHellman getInstance() throws AlgorithmIdentifierException
DiffieHellman
instance.AlgorithmIdentifierException
public static DiffieHellman getInstance(RandomBitsSource rbs, int len) throws java.lang.IllegalArgumentException, AlgorithmIdentifierException
DiffieHellman
instance.rbs
- The RandomBitsSource to use in this DiffieHellman object.len
- The bit length of the prime.java.lang.IllegalArgumentException
AlgorithmIdentifierException
public static DiffieHellman getInstance(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs) throws AlgorithmIdentifierException
DiffieHellman
instance.p
- The BigInteger prime p.g
- The BigInteger generator g.rbs
- The RandomBitsSource to use in this DiffieHellman object.AlgorithmIdentifierException
public void initialize(RandomBitsSource rbs, int len)
generatePandG(oracle.security.crypto.core.RandomBitsSource, int)
and generateValues(oracle.security.crypto.core.RandomBitsSource)
.public void initialize(java.math.BigInteger p, java.math.BigInteger g, RandomBitsSource rbs)
DiffieHellman
, and invokes generateValues(oracle.security.crypto.core.RandomBitsSource)
.protected void generatePandG(RandomBitsSource rbs, int len)
DiffieHellman
and sets the generator (g) to 4.protected void generateValues(RandomBitsSource rbs)
DiffieHellman
, and uses its prime (p) and generator (g) to compute the value g^x.public java.math.BigInteger getPrime()
public java.math.BigInteger getGen()
public java.math.BigInteger myValue()
public java.math.BigInteger getKey(java.math.BigInteger gy)
gy
- The generated value received from the peer.public java.lang.String toString()
toString
in class java.lang.Object
public void erase()
public void finalize()
finalize
in class java.lang.Object
|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |