androidrsaspongycastle

UnsupportedOperationException raised on Android 4.4 when signing/checking signature using SpongyCastle


The following piece of code throws an UnsupportedOperationException when executed on Android 4.4 but it works fine on Android 5 and 6 (tested on device and emulator). The exception is thrown on the setParameter.

    Signature signature = Signature.getInstance("SHA256withRSA/PSS", "SC");
    PSSParameterSpec spec1 = new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1);
    signature.setParameter(spec1);

I am using Spongy Castle to be able to use SHA256withRSA/PSS.

Any idea why?


Solution

  • In the android open source project issue 63139 documents this exact error. This occurs for any android version below 5.0. Specifically, "The implementation of private static SignatureImpl class(line 590) lacks one of the engineSetParameter implementations." Please read the issue report for more information.

    https://code.google.com/p/android/issues/detail?id=63139