Blackberry smartcard reader example

BlackberryCryptographyRsaSmartcardSmartcard Reader

Blackberry Problem Overview


I am writing an app for BlackBerry that utilizes a BlackBerry smartcard reader. There is not much documentation on the subject, so I'd really like if someone could give me starting examples.

Basically, there is one RSA private key on the card plus a certificate (for paired public key). I would like to be able to encrypt/decrypt data and also sign it as well. The final goal would be to establish an mutual-authenticated SSL connection using client certificate contained on the smartcard.

Here is the code I managed to come up with so far:

SmartCardReader btReader = null;
SmartCardReader[] readers = SmartCardReaderFactory.getInstalledReaders();
for (int i = 0; i < readers.length; i++) {
    SmartCardReader reader = readers[i];
    if (reader.getType().equalsIgnoreCase("bluetooth")) {
        btReader = reader;
        break;
    }
}

SmartCardReaderSession readerSession = reader.openSession();
CryptoSmartCard card = (CryptoSmartCard) readerSession.getSmartCard();
RSACryptoToken token = (RSACryptoToken) card.getCryptoToken("RSA");

This token looks promising - has some nice methods, but with "cryptic" arguments. What to do next?

Blackberry Solutions


Solution 1 - Blackberry

I think this is what you are looking for:

http://code.google.com/p/seek-for-android/wiki/BTPCSC

Solution 2 - Blackberry

You have to implement SmartCardSession methods, also implement RSACryptoToken methods. With SmartCardSession methods you will be able to communicate with smart card, and with RSACryptoToken methods, you will be able to perform crypto operations. You have to read also about APDU protocol.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpajtonView Question on Stackoverflow
Solution 1 - Blackberryuser1094607View Answer on Stackoverflow
Solution 2 - BlackberryTarasView Answer on Stackoverflow