net.rim.device.api.crypto
Class SPKMKDFPseudoRandomSource

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

public final class SPKMKDFPseudoRandomSource
extends AbstractPseudoRandomSource
implements PseudoRandomSource

Implements the key derivation function (KDF) found in RFC 2025. This KDF does not have a definite length and can be used to generate a variety of symmetric keys. SPKM stands for "Simple Public-Key Mechanism."

Note: Because of an oddity in the definition of this KDF, you can all call it once ( through xorBytes, getBytes, etc. ) to get random data. Any subsequent calls will throw an IllegalStateException.

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 4.0.0

Constructor Summary
Category: Signed SPKMKDFPseudoRandomSource(byte[] sharedSecret)
          Creates an SPKMKDFPseudoRandomSource object using the given shared secret, keyed integrity ( ie. the 'I' character will be used ), '0' as the algorithm number, and the default SHA-1 digest.
Category: Signed SPKMKDFPseudoRandomSource(byte[] sharedSecret, int offset, int length, boolean confidentiality, int algorithmNumber, Digest digest)
          Creates an SPKMKDFPseudoRandomSource object using the given parameters and the specified digest.
 
Method Summary
Category: Signed  String getAlgorithm()
          Returns the name of this PseaudoRandomSource "SPKMKDF".
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 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

SPKMKDFPseudoRandomSource

public SPKMKDFPseudoRandomSource(byte[] sharedSecret)
Creates an SPKMKDFPseudoRandomSource object using the given shared secret, keyed integrity ( ie. the 'I' character will be used ), '0' as the algorithm number, and the default SHA-1 digest.

The intended use of this PseudoRandomSource is in order to create a shared secret key between two people ( party A and party B ). So the javadocs refer to the different parameters as belonging to one party or the other. That does not restrict the use of this PseudoRandomSource, however. The parameters could all be created by one user and passed in.

 Assume sharedSecret has been set.

 SPKMKDFPseudoRandomSource source = new SPKMKDFPseudoRandomSource( sharedSecret );
 byte[] keyData = source.getBytes( TripleDESKey.LENGTH );
 TripleDESKey key = new TripleDESKey( keyData );
 

Note: Because of an oddity in the definition of this KDF, you can all call it once ( through xorBytes, getBytes, etc. ) to get random data. Any subsequent calls will throw an IllegalStateException.

Parameters:
sharedSecret - A byte array containing the shared secret generated by a key-agreement scheme.
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 4.0.0

SPKMKDFPseudoRandomSource

public SPKMKDFPseudoRandomSource(byte[] sharedSecret,
                                 int offset,
                                 int length,
                                 boolean confidentiality,
                                 int algorithmNumber,
                                 Digest digest)
Creates an SPKMKDFPseudoRandomSource object using the given parameters and the specified digest.

The intended use of this PseudoRandomSource is in order to create a shared secret key between two people ( party A and party B ). So the javadocs refer to the different parameters as belonging to one party or the other. That does not restrict the use of this PseudoRandomSource, however. The parameters could all be created by one user and passed in.

 Assume sharedSecret has been set.  We'll assume the optional parameters to the defaults for clarity sake.

 SPKMKDFPseudoRandomSource source = new SPKMKDFPseudoRandomSource( sharedSecret, 0, sharedSecret.length,
                                      false, 0, new SHA1Digest() );
 byte[] keyData = source.getBytes( TripleDESKey.LENGTH );
 TripleDESKey key = new TripleDESKey( keyData );
 

Note: Because of an oddity in the definition of this KDF, you can all call it once ( through xorBytes, getBytes, etc. ) to get random data. Any subsequent calls will throw an IllegalStateException.

Parameters:
sharedSecret - A byte array containing the shared secret generated by a key-agreement scheme.
offset - The offset into sharedSecret array.
length - The length of the shared secret.
confidentiality - If true then this will be used with a confidentiality algorithm so a 'C' is inserted, otherwise it is for integrity so insert a 'I'.
algorithmNumber - The number of the algorithm in the appropriate agreed upon list.
digest - An instance of the digest to use for hashing.
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 4.0.0


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of this PseaudoRandomSource "SPKMKDF".

Specified by:
getAlgorithm in interface PseudoRandomSource
Returns:
A String representing 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 4.0.0

xorBytes

public void xorBytes(byte[] buffer,
                     int offset,
                     int length)
Description copied from class: AbstractPseudoRandomSource
Exclusive-OR's 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 byte array 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 4.0.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 4.0.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 4.0.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