net.rim.device.api.crypto
Class RandomSource

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

public final class RandomSource
extends Object

A random number generator that generates cryptographically random bytes. The random bytes are used in the generation of keys and for other cryptographic operations.

Random bits are continually harvested from the system and pooled for future use.

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 Summary
Category: Signed static void add(Object obj)
          Adds the cryptographic hash of a deep scan of the given object to the pool of randomness (ie the contents of the object, and anything it references, will be hashed).
Category: Signed static void getBytes(byte[] buffer)
          Generates random bytes, filling the given buffer entirely.
Category: Signed static void getBytes(byte[] buffer, int offset, int length)
          Inserts random bytes into the given buffer starting at the specified array index offset.
Category: Signed static byte[] getBytes(int length)
          Generates a specified length of random bytes, returning them as a byte array of the specified size.
Category: Signed static int getInt()
          Returns a random integer.
Category: Signed static int getInt(int num)
          Returns a random non-negative integer modulo.
Category: Signed static long getLong()
          Returns a random long integer.
Category: Signed static long getLong(long num)
          Returns a random non-negative long integer modulo.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

getLong

public static long getLong()
Returns a random long integer.

Returns:
A random value of type long.
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

getInt

public static int getInt()
Returns a random integer.

Returns:
A random value of type int.
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

getLong

public static long getLong(long num)
Returns a random non-negative long integer modulo.

Parameters:
num - A positive modulus num. The random long integer returned will be in the range 0..num-1, inclusive.
Returns:
A random value of type long.
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

getInt

public static int getInt(int num)
Returns a random non-negative integer modulo.

Parameters:
num - A positive modulus num. The random integer returned will be in the range 0..num-1, inclusive.
Returns:
A random value of type int.
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

getBytes

public static void getBytes(byte[] buffer,
                            int offset,
                            int length)
Inserts random bytes into the given buffer starting at the specified array index offset.

Parameters:
buffer - The buffer to store the random bytes.
offset - The start, or initial position, of the data within the buffer.
length - The number of random bytes to store.
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

getBytes

public static byte[] getBytes(int length)
Generates a specified length of random bytes, returning them as a byte array of the specified size.

Parameters:
length - The number of random bytes to generate.
Returns:
A byte array containing the random 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

getBytes

public static void getBytes(byte[] buffer)
Generates random bytes, filling the given buffer entirely.

Parameters:
buffer - The byte array to fill with random 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

add

public static void add(Object obj)
Adds the cryptographic hash of a deep scan of the given object to the pool of randomness (ie the contents of the object, and anything it references, will be hashed).

Parameters:
obj - The object whose hash is to be added to the pool of randomness.
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.