List of usage examples for java.security.spec RSAKeyGenParameterSpec RSAKeyGenParameterSpec
public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent)
From source file:org.texai.x509.X509Utils.java
/** Creates a random 3072 bit RSA key pair. * @return a random 3072 bit RSA key pair * @throws NoSuchAlgorithmException when an invalid algorithm is given * @throws NoSuchProviderException when an invalid provider is given * @throws InvalidAlgorithmParameterException when an invalid algorithm parameter is given *//*from w w w . j ava2 s . c om*/ public static KeyPair generateRSAKeyPair3072() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", BOUNCY_CASTLE_PROVIDER); final AlgorithmParameterSpec algorithmParameterSpec = new RSAKeyGenParameterSpec(3072, RSAKeyGenParameterSpec.F4); keyPairGenerator.initialize(algorithmParameterSpec, getSecureRandom()); return keyPairGenerator.generateKeyPair(); }
From source file:test.integ.be.agiv.security.IPSTSTest.java
private KeyPair generateKeyPair() throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); SecureRandom random = new SecureRandom(); keyPairGenerator.initialize(new RSAKeyGenParameterSpec(1024, RSAKeyGenParameterSpec.F4), random); KeyPair keyPair = keyPairGenerator.generateKeyPair(); return keyPair; }
From source file:org.texai.x509.X509Utils.java
/** Creates a random 2048 bit RSA key pair. * @return a random 2048 bit RSA key pair * @throws NoSuchAlgorithmException when an invalid algorithm is given * @throws NoSuchProviderException when an invalid provider is given * @throws InvalidAlgorithmParameterException when an invalid algorithm parameter is given *//*from www . j a v a2 s .c o m*/ public static KeyPair generateRSAKeyPair2048() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", BOUNCY_CASTLE_PROVIDER); final AlgorithmParameterSpec algorithmParameterSpec = new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4); keyPairGenerator.initialize(algorithmParameterSpec, getSecureRandom()); return keyPairGenerator.generateKeyPair(); }