bouncycastle

AES GCM encryption and decryption: PHP VS C# BouncyCastle

若如初见. 提交于 2021-02-20 03:38:29
问题 I am currently working on transforming my C# AES-GCM cryptography code to PHP. However, after some research, the text encrypted by my PHP system cannot be decrypted by the C# one. I want to know if there is any difference from both codes: C# with BouncyCastle: using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Security; using System; using System.IO; using System.Text; /

AES GCM encryption and decryption: PHP VS C# BouncyCastle

亡梦爱人 提交于 2021-02-20 03:38:09
问题 I am currently working on transforming my C# AES-GCM cryptography code to PHP. However, after some research, the text encrypted by my PHP system cannot be decrypted by the C# one. I want to know if there is any difference from both codes: C# with BouncyCastle: using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Security; using System; using System.IO; using System.Text; /

Read DER private key in C# using BouncyCastle

家住魔仙堡 提交于 2021-02-18 07:50:09
问题 I am trying to read an RSA private key into .Net using BouncyCastle to test data I have previously encrypted. The encrypted data is working fine using the public key and Bouncy Castle and I have also used the same private key as below (which is DER format) to successfully decrypt my data in a PHP application but I don't know why I can't create the private key in .Net to do the same thing: byte[] privatekey = File.ReadAllBytes(@"C:\Users\Luke\privkey.der"); var rsaKeyParameters =

Adding a signature to a certificate

我怕爱的太早我们不能终老 提交于 2021-02-11 15:54:03
问题 I have some odd requirements that I have to live with. I need to pass my crypto system a TBS certificate, they will sign it and send back a String of the signature which I need to incorporate into a certificate to make a signed certificate. Looking at com.ibm.security.x509.X509CertImpl and various BouncyCastle posts on SO, I can't find out how to do that. Questions: Is this possible ? If so, how ? 回答1: I'd refer to the source code for the BouncyCastle X509v3CertificateBuilder class (pkix jar)

Adding a signature to a certificate

帅比萌擦擦* 提交于 2021-02-11 15:52:51
问题 I have some odd requirements that I have to live with. I need to pass my crypto system a TBS certificate, they will sign it and send back a String of the signature which I need to incorporate into a certificate to make a signed certificate. Looking at com.ibm.security.x509.X509CertImpl and various BouncyCastle posts on SO, I can't find out how to do that. Questions: Is this possible ? If so, how ? 回答1: I'd refer to the source code for the BouncyCastle X509v3CertificateBuilder class (pkix jar)

Unable to verify the Signature with two different mechanism

心已入冬 提交于 2021-02-11 12:41:01
问题 I have two clients, first client expect CMS/PKCS to verify signature second client expect only signature (EncryptedDigestMessage). Original file and certificate separately to verify signature So, I want to create one method that should return the appropriate output based on format (PKCS or SignOnly) public static byte[] digitalSign(byte[] fileContent , PrivateKey privkey , X509Certificate x509Certificate , String format) throws Exception{ Security.addProvider(new BouncyCastleProvider()); List

Get signing chain from CMSSignedData

好久不见. 提交于 2021-02-08 07:55:40
问题 How can I get a signing chain from a CMSSignedData (BouncyCastle) to verify it with the signing chain store? Certificate[] storeCertChain = store.getCertificateChain(alias) Isn't there a command or something like this I can get the signing chain of the data? Or get the certificate from it and there from the signing chain? 回答1: The chain of the certificate used to sign might be in the CMSSignedData , but it's not mandatory. According to RFC 3852, a CMS SignedData has the following structure

unsupported SignatureMethod algorithm, but the algorithm is listed as available Service by BC-Provider

我是研究僧i 提交于 2021-02-08 05:34:32
问题 to keep it short, my problem is as follows: I add the BC-Provider at the beginning of my function: Security.addProvider(new BouncyCastleProvider()); when i List all Services BouncyCastleProvider().getServices(); the List contains "RIPEMD160WITHECDSA" on the last line of this codesnippet: XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM"); DOMValidateContext valContext = new DOMValidateContext(pubkeys[i], sigElement); valContext.setURIDereferencer(new FileDereferencer(

Get DER-encoded public key

元气小坏坏 提交于 2021-02-07 19:39:18
问题 Using BounceCastle I have the following code working. It generates a keypair and return the ASN.1 DER-encoded format. //Generate new key var generator = new RsaKeyPairGenerator (); generator.Init (new KeyGenerationParameters (new SecureRandom (), 1024)); var keyPair = generator.GenerateKeyPair (); //Save private key for later use keyParameters = (RsaKeyParameters)keyPair.Private; //Export ASN.1 DER-encoded SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo

JAVA API to create a keystore and attaching a csr and keypair to it

房东的猫 提交于 2021-02-07 10:51:44
问题 I need to attach an existing csr and keypair to a keystore. Given below is an implementation that uses GUI(java swing) to take the input from the user such as keystore name, alias,common name, organization etc. I try to link the csr to the keystore using keystore.setkeyentry(...), however the keystore is still empty. I have attached my code below, any help will be very useful: This code below is used to create a csr public String getCSR(String cn, String ou, String o, String l,String s)