net.rim.device.api.crypto
Class BlockEncryptor

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.BlockEncryptor

public class BlockEncryptor
extends EncryptorOutputStream

The superclass of all classes that implement block ciphers. The block ciphers sit on the Encryptor output stream and any data that is written to the output stream is acted on by the Block cipher. The class BlockEncryptor itself simply overrides many of the methods defined for the Encryptor class with methods that are specific to block ciphers.

It is important to note that the default mode for all block ciphers is Electronic Code Book mode (ECB) where each block is encrypted/decrypted separately and independently from all other blocks.

Note: For the block cipher algorithm classes, each block is encrypted one block at a time.

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 BlockEncryptor(BlockEncryptorEngine encryptorEngine, OutputStream out)
          Creates a BlockEncryptor object using the specified block encryptor engine and output stream.
Category: Signed BlockEncryptor(BlockFormatterEngine formatterEngine, OutputStream out)
          Creates a BlockEncryptor object using the specified block encoder and output stream.
 
Method Summary
Category: Signed  void close()
          Closes the output stream.
Category: Signed  void flush()
          Flushes out the remainder of the data in the output stream.
Category: Signed  void flush(boolean pad)
          Flushes any pending data to the stream and, optionally, does any necessary padding correctly.
Category: Signed  String getAlgorithm()
          Returns the name of the algorithm or both the algorithm and formatter engine used, depending what BlockEncryptor constructor was used.
Category: Signed  int getInputBlockLength()
          Returns the input block length of the cipher in bytes.
Category: Signed  int getOutputBlockLength()
          Returns the output block length of the cipher in bytes.
Category: Signed protected  void pad()
          Pads the output properly.
Category: Signed  void write(byte[] data, int offset, int length)
          Writes a specified length of bytes from the given byte array to this output stream.
 
Methods inherited from class net.rim.device.api.crypto.CryptoOutputStream
getOutputStream, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

BlockEncryptor

public BlockEncryptor(BlockFormatterEngine formatterEngine,
                      OutputStream out)
Creates a BlockEncryptor object using the specified block encoder and output stream.

Parameters:
formatterEngine - The formatter engine that will be used to encode the data.
out - The output stream that the data will be written to.
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

BlockEncryptor

public BlockEncryptor(BlockEncryptorEngine encryptorEngine,
                      OutputStream out)
Creates a BlockEncryptor object using the specified block encryptor engine and output stream.

Parameters:
encryptorEngine - The encryptor engine that will be used to encrypt the data.
out - The output stream that the data will be written to.
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 algorithm or both the algorithm and formatter engine used, depending what BlockEncryptor constructor was used.

Specified by:
getAlgorithm in class CryptoOutputStream
Returns:
A string representing the name of the algorithm and block formatter engine used (if one is used) to encrypt the data.
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

getInputBlockLength

public int getInputBlockLength()
Returns the input block length of the cipher in bytes.

Returns:
An integer representing the input block length.
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

getOutputBlockLength

public int getOutputBlockLength()
Returns the output block length of the cipher in bytes.

Returns:
An integer representing the output block length.
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

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws IOException
Description copied from class: CryptoOutputStream
Writes a specified length of bytes from the given byte array to this output stream.

Specified by:
write in class CryptoOutputStream
Parameters:
data - The byte array containing the bytes that are going to be written to the output stream.
offset - The offset in the byte array where the method will start writing from.
length - The number of bytes that will be written to the output stream.

Throws:
IOException - Thrown if an I/O error occurs.
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

flush

public void flush()
           throws IOException
Description copied from class: CryptoOutputStream
Flushes out the remainder of the data in the output stream.

Overrides:
flush in class CryptoOutputStream
Throws:
IOException - Thrown if an I/O error occurs.
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

flush

public void flush(boolean pad)
           throws IOException
Flushes any pending data to the stream and, optionally, does any necessary padding correctly.

This function is useful if you wish to re-use this object and so require that the previously written data have any necessary padding completed for it.

Overrides:
flush in class EncryptorOutputStream
Parameters:
pad - If true, then perform the appropriate padding code. Otherwise, just flush normally.
Throws:
IOException
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 4.0.0

pad

protected void pad()
            throws IOException
Pads the output properly.

Throws:
IOException - Thrown if an I/O error occurs.
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

close

public void close()
           throws IOException
Description copied from class: CryptoOutputStream
Closes the output stream.

Before closing the stream, it flushes out all of the data that is in the output stream.

See the flush() method for more information.

Overrides:
close in class CryptoOutputStream
Throws:
IOException - Thrown if an I/O error occurs.
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