net.rim.device.api.crypto
Class RSACryptoToken

java.lang.Object
  extended by net.rim.device.api.crypto.RSACryptoToken
All Implemented Interfaces:
AsymmetricCryptoToken, CryptoToken, Persistable
Direct Known Subclasses:
SmartCardRSACryptoToken

public abstract class RSACryptoToken
extends Object
implements AsymmetricCryptoToken, Persistable

A class for RSA cryptographic tokens to extend. The RIM Crypto API will call this class when an RSA operation is to be performed on a RSA enabled cryptographic token.

A description of the RSA algorithm can be found in PKCS #1 version 2.1. We support this definition of RSA.

Note: This class must be extended in order to override the default implementation.

Note: It is considered good practice to implement the equals and hashCode methods when extending this class. Otherwise, odd behaviour can occur.

Details on implementing for smart cards.

See Also:
CryptoToken
Since:
BlackBerry API 3.6.0

Field Summary
 
Fields inherited from interface net.rim.device.api.crypto.AsymmetricCryptoToken
KEY_GENERATION, PRIVATE_KEY_OPERATION, PUBLIC_KEY_OPERATION
 
Constructor Summary
protected RSACryptoToken()
          Creates a new RSACryptoToken object.
 
Method Summary
 RSAKeyPair createRSAKeyPair(RSACryptoSystem cryptoSystem, byte[] e)
          Creates a key pair given a crypto system and a byte array containing e.
 void decryptRSA(RSACryptoSystem cryptoSystem, CryptoTokenPrivateKeyData privateKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset)
          Performs a raw RSA decryption operation.
 void decryptRSA(RSACryptoSystem cryptoSystem, CryptoTokenPrivateKeyData privateKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset, Object context)
          Performs a raw RSA decryption operation.
 void deleteRSAPrivateKey(CryptoTokenPrivateKeyData data)
          Delete the specified key on the crypto token.
 void deleteRSAPublicKey(CryptoTokenPublicKeyData data)
          Delete the specified key on the crypto token.
 void encryptRSA(RSACryptoSystem cryptoSystem, CryptoTokenPublicKeyData publicKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset)
          Performs a raw RSA encryption operation.
 byte[] extractRSAPrivateKeyD(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'd' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyDModPm1(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'd mod (p-1)' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyDModQm1(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'd mod (q-1)' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyE(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'e' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyN(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'n' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyP(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'p' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyQ(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'q' RSA parameter, or null if not available.
 byte[] extractRSAPrivateKeyQInvModP(CryptoTokenPrivateKeyData cryptoTokenData)
          Returns the 'q^(-1) mod p' RSA parameter, or null if not available.
 byte[] extractRSAPublicKeyE(CryptoTokenPublicKeyData cryptoTokenData)
          Returns the 'e' RSA parameter, or null if not available.
 byte[] extractRSAPublicKeyN(CryptoTokenPublicKeyData cryptoTokenData)
          Returns the 'n' RSA parameter, or null if not available.
 String getAlgorithm()
          Returns the algorithm supported by this token, ie "RSA".
 RSACryptoSystem[] getSuggestedRSACryptoSystems()
          Returns a list of supported or suggested crypto systems.
 CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem, byte[] e, byte[] d, byte[] n)
          Inserts (or injects) the key onto the crypto token.
 CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem, byte[] e, byte[] d, byte[] p, byte[] q)
          Inserts (or injects) the key onto the crypto token.
 CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem, byte[] e, byte[] p, byte[] q, byte[] dModPm1, byte[] dModQm1, byte[] qInvModP)
          Inserts (or injects) the key onto the crypto token.
 CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem, byte[] e, byte[] d, byte[] n, byte[] p, byte[] q, byte[] dModPm1, byte[] dModQm1, byte[] qInvModP)
          Inserts (or injects) the key onto the crypto token.
 CryptoTokenPublicKeyData injectRSAPublicKey(RSACryptoSystem cryptoSystem, byte[] e, byte[] n)
          Inserts (or injects) the key onto the crypto token.
 boolean isSupported(CryptoSystem cryptoSystem, int operation)
          Indicates whether the chosen operation is supported by this CryptoToken using the provided CryptoSytem.
 boolean isSupportedDecryptRSA(RSACryptoSystem cryptoSystem, CryptoTokenPrivateKeyData privateKeyData)
          Returns a boolean that determines if the given key and crypto system support RSA encryption.
 boolean isSupportedEncryptRSA(RSACryptoSystem cryptoSystem, CryptoTokenPublicKeyData publicKeyData)
          Returns a boolean that determines if the given key and crypto system support RSA encryption.
 boolean providesUserAuthentication()
          Returns true if the token provides its own user authentication checks, eg a smartcard will prompt for a password before allowing access to the keys.
 void signRSA(RSACryptoSystem cryptoSystem, CryptoTokenPrivateKeyData privateKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset)
          Performs a raw RSA signature operation.
 void signRSA(RSACryptoSystem cryptoSystem, CryptoTokenPrivateKeyData privateKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset, Object context)
          Performs a raw RSA signature operation.
 void verifyRSA(RSACryptoSystem cryptoSystem, CryptoTokenPublicKeyData publicKeyData, byte[] input, int inputOffset, byte[] output, int outputOffset)
          Performs a raw RSA verification operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

RSACryptoToken

protected RSACryptoToken()
Creates a new RSACryptoToken object.

This constructor is not used.

Since:
BlackBerry API 3.6.0


Method Detail

getAlgorithm

public final String getAlgorithm()
Returns the algorithm supported by this token, ie "RSA".

Specified by:
getAlgorithm in interface CryptoToken
Returns:
A String that represents the name of the algorithm.
Since:
BlackBerry API 3.6.0

providesUserAuthentication

public boolean providesUserAuthentication()
Returns true if the token provides its own user authentication checks, eg a smartcard will prompt for a password before allowing access to the keys. This default implementation returns false.

Specified by:
providesUserAuthentication in interface CryptoToken
Returns:
true if the user will be authenticated by the token itself.
Since:
BlackBerry API 3.6.0

extractRSAPublicKeyE

public byte[] extractRSAPublicKeyE(CryptoTokenPublicKeyData cryptoTokenData)
                            throws CryptoTokenException,
                                   CryptoUnsupportedOperationException
Returns the 'e' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The public key data associated with the token.
Returns:
A byte array containing e.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPublicKeyN

public byte[] extractRSAPublicKeyN(CryptoTokenPublicKeyData cryptoTokenData)
                            throws CryptoTokenException,
                                   CryptoUnsupportedOperationException
Returns the 'n' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The public key data associated with the token.
Returns:
A byte array containing n.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyE

public byte[] extractRSAPrivateKeyE(CryptoTokenPrivateKeyData cryptoTokenData)
                             throws CryptoTokenException,
                                    CryptoUnsupportedOperationException
Returns the 'e' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The priavte key data associated with the token.
Returns:
A byte array containing e.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyN

public byte[] extractRSAPrivateKeyN(CryptoTokenPrivateKeyData cryptoTokenData)
                             throws CryptoTokenException,
                                    CryptoUnsupportedOperationException
Returns the 'n' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The private key data associated with the token.
Returns:
A byte array containing n.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyD

public byte[] extractRSAPrivateKeyD(CryptoTokenPrivateKeyData cryptoTokenData)
                             throws CryptoTokenException,
                                    CryptoUnsupportedOperationException
Returns the 'd' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The private key data associated with the token.
Returns:
A byte array containing d.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyP

public byte[] extractRSAPrivateKeyP(CryptoTokenPrivateKeyData cryptoTokenData)
                             throws CryptoTokenException,
                                    CryptoUnsupportedOperationException
Returns the 'p' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The public key data associated with the token.
Returns:
A byte array containing p.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyQ

public byte[] extractRSAPrivateKeyQ(CryptoTokenPrivateKeyData cryptoTokenData)
                             throws CryptoTokenException,
                                    CryptoUnsupportedOperationException
Returns the 'q' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The private key data associated with the token.
Returns:
A byte array containing q.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyDModPm1

public byte[] extractRSAPrivateKeyDModPm1(CryptoTokenPrivateKeyData cryptoTokenData)
                                   throws CryptoTokenException,
                                          CryptoUnsupportedOperationException
Returns the 'd mod (p-1)' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The public key data associated with the token.
Returns:
A byte array containing DModPm1.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyDModQm1

public byte[] extractRSAPrivateKeyDModQm1(CryptoTokenPrivateKeyData cryptoTokenData)
                                   throws CryptoTokenException,
                                          CryptoUnsupportedOperationException
Returns the 'd mod (q-1)' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The public key data associated with the token.
Returns:
A byte array containing DModQm1.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

extractRSAPrivateKeyQInvModP

public byte[] extractRSAPrivateKeyQInvModP(CryptoTokenPrivateKeyData cryptoTokenData)
                                    throws CryptoTokenException,
                                           CryptoUnsupportedOperationException
Returns the 'q^(-1) mod p' RSA parameter, or null if not available.

Parameters:
cryptoTokenData - The private key data associated with the token.
Returns:
A byte array containing QInvModP.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

isSupported

public boolean isSupported(CryptoSystem cryptoSystem,
                           int operation)
Indicates whether the chosen operation is supported by this CryptoToken using the provided CryptoSytem.

Specified by:
isSupported in interface AsymmetricCryptoToken
Parameters:
cryptoSystem - The CryptoSystem to check against.
operation - An integer, either KEY_GENERATION, PUBLIC_KEY_OPERATION, PRIVATE_KEY_OPERATION, or some other value specific to the cryptosystem that indicates the operation to be checked.
Since:
BlackBerry API 3.6.0

getSuggestedRSACryptoSystems

public RSACryptoSystem[] getSuggestedRSACryptoSystems()
                                               throws CryptoTokenException,
                                                      CryptoUnsupportedOperationException
Returns a list of supported or suggested crypto systems.

This list does not have to be exhaustive.

Returns:
An array of crypto systems.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

createRSAKeyPair

public RSAKeyPair createRSAKeyPair(RSACryptoSystem cryptoSystem,
                                   byte[] e)
                            throws InvalidKeyException,
                                   CryptoTokenException,
                                   CryptoUnsupportedOperationException,
                                   UnsupportedCryptoSystemException
Creates a key pair given a crypto system and a byte array containing e.

Parameters:
cryptoSystem - The crypto system associated with the key.
e - A byte array containing e. null indicates to use the default value for e
Returns:
The RSAKeyPair.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

injectRSAPublicKey

public CryptoTokenPublicKeyData injectRSAPublicKey(RSACryptoSystem cryptoSystem,
                                                   byte[] e,
                                                   byte[] n)
                                            throws InvalidKeyException,
                                                   CryptoTokenException,
                                                   CryptoUnsupportedOperationException,
                                                   UnsupportedCryptoSystemException
Inserts (or injects) the key onto the crypto token.

Parameters:
cryptoSystem - The crypto system associated with the token.
e - A byte array containing e.
n - A byte array containing n.
Returns:
The public key data associated with the crypto token.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

injectRSAPrivateKey

public CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem,
                                                     byte[] e,
                                                     byte[] d,
                                                     byte[] n)
                                              throws InvalidKeyException,
                                                     CryptoTokenException,
                                                     CryptoUnsupportedOperationException,
                                                     UnsupportedCryptoSystemException
Inserts (or injects) the key onto the crypto token.

Parameters:
cryptoSystem - The crypto system associated with the token.
e - A byte array containing e.
d - A byte array containing d.
n - A byte array containing n.
Returns:
The private key data associated with the crypto token.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

injectRSAPrivateKey

public CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem,
                                                     byte[] e,
                                                     byte[] d,
                                                     byte[] p,
                                                     byte[] q)
                                              throws InvalidKeyException,
                                                     CryptoTokenException,
                                                     CryptoUnsupportedOperationException,
                                                     UnsupportedCryptoSystemException
Inserts (or injects) the key onto the crypto token.

Parameters:
cryptoSystem - The crypto system associated with the token.
e - A byte array containing e.
d - A byte array containing d.
p - A byte array containing p.
q - A byte array containing q.
Returns:
The private key data associated with the crypto token.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

injectRSAPrivateKey

public CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem,
                                                     byte[] e,
                                                     byte[] p,
                                                     byte[] q,
                                                     byte[] dModPm1,
                                                     byte[] dModQm1,
                                                     byte[] qInvModP)
                                              throws InvalidKeyException,
                                                     CryptoTokenException,
                                                     CryptoUnsupportedOperationException,
                                                     UnsupportedCryptoSystemException
