Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behaviour for signature on Desktop / Android #26

Open
TheBlusky opened this issue Aug 15, 2016 · 0 comments
Open

Different behaviour for signature on Desktop / Android #26

TheBlusky opened this issue Aug 15, 2016 · 0 comments

Comments

@TheBlusky
Copy link

TheBlusky commented Aug 15, 2016

I use the following code in order to sign data:

static public byte[] sign(byte[] data, PrivateKey privateKey, int saltLength) throws Exception {
        Signature instance = Signature.getInstance("SHA256withRSA/PSS", provider);
        MGF1ParameterSpec mgf1ParameterSpec = new MGF1ParameterSpec("SHA-256");
        PSSParameterSpec pssParameterSpec = new PSSParameterSpec("SHA-256", "MGF1",mgf1ParameterSpec , saltLength, 1);
        instance.setParameter(pssParameterSpec);
        instance.initSign(privateKey);
        instance.update(data);
        return instance.sign();
}

(The code is very similar for checking sign)

On desktop (with BC or SC), the code is working fine, and signature can be checked with other platform (tested with python, node, ...).

On Android, the "saltLength" is not read, and is forced to 32bits, so I can't sign / verify signature from device on other platform if another "saltLength" is used. (I verified it by brute-forcing saltLength value on desktop).

I really don't know how to debug it, the very same Java code has different behavior between launched on desktop or Android. Any idea how to force "saltLength" on Android ?

Thanks in advance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant