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;
}
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);
}
Aggregations