Package net.i2p.crypto
Class KeyGenerator
- java.lang.Object
-
- net.i2p.crypto.KeyGenerator
-
public final class KeyGenerator extends Object
Define a way of generating asymmetrical key pairs as well as symmetrical keys- Author:
- jrandom
-
-
Field Summary
Fields Modifier and Type Field Description static int
PUBKEY_EXPONENT_SIZE
Deprecated.use getElGamalExponentSize() which allows override in the properties
-
Constructor Summary
Constructors Constructor Description KeyGenerator(I2PAppContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object[]
generatePKIKeypair()
ElGamal only.SimpleDataStructure[]
generatePKIKeys()
ElGamal only.KeyPair
generatePKIKeys(EncType type)
Supports EncTypesSessionKey
generateSessionKey()
Generate a private 256 bit session keySessionKey
generateSessionKey(byte[] salt, byte[] passphrase)
PBE the passphrase with the salt.Object[]
generateSigningKeypair()
Generate a pair of DSA keys, where index 0 is a SigningPublicKey, and index 1 is a SigningPrivateKey.SimpleDataStructure[]
generateSigningKeys()
DSA-SHA1 only.SimpleDataStructure[]
generateSigningKeys(SigType type)
Generic signature type, supports DSA, RSA, ECDSA, EdDSAint
getElGamalExponentSize()
static KeyGenerator
getInstance()
static PublicKey
getPublicKey(PrivateKey priv)
Convert a PrivateKey to its corresponding PublicKey.static SigningPublicKey
getSigningPublicKey(SigningPrivateKey priv)
Convert a SigningPrivateKey to a SigningPublicKey.static void
main(String[] args)
Usage: KeyGenerator [sigtype...]boolean
useLongElGamalExponent()
-
-
-
Field Detail
-
PUBKEY_EXPONENT_SIZE
@Deprecated public static final int PUBKEY_EXPONENT_SIZE
Deprecated.use getElGamalExponentSize() which allows override in the properties
-
-
Constructor Detail
-
KeyGenerator
public KeyGenerator(I2PAppContext context)
-
-
Method Detail
-
getInstance
public static KeyGenerator getInstance()
-
generateSessionKey
public SessionKey generateSessionKey()
Generate a private 256 bit session key- Returns:
- session key
-
generateSessionKey
public SessionKey generateSessionKey(byte[] salt, byte[] passphrase)
PBE the passphrase with the salt. Warning - SLOW
-
useLongElGamalExponent
public boolean useLongElGamalExponent()
- Since:
- 0.9.8
-
getElGamalExponentSize
public int getElGamalExponentSize()
- Since:
- 0.9.8
-
generatePKIKeypair
public Object[] generatePKIKeypair()
ElGamal only. Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKey- Returns:
- pair of keys
-
generatePKIKeys
public SimpleDataStructure[] generatePKIKeys()
ElGamal only. Same as generatePKIKeypair() but different return type.- Since:
- 0.8.7
-
getPublicKey
public static PublicKey getPublicKey(PrivateKey priv)
Convert a PrivateKey to its corresponding PublicKey. As of 0.9.38, supports EncTypes- Parameters:
priv
- PrivateKey object- Returns:
- the corresponding PublicKey object
- Throws:
IllegalArgumentException
- on bad key
-
generateSigningKeypair
public Object[] generateSigningKeypair()
Generate a pair of DSA keys, where index 0 is a SigningPublicKey, and index 1 is a SigningPrivateKey. DSA-SHA1 only.- Returns:
- pair of keys
-
generateSigningKeys
public SimpleDataStructure[] generateSigningKeys()
DSA-SHA1 only. Same as above but different return type- Since:
- 0.8.7
-
generateSigningKeys
public SimpleDataStructure[] generateSigningKeys(SigType type) throws GeneralSecurityException
Generic signature type, supports DSA, RSA, ECDSA, EdDSA- Throws:
GeneralSecurityException
- Since:
- 0.9.9
-
getSigningPublicKey
public static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv)
Convert a SigningPrivateKey to a SigningPublicKey. As of 0.9.16, supports all key types.- Parameters:
priv
- a SigningPrivateKey object- Returns:
- a SigningPublicKey object
- Throws:
IllegalArgumentException
- on bad key or unknown type
-
main
public static void main(String[] args)
Usage: KeyGenerator [sigtype...]
-
-