Class KeyGenerator


  • public final class KeyGenerator
    extends Object
    Define a way of generating asymmetrical key pairs as well as symmetrical keys
    Author:
    jrandom
    • Field Detail

      • PUBKEY_EXPONENT_SIZE

        @Deprecated
        public static final int PUBKEY_EXPONENT_SIZE
        Deprecated.
        use getElGamalExponentSize() which allows override in the properties
    • Constructor Detail

    • Method Detail

      • 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
      • generatePKIKeys

        public KeyPair generatePKIKeys​(EncType type)
        Supports EncTypes
        Since:
        0.9.38
      • 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
      • 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...]