Inserts (or injects) the key onto the crypto token.

Parameters:
cryptoSystem - The crypto system associated with the token.
e - A byte array containing e.
p - A byte array containing p.
q - A byte array containing q.
dModPm1 - A byte array containing d mod p - 1.
dModQm1 - A byte array containing d mod q - 1.
qInvModP - A byte array containing q inverse mod p.
Returns:
The private key data associated with the crypto token.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

injectRSAPrivateKey

public CryptoTokenPrivateKeyData injectRSAPrivateKey(RSACryptoSystem cryptoSystem,
                                                     byte[] e,
                                                     byte[] d,
                                                     byte[] n,
                                                     byte[] p,
                                                     byte[] q,
                                                     byte[] dModPm1,
                                                     byte[] dModQm1,
                                                     byte[] qInvModP)
                                              throws InvalidKeyException,
                                                     CryptoTokenException,
                                                     CryptoUnsupportedOperationException,
                                                     UnsupportedCryptoSystemException
Inserts (or injects) the key onto the crypto token.

Parameters:
cryptoSystem - The crypto system associated with the token.
e - A byte array containing e.
d - A byte array containing d.
n - A byte array containing n.
p - A byte array containing p.
q - A byte array containing q.
dModPm1 - A byte array containing d mod p - 1.
dModQm1 - A byte array containing d mod q - 1.
qInvModP - A byte array containing q inverse mod p.
Returns:
The private key data associated with the crypto token.
Throws:
InvalidKeyException - Thrown if the specified key is invalid.
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
UnsupportedCryptoSystemException - Thrown if the specified crypto system is specified.
Since:
BlackBerry API 3.6.0

