Questions tagged [bouncycastle]

Bouncy Castle is a cryptography API providing various cryptography, encryption, and security protocols. There are fairly similar libraries in both C# and Java that implement the API. Additionally, Bouncy Castle provides a JCE-compliant crypto provider for Java.

  • Generation and parsing of PKCS#12 files.
  • X.509: Generators and parsers for V1 and V3 certificates, V2 CRLs and attribute certificates.
  • PBE algorithms supported by PBEUtil: PBEwithMD2andDES-CBC, PBEwithMD2andRC2-CBC, PBEwithMD5andDES-CBC, PBEwithMD5andRC2-CBC, PBEwithSHA1andDES-CBC, PBEwithSHA1andRC2-CBC, PBEwithSHA-1and128bitRC4, PBEwithSHA-1and40bitRC4, PBEwithSHA-1and3-keyDESEDE-CBC, PBEwithSHA-1and2-keyDESEDE-CBC, PBEwithSHA-1and128bitRC2-CBC, PBEwithSHA-1and40bitRC2-CBC, PBEwithHmacSHA-1, PBEwithHmacSHA-224, PBEwithHmacSHA-256, PBEwithHmacRIPEMD128, PBEwithHmacRIPEMD160, and PBEwithHmacRIPEMD256.
  • Signature algorithms supported by SignerUtilities: MD2withRSA, MD4withRSA, MD5withRSA, RIPEMD128withRSA, RIPEMD160withRSA, RIPEMD256withRSA, SHA-1withRSA, SHA-224withRSA, SHA-256withRSAandMGF1, SHA-384withRSAandMGF1, SHA-512withRSAandMGF1, SHA-1withDSA, and SHA-1withECDSA.
  • Symmetric key algorithms: AES, Blowfish, Camellia, CAST5, CAST6, DESede, DES, GOST28147, HC-128, HC-256, IDEA, NaccacheStern, RC2, RC4, RC5-32, RC5-64, RC6, Rijndael, Serpent, Skipjack, TEA/XTEA, Twofish, and VMPC.
  • Symmetric key modes: CBC, CFB, CTS, GOFB, OFB, OpenPGPCFB, and SIC (or CTR).
  • Symmetric key paddings: ISO10126d2, ISO7816d4, PKCS#5/7, TBC, X.923, and Zero Byte.
  • Asymmetric key algorithms: RSA (with blinding), ElGamal, DSA, ECDSA.
  • Asymmetric key paddings/encodings: ISO9796d1, OAEP, and PKCS#1.
  • Digests: GOST3411, MD2, MD4, MD5, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, Tiger, and Whirlpool.
  • Signer mechanisms: DSA, ECDSA, ECGOST3410, GOST3410, ISO9796d2, PSS, RSA.
  • Key Agreement: Diffie-Hellman and EC-DH.
  • Macs: CBCBlockCipher, CFBBlockCipher, GOST28147, HMac, and ISO9797 Alg. 3.
  • PBE generators: PKCS#12, and PKCS#5 - schemes 1 and 2.
  • OpenPGP (RFC 2440)
  • Cryptographic Message Syntax (CMS, RFC 3852), including streaming API.
  • Online Certificate Status Protocol (OCSP, RFC 2560).
  • Time Stamp Protocol (TSP, RFC 3161).
  • TLS/SSL Client with support for client side authentication.
3108 questions
35
votes
2 answers

Android RSA Keypair Generation - Should I use Standard Java/Bouncy Castle/Spongy Castle/JSch/Other?

I've been looking around for about a week+ to implement a method I have in mind. I have came across (and read) many articles on all of these different methods, but I am still left confused, so I was hoping maybe someone can spread their knowledge of…
EGHDK
  • 17,818
  • 45
  • 129
  • 204
33
votes
5 answers

Correct way to sign and verify signature using bouncycastle

I am using bcmail-jdk16-1.46.jar and bcprov-jdk16-1.46.jar (Bouncycastle libraries) to sign a string and then verify the signature. This is my code to sign a string: package my.package; import java.io.FileInputStream; import…
Oscar Jara
  • 14,129
  • 10
  • 62
  • 94
31
votes
2 answers

Where is the Bouncy Castle API documentation?

