SHOW Signed
 

net.rim.device.api.crypto
Class PKCS1FormatterEngine

java.lang.Object
  |
  +--net.rim.device.api.crypto.PKCS1FormatterEngine
All Implemented Interfaces:
BlockFormatterEngine

public final class PKCS1FormatterEngine
extends Object
implements BlockFormatterEngine

The PKCS1FormatterEngine class provides the PKCS1 encoding functionality on a block by block basis. The block length is the size of the modulus of an EncryptorEngine minus the overhead.

We implemented the PKCS1 formatter engine as per the PKCS #1 version 2.1 document.

For a code sample using the PKCS1 formatter engine, click here.

For information on cryptographic algorithms, see Crypto Algorithms.

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:
JDE 3.6.0
See Also:
PKCS1UnformatterEngine

Constructor Summary
 Category: Signed PKCS1FormatterEngine(PublicKeyEncryptorEngine encryptorEngine)
          Creates a PKCS1FormatterEngine object that takes a PublicKeyEncryptorEngine object that will be used for encrypting the ciphertext.
 
Method Summary
 Category: Signed  int formatAndEncrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
          Formats the input into the proper format and then encrypts it, assuming this is not the last block to be encrypted.
 Category: Signed  int formatAndEncrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, boolean lastBlock)
          Formats the input into the proper format and then encrypts it.
 Category: Signed  String getAlgorithm()
          Returns the name of the algorithm used, ie PublicKeyEncryptorEngine.getAlgorithm() + "_PKCS1".
 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

PKCS1FormatterEngine

public PKCS1FormatterEngine(PublicKeyEncryptorEngine encryptorEngine)
Creates a PKCS1FormatterEngine object that takes a PublicKeyEncryptorEngine object that will be used for encrypting the ciphertext.

Parameters:
encryptorEngine - The private key engine to encrypt the data with.
Since:
JDE 3.6.0
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.
Method Detail

formatAndEncrypt

public int formatAndEncrypt(byte[] input,
                            int inputOffset,
                            int inputLength,
                            byte[] output,
                            int outputOffset)
                     throws MessageTooLongException,
                            CryptoTokenException
Description copied from interface: BlockFormatterEngine
Formats the input into the proper format and then encrypts it, assuming this is not the last block to be encrypted.

Since:
JDE 3.6.0

Following copied from interface: BlockFormatterEngine
Parameters:
input - A byte array containing the data to be encrypted.
inputOffset - The offset, or initial bit position, of the data within the byte array.
inputLength - The amount of data to encrypt.
output - A byte array to hold the encoded and encrypted data.
outputOffset - The offset, or initial bit position, of the data within the byte array.
Returns:
The actual number of bytes encrypted and placed into the output array.
Throws:
MessageTooLongException - Thrown if the input is too long to be encoded with the given encoding scheme.
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.

formatAndEncrypt

public int formatAndEncrypt(byte[] input,
                            int inputOffset,
                            int inputLength,
                            byte[] output,
                            int outputOffset,
                            boolean lastBlock)
                     throws MessageTooLongException,
                            CryptoTokenException
Description copied from interface: BlockFormatterEngine
Formats the input into the proper format and then encrypts it.

Since:
JDE 3.6.0

Following copied from interface: BlockFormatterEngine
Parameters:
input - A byte array containing the data to be encrypted.
inputOffset - The offset, or initial bit position, of the data within the byte array.
inputLength - The amount of data to encrypt.
output - A byte array to hold the encoded and encrypted data.
outputOffset - The offset, or initial bit position, of the data within the byte array.
lastBlock - A boolean that indicates the last block to be encrypted.
Returns:
The actual number of bytes encrypted and inserted into the output array.
Throws:
MessageTooLongException - Thrown if the input is too long to be encoded with the given encoding scheme.
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.

getAlgorithm

public String getAlgorithm()
Returns the name of the algorithm used, ie PublicKeyEncryptorEngine.getAlgorithm() + "_PKCS1".

Returns:
A String that represents the name of the algorithm.
Since:
JDE 3.6.0
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.

getInputBlockLength

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

Since:
JDE 3.6.0

Following copied from interface: BlockFormatterEngine
Returns:
An integer that represents the length of a block in bytes.
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.

getOutputBlockLength

public int getOutputBlockLength()
Description copied from interface: BlockFormatterEngine
Returns the length of an output block in bytes.

Since:
JDE 3.6.0

Following copied from interface: BlockFormatterEngine
Returns:
An integer that represents the output block length in bytes.
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.



Copyright 1999-2009 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.