Search in sources :

Example 31 with RSAKeyGenParameterSpec

use of java.security.spec.RSAKeyGenParameterSpec in project poi by apache.

the class PkiTestUtils method generateKeyPair.

static 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;
}
Also used : KeyPair(java.security.KeyPair) SecureRandom(java.security.SecureRandom) RSAKeyGenParameterSpec(java.security.spec.RSAKeyGenParameterSpec) KeyPairGenerator(java.security.KeyPairGenerator)

Example 32 with RSAKeyGenParameterSpec

use of java.security.spec.RSAKeyGenParameterSpec in project android_frameworks_base by crdroidandroid.

the class AndroidKeyPairGeneratorTest method testKeyPairGenerator_GenerateKeyPair_RSA_WithParams_Unencrypted_Success.

public void testKeyPairGenerator_GenerateKeyPair_RSA_WithParams_Unencrypted_Success() throws Exception {
    AlgorithmParameterSpec spec = new RSAKeyGenParameterSpec(1024, BigInteger.valueOf(3L));
    mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext()).setAlias(TEST_ALIAS_1).setKeySize(1024).setAlgorithmParameterSpec(spec).setSubject(TEST_DN_1).setSerialNumber(TEST_SERIAL_1).setStartDate(NOW).setEndDate(NOW_PLUS_10_YEARS).build());
    final KeyPair pair = mGenerator.generateKeyPair();
    assertNotNull("The KeyPair returned should not be null", pair);
    assertKeyPairCorrect(pair, TEST_ALIAS_1, "RSA", 1024, spec, TEST_DN_1, TEST_SERIAL_1, NOW, NOW_PLUS_10_YEARS);
}
Also used : KeyPairGeneratorSpec(android.security.KeyPairGeneratorSpec) KeyPair(java.security.KeyPair) RSAKeyGenParameterSpec(java.security.spec.RSAKeyGenParameterSpec) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec)

Aggregations

RSAKeyGenParameterSpec (java.security.spec.RSAKeyGenParameterSpec)32 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)16 BigInteger (java.math.BigInteger)12 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)12 KeyPair (java.security.KeyPair)7 KeyPairGeneratorSpec (android.security.KeyPairGeneratorSpec)5 ExportResult (android.security.keymaster.ExportResult)5 ASN1Integer (com.android.org.bouncycastle.asn1.ASN1Integer)5 DERBitString (com.android.org.bouncycastle.asn1.DERBitString)5 DERInteger (com.android.org.bouncycastle.asn1.DERInteger)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InvalidKeyException (java.security.InvalidKeyException)5 PrivateKey (java.security.PrivateKey)5 ProviderException (java.security.ProviderException)5 PublicKey (java.security.PublicKey)5 Certificate (java.security.cert.Certificate)5 CertificateFactory (java.security.cert.CertificateFactory)5 X509Certificate (java.security.cert.X509Certificate)5 ECKey (java.security.interfaces.ECKey)5 ECPublicKey (java.security.interfaces.ECPublicKey)5