net.i2p.crypto
Class KeyGenerator

java.lang.Object
  extended by net.i2p.crypto.KeyGenerator

public class KeyGenerator
extends java.lang.Object

Define a way of generating asymetrical key pairs as well as symetrical keys

Author:
jrandom

Field Summary
static int PUBKEY_EXPONENT_SIZE
           
 
Constructor Summary
KeyGenerator(I2PAppContext context)
           
 
Method Summary
 java.lang.Object[] generatePKIKeypair()
          Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKey
 SessionKey generateSessionKey()
          Generate a private 256 bit session key
 SessionKey generateSessionKey(byte[] salt, byte[] passphrase)
          PBE the passphrase with the salt
 java.lang.Object[] generateSigningKeypair()
          Generate a pair of DSA keys, where index 0 is a SigningPublicKey, and index 1 is a SigningPrivateKey
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(java.lang.String[] args)
           
(package private) static byte[] padBuffer(byte[] src, int length)
          Pad the buffer w/ leading 0s or trim off leading bits so the result is the given length.
 
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 java.lang.Object[] generatePKIKeypair()
Generate a pair of keys, where index 0 is a PublicKey, and index 1 is a PrivateKey

Returns:
pair of keys

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 java.lang.Object[] generateSigningKeypair()
Generate a pair of DSA keys, where index 0 is a SigningPublicKey, and index 1 is a SigningPrivateKey

Returns:
pair of keys

getSigningPublicKey

public static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv)
Convert a SigningPrivateKey to a SigningPublicKey

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

padBuffer

static final byte[] padBuffer(byte[] src,
                              int length)
Pad the buffer w/ leading 0s or trim off leading bits so the result is the given length.


main

public static void main(java.lang.String[] args)