|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.rim.device.api.crypto.AbstractPseudoRandomSource
|
+--net.rim.device.api.crypto.CTRPseudoRandomSource
CTRPseudoRandomSource uses a symmetric key block cipher in Counter Mode to provide a sequence of pseudo random bytes. CTR mode is defined in FIPS SP 800-38A
More than one message can be encrypted with the same key provided that a different initialization vector (IV) is used every time.
Note that any change in the ciphertext directly affects the plaintext. A ciphertext error only effects the corresponding bit of plaintext (this is why it is considered a stream cipher).
The width of the feedback is the block size of the cipher. For example, when used with DES, CTR uses 64 bit feedback.
For a code sample using the CTR pseudo random source, click here.
| Constructor Summary | ||
|
CTRPseudoRandomSource(SymmetricKeyEncryptorEngine engine,
InitializationVector iv)
Creates an CTRPseudoRandomSource object based on the specified encryptor engine and
initialization vector. |
|
|
CTRPseudoRandomSource(SymmetricKeyEncryptorEngine engine,
long iv)
Creates an CTRPseudoRandomSource object based on the specified encryptor engine and
initialization vector. |
|
| Method Summary | ||
|
String |
getAlgorithm()
Returns the name of this PseudoRandomSource. |
|
int |
getAvailable()
Returns the number of pseudo random bytes currently available. |
|
int |
getMaxAvailable()
Returns the maximum number of pseudo random bytes that this PRNG can produce. |
|
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 |
public CTRPseudoRandomSource(SymmetricKeyEncryptorEngine engine, InitializationVector iv) throws CryptoTokenException
CTRPseudoRandomSource object based on the specified encryptor engine and
initialization vector.
engine - The encryption engine (algorithm) that will be used for the CTR mode.iv - The starting value for the counter that is to be used for the CTR mode (must have
the same length as the engine's block length).CryptoTokenException - Thrown if an error occurs with the crypto
token or the crypto token is invalid.public CTRPseudoRandomSource(SymmetricKeyEncryptorEngine engine, long iv) throws CryptoTokenException
CTRPseudoRandomSource object based on the specified encryptor engine and
initialization vector.
engine - The encryption engine (algorithm) that will be used for the CTR mode.iv - The starting value for the counter that is to be used for the CTR mode (must have
the same length as the engine's block length).CryptoTokenException - Thrown if an error occurs with the crypto
token or the crypto token is invalid.| Method Detail |
public String getAlgorithm()
SymmetricKeyEncryptorEngine.getAlgorithm() + "/CTR".
PseudoRandomSourcepublic int getAvailable()
PseudoRandomSource
For PRNG sources that have an indefinite length but implement
this interface, the value returned is Integer.MAX.
PseudoRandomSourceCryptoTokenException - Thrown when a problem occurs with a crypto token or the crypto token is invalid.public int getMaxAvailable()
PseudoRandomSource
For PRNG sources that have an indefinite length but implement
this interface, the value returned is Integer.MAX.
PseudoRandomSourceCryptoTokenException - Thrown when a problem occurs with a crypto token or the crypto token is invalid.
public void xorBytes(byte[] buffer,
int offset,
int length)
throws CryptoTokenException
PseudoRandomSourcexorBytes in interface PseudoRandomSourcexorBytes in class AbstractPseudoRandomSource
PseudoRandomSourcebuffer - 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.IllegalStateException - if the available random bytes are exhausted.CryptoTokenException - Thrown when a problem occurs with a crypto token or the crypto token is invalid.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2007 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.