Android KeyStoreException Unknown Error

I found my answer on the Android Issue Tracker; from what I understand the unrestricted PublicKey, created to work around another known issue, becomes incompatible with the current Cipher. The work-around for this is to specify an OAEPParameterSpec when the Cipher is initialized:

OAEPParameterSpec spec = new OAEPParameterSpec(
        "SHA-256", "MGF1", MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT);

mCipher.init(opmode, unrestricted, spec);

Leave a Comment