net.rim.device.api.crypto
Class MACFactory

java.lang.Object
  extended by net.rim.device.api.crypto.MACFactory

public abstract class MACFactory
extends Object

Creates a Message Authentication Code MAC using the specified parameters.

For more information on the cryptographic algorithms supported by this factory, see Crypto Algorithms.

See Also:
MAC, SymmetricKeyFactory
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 MACFactory()
          Creates a new MACFactory object.
 
Method Summary
Category: Signed protected abstract  MAC create(String algorithm, String parameters, SymmetricKey key)
          Called to create the MAC.
Category: Signed static Enumeration getAlgorithms()
          Returns an Enumeration of String representing all of the registered algorithms with this factory.
Category: Signed protected abstract  String[] getFactoryAlgorithms()
          Called to determine what SymmetricKey's are supported.
Category: Signed static MAC getInstance(String algorithm, SymmetricKey key)
          Constructs and returns a new MAC.
Category: Signed static MAC getInstance(SymmetricKey key)
          Constructs and returns a new MAC.
Category: Signed static void register(MACFactory factory)
          Registers the given MACFactory object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

MACFactory

protected MACFactory()
Creates a new MACFactory 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

getInstance

public static MAC getInstance(SymmetricKey key)
                       throws NoSuchAlgorithmException,
                              CryptoTokenException,
                              CryptoUnsupportedOperationException
Constructs and returns a new MAC. A MACFactory object is selected based on key.getAlgorithm(), eg an HMAC key will return an HMAC object, and a DES key will return a CBCMAC object.

Parameters:
key - The key used to extract the key data from.
Returns:
The MAC.
Throws:
NoSuchAlgorithmException - Thrown if the MAC cannot be constructed.
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.
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

getInstance

public static MAC getInstance(String algorithm,
                              SymmetricKey key)
                       throws NoSuchAlgorithmException,
                              CryptoTokenException,
                              CryptoUnsupportedOperationException
Constructs and returns a new MAC.

A MACFactory object is selected based on the String alone. The keydata will simply be extracted from the symmetric key.

Parameters:
algorithm - A String containing the specified MAC algorithm. e.g. "HMAC/SHA1", "CBCMAC/DES"
key - The key used to extract key data from.
Returns:
The MAC.
Throws:
NoSuchAlgorithmException - Thrown if the MAC cannot be constructed.
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.
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

register

public static void register(MACFactory factory)
Registers the given MACFactory object.

If a previous call registered a MACFactory with the same algorithm name, then the this MACFactory will not be added.

Parameters:
factory - The MACFactory object to be registered.
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

getAlgorithms

public static Enumeration getAlgorithms()
Returns an Enumeration of String representing all of the registered algorithms with this factory.

Returns:
An Enumeration of Strings representing all of the registered algorithms with this factory.
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

getFactoryAlgorithms

protected abstract String[] getFactoryAlgorithms()
Called to determine what SymmetricKey's are supported.

Returns:
A String containing the names of supported algorithms.
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

create

protected abstract MAC create(String algorithm,
                              String parameters,
                              SymmetricKey key)
                       throws NoSuchAlgorithmException,
                              ClassCastException,
                              CryptoTokenException,
                              CryptoUnsupportedOperationException,
                              CryptoException
Called to create the MAC.

Parameters:
algorithm - A String representing the name of the algorithm.
parameters - A String containing the paramters for the MAC.
keyData - The keydata used to create the MAC.
offset - The offset, or start position, of the data within the array.
length - The length of the data, in bytes.
Returns:
The MAC.
Throws:
NoSuchAlgorithmException - Thrown if an error occurs when creating the MAC.
ClassCastException - Thrown if the class is improperly cast.
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.
CryptoException
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.