android java, PBKDF2with8BIT implementation not found

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

android java, PBKDF2with8BIT implementation not found

redwave
Hi,

I am developing with Box.net API (json web token[JWT]) on android and it
uses bouncycastle for decrypting its private key.

I had imported the following jar files:
bcpg-jdk15on-162.jar
bcpkix-jdk15on-162.jar
bcprov-ext-jdk15on-162.jar
bctls-jdk15on-162.jar

below is the code copied from the box.net example code.

Security.addProvider(new BouncyCastleProvider());

        // Using BouncyCastle's PEMParser we convert the
        // encrypted private key into a keypair object
        PEMParser pemParser = new PEMParser(
                new
StringReader(boxCredSettings.boxAppSettings.appAuth.privateKey)
        );
        Object keyPair = pemParser.readObject();


        // Finally, we decrypt the key using the passphrase
        char[] passphrase =
boxCredSettings.boxAppSettings.appAuth.passphrase.toCharArray();
        JceOpenSSLPKCS8DecryptorProviderBuilder decryptBuilder =
                new
JceOpenSSLPKCS8DecryptorProviderBuilder().setProvider("BC");
        InputDecryptorProvider decryptProvider
                = decryptBuilder.build(passphrase);

        PrivateKeyInfo keyInfo
                = ((PKCS8EncryptedPrivateKeyInfo)
keyPair).decryptPrivateKeyInfo(decryptProvider);

        // In the end, we will use this key in the next steps
        key = (new JcaPEMKeyConverter()).getPrivateKey(keyInfo);

        pemParser.close();

The error is from decryptPrivateKeyInfo() function.

here is the following error:
org.bouncycastle.pkcs.PKCSException: unable to read encrypted data:
1.2.840.113549.1.5.13 not available: SecretKeyFactory PBKDF2with8BIT
implementation not found



--
Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html

Reply | Threaded
Open this post in threaded view
|

Re: android java, PBKDF2with8BIT implementation not found

cryptearth
Hey,

Android ships with its own modified/cut-down version of BouncyCastle not
contain all the "normal" release has - hence a fork "SpongyCastle" was
done wich provides a "re-release" of BC on a different name scheme to
avoid conflicts. Give it a try.

Matt

Am 02.08.2019 um 07:08 schrieb redwave:

> Hi,
>
> I am developing with Box.net API (json web token[JWT]) on android and it
> uses bouncycastle for decrypting its private key.
>
> I had imported the following jar files:
> bcpg-jdk15on-162.jar
> bcpkix-jdk15on-162.jar
> bcprov-ext-jdk15on-162.jar
> bctls-jdk15on-162.jar
>
> below is the code copied from the box.net example code.
>
> Security.addProvider(new BouncyCastleProvider());
>
>          // Using BouncyCastle's PEMParser we convert the
>          // encrypted private key into a keypair object
>          PEMParser pemParser = new PEMParser(
>                  new
> StringReader(boxCredSettings.boxAppSettings.appAuth.privateKey)
>          );
>          Object keyPair = pemParser.readObject();
>
>
>          // Finally, we decrypt the key using the passphrase
>          char[] passphrase =
> boxCredSettings.boxAppSettings.appAuth.passphrase.toCharArray();
>          JceOpenSSLPKCS8DecryptorProviderBuilder decryptBuilder =
>                  new
> JceOpenSSLPKCS8DecryptorProviderBuilder().setProvider("BC");
>          InputDecryptorProvider decryptProvider
>                  = decryptBuilder.build(passphrase);
>
>          PrivateKeyInfo keyInfo
>                  = ((PKCS8EncryptedPrivateKeyInfo)
> keyPair).decryptPrivateKeyInfo(decryptProvider);
>
>          // In the end, we will use this key in the next steps
>          key = (new JcaPEMKeyConverter()).getPrivateKey(keyInfo);
>
>          pemParser.close();
>
> The error is from decryptPrivateKeyInfo() function.
>
> here is the following error:
> org.bouncycastle.pkcs.PKCSException: unable to read encrypted data:
> 1.2.840.113549.1.5.13 not available: SecretKeyFactory PBKDF2with8BIT
> implementation not found
>
>
>
> --
> Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html
>


Reply | Threaded
Open this post in threaded view
|

Re: android java, PBKDF2with8BIT implementation not found

redwave
Hi, Good Day;

After trying out the android version of the BouncyCastle, I was able to
decrypt the key and get the needed value to proceed further with using the
BOX API.

Thank you very much
Red



--
Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html