bouncycastle

How to use BouncyCastle to get the certification path between a root CA and an end entity?

落花浮王杯 提交于 2020-08-09 08:19:58
问题 I have a root CA, a set of intermediate CAs and an end entity. All represented as org.bouncycastle.cert.X509CertificateHolder instances. How can I get the certification path (aka certificate chain) between the root and the end entity, or get an exception if no path was found? Here's how to do it with pure Java code, but since I'm already using BouncyCastle, I think it'd be more performant and maintainable to use BouncyCastle for this too -- Also, I'd prefer to avoid converting between Java

How to use BouncyCastle to get the certification path between a root CA and an end entity?

谁说我不能喝 提交于 2020-08-09 08:18:46
问题 I have a root CA, a set of intermediate CAs and an end entity. All represented as org.bouncycastle.cert.X509CertificateHolder instances. How can I get the certification path (aka certificate chain) between the root and the end entity, or get an exception if no path was found? Here's how to do it with pure Java code, but since I'm already using BouncyCastle, I think it'd be more performant and maintainable to use BouncyCastle for this too -- Also, I'd prefer to avoid converting between Java

Using a specific Java security provider only in the scope of a method

吃可爱长大的小学妹 提交于 2020-08-05 06:24:26
问题 So I am looking ways to use a security provider only in the scope of a function. I can already do this by adding these two lines: (assume BouncyCastle is the provider) Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC"); // do some stuff with converter Security.removeProvider("BC"); So i just want to use BC for JcaPEMKeyConverter and then for the rest use default security provider. Is there a

Using a specific Java security provider only in the scope of a method

懵懂的女人 提交于 2020-08-05 06:23:08
问题 So I am looking ways to use a security provider only in the scope of a function. I can already do this by adding these two lines: (assume BouncyCastle is the provider) Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC"); // do some stuff with converter Security.removeProvider("BC"); So i just want to use BC for JcaPEMKeyConverter and then for the rest use default security provider. Is there a

Can JcaPEMWriter generate PKCS#8 output?

一曲冷凌霜 提交于 2020-06-16 03:37:31
问题 The following code uses the JcaPEMWriter class from BouncyCastle to output a randomly generated RSA private key in PKCS#1 format ( -----BEGIN RSA PRIVATE KEY----- ): public static void main(String[] args) throws Exception { final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(2048, null); final KeyPair kp = kpg.generateKeyPair(); final PrivateKey privateKey = kp.getPrivate(); final StringWriter s = new StringWriter(); try (JcaPEMWriter w = new JcaPEMWriter(s)) { w

Bouncy Castle - how to get Public Key Info from JceOpenSSLPKCS8DecryptorProviderBuilder

江枫思渺然 提交于 2020-06-01 08:03:40
问题 I have the following code to extract Private Key PEMParser parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(decoded))); Object object = parser.readObject(); PEMDecryptorProvider provider = new JcePEMDecryptorProviderBuilder() .build(props.getProperty(KeytoolFlags.KEYPASS.name()).toCharArray()); JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME); if (object instanceof PEMEncryptedKeyPair) { KeyPair pair = converter

Bouncy Castle - how to get Public Key Info from JceOpenSSLPKCS8DecryptorProviderBuilder

隐身守侯 提交于 2020-06-01 08:02:17
问题 I have the following code to extract Private Key PEMParser parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(decoded))); Object object = parser.readObject(); PEMDecryptorProvider provider = new JcePEMDecryptorProviderBuilder() .build(props.getProperty(KeytoolFlags.KEYPASS.name()).toCharArray()); JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME); if (object instanceof PEMEncryptedKeyPair) { KeyPair pair = converter

bouncycastle connect to android studio

一世执手 提交于 2020-05-31 02:03:19
问题 Good time of day, I need to somehow connect the bouncycastle library to android studio. How can this be done? I've never dealt with one before. Here is the code for which I need this library: Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); byte[] input = "www.javaCODEgeeks.com".getBytes(); byte[] keyBytes = new byte[]{0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef}; byte[] ivBytes = new byte[]{0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01

bouncycastle connect to android studio

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-31 02:02:38
问题 Good time of day, I need to somehow connect the bouncycastle library to android studio. How can this be done? I've never dealt with one before. Here is the code for which I need this library: Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); byte[] input = "www.javaCODEgeeks.com".getBytes(); byte[] keyBytes = new byte[]{0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef}; byte[] ivBytes = new byte[]{0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01