I need to do some cryptography based work, and I have found out Bouncy Castle API which is both available for C# and Java, for Java it has documentation, but it has no documentation for C#. Can anyone provide me some resources from where I can get…
habibalsaki
  • 1,082
  • 4
  • 13
  • 25
29
votes
3 answers

How to include the Spongy Castle JAR in Android?

Apparently Spongy Castle is the Android alternative to using a full version of Bouncy Castle. However, on importing the jar I'm getting all kinds of "cannot be resolved" errors because it relies on packages not included with Android, primarily…
Nathan Fig
  • 14,970
  • 9
  • 43
  • 57
29
votes
3 answers

C# BouncyCastle - RSA Encryption with Public/Private keys

I need to encrypt data in C# in order to pass it to Java. The Java code belongs to a 3rd party but I have been given the relevant source, so I decided that as the Java uses the Bouncy Castle libs, I will use the C# port. Decryption works fine.…
scudsucker
  • 934
  • 1
  • 10
  • 16
28
votes
7 answers

How do I get started using BouncyCastle?

So after CodingHorror's fun with encryption and the thrashing comments, we are reconsidering doing our own encryption. In this case, we need to pass some information that identifies a user to a 3rd party service which will then call back to a…
Jeff Martin
  • 10,812
  • 7
  • 48
  • 74
28
votes
4 answers

Reliable implementation of PBKDF2-HMAC-SHA256 for JAVA

UPDATED 2019: Bouncycastle now support PBKDF2-HMAC-SHA256 since bouncycastle 1.60 Is there any reliable implementation of PBKDF2-HMAC-SHA256 for JAVA? I used to encrypt using bouncycastle but it does not provide PBKDF2WithHmacSHA256'. I do not want…
dgregory
  • 1,397
  • 1
  • 12
  • 26
28
votes
3 answers

How do I do TLS with BouncyCastle?

Does anybody know about examples of TLS with BouncyCastle? I was surprised by the lack of them on Internet. If there are really none, let's collect them as answers.
Jakub Adamek
  • 881
  • 1
  • 9
  • 10
28
votes
2 answers

Programmatically Obtain KeyStore from PEM

How can one programmatically obtain a KeyStore from a PEM file containing both a certificate and a private key? I am attempting to provide a client certificate to a server in an HTTPS connection. I have confirmed that the client certificate works…
Ryan
  • 7,499
  • 9
  • 52
  • 61
27
votes
3 answers

bouncycastle provider can't find classes needed for algorithm

I'm trying to use bouncycastle to encrypt a file using a public key. I've registered the provider programatically: Security.addProvider(new BouncyCastleProvider()); I created the public key object successfully. when i get to encrypting the file…
Sam
  • 305
  • 1
  • 3
  • 6
27
votes
2 answers

Encrypt string with Bouncy Castle AES/CBC/PKCS7

I have been looking everywhere for some sample code on how to encrypt a simple string with the encryption in the title using the Bouncy Castle Framework. This code will run on a Windows Universal project. My previous attempts to encrypt using the…
timr
  • 6,668
  • 7
  • 47
  • 79
26
votes
5 answers

bouncycastle + JBoss AS7: JCE cannot authenticate the provider BC

I use BouncyCastle for encryption in my application. When I run it standalone, everything works fine. However, if I put it in the webapp and deploy on JBoss server, I get a following error: javax.servlet.ServletException: error constructing MAC:…
mrzasa
  • 22,895
  • 11
  • 56
  • 94
26
votes
4 answers

Self signed X509 Certificate with Bouncy Castle in Java

I need to create a self signed X509 Certificate with Bouncy Castle in Java, but every class I try to include is deprecated. How can I solve this? Is there some other class to include? Thanks
paola91
  • 339
  • 1
  • 5
  • 14
25
votes
2 answers

X.509 Certificate validation with Java and Bouncycastle

through the bouncycastle wiki page I was able to understand how to create a X.509 root certificate and a certification request, but I do not quite understand how to proceed concept- and programming wise after that. Lets assume party A does a cert…
Rob
  • 251
  • 1
  • 3
  • 3
25
votes
2 answers

Generating the CSR using BouncyCastle API

I am new to the security side of Java and stumbled across this library called BouncyCastle. But the examples that they provide and the ones out on the internet ask to use return new PKCS10CertificationRequest("SHA256withRSA", new X500Principal( …
Fox
  • 9,384
  • 13
  • 42
  • 63