Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
division_bell
Posts: 6
Registered: ‎12-20-2011
My Device: 9105
My Carrier: null

Raw RSA signing/decrypting

Hi everyone!

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

Please use plain text.
Developer
streak81
Posts: 204
Registered: ‎08-09-2010
My Device: 9930, PlayBook
My Carrier: Verizon Wireless

Re: Raw RSA signing/decrypting

//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()];
signer.sign(signatureBytes, 0);

 

 

//...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

Please use plain text.
New Contributor
division_bell
Posts: 6
Registered: ‎12-20-2011
My Device: 9105
My Carrier: null

Re: Raw RSA signing/decrypting

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"

Please use plain text.
Developer
anditsung
Posts: 229
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: Raw RSA signing/decrypting

you need to ask rim about signature for RSA.
Please use plain text.
New Contributor
division_bell
Posts: 6
Registered: ‎12-20-2011
My Device: 9105
My Carrier: null

Re: Raw RSA signing/decrypting

Thanks for the answer. But how can I ask RIM about it? 

Is there any way to send them an ask??

Please use plain text.