net.rim.device.api.crypto
Class CFBEncryptor

java.lang.Object
  extended by java.io.OutputStream
      extended by net.rim.device.api.crypto.CryptoOutputStream
          extended by net.rim.device.api.crypto.EncryptorOutputStream
              extended by net.rim.device.api.crypto.StreamEncryptor
                  extended by net.rim.device.api.crypto.CFBEncryptor

public final class CFBEncryptor
extends StreamEncryptor

CFBEncryptor is the class used to iterate a given block cipher in 8 or 64-bit Cipher Feedback (CFB) mode. CFB mode is defined in FIPS 81.

Note: CFB mode uses encryption for both the encryption and decryption of the block cipher and hence should only be used with symmetric cryptography and not with asymmetric cryptography.

For a code sample using the CFB encryptor, click here.

For information on cryptographic algorithms, see Crypto Algorithms.

See Also:
InitializationVector, CFBDecryptor
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

Field Summary
 
Fields inherited from class net.rim.device.api.crypto.CryptoOutputStream
_out
 
Constructor Summary
Category: Signed CFBEncryptor(SymmetricKeyEncryptorEngine engine, InitializationVector iv, OutputStream output, boolean eightBitCFB)
          Creates a CFB cipher with the given symmetric key engine and initialization vector.
 
Method Summary
Category: Signed protected  void encrypt(byte[] plaintext, int plaintextOffset, int plaintextLength, byte[] ciphertext)
          Encrypts data using the specific implementation of the chosen stream encryptor.
Category: Signed  String getAlgorithm()
          Returns the name of the encryption algorithm used, ie SymmetricKeyEncryptorEngine.getAlgorithm() + "/CFB".
Category: Signed  InitializationVector getIV()
          Returns the initialization vector.
 
Methods inherited from class net.rim.device.api.crypto.StreamEncryptor
flush, write
 
Methods inherited from class net.rim.device.api.crypto.CryptoOutputStream
close, flush, getOutputStream, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

CFBEncryptor

public CFBEncryptor(SymmetricKeyEncryptorEngine engine,
                    InitializationVector iv,
                    OutputStream output,
                    boolean eightBitCFB)
Creates a CFB cipher with the given symmetric key engine and initialization vector.

Parameters:
engine - The algorithm engine to use for encryption.
iv - The initialization vector for the block cipher mode. This must have the same length as the block length of the engine.
output - The underlying output stream that all data will be written to.
eightBitCFB - A boolean to indicate the amount of cipher feedback. If set, then 8 bits of cipher feedback are used, otherwise, the encryptor engine's block size determines the amount of cipher feedback.
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 Detail

getAlgorithm

public String getAlgorithm()
Returns the name of the encryption algorithm used, ie SymmetricKeyEncryptorEngine.getAlgorithm() + "/CFB".

Specified by:
getAlgorithm in class CryptoOutputStream
Returns:
A string representing the name of the algorithm and mode used.
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

getIV

public InitializationVector getIV()
Returns the initialization vector.

Returns:
The initialization vector.
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

encrypt

protected void encrypt(byte[] plaintext,
                       int plaintextOffset,
                       int plaintextLength,
                       byte[] ciphertext)
                throws CryptoTokenException
Description copied from class: StreamEncryptor
Encrypts data using the specific implementation of the chosen stream encryptor.

Specified by:
encrypt in class StreamEncryptor
Parameters:
plaintext - A byte array containing the input to the stream cipher.
plaintextOffset - The offset, or initial position within the array, of the information to encrypt.
plaintextLength - The length of the information to encrypt.
ciphertext - A byte array to hold the output of the stream cipher.
Throws:
CryptoTokenException - Thrown when a problem occurs with the 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-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.