|| output.length < outputOffset + modulusLength) {
throw new IllegalArgumentException();
}
// Construct the response Application Protocol Data Unit.
final ResponseAPDU response = new ResponseAPDU();
// Construct the command and set its information.
// TODO: Create a CommandAPDU which your smart card will understand.
final 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 smart card
sendAPDU(signAPDU, response);
// Validate the status words of the response.
// TODO: Check for response codes specific to your smart card.
if (response.checkStatusWords((byte) 0x90, (byte) 0x00)) {
final 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));
}
}