bouncycastle

X.509 Certificate validation with Java and Bouncycastle

Hi, 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 request and gets his client certificate from the CA. How can some party B validate A's...

how to add bouncycastle algorithm to android

Hi friends, I am trying to write a small application using bouncycastle algorithm, from the http://tinyurl.com/ylclavn (BouncyCastleProvider.java) it says we have to import and add the provider during runtime by the following code import org.bouncycastle.jce.provider.BouncyCastleProvider; Security.addProvider(new BouncyCastleProvider(...

Verify a X.509 certificate with Java ME and Bouncy Castle

Hi, Can anybody point me to an example of verifying a X.509 certificate with Bouncy Castle under Java ME? I can see how to easily do this in Java SE code with java.security.cert.Certificate.verify(), but I could not find an equivalent method in the lightweight BC API. Thanks in advance! Cheers Dino ...

How to read a password encrypted key with java?

Hi, I have private key stored in file in PKCS8 DER format and protected by password. What is the easiest way to read it? Here is the code I use to load unencrypted one: InputStream in = new FileInputStream(privateKeyFilename); byte[] privateKeydata = new byte[in.available()]; in.read(privateKeydata); in.close(); KeyFactory privateKey...

Need example for BouncyCastle PGP File encryption in C#

Hi, I'm trying to encrypt files using my private key (in ascii format) and any other public key (also in ascii format). The BouncyCastle library looks like the correct thing to use, but I cannot find documentation for C#. Could anyone please assist me with an example. Thank you. ...

Creating a Cerificate for Bouncy Castle Encryption

I am trying to create a self-signed certificate to use for encrypting an email using bouncycaste. What would be the best way to generate a certificate? I have tried using openssl but I have had problems with certificate. Here is the code I am using to encrypt, I am using 3des. SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator...

How to use Bouncy Castle to remove a signature from a CMS?

I have a signedCMS, and would like to know how to use Bouncy Castle API to remove the signature so I can have clear access to the plain text file underneath? Thanks ...

Can a product that uses BouncyCastle be exported from the UK

We are doing work for a company, based in the UK, who are planning on developing an application that uses the BouncyCastle.Crypto.dll. They intend to make their product (including the crypto dll) available for download over the Internet. Are there UK restrictions on the export of crypto software that would prevent them from doing this? F...

Object is not created in BouncyCastle

TextReader trCer = new StreamReader("C:\\Test.key.pem"); PemReader rdCer = new PemReader(trCer); X509Certificate Cert = (X509Certificate)rdCer.ReadObject(); //Returns nothing here AsymmetricKeyParameter pk = Cert.GetPublicKey(); //here mark error because pk is null What should I do to get back a valid object? ...

Should I use the bouncy castle libraries or the ones included in Android for AES

I'm writing an android app where I need to use AES. Is it better to use the bouncy castle libraries or should I just stick with what is included in default android libraries? ...

NullPointerException when generating RSA keys with BouncyCastle

public static void main(String[] args) throws Exception { RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator(); AsymmetricCipherKeyPair keyPair = rsaKeyPairGen.generateKeyPair(); } the rsaKeyPairGen is not null, but the generateKeyPair() method is throwing NullPointerException. What may be wrong? Error message: java....

Can't send client certificate via SslStream

I am doing an SSL3 handshake using an SslStream, but, in spite of my best efforts, the SslStream never sends a client certificate on my behalf. Here is the code: SSLConnection = new System.Net.Security.SslStream(SSLInOutStream, false, new System.Net.Security.RemoteCertificateValidationCallback(AlwaysValidRemoteCertificate), new System.N...

How to use Bouncy Castle lightweight API with AES and PBE

I have a block of ciphertext that was created using the JCE algorithim "PBEWithSHA256And256BitAES-CBC-BC". The provider is BouncyCastle. What I'd like to do it decrypt this ciphertext using the BouncyCastle lightweight API. I don't want to use JCE because that requires installing the Unlimited Strength Jurisdiction Policy Files. Documen...

RSA decryption using only D, Exponent and Modulus

I'm trying to decrypt using RSACryptoServiceProvider, but I only have the modulus and d pair as a private key and also the exponent. RsaParameters struct wont make do with these. It rejects me upon decryption with an exception "Bad key". To my understanding, this pair is enough to decrypt without the entire DQ DP INVERSEQ parts. More o...

How to add PrivateKeyUsage extension to a certificate using bouncycastle in java?

i have an X509Certificate that i want to add extensions to... i want to add the PrivateKeyUsage extension, but i dont know how to create a PrivateKeyUsage object or how to give it notBefore & notAfter values ... thanks ...

Bouncy Castle RSA keypair generation using Lightweight API

Surprisingly enough there's very little information on the Web about using Bouncy Castle's lightweight API. After looking around for a while I was able to put together a basic example: RSAKeyPairGenerator generator = new RSAKeyPairGenerator(); generator.init(new RSAKeyGenerationParameters ( new BigInteger("10001", 16),//publ...

PKCS10CertificationRequest creation on android

Hello: I'm very new to android and java both, so hopefully I'm missing something easy here. All I want to do is create a simple PKCS10 certificate signing request. I have some code that will compile and run on my ubuntu box (java-6-openjdk), but throws a null pointer exception in the android emulator: KeyPair myKeyPair = KeyP...

How to properly use Bouncy Castle's OAEPEncoding for RSA (Lightweight API)

I've been playing around with Bouncy Castle's implementation of RSA (Lightweight API) and got the basics figured out. Looking at their spec for JCE provider implementation I noticed that different padding schemes can be used with RSA. From what I understand, by default null padding is used. So I began exploring OAEP padding, particularly...

Hash String via SHA-256 in Java

By looking around here as well as the internet in general, I have found Bouncy Castle. I want to use Bouncy Castle (or some other freely available utility) to generate a SHA-256 Hash of a String in Java. Looking at their documentation I can't seem to find any good examples of what I want to do. Can anybody here help me out? ...

From DEROctetString to KeyUsage

In bouncycastle I can create a DEROctetString starting from a KeyUsage. How can I obtain KeyUsage starting from a DEROctetString then? Example: DEROctetString derString = new DEROctetString(new KeyUsage(KeyUsage.digitalSignature)); KeyUsage ku = ...(some code to get back KeyUsage starting from derString)... I need this because I'm a...