[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    Re: [dev-crypto] JDKKeyStore file format-what is it?
From:       Matthew Hall <mhall () mhcomputing ! net>
Date:       2013-04-29 15:50:24
Message-ID: 6356c756-2772-49ff-a4c3-cae295ba78c6 () email ! android ! com
[Download RAW message or body]

That should work, try storing and then reloading from JKS and see if the key works afterward. But PrivateKeyFactory might be easier. In my case I use the JDK PKCS11 provider for my keys because it runs fast in libnss optimized C code so I am not quite as familiar with BC cipher objects.
-- 
Sent from my mobile device.

Chris Oman <COman@ext-inc.com> wrote:

>Well, after some more twiddling, this is what I came up with. Does this
>look correct?
>
> RSAKeyParameters privateKey = (RSAKeyParameters) keyPair.getPrivate();
>RSAPrivateKeySpec privateKeySpec = new
>RSAPrivateKeySpec(privateKey.getModulus(), privateKey.getExponent());
>PrivateKey jPrivateKey =
>KeyFactory.getInstance("RSA").generatePrivate(privateKeySpec);
>
>
>On Apr 29, 2013, at 8:22 AM, Chris Oman <COman@ext-inc.com> wrote:
>
>> I thought that was what I needed to do, but I can't figure out how to
>get from the private key in the AsymmetricCipherKeyPair to a
>java.security.Key. Any hints on that?
>> 
>> 
>> On Apr 26, 2013, at 5:15 PM, Matthew Hall <mhall@mhcomputing.net>
>wrote:
>> 
>>> On Fri, Apr 26, 2013 at 01:09:46PM -0700, Chris Oman wrote:
>>>>      JDKKeyStore keystore = new JDKKeyStore();
>>>>      keystore.engineSetKeyEntry("default", privateKey.getEncoded(),
>>>>              new Certificate[]{x509CertificateObject});
>>> 
>>> Chris,
>>> 
>>> This part of JCE isn't documented so well but I had to figure it out
>a few
>>> weeks ago also.
>>> 
>>> This one you tried above is going to be a Bouncy Castle style
>KeyStore which
>>> is a different kind of file.
>>> 
>>> To get Java style KeyStore, JKS or JCEKS, try this:
>>> 
>>> KeyStore.getInstance("JKS");
>>> KeyStore.getInstance("JCEKS");
>>> 
>>> That should give you one that'll work with keytool.
>>> 
>>> Matthew.
>> 
>> 
>> Chris Oman
>> Lead Developer - Interfaces
>> EXTENSION, INC.
>> Email:   COman@ext-inc.com
>> Office:  260-797-0200
>> General: 877-207-3753
>> www.OpenTheRedBox.com
>> 
>> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic