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
Modifier and Type Method Description Object[]
generatePKIKeypair()
Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKeySimpleDataStructure[]
generatePKIKeys()
Same as above but different return typeKeyPair
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 Details
-
PUBKEY_EXPONENT_SIZE
Deprecated.use getElGamalExponentSize() which allows override in the properties
-
-
Constructor Details
-
Method Details
-
getInstance
-
generateSessionKey
Generate a private 256 bit session key- Returns:
- session key
-
generateSessionKey
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
Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKey- Returns:
- pair of keys
-
generatePKIKeys
Same as above but different return type- Since:
- 0.8.7
-
generatePKIKeys
Supports EncTypes- Since:
- 0.9.38
-
getPublicKey
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
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
DSA-SHA1 only. Same as above but different return type- Since:
- 0.8.7
-
generateSigningKeys
Generic signature type, supports DSA, RSA, ECDSA, EdDSA- Throws:
GeneralSecurityException
- Since:
- 0.9.9
-
getSigningPublicKey
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
Usage: KeyGenerator [sigtype...]
-