bouncycastle

Generate valid CMS Signature file adding external PKCS#1 with Java

耗尽温柔 提交于 2020-01-15 05:56:07
问题 I'm generating CMS signature files with external PKCS#1 based on this thread. The first step is obtain the signed attributes from the original file to be signed in external application which is returning PKCS#1 byte array. Then build standard org.bouncycastle.cms.SignerInfoGenerator with original file hash, signed data (PKCS#1) and certificate to add to CMS, and finally create the attached signature . But when i'd tried to validate it using this code: String originalFile =

Bouncycastle for JDK 1.7 and PKCS libraries

和自甴很熟 提交于 2020-01-15 04:42:07
问题 I am trying to locate the PKCS libraries (pkcs10 CSR calls) of the Bouncycastle for JDK 1.7. I came across the official Bouncycastle maven repository and got totally confused because of the amount of different versions. I have specially looked for bcmail.jar (and fount one for JDK 1.5) but did not found any for JDK 1.7. Can somebody tell me which jar should I use and how can I integrate maven dependency for Bouncycastle in my pom.xml , so that this references the latest bouncycastle release?

Is rapidly creating BouncyCastle SecureRandom instances problematic?

半城伤御伤魂 提交于 2020-01-15 02:29:21
问题 As noted at Random number generator only generating one random number, it's generally incorrect to create a new instance of System.Random every time that you need another random number, since System.Random is seeded based upon the clock and so multiple instances created in the same tick will yield identical random numbers. As such, one common practice (at least in single-threaded applications) is to create a single instance of Random stored in a static field that is used for all random number

iText setEncryption error

一曲冷凌霜 提交于 2020-01-14 14:40:13
问题 I've recently had to upgrade to iText, but I'm having problems getting setEncryption to work. I'm using iText 5.5.6. document = new Document(PageSize.LETTER, 36, 36, 72, 72); writer = PdfWriter.getInstance(document, out); writer.setEncryption(null, OWNER_PASSWORD.getBytes(), writer.AllowPrinting|writer.AllowCopy, PdfWriter.STANDARD_ENCRYPTION_128); gets me the following error: java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer

CA x.509 generated by bouncy castle is seen on Android as user certificate

久未见 提交于 2020-01-14 05:46:12
问题 I am using following code to generate root CA: public static X509Certificate buildRootCert(KeyPair keyPair) throws Exception { X509v1CertificateBuilder certBldr = new JcaX509v1CertificateBuilder( new X500Name("CN=Root"), BigInteger.valueOf(1), new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis() + 1000 * 3600 * 24), new X500Name("CN=Root"), keyPair.getPublic()); ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA") .setProvider("BC").build(keyPair.getPrivate()

create PKCS7 with presigned data using bouncy castle

ⅰ亾dé卋堺 提交于 2020-01-13 20:34:13
问题 I would like to create a detached signature in a PDF file using a PKCS7 container. The data (hash) is being signed beforehand on a different device with the private key. I want to create a PKCS7 containing the signed data along with the certificate with the public key. I can't seem to create the PKCS7 with bouncy castle without supplying the private key and having the library signing the data. This doesn't seem to work: InputStream inStream = new FileInputStream("1_public.pem");

AES cbc padding encryption/decryption on cross platform (.net c# and codename one bouncy castle)

风流意气都作罢 提交于 2020-01-13 19:43:10
问题 Encryption/Decryption won't work in cross platform. I have used this link to encrypt/decrypt text using bouncy castle AES cipher within codename one. AES Encryption/Decryption with Bouncycastle Example in J2ME While from server side (.net) , i am using this link to implement same method. http://zenu.wordpress.com/2011/09/21/aes-128bit-cross-platform-java-and-c-encryption-compatibility/ now i am not getting any error but encrypted from codename one will not getting fully decrypted on server

Decrypttion fails on S/MIME enveloped message with OAEP key encryption?

*爱你&永不变心* 提交于 2020-01-13 19:13:10
问题 With Java and BouncyCastle I am able to decrypt lots of S/MIME enveloped messages. But when the key encryption algorithm is 1.2.840.113549.1.1.7 (id-RSAES-OAEP), the decryption fails (stack trace at the end of this question). The line where it happens: content = messageRecipientInfo.getContent(new JceKeyTransEnvelopedRecipient(pc).setProvider("BC")); Formerly I used that line to decrypt: content = messageRecipientInfo.getContent(givenCertRecipient); It's all the same. Any guess? EDIT * I now

Bouncy Castle's Password Based Encryption With AES in CBC mode

谁说胖子不能爱 提交于 2020-01-13 05:51:06
问题 I've recently came across a piece of code that uses BouncyCastle's PBE with AES in CBC mode ("PBEWithSHA1And256BitAES-CBC-BC"). public static final String ALGORITHM = "PBEWithSHA1And256BitAES-CBC-BC"; public static byte[] encrypt(final byte[] key, final byte[] salt, final byte[] plainText) throws CryptoException { try { // Create the encryption key final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM, "BC"); final PBEKeySpec keySpec = new PBEKeySpec(new String(key)

How to verify this PGP message in C# using Bouncy Castle or other c# library

倖福魔咒の 提交于 2020-01-13 04:54:05
问题 All i need to do is verify the message below but I can not get Bouncy Castle to take the data in and given the public key verify the message. I am happy for it to be some other Lib that is used if it is free. This is to be embedded in my app that receives data over the Internet so i would prefer to keep it all managed code if at all possible. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SCI Version: 1.0 SCI Code: 1 SCI Reason: OK SCI Balance: 0.00050000 -----BEGIN PGP SIGNATURE----- Version: