Page 1 of 1

Get a CryptoException when creating signature

Posted: Mon Feb 29, 2016 1:56 am
by pitbar
I am going to create a signature. But I get a CryptoException with ReasonCode IllegalUse. Could someone tell me what happened? Did I make a mistake?
And here is my code.

Code: Select all

signature = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1, false);
byte[] mSignature = new byte[20];
byte[] m = {0x01, 0x02, 0x04, 0x05, 0x06, 0x07};
signature.sign(m, (short) 0, (short)m.length, mSignature, (short) 0);

Re: Get a CryptoException when creating signature

Posted: Wed Mar 02, 2016 6:15 am
by horse dream
Remember to initialize the signature instance with a signing key.

If convenient, could you post the complete code of your applet?