21
3: Code samples
if ( zeros != 0 ) {
array = Arrays.copy( array, zeros, array.length - zeros );
}
int length = array.length;
if( length > 8 ) {
throw new IllegalArgumentException();
}
long n = 0;
for( int i=0; i<length; i++ ) {
n <<= 8;
n += array[i] & 0xff;
}
return n;
}
/**
* Retrieve some random data from the smart cards internal Random Number Generator.
*/
protected byte [] getRandomBytesImpl( int maxBytes ) throws SmartCardException
{
// Create a CommandAPDU which your smart card will understand
CommandAPDU command = new CommandAPDU( (byte)0x00, (byte)0x4C, (byte)0x00,
(byte)0x00, maxBytes );
ResponseAPDU response = new ResponseAPDU();
sendAPDU( command, response );
// Check for response codes specific to your smart card
if( response.checkStatusWords( (byte)0x90, (byte)0x00 ) ) {
// The appropriate response code containing the random data
return response.getData();
}
return null;
}
/**
* Retrieve certificates from the card.
*
* @return An array of certificates which are present on the card.
*/
protected CryptoSmartCardKeyStoreData[] getKeyStoreDataArrayImpl() throws
SmartCardException, CryptoTokenException
{
try {
// Show a progress dialog to the user as this operation may take a long time.
displayProgressDialog( WAITING_MSG, 4 );
// The certificates need to be associated with a particular card.
SmartCardID smartCardID = getSmartCardID();
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE
Page 4: ......
Page 6: ......
Page 14: ...10 Cryptographic Smart Card Driver Development Guide...
Page 17: ...13 2 Testing a cryptographic smart card driver...
Page 18: ...14 Cryptographic Smart Card Driver Development Guide...
Page 34: ...30 Cryptographic Smart Card Driver Development Guide...
Page 35: ......
Page 36: ...2007 Research In Motion Limited Published in Canada...