bouncycastle

How do I repackage certificates into pkcs #7 certificate using bouncy castle?

风流意气都作罢 提交于 2019-12-13 09:52:36
问题 I have root, intermediate and end entity certificates and, I want to package it in pkcs # 7 format using bouncy castle. How can I do it? 回答1: At the very first, you have to read latest RFC on PKCS#7/CMS. Please click on this RFC Link to read. Now to fulfill your objective, use bouncycastle. You need to generate CMSSignedData data. For that, you need to prepare private key and Certificate chain. Here, I am going to assume, you already have those. Now prepare CMSProcessableByteArray.

How to import a bitcoin private key to BigInteger?

好久不见. 提交于 2019-12-13 07:59:03
问题 I use the following codes to try to import a bitcoin private key and compute the public key. The computed ECPublicKey is not equal to bitcoinPublicKey. How to correct? string bitcoinPrivateKeyStr = "cVnb9S9GgHxsBxfaApvGnWvfwqXRYdV8f1Q2CkQeBa4EsWTNmsGS"; BitcoinSecret bs = new BitcoinSecret(bitcoinPrivateKeyStr); byte[] bitcoinPrivateKeyBytes = bs.PrivateKey.ToBytes(); byte[] bitcoinPublicKeybytes = bs.PubKey.Decompress().ToBytes(); X9ECParameters curve = SecNamedCurves.GetByName("secp256k1");

Java SecurityException no manifiest section for signature file

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 07:49:18
问题 When I'm running a executable .jar file created with maven build, I'm getting the below error: Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry org/bouncycastle/cms/CMSSignedDataStreamGenerator$TeeOutputStream.class at sun.security.util.SignatureFileVerifier.verifySection(Unknown Source) at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source) at sun.security.util.SignatureFileVerifier.process(Unknown Source) at java.util.jar

How to generate 33-byte compressed NIST P-256 public key?

怎甘沉沦 提交于 2019-12-13 03:26:58
问题 I need to generate such public key and do the additional signing of the bytes (which will include this generated previously key) I need to construct bytes of: ASN.1 prefix + signature of (33-byte compressed NIST P-256 public key) The signature should be delivered from other defined private key The ECDSA specifications: ● Curve: NIST P-256 Otherwise known as secp256r1 and prime256v1 (openssl) ● Signature format ASN.1. The r and s values of the ECDSA signature must be positive integers, and DER

Java - Sending certificate through socket

蓝咒 提交于 2019-12-13 03:24:29
问题 i need to send a v3certificate from the server to the client using socket. To do this: server side, i generate a certificate which i encode with base64.encode , then i send it to the client. Client side, i receive the string which contain the certificate, Server code: X509Certificate certificate = ...; sendAnswer(new String(certificate.getEncoded())); public static void sendAnswer(String ans) { try { s.shutdownInput(); PrintWriter output = new PrintWriter(s.getOutputStream(), true); output

Problem in decrypting a pdf.p7m file with the Bouncy Castle library c#

a 夏天 提交于 2019-12-13 03:06:18
问题 I have "translated" java code in c # for the dercrypt of a pdf file. I don't understand why when I start a new CmsEnvelopedData object, I get an exception: "Attempted to read past the end of the stream". I also tried to download the Bouncy Castle sources without installing the NuGet package, but I couldn't figure out what the problem might be. Thanks to those who will help. Code Java: public final synchronized byte[] decryptData(byte[] cipherData, String pwd) throws CSException { cipherData =

How to convert X509 certificate into PKCS7 using bouncycastle?

拟墨画扇 提交于 2019-12-13 02:48:09
问题 Hi, all! My problem is following: I 'm trying to encrypt X509 certificate to PKCS7 but I receive a wrong result. The first attempt is:(used bcmail-jdk16:1.46) Security.addProvider(new BouncyCastleProvider()); keystore = KeyStore.getInstance("PKCS12", "BC"); keystore.load (new FileInputStream(PATH+"//pkcs7-csr-cer//identity.p12"), "testpassword".toCharArray()); PrivateKey privateKey = (PrivateKey)keystore.getKey("testclientcert", "testpassword".toCharArray()); CMSSignedDataGenerator

What is the simplest way to encrypt/ decrypt a byte array using BouncyCastle's block cipher?

走远了吗. 提交于 2019-12-13 02:31:31
问题 If I have a BlockCipher and a byte[] that I got from a String containing a secret message, what's the easiest way to get a byte[] of the message encrypted? In the normal Java API, I could just do cipher.doFinal(secretMessage) , but there doesn't seem to be anything like that here, it only processes blocks. I know I can use a BufferedBlockCipher , but this still doesn't simplify things significantly. What's the easiest high-level way to use this cipher? 回答1: OK, so using the lightweight API

c# BouncyCastle Exception: pad block corrupted

与世无争的帅哥 提交于 2019-12-13 01:25:07
问题 I've been using the code that was posted here to encrypt and decrypt, written by @nerdybeardo. However, I'm getting the error "pad block corrupted" when trying to decrypt. The Encryptor class looks like this, which implements encrypt then MAC: /// <summary> /// Encrypt/decrypt + HMAC using BouncyCastle (C# Java port) /// </summary> /// <typeparam name="TBlockCipher">The type of the block cipher.</typeparam> /// <typeparam name="TDigest">The type of the digest.</typeparam> /// <see cref="https

ECDH secrets generated by BouncyCastle Java API and by OpenSSL are different

与世无争的帅哥 提交于 2019-12-13 00:09:23
问题 I'm trying to make use of elliptic curve crypto. I need two implementations of the same thing, one in Java and one in C. I'm testing them using two key pairs which were generated using the curve secp256k1 . When I generate the derived secret in Java I always get a different number from what I get from OpenSSL. Java code: /* privateKey and peerPublicKey are generated with the following parameters */ ECParameterSpec paramSpec = ECNamedCurveTable.getParameterSpec("secp256k1"); /* ... */ Provider