bouncycastle

Adding attributes to certificate request, java + bouncycastle 1.48

痞子三分冷 提交于 2019-12-11 14:49:25
问题 I'm currently working on creating attribute certificate requests using bouncycastle 1.48. Since there were some changes in API (and I'm beginner in this matter) I am unnable to add attributes to created request My current code is KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(512); KeyPair rsaKey = keyGen.generateKeyPair(); PrivateKey privateKey = rsaKey.getPrivate(); PublicKey publicKey = rsaKey.getPublic(); System.out.println(privateKey.getEncoded());

Can't bind cert using netsh when importing it with X509Store

僤鯓⒐⒋嵵緔 提交于 2019-12-11 14:33:13
问题 Well i have generated a certificate with the following code: public X509Certificate2 GenerateSelfSignedCertificate(string friendlyName, string subjectName, int keyStrength = 2048, int validNumberOfMonths = 3) { // Generating Random Numbers var randomGenerator = new CryptoApiRandomGenerator(); var random = new SecureRandom(randomGenerator); // The Certificate Generator var certificateGenerator = new X509V3CertificateGenerator(); // Serial Number var serialNumber = BigIntegers

Differ result on byte array encoding+decoding with Bouncy Castle

心不动则不痛 提交于 2019-12-11 14:27:56
问题 Using Java BouncyCastle library for encrypting and decrypting byte arrays. Noticed problem that after encrypting-decrypting cycle result arrays contatins redundant zero bytes at the end. public static void main(String[] args) throws IOException { Security.addProvider(new BouncyCastleProvider()); File f = new File("C:/~Test/a.txt"); byte[] bytes = FileUtils.readFileToByteArray(f); byte[] encrypt = encrypt(bytes, "3".getBytes()); byte[] decrypt = decrypt(encrypt, "3".getBytes()); boolean equals

Cannot read from stream (IOException: non-blocking socket would block) using Bouncy Castle with Xamarin and Java Server

白昼怎懂夜的黑 提交于 2019-12-11 13:47:09
问题 Prerequisites: I'm using Xamarin to write a mobile app which should exchange small message chunks with a java server. I'm using the .NET implementation of Bouncy Castle for sending data over TLS, since I'm restricted to a specific cipher suite (TLS_ECDH_anon_WITH_AES_256_CBC_SHA) which is not supported by default for Android phones above API Level 23. The problem: If I only try to send data via the following code, everything is fine. But if I try to also read the response back, the stream

Bouncy Castle: Signed Certificate with an existing CA

别说谁变了你拦得住时间么 提交于 2019-12-11 13:36:55
问题 I'm trying to create a certificate (A) which is signed for other certificate (B) stored in a p12 keystore. This stored certificate (B) was added to the trusted certificate store of my local machine. Certificate A is used to sign a pdf document using bouncy castle 1.52 library, but the digital signature that I obtain in the signed document is invalid. I'm going to explain the steps done just if somebody can help me. First, I create a CSR from the p12 keystore(B): private static

Encrypt String AES Windows Phone 8.1

元气小坏坏 提交于 2019-12-11 12:08:23
问题 I'm making an app which will need to encrypt a string. I'm completely new to AES encryption. I have to code that runs on the server to encrypt. public static string Encrypt(string text, byte[] key, byte[] iv, int keysize = 128, int blocksize = 128, CipherMode cipher = CipherMode.CBC, PaddingMode padding = PaddingMode.PKCS7) { AesCryptoServiceProvider aes = new AesCryptoServiceProvider(); aes.BlockSize = blocksize; aes.KeySize = keysize; aes.Mode = cipher; aes.Padding = padding; byte[] src =

Can I use PKCS5Padding padding algorithm while decryption for already encrypted data using PKCS7Padding?

久未见 提交于 2019-12-11 11:56:53
问题 I'm replacing PKCS7Padding padding with PKCS5Padding for my AES encryptions. Can I use PKCS5Padding padding algorithm while decryption for already encrypted data using PKCS7Padding? I tried using a sample program on local and somehow it works and didn't give any error. Just want to ensure if we need any sort of Migration for all the existing records. For all the existing records, Do I need to decrypt first using PKCS7Padding and then again encrypt using PKCS5Padding and store it back in the

J2ME bouncycastle incompatible types required: Throwable found DataLengthException

耗尽温柔 提交于 2019-12-11 11:53:44
问题 I have some code with bouncycastle that generates an exception, but even if i surround with try catch, the catch statement still give me this error : incompatible types required: java.lang.Throwable found: org.bouncycastle.crypto.DataLengthException here is my code: int decryptedLength; try { decryptedLength = cipher.processBytes(cipherBytes, 0, cipherBytes.length, decryptedBytes, 0); } catch (DataLengthException ex) { } the catch statement doesn't accept the exception, how to solve this ?

Symmetric key generation after ECDHC using KDF with SHA-256

流过昼夜 提交于 2019-12-11 11:36:54
问题 I want to generate a Symmetric key using Single-step Key Derivation Function (KDF) based on SHA-256. I think key derivations are in the lightweight API of Bouncy Castle since 1.50. I have successfully generated the secret key "Z" .And have a code for generating KDF from Z. Please kind the code below byte[] data = new byte[16]; SecretKey secretKeyA = generateSharedSecretZ(keyPairA.getPrivate(), keyPairB.getPublic()); System.out.println(bytesToHex(secretKeyA.getEncoded())); //Single-Step KDF

Sign and encrypt a file using S/MIME

北战南征 提交于 2019-12-11 11:32:50
问题 I am currently trying to adapt a few scripts we use to sign an encrypt/decrypt xml files using OpenSSL and S/MIME using Java and BouncyCastle. The command to sign and encrypt our file: openssl smime -sign -signer Pub1.crt -inkey Priv.key -in foo.xml | openssl smime -encrypt -out foo.xml.smime Pub2.crt Pub1.crt This generates a signed and encrypted smime-file containing our xml file. Currently this happens using a set of shell scripts under linux using the OpenSSL library. In the future we