Package java.security

Class KeyPairGenerator

    • Constructor Detail

      • KeyPairGenerator

        protected KeyPairGenerator​(String algorithm)
        Constructs a new instance of KeyPairGenerator with the name of the algorithm to use.
        Parameters:
        algorithm - the name of algorithm to use
    • Method Detail

      • getAlgorithm

        public String getAlgorithm()
        Returns the name of the algorithm of this KeyPairGenerator.
        Returns:
        the name of the algorithm of this KeyPairGenerator
      • getInstance

        public static KeyPairGenerator getInstance​(String algorithm)
                                            throws NoSuchAlgorithmException
        Returns a new instance of KeyPairGenerator that utilizes the specified algorithm.
        Parameters:
        algorithm - the name of the algorithm to use
        Returns:
        a new instance of KeyPairGenerator that utilizes the specified algorithm
        Throws:
        NoSuchAlgorithmException - if the specified algorithm is not available
        NullPointerException - if algorithm is null
      • getInstance

        public static KeyPairGenerator getInstance​(String algorithm,
                                                   Provider provider)
                                            throws NoSuchAlgorithmException
        Returns a new instance of KeyPairGenerator that utilizes the specified algorithm from the specified provider. The provider supplied does not have to be registered.
        Parameters:
        algorithm - the name of the algorithm to use
        provider - the provider
        Returns:
        a new instance of KeyPairGenerator that utilizes the specified algorithm from the specified provider
        Throws:
        NoSuchAlgorithmException - if the specified algorithm is not available
        NullPointerException - if algorithm is null
        IllegalArgumentException - if provider == null
      • getProvider

        public final Provider getProvider()
        Returns the provider associated with this KeyPairGenerator.
        Returns:
        the provider associated with this KeyPairGenerator
      • initialize

        public void initialize​(int keysize)
        Initializes this KeyPairGenerator with the given key size. The default parameter set and a default SecureRandom instance will be used.
        Parameters:
        keysize - the size of the key (number of bits)
      • genKeyPair

        public final KeyPair genKeyPair()
        Computes and returns a new unique KeyPair each time this method is called.

        This does exactly the same as generateKeyPair().

        Returns:
        a new unique KeyPair each time this method is called
      • generateKeyPair

        public KeyPair generateKeyPair()
        Computes and returns a new unique KeyPair each time this method is called.

        This does exactly the same as genKeyPair().

        Specified by:
        generateKeyPair in class KeyPairGeneratorSpi
        Returns:
        a new unique KeyPair each time this method is called
      • initialize

        public void initialize​(int keysize,
                               SecureRandom random)
        Initializes this KeyPairGenerator with the given key size and the given SecureRandom. The default parameter set will be used.
        Specified by:
        initialize in class KeyPairGeneratorSpi
        Parameters:
        keysize - the key size
        random - the source of randomness