01-26-2012 11:53 AM
I need help, I'm implementing RSACryptoToken, and I've faced the issue, connected with
decryptRSA and signRSA. According to the documentation, they need to perform raw RSA decrypting and signing.
Does BB provides such API, and how to implement this? Maybe there are any examples.
Thanks in advance
01-26-2012 01:14 PM
//here is how you would use RSA to sign data:
byte dataBytes = [bytes of data to sign];
PKCS1SignatureSigner signer = (PKCS1SignatureSigner) SignatureSignerFactory.getInstance([RSA Private Key], "RSA_PKCS1_V15/SHA1");
signer.update(dataBytes, 0, dataBytes.length);
byte signatureBytes = new byte[signer.getLength()];
//...and to decrypt using RSA...
ByteArrayInputStream inputStream = new ByteArrayInputStream([encrypted bytes]);
BlockDecryptor decryptor = new BlockDecryptor(new PKCS1UnformatterEngine(new RSADecryptorEngine([RSA Private Key])), inputStream);
byte decrypted = IOUtilities.streamToBytes(decryptor);
Take a look at the net.rim.device.api.crypto libraries
01-27-2012 03:50 AM
Thanks for reply!
But it still doesn't help me.
I sign S/MIME message with RSACryptoToken method signRSA, and after signing I get a message from S/MIME:
"Verification failed: invalid signature"