net.rim.device.api.crypto
Interface PseudoRandomSource
- All Known Implementing Classes:
- AESCTRDRBGPseudoRandomSource, ARC4PseudoRandomSource, CTRPseudoRandomSource, FIPS186PseudoRandomSource, OFBPseudoRandomSource, P1363KDF1PseudoRandomSource, PKCS1MGF1PseudoRandomSource, PKCS5KDF1PseudoRandomSource, PKCS5KDF2PseudoRandomSource, RFC2631KDFPseudoRandomSource, SPKMKDFPseudoRandomSource, X942KDFPseudoRandomSource, X963KDFPseudoRandomSource
public interface PseudoRandomSource
PseudoRandomSource
is an interface that represents a pseudo-random number generator (PRNG).
A PRNG expands a finite length seed into an arbitrarily long stream of pseudo-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
Method Summary |
|
String |
getAlgorithm()
Returns the name of the algorithm, eg "X963KDF". |
|
int |
getAvailable()
Returns the number of pseudo random bytes currently available. |
|
void |
getBytes(byte[] buffer)
Generates random bytes, filling the given buffer entirely. |
|
void |
getBytes(byte[] buffer,
int offset,
int length)
Inserts random bytes into the given buffer starting at
the specified array offset. |
|
byte[] |
getBytes(int length)
Generates a specified length of random bytes, returning them as a byte
array of exactly that size. |
|
int |
getMaxAvailable()
Returns the maximum number of pseudo random bytes that this
PRNG can produce. |
|
void |
xorBytes(byte[] buffer)
Exclusive-OR's (xor) random bytes into the given buffer. |
|
void |
xorBytes(byte[] buffer,
int offset,
int length)
Exclusive-OR's (xor) random bytes into the given buffer starting at
the specified array offset. |
|
void |
xorBytes(byte[] data,
int dataOffset,
int dataLength,
byte[] buffer,
int bufferOffset)
Copies the bytes of the given data into the given buffer, and then exclusive-OR's
random bytes into the copy. |
|
byte[] |
xorCopy(byte[] data)
Copies the bytes of the given data into a new buffer, and then exclusive-OR's
random bytes into the copy. |
|
byte[] |
xorCopy(byte[] data,
int offset,
int length)
Copies the bytes of the given data into a new buffer, and then exclusive-OR's
random bytes into the copy. |
getAlgorithm
String getAlgorithm()
- Returns the name of the algorithm, eg "X963KDF".
- 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 3.6.0
xorBytes
void xorBytes(byte[] buffer,
int offset,
int length)
throws CryptoTokenException
- Exclusive-OR's (xor) random bytes into the given buffer starting at
the specified array offset.
- Parameters:
buffer
- The buffer to xor the bytes into.offset
- The starting offset, or initial bit position, of the data
within the buffer.length
- The number of bytes to xor.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
xorBytes
void xorBytes(byte[] buffer)
throws CryptoTokenException
- Exclusive-OR's (xor) random bytes into the given buffer.
- Parameters:
buffer
- The buffer to be xor'ed with the random bytes.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
xorBytes
void xorBytes(byte[] data,
int dataOffset,
int dataLength,
byte[] buffer,
int bufferOffset)
throws CryptoTokenException
- Copies the bytes of the given data into the given buffer, and then exclusive-OR's
random bytes into the copy.
- Parameters:
data
- The array containing the data to xor.dataOffset
- The starting offset, or initial position, of the data within the buffer.dataLength
- The number of bytes to xor.buffer
- The buffer to xor the bytes into.offset
- The starting offset, or initial bit position, of the data
within the buffer.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
xorCopy
byte[] xorCopy(byte[] data)
throws CryptoTokenException
- Copies the bytes of the given data into a new buffer, and then exclusive-OR's
random bytes into the copy.
- Parameters:
data
- The data to be xor'ed.
- Returns:
- The xor'ed byte array.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
xorCopy
byte[] xorCopy(byte[] data,
int offset,
int length)
throws CryptoTokenException
- Copies the bytes of the given data into a new buffer, and then exclusive-OR's
random bytes into the copy.
- Parameters:
data
- The array containing the data to xor.offset
- The starting offset, or initial position, of the data within the buffer.length
- The number of bytes to xor.
- Returns:
- The xor'ed byte array.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
getBytes
void getBytes(byte[] buffer,
int offset,
int length)
throws CryptoTokenException
- Inserts random bytes into the given buffer starting at
the specified array offset.
- Parameters:
buffer
- The array to hold the bytes.offset
- The starting offset, or initial bit position, of the data within the buffer.length
- The number of bytes to get.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
getBytes
byte[] getBytes(int length)
throws CryptoTokenException
- Generates a specified length of random bytes, returning them as a byte
array of exactly that size.
- Parameters:
length
- The number of random bytes to generate.
- Returns:
- A new byte array containing the random bytes.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
getBytes
void getBytes(byte[] buffer)
throws CryptoTokenException
- Generates random bytes, filling the given buffer entirely.
- Parameters:
buffer
- The array to fill with random bytes.
- Throws:
IllegalStateException
- if the available random bytes are exhausted.
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.
- Since:
- BlackBerry API 3.6.0
getAvailable
int getAvailable()
throws CryptoTokenException
- 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
.
- Returns:
- An integer that represents the number of 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.
- Since:
- BlackBerry API 3.6.0
getMaxAvailable
int getMaxAvailable()
throws CryptoTokenException
- 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
.
- Returns:
- An integer that specifies the maximum number of random bytes that
can be produced.
- 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.
- 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