|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.crypto.AbstractPseudoRandomSource
net.rim.device.api.crypto.ARC4PseudoRandomSource
public final class ARC4PseudoRandomSource
Represents a pseudo-random number generator (PRNG) that uses the Alledged RC4 (ARC4) algorithm to expand a finite length seed into an arbitrarily long stream of pseudo-random bytes.
We implemented ARC4 as described in "Applied Cryptography", by Bruce Schneier, in Section 17.1 ( published 1996 ).
ARC4 is a version of the proprietary RC4 algorithm that was supposedly released onto the Internet in 1994. RC4 is a variable key size stream cipher developed in 1987 by Ron Rivest for RSA Data Security Inc. The algorithm is very simple and works in OFB mode where the keystream is independent of the plaintext.
For a code sample using the ARC4 pseudo random source, click here.
For information on cryptographic algorithms, see Crypto Algorithms.
ARC4Key
Constructor Summary | ||
---|---|---|
|
ARC4PseudoRandomSource(byte[] seed)
Creates an ARC4PseudoRandomSource object with the given (secret) seed data. |
|
|
ARC4PseudoRandomSource(byte[] seed,
int offset,
int length)
Creates an ARC4PseudoRandomSource object with the given (secret) seed data. |
|
|
ARC4PseudoRandomSource(ARC4Key key)
Creates an ARC4PseudoRandomSource object using the specified ARC4Key to
initialize the pseudo-random source. |
Method Summary | ||
---|---|---|
|
String |
getAlgorithm()
Returns the name of the algorithm used, ie "ARC4". |
|
int |
getAvailable()
Returns an integer that specifies the number of pseudo-random bytes currently available (this value is reset to the value returned by getMaxAvailable() with calls to reset()). |
|
int |
getMaxAvailable()
Returns the maximum number of pseudo-random bytes that this PRNG can produce following a call to reset() . |
|
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 |
---|
public ARC4PseudoRandomSource(byte[] seed)
ARC4PseudoRandomSource
object with the given (secret) seed data.
seed
- The seed data to initialize the random source.public ARC4PseudoRandomSource(byte[] seed, int offset, int length)
ARC4PseudoRandomSource
object with the given (secret) seed data.
seed
- The seed data for the random source.offset
- The offset, or first bit position, of the seed data in the array.length
- The number of bytes to use from the array.public ARC4PseudoRandomSource(ARC4Key key) throws CryptoTokenException
ARC4PseudoRandomSource
object using the specified ARC4Key to
initialize the pseudo-random source.
key
- The ARC4 key used to seed the random source.
CryptoTokenException
- Thrown when a problem occurs with a crypto
token or the crypto token is invalid.Method Detail |
---|
public String getAlgorithm()
This method will always return "ARC4"
getAlgorithm
in interface PseudoRandomSource
public void xorBytes(byte[] buffer, int offset, int length)
xorBytes
in interface PseudoRandomSource
xorBytes
in class AbstractPseudoRandomSource
buffer
- The byte array to be xor'ed with random bytes.offset
- The offset, or first bit position, of the data within the
array.length
- ie "ARC4". The number of bytes to be xor'ed.public int getAvailable()
getMaxAvailable()
with calls to reset()).
For PRNG sources that have an indefinite length but implement this interface, the value returned is the maximum signed value that will fit into an int.
getAvailable
in interface PseudoRandomSource
public int getMaxAvailable()
reset()
. For PRNG sources that have
an indefinite length but implement this interface, the value
returned is the maximum signed value that will fit into an int.
getMaxAvailable
in interface PseudoRandomSource
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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