getKeySize of (PBE) secret key not possible with BC?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

getKeySize of (PBE) secret key not possible with BC?

Hohwiller, Jörg
Hi Legend,

With JCE I can do this to get a PBEKeySpec and then retrieve the key
size back from a secret key:

PBEKeySpec keySpec = (PBEKeySpec) keyFactory.getKeySpec(key,
PBEKeySpec.class);

However, for bouncycastle (with a BCPBEKey) the same fails with:

java.security.spec.InvalidKeySpecException:
java.lang.NoSuchMethodException: javax.crypto.spec.PBEKeySpec.<init>([B)
    at
org.bouncycastle.jcajce.provider.symmetric.util.BaseSecretKeyFactory.engineGetKeySpec(Unknown
Source)
    at javax.crypto.SecretKeyFactory.getKeySpec(SecretKeyFactory.java:374)

Can you give me a hint how to retrieve the key size back from a secret
key with bouncy castle?

(Of course I could use reflection on the BCPBEKey object, but I would
like to find an official API to do it)

Thanks in advance

  Jörg