bouncycastle

How to use BouncyCastle's Diffie-Hellman in C#?

一个人想着一个人 提交于 2019-12-07 10:47:08
问题 I'm writing an app that'll exchange data between a phone and a Windows PC, and I want to protect the data sent with key generated with a Diffie-Hellman exchange. I'm trying to use BouncyCastle for that, but the almost non-existant documentation for the C# implementation has me stumped. What I want to know is: what's the workflow for generating a DH key and computing a shared key when the other side's key is received? (I'm assuming I can send my key as a string and I can work with the other

how can i convert pem public key to rsa public key with bouncycastle in c#?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 09:44:24
问题 i have a pem public key and i want to convert to xml format public key or AsymmetricKeyParameter. i can convert pem Private key to Public/Private xml format or asymmetricKeyParameter with PemReader in bouncyCastle in C#.but when use Pem Public Key in PemReader , i receive error. please help me. what else solution for my problem? 回答1: This should do what you were looking for using BouncyCastle. Dependencies: using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Parameters; using Org

Adding external PKCS1 byte array and Certificate to CMS container with Java

末鹿安然 提交于 2019-12-07 09:41:36
问题 We have client applications (Applets and Silverlight) that create a PKCS1 v2.1 digital signature. The digital signature is created as PKCS1 since the original content is not downloaded to the client, only the contents' hash is sent to the client to conserve bandwidth. We are attempting to create a PKCS7/CMS container server side, based on the information from this post: Reading certificate and loading as X509Certificate type Reading PKCS1 signature as base64 and loading as byte array

Java how to use private key file instead of PEM to decrypt?

本小妞迷上赌 提交于 2019-12-07 08:46:06
问题 Using Java and Bouncy Castle 1.52, I can load the private key through the PEM certificate using the following code. I also have a private.key file of the same in PKCS8 format. What is the code to use the private.key file directly instead of the PEM? String keyPath = "C:\\RSA7\\privatenopass.pem"; BufferedReader br = new BufferedReader(new FileReader(keyPath)); PEMParser pp = new PEMParser(br); PEMKeyPair pemKeyPair = (PEMKeyPair) pp.readObject(); KeyPair kp = new JcaPEMKeyConverter()

How to generate a symmetric key with Bouncy Castle?

最后都变了- 提交于 2019-12-07 07:41:23
问题 How can I generate a symmetric key with Bouncy Castle? Both PrivateKeyFactory and PublicKeyFactory seem related to AsymmetricKeyParameter. I don't want to know any JCA/JCE API - instead I'm only interested in Bouncy Castle specific API. Can (should) I just generate a random bytes? 回答1: AES does not have any weak keys, so a straightforward random generation should be fine. // SecureRandom is expensive to initialize (takes several milliseconds) – // consider keeping the instance around if you

BouncyCastle does not find algorithms that it provides?

为君一笑 提交于 2019-12-07 07:10:25
问题 I'm playing around with BouncyCastle 1.46 To my surprise, the catch-block in the snippet below is tripped quite often. Security.addProvider(new BouncyCastleProvider()); final Set<String> found = new HashSet<String>(); final Set<String> missing = new HashSet<String>(); final DefaultSignatureAlgorithmIdentifierFinder finder = new DefaultSignatureAlgorithmIdentifierFinder(); for (Service service : new BouncyCastleProvider().getServices()) { if ("Signature".equals(service.getType())) { final

Bouncy Castle Sha3 wrong output?

元气小坏坏 提交于 2019-12-07 05:59:15
问题 I'm working on a JAVA project that needs to perform a sha3-256 hash. Since Bouncy Castle implemented Sha3 in its latest update, I plan to use their implementation. Here is my code: public static String sha3(final String input) { String hash = ""; final SHA3.DigestSHA3 md = new SHA3.DigestSHA3(256); md.update(input.getBytes()); hash = Main2.toString(md.digest()); return hash; } When running System.out.println(Main2.sha3("")); , I get the following output:

Why doesn't my key identifier match?

泪湿孤枕 提交于 2019-12-07 01:42:26
问题 I'm attempting to decrypt an S/MIME email (sent originally via Outlook), and to do that, I'm using the bouncycastle API. I'm running into a snag, though. I have, in the Windows certificate store, the certificate for the recipient. I had previously used it to send a signed and encrypted email to the other party, and they in turn used it to send me an encrypted reply. I then exported the certificate (with private key) as a .pfx file, and I loaded this pfx file into a Java KeyStore. It doesn't

sign file with bouncy castle in java

假装没事ソ 提交于 2019-12-07 01:36:55
问题 I want to sign a file content with certificate in java. With terminal and openssl, I can do this : openssl smime -sign -in nosign.mobileconfig -out signed.mobileconfig -signer server.crt -inkey server.key -certfile cacert.crt -outform der -nodetach server.crt and .key are the files to sign, and I think I understand the cacert.crt is embedded inside the out content. finally, I have a file signed and trusted. In Java, I can't use openssl (don't want to launch openssl command) so, I have to sign

How to create a PBKDF2-SHA256 password hash in C# / Bouncy Castle

北慕城南 提交于 2019-12-07 00:10:49
问题 I need to create a PBKDF2-SHA256 password hash, but am having some trouble. I downloaded the Bouncy Castle repo, but got a bit stuck finding what I was looking for in the Unit Tests. Found some sample code here, but this only does SHA1. The key bit of code is: /// <summary> /// Computes the PBKDF2-SHA1 hash of a password. /// </summary> /// <param name="password">The password to hash.</param> /// <param name="salt">The salt.</param> /// <param name="iterations">The PBKDF2 iteration count.<