deleteRSAPublicKey

public void deleteRSAPublicKey(CryptoTokenPublicKeyData data)
                        throws CryptoTokenException,
                               CryptoUnsupportedOperationException
Delete the specified key on the crypto token.

Parameters:
data - The key data contained within the token.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

deleteRSAPrivateKey

public void deleteRSAPrivateKey(CryptoTokenPrivateKeyData data)
                         throws CryptoTokenException,
                                CryptoUnsupportedOperationException
Delete the specified key on the crypto token.

Parameters:
data - The key data contained within the token.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0

isSupportedEncryptRSA

public boolean isSupportedEncryptRSA(RSACryptoSystem cryptoSystem,
                                     CryptoTokenPublicKeyData publicKeyData)
                              throws CryptoTokenException
Returns a boolean that determines if the given key and crypto system support RSA encryption.

Parameters:
cryptoSystem - The crypto system to check.
publicKeyData - The public key data.
Returns:
A boolean that indicates if this token supports RSA encryption.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
BlackBerry API 3.6.0

encryptRSA

public void encryptRSA(RSACryptoSystem cryptoSystem,
                       CryptoTokenPublicKeyData publicKeyData,
                       byte[] input,
                       int inputOffset,
                       byte[] output,
                       int outputOffset)
                throws CryptoTokenException
