bouncycastle

Java Bouncy Castle generated ES256 key doesn't work with JWT.io

依然范特西╮ 提交于 2020-05-17 03:03:01
问题 I am generating a keypair like below: public static void main(String args[]) throws Exception{ StringWriter pemStrWriter = new StringWriter(); JcaPEMWriter pemWriter = new JcaPEMWriter(pemStrWriter); Security.addProvider(new BouncyCastleProvider()); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1"); g.initialize(spec); KeyPair keyPair = g.generateKeyPair(); pemWriter.writeObject(new JcaPKCS8Generator(keyPair

Java Bouncy Castle generated ES256 key doesn't work with JWT.io

依然范特西╮ 提交于 2020-05-17 03:01:09
问题 I am generating a keypair like below: public static void main(String args[]) throws Exception{ StringWriter pemStrWriter = new StringWriter(); JcaPEMWriter pemWriter = new JcaPEMWriter(pemStrWriter); Security.addProvider(new BouncyCastleProvider()); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1"); g.initialize(spec); KeyPair keyPair = g.generateKeyPair(); pemWriter.writeObject(new JcaPKCS8Generator(keyPair

Unable to read BouncyCastle generated privatekey in Java

夙愿已清 提交于 2020-05-16 02:28:45
问题 I have a method that generates a keypair as below: public void create() throws Exception{ StringWriter pemStrWriter = new StringWriter(); JcaPEMWriter pemWriter = new JcaPEMWriter(pemStrWriter); Security.addProvider(new BouncyCastleProvider()); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1"); g.initialize(spec); KeyPair keyPair = g.generateKeyPair(); pemWriter.writeObject(keyPair.getPrivate()); pemWriter.close();

C# BouncyCastle PKCS#8

邮差的信 提交于 2020-04-18 06:10:42
问题 I want load the PEM using .net framework (not .netcore) -----BEGIN ENCRYPTED PRIVATE KEY----- MIHs........................................................CAAw DAYI........................................................gZAf Y/Iu........................................................X7DZ ZKoE........................................................OYQQ 3ZST........................................................A2E= -----END ENCRYPTED PRIVATE KEY----- I tried to use the following code using

Excluding unit tests from external library

强颜欢笑 提交于 2020-04-16 05:44:48
问题 I newly replaced spongyCastle by bouncyCastle in an Android project: implementation "org.bouncycastle:bcpkix-jdk15on:$project.bouncyCastleVersion" Since then on Jenkins (our CI) it seems that there are tests being executed from this lib, could this be true? I never saw external libs with units tests executing automatically. The issue is now I see many failed tests, for example: org.bouncycastle.pqc.crypto.qtesla.QTeslaKeyEncodingTests.testDecodeEncodePrivateKeyQT3P 27 ms 1 org.bouncycastle

How to construct Pkcs12Store from X509Certificate2

Deadly 提交于 2020-04-16 04:52:22
问题 I have an object of System.Security.Cryptography.X509Certificates.X509Certificate2. I want to construct an instance of Pkcs12Store (Org.BouncyCastle.Pkcs) using this object. I tried: Approach 1: public Pkcs12Store GetPkcs12Store(X509Certificate2 cert, string password) { byte[] rawdata = cert.RawData; MemoryStream memStream = new MemoryStream(rawdata); Pkcs12Store pk12; pk12 = new Pkcs12Store(memStream, password.ToCharArray()); return pk12; } In this approach, I am getting the exception:

CTR mode of operation in the Bouncy Castle lightweight API?

岁酱吖の 提交于 2020-03-23 14:44:26
问题 Is there an implementation of CTR (counter) mode of operation in the Java / C# Bouncy Castle lightweight API? 回答1: Yes, you can use org.bouncycastle.crypto.modes.SICBlockCipher . The documentation of that class reads: Implements the Segmented Integer Counter (SIC) mode on top of a simple block cipher. This mode is also known as CTR mode. Note that the SICBlockCipher class does not seem to implement buffering of large key streams. It does also not provide functionality to encryption / decrypt

CTR mode of operation in the Bouncy Castle lightweight API?

谁说胖子不能爱 提交于 2020-03-23 14:44:22
问题 Is there an implementation of CTR (counter) mode of operation in the Java / C# Bouncy Castle lightweight API? 回答1: Yes, you can use org.bouncycastle.crypto.modes.SICBlockCipher . The documentation of that class reads: Implements the Segmented Integer Counter (SIC) mode on top of a simple block cipher. This mode is also known as CTR mode. Note that the SICBlockCipher class does not seem to implement buffering of large key streams. It does also not provide functionality to encryption / decrypt

Decrypt passphrase protected PEM containing private key

情到浓时终转凉″ 提交于 2020-03-21 16:09:58
问题 I have the following method that creates an Encrypted Private Key using Bouncy Castle for C#: public string GetPrivateKey(AsymmetricCipherKeyPair keyPair, string password) { var generator = new Pkcs8Generator(keyPair.Private, Pkcs8Generator.PbeSha1_3DES); generator.IterationCount = 4; generator.Password = password.ToCharArray(); var pem = generator.Generate(); TextWriter textWriter = new StringWriter(); PemWriter pemWriter = new PemWriter(textWriter); pemWriter.WriteObject(pem); pemWriter

Decrypt passphrase protected PEM containing private key

半腔热情 提交于 2020-03-21 16:08:52
问题 I have the following method that creates an Encrypted Private Key using Bouncy Castle for C#: public string GetPrivateKey(AsymmetricCipherKeyPair keyPair, string password) { var generator = new Pkcs8Generator(keyPair.Private, Pkcs8Generator.PbeSha1_3DES); generator.IterationCount = 4; generator.Password = password.ToCharArray(); var pem = generator.Generate(); TextWriter textWriter = new StringWriter(); PemWriter pemWriter = new PemWriter(textWriter); pemWriter.WriteObject(pem); pemWriter