net.i2p.crypto

## Class KeyGenerator

- java.lang.Object
- - net.i2p.crypto.KeyGenerator

    public class KeyGenerator
    extends Object

Define a way of generating asymmetrical key pairs as well as symmetrical keys

Author:
  jrandom

### Field Summary

Fields
`static int` `PUBKEY_EXPONENT_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`KeyGenerator(I2PAppContext context)`

### Method Summary

Methods
`Object[]` `generatePKIKeypair()` Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKey
`SimpleDataStructure[]` `generatePKIKeys()` Same as above but different return type
`SessionKey` `generateSessionKey()` Generate a private 256 bit session key
`SessionKey` `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()` Same as above but different return type
`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

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### PUBKEY_EXPONENT_SIZE

    public static final int PUBKEY_EXPONENT_SIZE

See Also:
  Constant Field Values

### 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

#### generatePKIKeypair

    public Object[] generatePKIKeypair()

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()

Same as above but different return type

Since:
  0.8.7

#### getPublicKey

    public static PublicKey getPublicKey(PrivateKey priv)

Convert a PrivateKey to its corresponding PublicKey

Parameters:
  `priv` - PrivateKey object
Returns:
  the corresponding PublicKey object

#### generateSigningKeypair

    public Object[] generateSigningKeypair()

Generate a pair of DSA keys, where index 0 is a SigningPublicKey, and index 1 is a SigningPrivateKey

Returns:
  pair of keys

#### generateSigningKeys

    public SimpleDataStructure[] generateSigningKeys()

Same as above but different return type

Since:
  0.8.7

#### getSigningPublicKey

    public static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv)

Convert a SigningPrivateKey to a SigningPublicKey

Parameters:
  `priv` - a SigningPrivateKey object
Returns:
  a SigningPublicKey object