Performs a raw RSA encryption operation.

Parameters:
cryptoSystem - The crypto system to check.
publicKeyData - The RSA public key data.
input - The input data.
inputOffset - The offset in the input data to begin reading from
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
Since:
BlackBerry API 3.6.0

isSupportedDecryptRSA

public boolean isSupportedDecryptRSA(RSACryptoSystem cryptoSystem,
                                     CryptoTokenPrivateKeyData privateKeyData)
                              throws CryptoTokenException
Returns a boolean that determines if the given key and crypto system support RSA encryption.

Parameters:
cryptoSystem - The crypto system to check.
privateKeyData - The private key data.
Returns:
A boolean that indicates if the token supports RSA encryption.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
BlackBerry API 3.6.0

decryptRSA

public void decryptRSA(RSACryptoSystem cryptoSystem,
                       CryptoTokenPrivateKeyData privateKeyData,
                       byte[] input,
                       int inputOffset,
                       byte[] output,
                       int outputOffset)
                throws CryptoTokenException
Performs a raw RSA decryption operation.

Notes: The token should do a raw RSA private key operation on the input data to reveal the plaintext bytes. The plaintext byes will typically be padded; the type of padding will depend on the application which encrypted the data. Typically PKCS #1 version 2.0 will be used for padding the data, but other schemes (such as OAEP) could be used. If the token removes the padding this method will need to re-add the same type of padding before returning. Data encrypted with BlackBerry's S/MIME implementation currently uses PKCS #1 padding but may use other padding methods in the future.

Parameters:
cryptoSystem - The crypto system associated with the token.
privateKeyData - The RSA private key.
input - The input data.
inputOffset - The offset in the input data to begin reading from.
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
BlackBerry API 3.6.0

