Troubleshooting guide

106
BlackBerry Java Development Environment Development Guide
if ( ( input.length < inputOffset + modulusLength ) || ( output.length <
outputOffset + modulusLength ) ) {
throw new IllegalArgumentException();
}
// Construct the response Application Protocol Data Unit
ResponseAPDU response = new ResponseAPDU();
// Construct the command and set its information
// Create a CommandAPDU which your smart card will understand
CommandAPDU signAPDU = new CommandAPDU( (byte)0x80, (byte)0x56, (byte)0x00,
(byte)0x00, modulusLength );
signAPDU.setLcData( input, inputOffset, input.length - inputOffset );
// Send the command to the smartcard
sendAPDU( signAPDU, response );
// Validate the status words of the response
// Check for response codes specific to your smart card
if ( response.checkStatusWords( (byte)0x90, (byte)0x00 ) ) {
byte [] responseData = response.getData();
System.arraycopy( responseData, 0, output, outputOffset, responseData.length );
}
else {
throw new SmartCardException( “Invalid response code, sw1=” +
Integer.toHexString( response.getSW1() & 0xff ) + “ sw2=” + Integer.toHexString(
response.getSW2() & 0xff ) );
}
}
}
Create a CryptoToken for private key operations
Task Steps
Create a token class. > In your application, create a class that extends an RSA, DSA, or ECC token class. For example:
final class MyRSACryptoToken extends RSACryptoToken implements
Persistable
Determine if the token can perform
BlackBerry® device user authentication.
> Create a method that returns true if your token class prompts the BlackBerry device user for
authentication information.
public boolean providesUserAuthentication()
{
return true;
}