bouncycastle

Verify a signature with bouncy castle

Deadly 提交于 2021-02-07 10:19:00
问题 I inherited some code using the deprecated bouncycastle API. Before updating it to the new API I wanted to write a test to verify that I didn't change its behaviour. However, I cannot work out the correct way to verify this signature that is generated. The code to be changed is: public static byte[] createSignedData(byte[] content, X509Certificate cert, PrivateKey key) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException, IOException { // set up the generator

Verify a signature with bouncy castle

被刻印的时光 ゝ 提交于 2021-02-07 10:18:13
问题 I inherited some code using the deprecated bouncycastle API. Before updating it to the new API I wanted to write a test to verify that I didn't change its behaviour. However, I cannot work out the correct way to verify this signature that is generated. The code to be changed is: public static byte[] createSignedData(byte[] content, X509Certificate cert, PrivateKey key) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException, IOException { // set up the generator

ECDSA with SHA256 in Bouncy castle throws No Such Algorithm Exception

我只是一个虾纸丫 提交于 2021-02-07 08:50:41
问题 I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows, I add the provider in the begining I have built the ECPrivatekey Signature s_oSignature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME); but step 3 throws "java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC" . But same "SHA256withECDSA" thing when replaced with "SHA1withECDSA" prceeds without any exception. How is it possible? I am

ECDSA with SHA256 in Bouncy castle throws No Such Algorithm Exception

此生再无相见时 提交于 2021-02-07 08:47:20
问题 I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows, I add the provider in the begining I have built the ECPrivatekey Signature s_oSignature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME); but step 3 throws "java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC" . But same "SHA256withECDSA" thing when replaced with "SHA1withECDSA" prceeds without any exception. How is it possible? I am

ECDSA with SHA256 in Bouncy castle throws No Such Algorithm Exception

我的梦境 提交于 2021-02-07 08:45:12
问题 I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows, I add the provider in the begining I have built the ECPrivatekey Signature s_oSignature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME); but step 3 throws "java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC" . But same "SHA256withECDSA" thing when replaced with "SHA1withECDSA" prceeds without any exception. How is it possible? I am

ECDSA with SHA256 in Bouncy castle throws No Such Algorithm Exception

我是研究僧i 提交于 2021-02-07 08:44:51
问题 I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows, I add the provider in the begining I have built the ECPrivatekey Signature s_oSignature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME); but step 3 throws "java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC" . But same "SHA256withECDSA" thing when replaced with "SHA1withECDSA" prceeds without any exception. How is it possible? I am

C# BouncyCastle RSA Encryption and Decryption

大兔子大兔子 提交于 2021-02-07 08:16:35
问题 There are many topics on RSA Encryption and Decryption using BouncyCastle, however I'm encountering some unexpected behaviour. I'm attempting to encrypt a 64 byte data blocking using a private key of size 64 bytes I compute the RSA Encryption as followings: public byte[] Encrypt(byte[] data, AsymmetricKeyParameter key) { var engine = new RsaEngine(); engine.Init(true, key); var blockSize = engine.GetInputBlockSize(); return engine.ProcessBlock(data, 0, blockSize ); } I compute the decryption

C# BouncyCastle RSA Encryption and Decryption

家住魔仙堡 提交于 2021-02-07 08:15:21
问题 There are many topics on RSA Encryption and Decryption using BouncyCastle, however I'm encountering some unexpected behaviour. I'm attempting to encrypt a 64 byte data blocking using a private key of size 64 bytes I compute the RSA Encryption as followings: public byte[] Encrypt(byte[] data, AsymmetricKeyParameter key) { var engine = new RsaEngine(); engine.Init(true, key); var blockSize = engine.GetInputBlockSize(); return engine.ProcessBlock(data, 0, blockSize ); } I compute the decryption

ECDSA signature generation using secp256r1 curve and SHA256 algorithm - BouncyCastle

一个人想着一个人 提交于 2021-02-07 04:00:48
问题 I am trying to generate signature using ECDSA with secp256r1 curve (P256) and SHA256 algorithm for message hash. Also i am using Bouncy Castle libraries. Code below, public class MyTest { /** * @param args */ public static void main(String[] args) { new MyTest().getSign(); } void getSign() { // Get the instance of the Key Generator with "EC" algorithm try { KeyPairGenerator g = KeyPairGenerator.getInstance("EC"); ECGenParameterSpec kpgparams = new ECGenParameterSpec("secp256r1"); g.initialize

How to make a Bouncy Castle ECPublicKey

末鹿安然 提交于 2021-02-06 04:47:08
问题 I know the curve name ( secp256k1 ) and the X and Y coordinates of the EC public key. How do I make a org.bouncycastle.jce.interfaces.ECPublicKey out of them? I've read https://stackoverflow.com/a/29355749/5453873 but the code there uses java.security... instead of org.bouncycastle... and ECPublicKey is an interface in org.bouncycastle... not an instantiable class. 回答1: Generating ECPublicKey using Bouncy Castle This generates the EC public key as used in the JCE/JCA. The Bouncy Castle