Troubleshooting guide
107
5: Using smart cards
Determine if the token supports the
chosen operation using the current crypto
system.
> Create a method that returns a Boolean value that indicates if the token object supports the
current crypto system.
public boolean isSupported( CryptoSystem cryptoSystem, int operation
)
{
return ( operation == PRIVATE_KEY_OPERATION );
}
Determine if the given key and crypto
system support the type of encryption
method.
> Create a method that returns a Boolean value that indicates if the token object supports the
chosen encryption method.
public boolean isSupportedDecryptRSA( RSACryptoSystem cryptoSystem,
CryptoTokenPrivateKeyData privateKeyData )throws
CryptoTokenException
{
return privateKeyData instanceof MyCryptoTokenData;
}
Activate raw decryption. >Create a method that performs raw decryption.
public void decryptRSA( RSACryptoSystem cryptoSystem,
CryptoTokenPrivateKeyData privateKeyData,byte[] input, int
inputOffset,
byte[] output, int outputOffset )throws CryptoTokenException
{
try {//signDecryptHelper is a private helper method. See the code
sample for more information.
signDecryptHelper( cryptoSystem, privateKeyData, input, inputOffset,
output, outputOffset, DECRYPT_DESC,
SmartCardSession.DECRYPT_OPERATION );
}
catch ( CryptoUnsupportedOperationException e ) {
throw new CryptoTokenException( e.toString() );
}
}
Activate raw signing. > Create a method that performs raw signing.
public void signRSA( RSACryptoSystem cryptoSystem,
CryptoTokenPrivateKeyData privateKeyData, byte[] input, int
inputOffset,byte[] output, int outputOffset )
throws CryptoTokenException, CryptoUnsupportedOperationException
{
signDecryptHelper( cryptoSystem, privateKeyData, input, inputOffset,
output, outputOffset, SIGN_DESC, SmartCardSession.SIGN_OPERATION );
}
Task Steps