net.rim.device.api.crypto
Class PKCS5UnformatterEngine

java.lang.Object
  extended by net.rim.device.api.crypto.PKCS5UnformatterEngine
All Implemented Interfaces:
BlockUnformatterEngine

public final class PKCS5UnformatterEngine
extends Object
implements BlockUnformatterEngine

Provides the PKCS#5 padding scheme. The scheme pads the plaintext to the size of the block length and uses the number of bytes used for this padding as the actual byte to pad with. That is, if there are two bytes that needed to be padded out to get the correct block length then the two bytes used for padding would be 0x02.

We implemented the PKCS5 formatting as per PKCS #5 version 2.0 ( March 1999 ).

For a code sample using the PKCS5 unformatter engine, click here.

See Also:
PKCS5FormatterEngine
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

Constructor Summary
Category: Signed PKCS5UnformatterEngine(BlockDecryptorEngine decryptorEngine)
          Creates a PKCS5UnformatterEngine object using a given SymmetricKeyDecryptorEngine for decrypting the plaintext.
 
Method Summary
Category: Signed  int decryptAndUnformat(byte[] input, int inputOffset, byte[] output, int outputOffset)
          Decrypts the input and then "unformats" it into the original plaintext assuming this block is not the last block in the stream.
Category: Signed  int decryptAndUnformat(byte[] input, int inputOffset, byte[] output, int outputOffset, boolean lastBlock)
          Decrypts the input and then "unformats" it into the original plaintext.
Category: Signed  String getAlgorithm()
          Returns the name of the algorithm used, ie SymmetricKeyDecryptorEngine.getAlgorithm() + "/PKCS5".
Category: Signed  int getInputBlockLength()
          Returns the length of an input block in bytes.
Category: Signed  int getOutputBlockLength()
          Returns the length of an output block in bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

PKCS5UnformatterEngine

public PKCS5UnformatterEngine(BlockDecryptorEngine decryptorEngine)
Creates a PKCS5UnformatterEngine object using a given SymmetricKeyDecryptorEngine for decrypting the plaintext.

Parameters:
decryptorEngine - The engine that will be used to decrypt 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


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of the algorithm used, ie SymmetricKeyDecryptorEngine.getAlgorithm() + "/PKCS5".

Specified by:
getAlgorithm in interface BlockUnformatterEngine
Returns:
A String that represents 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

getInputBlockLength

public int getInputBlockLength()
Description copied from interface: BlockUnformatterEngine
Returns the length of an input block in bytes.

Specified by:
getInputBlockLength in interface BlockUnformatterEngine
Returns:
An integer representing the length, in bytes, of an input block.
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()
Description copied from interface: BlockUnformatterEngine
Returns the length of an output block in bytes.

Specified by:
getOutputBlockLength in interface BlockUnformatterEngine
Returns:
An integer that represents the length, in bytes, of an output block.
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

decryptAndUnformat

public int decryptAndUnformat(byte[] input,
                              int inputOffset,
                              byte[] output,
                              int outputOffset,
                              boolean lastBlock)
                       throws DecodeException,
                              BadPaddingException,
                              CryptoTokenException
Description copied from interface: BlockUnformatterEngine
Decrypts the input and then "unformats" it into the original plaintext.

Specified by:
decryptAndUnformat in interface BlockUnformatterEngine
Parameters:
input - A byte array containing the encoded ciphertext.
inputOffset - The offset, or initial bit position, of the data within the byte array.
output - The byte array that will contain the plaintext.
outputOffset - The offset, or initial bit position, of the data within the byte array.
lastBlock - A boolean flag indicating whether this is the last block in the stream to be decrypted.
Returns:
An integer representing the value of the operation.
Throws:
DecodeException - Thrown if the input cannot be decoded properly.
BadPaddingException - Thrown if the input has improper padding.
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

decryptAndUnformat

public int decryptAndUnformat(byte[] input,
                              int inputOffset,
                              byte[] output,
                              int outputOffset)
                       throws DecodeException,
                              BadPaddingException,
                              CryptoTokenException
Description copied from interface: BlockUnformatterEngine
Decrypts the input and then "unformats" it into the original plaintext assuming this block is not the last block in the stream.

Specified by:
decryptAndUnformat in interface BlockUnformatterEngine
Parameters:
input - A byte array containing the encoded ciphertext.
inputOffset - The offset, or initial bit position, of the data within the byte array.
output - The byte array that will contain the plaintext.
outputOffset - The offset, or initial bit position, of the data within the byte array.
Returns:
An integer representing the value of the operation.
Throws:
DecodeException - Thrown if the input cannot be decoded properly.
BadPaddingException - Thrown if the input has improper padding.
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-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.