All Packages Class Hierarchy This Package Previous Next Index
Class is.logi.crypto.keys.DHKey
java.lang.Object
|
+----is.logi.crypto.Crypto
|
+----is.logi.crypto.keys.K
|
+----is.logi.crypto.keys.DHKey
- public class DHKey
- extends K
- implements Key
This object holds one Diffie-Hellman key. It is not used for encryption
or signatures, but only to initialize Difie-Hellman key-exchange objects.
CDS for a Diffie-Hellman key is DHKey(a,g,m,pub)
for a public key or DHKey(a,g,m,pri)
for a private
key. In both cases a
,g
and m
are
hexadecimal numbers.
- Author:
- Logi Ragnarsson
(logir@hi.is)
- See Also:
- DHKeyExNoninter
-
DHKey(BigInteger, BigInteger, BigInteger, boolean)
- Create new Diffie-Hellman key.
-
DHKey(int)
- Create a random private DHKey with an
n
bit modulus.
-
createKeys(int)
- Create a pair of public/private keys in a group with an
n
bit modulo.
-
equals(Object)
- Return true iff the two keys are eqivalent.
-
getAlgorithm()
- The name of the algorithm is "Diffie-Hellman".
-
getG()
- Return the generator for this key.
-
getGenerator(BigInteger)
- Return a Generator for a modulus group.
-
getKey()
- Return the BigInteger representing this key.
-
getM()
- Return the modulus for this key.
-
getModulus(int)
- Return a Diffie-Hellman modulus.
-
getPublic()
- Return the public key from the pair.
-
getSize()
- Return the "size" of the key.
-
isPrivate()
- Returns true iff this is a private key.
-
matches(Key)
- Check if a key mathces this.
-
parseCDS(String)
- If "DHKey( key )" is a valid CDS for a DHKey, then
DHKey.parseCDS(key) will return the described DHKey object.
-
toString()
- Return a CDS for this key.
DHKey
public DHKey(BigInteger a,
BigInteger g,
BigInteger m,
boolean pri)
- Create new Diffie-Hellman key. An object is created fo
a
in the group modulo m
with generator g
. It is
a private key iff pri is true
.
DHKey
public DHKey(int n)
- Create a random private DHKey with an
n
bit modulus.
Pe-calcualted modula exist for bit lengths 256, 512 and 1024. (The 2048 bit
modulus is still being calculated. Using these values saves a
lot of time and does not weaken the keys.
parseCDS
public static DHKey parseCDS(String key) throws InvalidCDSException
- If "DHKey( key )" is a valid CDS for a DHKey, then
DHKey.parseCDS(key) will return the described DHKey object.
A valid CDS can be created by calling the DHKey.toString() method.
- Throws: InvalidCDSException
- if the CDS is malformed.
- See Also:
- fromString
getModulus
public static BigInteger getModulus(int n)
- Return a Diffie-Hellman modulus.
Return the largest prime p
< 2^n
such
that (p
-1)/2 is prime. This takes a long time unless
n
is one of 256, 512, 1024 or 2048.
The reason for the second constraint on p
is to make
the Discrete-Logarithm problem harder in the group Zp. In
particular it thwarts the Pholig-Hellman algorithm.
getGenerator
public static BigInteger getGenerator(BigInteger m)
- Return a Generator for a modulus group.
Returns the smallest number g
> 1 with
gcd(g
,m-1
)=1.
createKeys
public static KeyPair createKeys(int n)
- Create a pair of public/private keys in a group with an
n
bit modulo.
Pe-calcualted modula exist for bit lengths 256, 512, 1024 and
2048. Using these values saves a lot of time and does not weaken
the keys.
getSize
public int getSize()
- Return the "size" of the key. This is a (fairly inaccurate) measure
of how difficult it is to break and is heavily dependant on the
algorithm used.
- Overrides:
- getSize in class K
getAlgorithm
public String getAlgorithm()
- The name of the algorithm is "Diffie-Hellman".
- Overrides:
- getAlgorithm in class K
isPrivate
public boolean isPrivate()
- Returns true iff this is a private key.
- Overrides:
- isPrivate in class K
getPublic
public DHKey getPublic()
- Return the public key from the pair.
getKey
public BigInteger getKey()
- Return the BigInteger representing this key.
getM
public BigInteger getM()
- Return the modulus for this key.
getG
public BigInteger getG()
- Return the generator for this key.
equals
public final boolean equals(Object o)
- Return true iff the two keys are eqivalent.
- Overrides:
- equals in class Object
matches
public boolean matches(Key key)
- Check if a key mathces this. This is true if this and key are a matched
pair of public/private.
- Overrides:
- matches in class K
toString
public String toString()
- Return a CDS for this key.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index