public final class KeyGenerator extends Object
Supports both legacy algorithms (DSA, ElGamal) and modern cryptographic schemes (EdDSA, ECDSA) with configurable parameters for security and performance optimization.
| Constructor and Description |
|---|
KeyGenerator(I2PAppContext context)Create a new KeyGenerator. |
| Modifier and Type | Method and Description |
|---|---|
Object[] | generatePKIKeypair()ElGamal only. |
SimpleDataStructure[] | generatePKIKeys()ElGamal only. |
KeyPair | generatePKIKeys(EncType type)Supports EncTypes |
SessionKey | generateSessionKey()Generate a private 256 bit session key |
SessionKey | generateSessionKey(byte[] salt,
byte[] passphrase)PBE the passphrase with the salt. |
SessionKey | generateSessionKey(byte[] salt,
byte[] passphrase,
int rounds)PBE the passphrase with the salt using specified rounds. |
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, EdDSA |
int | getElGamalExponentSize()Size of the ElGamal exponent in bits. |
static KeyGenerator | getInstance()Get the global KeyGenerator instance. |
int | getPBERT()Get current rounds for new encryptions. |
int | getPBERTLegacy()Get legacy rounds for migration. |
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()Whether to use a long (2048-bit) ElGamal exponent. |
public KeyGenerator(I2PAppContext context)
context - the I2P app contextpublic Object[] generatePKIKeypair()
public SimpleDataStructure[] generatePKIKeys()
public KeyPair generatePKIKeys(EncType type)
type - the encryption typepublic SessionKey generateSessionKey()
public SessionKey generateSessionKey(byte[] salt, byte[] passphrase)
salt - the saltpassphrase - the passphrasepublic SessionKey generateSessionKey(byte[] salt, byte[] passphrase, int rounds)
salt - 16 bytespassphrase - the passwordrounds - iteration count (1000 for legacy, 1000000 for current)public Object[] generateSigningKeypair()
public SimpleDataStructure[] generateSigningKeys()
public SimpleDataStructure[] generateSigningKeys(SigType type) throws GeneralSecurityException
type - the signature typeGeneralSecurityException - if key generation failspublic int getElGamalExponentSize()
public static KeyGenerator getInstance()
public int getPBERT()
public int getPBERTLegacy()
public static PublicKey getPublicKey(PrivateKey priv)
priv - PrivateKey objectIllegalArgumentException - on bad keypublic static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv)
priv - a SigningPrivateKey objectIllegalArgumentException - on bad key or unknown typepublic static void main(String[] args)
args - command line argumentspublic boolean useLongElGamalExponent()