net.rim.device.api.crypto
Class PKCS5KDF2PseudoRandomSource

java.lang.Object
  extended by net.rim.device.api.crypto.AbstractPseudoRandomSource
      extended by net.rim.device.api.crypto.PKCS5KDF2PseudoRandomSource
All Implemented Interfaces:
PseudoRandomSource

public final class PKCS5KDF2PseudoRandomSource
extends AbstractPseudoRandomSource
implements PseudoRandomSource

Provides PKCS #5 Key Derivation Function 2 pseudo random number generation. This is the recommended algorithm for new applications because the derived key length is not dependent on the hash algorithm length.

We implemented the PKCS5 KDF2 as per PKCS #5 version 2.0 ( March 1999 ).

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 PKCS5KDF2PseudoRandomSource(byte[] password, byte[] salt, int iterationCount)
          Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters using the default SHA-1 digest algorithm.
Category: Signed PKCS5KDF2PseudoRandomSource(byte[] password, int offset, int length, byte[] salt, int iterationCount)
          Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters using the default SHA-1 digest algorithm.
Category: Signed PKCS5KDF2PseudoRandomSource(byte[] password, int offset, int length, byte[] salt, int iterationCount, Digest digest)
          Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters.
Category: Signed PKCS5KDF2PseudoRandomSource(HMACKey key, byte[] salt, int iterationCount, Digest digest)
          Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters.
 
Method Summary
Category: Signed  String getAlgorithm()
          Returns the name of this PseudoRandomSource "PKCS5KDF2".
Category: Signed  int getAvailable()
          Returns the number of pseudo random bytes currently available.
Category: Signed  int getMaxAvailable()
          Returns the maximum number of pseudo random bytes that this PRNG can produce.
Category: Signed  void xorBytes(byte[] buffer, int offset, int length)
          Exclusive-OR's (xor) random bytes into the given buffer starting at the specified array offset.
 
Methods inherited from class net.rim.device.api.crypto.AbstractPseudoRandomSource
getBytes, getBytes, getBytes, xorBytes, xorBytes, xorCopy, xorCopy
 
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.PseudoRandomSource
getBytes, getBytes, getBytes, xorBytes, xorBytes, xorCopy, xorCopy
 



Constructor Detail

PKCS5KDF2PseudoRandomSource

public PKCS5KDF2PseudoRandomSource(byte[] password,
                                   byte[] salt,
                                   int iterationCount)
Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters using the default SHA-1 digest algorithm.

Parameters:
password - The password used to initialize the HMAC function.
salt - The salt data that is hashed to generate the key data.
iterationCount - The number of times to hash each block of the key.
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

PKCS5KDF2PseudoRandomSource

public PKCS5KDF2PseudoRandomSource(byte[] password,
                                   int offset,
                                   int length,
                                   byte[] salt,
                                   int iterationCount)
Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters using the default SHA-1 digest algorithm.

Parameters:
password - The password used to initialize the HMAC function.
offset - The offset, or starting position, of the password data within the array.
length - The number of bytes to use as password data.
salt - The salt data that is hashed to generate the key data.
iterationCount - The number of times to hash each block of the key.
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

PKCS5KDF2PseudoRandomSource

public PKCS5KDF2PseudoRandomSource(byte[] password,
                                   int offset,
                                   int length,
                                   byte[] salt,
                                   int iterationCount,
                                   Digest digest)
Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters.

Parameters:
password - The password used to initialize the HMAC function.
offset - The offset, or starting position, of the password data within the array.
length - The number of bytes to use as password data.
salt - The salt data that is hashed to generate the key data.
iterationCount - The number of times to hash each block of the key.
digest - The digest
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

PKCS5KDF2PseudoRandomSource

public PKCS5KDF2PseudoRandomSource(HMACKey key,
                                   byte[] salt,
                                   int iterationCount,
                                   Digest digest)
                            throws CryptoTokenException,
                                   CryptoUnsupportedOperationException
Creates a PKCS5KDF2PseudoRandomSource object with the desired parameters.

Parameters:
key - The key used to initialize the HMAC function.
salt - The salt data that is hashed to generate the key data.
iterationCount - The number of times to hash each block of the key.
digest - The digest algorithm to use.
Throws:
CryptoTokenException - Thrown when an error occurs with a crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown when 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


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of this PseudoRandomSource "PKCS5KDF2".

This method will always return the String "PKCS5KDF2".

Specified by:
getAlgorithm in interface PseudoRandomSource
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

xorBytes

public void xorBytes(byte[] buffer,
                     int offset,
                     int length)
Exclusive-OR's (xor) random bytes into the given buffer starting at the specified array offset.

Specified by:
xorBytes in interface PseudoRandomSource
Specified by:
xorBytes in class AbstractPseudoRandomSource
Parameters:
buffer - The buffer to xor the bytes into.
offset - The starting offset within buffer.
length - The number of bytes to xor.
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

getAvailable

public int getAvailable()
Description copied from interface: PseudoRandomSource
Returns the number of pseudo random bytes currently available.

For PRNG sources that have an indefinite length but implement this interface, the value returned is Integer.MAX.

Specified by:
getAvailable in interface PseudoRandomSource
Returns:
An integer that represents the number of bytes.
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

getMaxAvailable

public int getMaxAvailable()
Description copied from interface: PseudoRandomSource
Returns the maximum number of pseudo random bytes that this PRNG can produce.

For PRNG sources that have an indefinite length but implement this interface, the value returned is Integer.MAX.

Specified by:
getMaxAvailable in interface PseudoRandomSource
Returns:
An integer that specifies the maximum number of random bytes that can be produced.
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-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