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

Hohwiller, Jörg <joerg.hohwiller-gM/[email protected]> Sun, 28 Apr 2019 12:29:11 +0200
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
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