SHOW Signed
 

net.rim.device.api.crypto
Class HMAC

java.lang.Object
  |
  +--net.rim.device.api.crypto.AbstractMAC
        |
        +--net.rim.device.api.crypto.HMAC
All Implemented Interfaces:
MAC

public final class HMAC
extends AbstractMAC
implements MAC

HMAC is a Message Authentication Code algorithm based on a Digest function. HMAC is defined in RFC 2104. For information on cryptographic algorithms, see Crypto 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:
JDE 3.6.0

Constructor Summary
 Category: Signed HMAC(HMACKey key, Digest digest)
          Creates an instance of the HMAC object with a given key as the MAC key, using a specified digest as the hash function.
 
Method Summary
 Category: Signed  String getAlgorithm()
          Returns the name of this digest, ie "HMAC/" + Digest.getAlgorithm().
 Category: Signed  int getLength()
          Returns the length of the HMAC in bytes.
 Category: Signed  int getMAC(byte[] buffer, int offset, boolean reset)
          Puts the MAC of all the input data since the last reset into the given buffer starting at the specified offset.
 Category: Signed  void reset()
          Resets the hashing of the HMAC.
 Category: Signed  void update(byte[] data, int offset, int length)
          Feeds more data into the MAC algorithm.
 Category: Signed  void update(int data)
          Feeds more data into the MAC algorithm.
 
Methods inherited from class net.rim.device.api.crypto.AbstractMAC
checkMAC, checkMAC, checkMAC, checkMAC, getMAC, getMAC, getMAC, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.rim.device.api.crypto.MAC
checkMAC, checkMAC, checkMAC, checkMAC, getMAC, getMAC, getMAC, update
 

Constructor Detail

HMAC

public HMAC(HMACKey key,
            Digest digest)
     throws CryptoTokenException,
            CryptoUnsupportedOperationException
Creates an instance of the HMAC object with a given key as the MAC key, using a specified digest as the hash function.

Parameters:
key - The HMAC key to use with this instance.
digest - The hash function to use with this instance.
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:
JDE 3.6.0
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.
Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of this digest, ie "HMAC/" + Digest.getAlgorithm().
Specified by:
getAlgorithm in interface MAC
Overrides:
getAlgorithm in class AbstractMAC
Since:
JDE 3.6.0

Following copied from interface: MAC
Returns:
A String representing the mac algorithm along with the name of the digest or cipher.
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.

getLength

public int getLength()
Returns the length of the HMAC in bytes.

Specified by:
getLength in interface MAC
Overrides:
getLength in class AbstractMAC
Since:
JDE 3.6.0

Following copied from interface: MAC
Returns:
An integer that represents the length of the MAC.
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.

getMAC

public int getMAC(byte[] buffer,
                  int offset,
                  boolean reset)
           throws CryptoTokenException
Description copied from interface: MAC
Puts the MAC of all the input data since the last reset into the given buffer starting at the specified offset. The MAC is then reset.

Specified by:
getMAC in interface MAC
Overrides:
getMAC in class AbstractMAC
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
JDE 3.6.0
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.

reset

public void reset()
           throws CryptoTokenException
Resets the hashing of the HMAC.

This method resets the underlying digest and then updates that digest with the inner pad.

Specified by:
reset in interface MAC
Overrides:
reset in class AbstractMAC
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
Since:
JDE 3.6.0
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.

update

public void update(byte[] data,
                   int offset,
                   int length)
Description copied from interface: MAC
Feeds more data into the MAC algorithm.

Specified by:
update in interface MAC
Overrides:
update in class AbstractMAC
Since:
JDE 3.6.0

Following copied from interface: MAC
Parameters:
data - The array containing the input data.
offset - The offset, or initial position, of the data within the array.
length - The length of the input data, in bytes.
Throws:
CryptoTokenException - Thrown when a problem 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.

update

public void update(int data)
Description copied from interface: MAC
Feeds more data into the MAC algorithm.

Specified by:
update in interface MAC
Overrides:
update in class AbstractMAC
Since:
JDE 3.6.0

Following copied from interface: MAC
Parameters:
data - A byte of input data.
Throws:
CryptoTokenException - Thrown when a problem 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.



Copyright 1999-2009 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.