decryptRSA

public void decryptRSA(RSACryptoSystem cryptoSystem,
                       CryptoTokenPrivateKeyData privateKeyData,
                       byte[] input,
                       int inputOffset,
                       byte[] output,
                       int outputOffset,
                       Object context)
                throws CryptoTokenException
Performs a raw RSA decryption operation.

Notes: The token should do a raw RSA private key operation on the input data to reveal the plaintext bytes. The plaintext byes will typically be padded; the type of padding will depend on the application which encrypted the data. Typically PKCS #1 version 2.0 will be used for padding the data, but other schemes (such as OAEP) could be used. If the token removes the padding this method will need to re-add the same type of padding before returning. Data encrypted with BlackBerry's S/MIME implementation currently uses PKCS #1 padding but may use other padding methods in the future.

Parameters:
cryptoSystem - The crypto system associated with the token.
privateKeyData - The RSA private key.
input - The input data.
inputOffset - The offset in the input data to begin reading from.
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
context - The context object.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
BlackBerry API 5.0.0

signRSA

public void signRSA(RSACryptoSystem cryptoSystem,
                    CryptoTokenPrivateKeyData privateKeyData,
                    byte[] input,
                    int inputOffset,
                    byte[] output,
                    int outputOffset)
             throws CryptoTokenException,
                    CryptoUnsupportedOperationException
Performs a raw RSA signature operation.

Notes: The token should do a raw RSA private key operation on the input data. The input data will typically be padded; the type of padding will depend on the application requesting the signature. Typically PKCS #1 version 2.0 will be used for padding the data, but other schemes (such as PSS or ANSI X9.31) could be used. If the token requires that the padding be removed before signing, this method will need to detect the type of padding currently being used and remove it. The token should only re-apply the same type of padding which was originally applied to the data. If the token is unable to re-apply the same type of padding an UnsupportedOperationException should be thrown. Signature requests which come from BlackBerry's S/MIME implementation currently use PKCS #1 padding but may use other padding methods in the future.

Parameters:
cryptoSystem - The crypto system associated with the token.
privateKeyData - The RSA private key.
input - The input data.
inputOffset - The offset in the input data to begin reading from.
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation or if the token does not support signing due to the type of padding around the encoded message.
Since:
BlackBerry API 3.6.0

signRSA

public void signRSA(RSACryptoSystem cryptoSystem,
                    CryptoTokenPrivateKeyData privateKeyData,
                    byte[] input,
                    int inputOffset,
                    byte[] output,
                    int outputOffset,
                    Object context)
             throws CryptoTokenException,
                    CryptoUnsupportedOperationException
Performs a raw RSA signature operation. This function is intended to be used by the user authenticator framework.

Notes: The token should do a raw RSA private key operation on the input data. The input data will typically be padded; the type of padding will depend on the application requesting the signature. Typically PKCS #1 version 2.0 will be used for padding the data, but other schemes (such as PSS or ANSI X9.31) could be used. If the token requires that the padding be removed before signing, this method will need to detect the type of padding currently being used and remove it. The token should only re-apply the same type of padding which was originally applied to the data. If the token is unable to re-apply the same type of padding an UnsupportedOperationException should be thrown. Signature requests which come from BlackBerry's S/MIME implementation currently use PKCS #1 padding but may use other padding methods in the future.

Parameters:
cryptoSystem - The crypto system associated with the token.
privateKeyData - The RSA private key.
input - The input data.
inputOffset - The offset in the input data to begin reading from.
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
context - The context object.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation or if the token does not support signing due to the type of padding around the encoded message.
Since:
BlackBerry API 4.2.0

verifyRSA

public void verifyRSA(RSACryptoSystem cryptoSystem,
                      CryptoTokenPublicKeyData publicKeyData,
                      byte[] input,
                      int inputOffset,
                      byte[] output,
                      int outputOffset)
               throws CryptoTokenException,
                      CryptoUnsupportedOperationException
Performs a raw RSA verification operation.

Parameters:
cryptoSystem - The crypto system associated with the token.
publicKeyData - The RSA public key.
input - The input data.
inputOffset - The offset in the input data to begin reading from.
output - The buffer for the output data.
outputOffset - The offset in the output buffer to begin writing at.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
Since:
BlackBerry API 3.6.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal