net.rim.device.api.crypto
Class HMACCryptoToken

java.lang.Object
  extended by net.rim.device.api.crypto.HMACCryptoToken
All Implemented Interfaces:
CryptoToken, SymmetricCryptoToken, Persistable, Persistable

public abstract class HMACCryptoToken
extends Object
implements SymmetricCryptoToken, Persistable

Implements the HMAC crypto token.

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.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

Constructor Summary
Category: Signed protected HMACCryptoToken()
          Creates a new HMACCryptoToken object.
 
Method Summary
Category: Signed  CryptoTokenMACKeyData createKey(int length)
          Creates a key of a specified length on the crypto token.
Category: Signed  void deleteKey(CryptoTokenMACKeyData data)
          Delete the specified key on the crypto token.
Category: Signed  byte[] extractKeyData(CryptoTokenMACKeyData cryptoTokenData)
          Returns the key data contained in the crypto token.
Category: Signed  int extractKeyLength(CryptoTokenMACKeyData cryptoTokenData)
          Returns the key length of the crypto token.
Category: Signed  String getAlgorithm()
          Returns the algorithm supported by this token, ie "HMAC".
Category: Signed  int getMAC(CryptoTokenMACContext context, byte[] buffer, int offset, boolean reset)
          Returns the Message Authetication Code (MAC) associated with the crypto token.
Category: Signed  CryptoTokenMACContext initialize(CryptoTokenMACKeyData keyData, Digest digest)
          Initializes the crypto token.
Category: Signed  CryptoTokenMACKeyData injectKey(byte[] key, int offset, int length)
          Injects the specified raw key data into the crypto token.
Category: Signed  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.
Category: Signed  void reset(CryptoTokenMACContext context)
          Resets the crypto token.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

HMACCryptoToken

protected HMACCryptoToken()
Creates a new HMACCryptoToken object.

This constructor is not used.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Method Detail

getAlgorithm

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

This method will always return the String "HMAC".

Specified by:
getAlgorithm in interface CryptoToken
Returns:
A String that represents the name of the algorithm.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
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.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

extractKeyLength

public int extractKeyLength(CryptoTokenMACKeyData cryptoTokenData)
                     throws CryptoUnsupportedOperationException,
                            CryptoTokenException
Returns the key length of the crypto token.

Parameters:
cryptoTokenData - The data associated with the crypto token.
Returns:
An integer that represents the length of the key.
Throws:
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

extractKeyData

public byte[] extractKeyData(CryptoTokenMACKeyData cryptoTokenData)
                      throws CryptoUnsupportedOperationException,
                             CryptoTokenException
Returns the key data contained in the crypto token.

Parameters:
cryptoTokenData - The data associated with the crypto token.
Returns:
An integer that represents the length of the key.
Throws:
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

initialize

public CryptoTokenMACContext initialize(CryptoTokenMACKeyData keyData,
                                        Digest digest)
                                 throws CryptoUnsupportedOperationException,
                                        CryptoTokenException
Initializes the crypto token.

Parameters:
keyData - The key data associated with the crypto token.
digest - The digest used to initialize the crypto token.
Returns:
The CryptoTokenMACContext object.
Throws:
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

reset

public void reset(CryptoTokenMACContext context)
           throws CryptoTokenException
Resets the crypto token.

Parameters:
context - The context of the crypto token.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getMAC

public int getMAC(CryptoTokenMACContext context,
                  byte[] buffer,
                  int offset,
                  boolean reset)
           throws CryptoTokenException
Returns the Message Authetication Code (MAC) associated with the crypto token.

Parameters:
context - The context of the crypto token.
buffer - The byte array to contain the MAC.
offset - The offset, or start position, of the MAC data within the array.
Returns:
An integer representing the code.
Throws:
CryptoTokenException - Thrown if an error occurs with the crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

createKey

public CryptoTokenMACKeyData createKey(int length)
                                throws CryptoUnsupportedOperationException,
                                       CryptoTokenException
Creates a key of a specified length on the crypto token.

Parameters:
length - An integer that represents the length of the key, in bytes.
Returns:
The CryptoTokenMACKeyData object associated with the crypto token.
Throws:
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

injectKey

public CryptoTokenMACKeyData injectKey(byte[] key,
                                       int offset,
                                       int length)
                                throws CryptoUnsupportedOperationException,
                                       CryptoTokenException
Injects the specified raw key data into the crypto token.

Parameters:
key - A byte array containing the key.
offset - The offset, or start position, of the key within the array.
length - The length of the key, in bytes.
Returns:
The crypto token MAC key data.
Throws:
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

deleteKey

public void deleteKey(CryptoTokenMACKeyData 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.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.