net.rim.device.api.crypto
Class OAEPFormatterEngine

java.lang.Object
  extended by net.rim.device.api.crypto.OAEPFormatterEngine
All Implemented Interfaces:
BlockFormatterEngine

public final class OAEPFormatterEngine
extends Object
implements BlockFormatterEngine

Referenced from site http://www.rsa.com/.

Optimal Asymmetric Encryption Padding (OAEP) is a method for encoding messages developed by Mihir Bellare and Phil Rogaway [BR94]. The technique of encoding a message with OAEP and then encrypting it with RSA is provably secure in the random oracle model. Informally, this means that if hash functions are truly random, then an adversary who can recover such a message must be able to break RSA.

An OAEP encoded message consists of a ``masked data'' string concatenated with a ``masked random number''. In the simplest form of OAEP, the masked data is formed by taking the XOR of the plaintext message M and the hash G of a random string r. The masked random number is the XOR of r with the hash H of the masked data. The input to the RSA encryption function is then [M XOR G(r)] || [r XOR H(M XOR G(r))]

Often, OAEP is used to encode small items such as keys. There are other variations on OAEP (differing only slightly from the above) that include a feature called ``plaintext-awareness''. This means that to construct a valid OAEP encoded message, an adversary must know the original plaintext. To accomplish this, the plaintext message M is first padded (for example, with a string of zeroes) before the masked data is formed. OAEP is supported in the ANSI X9.44, IEEE P1363 and SET standards.

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

For information on cryptographic algorithms, see Crypto Algorithms.

See Also:
OAEPUnformatterEngine
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 OAEPFormatterEngine(PublicKeyEncryptorEngine engine)
          Creates an OAEPFormatterEngine object based on the given encryptor engine, as well as the SHA-1 digest algorithm.
Category: Signed OAEPFormatterEngine(PublicKeyEncryptorEngine engine, byte[] parameters)
          Creates an OAEPFormatterEngine object based on the given encryptor engine, as well as the SHA-1 digest algorithm, and the given parameters.
Category: Signed OAEPFormatterEngine(PublicKeyEncryptorEngine engine, Digest digest)
          Creates an OAEPFormatterEngine object based on the given encryptor engine and digest algorithm.
Category: Signed OAEPFormatterEngine(PublicKeyEncryptorEngine engine, Digest digest, byte[] parameters)
          Creates an OAEPFormatterEngine object based on the given encryptor engine, digest algorithm and parameters.
 
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() + "_OAEP".
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

OAEPFormatterEngine

public OAEPFormatterEngine(PublicKeyEncryptorEngine engine)
Creates an OAEPFormatterEngine object based on the given encryptor engine, as well as the SHA-1 digest algorithm.

Parameters:
engine - The PublicKeyEncryptorEngine object used to encrypt the formatted message.
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

OAEPFormatterEngine

public OAEPFormatterEngine(PublicKeyEncryptorEngine engine,
                           byte[] parameters)
Creates an OAEPFormatterEngine object based on the given encryptor engine, as well as the SHA-1 digest algorithm, and the given parameters.

Parameters:
engine - The PublicKeyEncryptorEngine used to encrypt the formatted message.
parameters - A byte array containing the parameters to be incorporated into the formatted message.
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

OAEPFormatterEngine

public OAEPFormatterEngine(PublicKeyEncryptorEngine engine,
                           Digest digest)
Creates an OAEPFormatterEngine object based on the given encryptor engine and digest algorithm.

Parameters:
engine - The PublicKeyEncryptorEngine object used to encrypt the formatted message.
digest - The digest to be used during the formatting process.
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

OAEPFormatterEngine

public OAEPFormatterEngine(PublicKeyEncryptorEngine engine,
                           Digest digest,
                           byte[] parameters)
Creates an OAEPFormatterEngine object based on the given encryptor engine, digest algorithm and parameters.

Parameters:
engine - The PublicKeyEncryptorEngine object used to encrypt the formatted message.
digest - The digest to be used during the formatting process.
parameters - A byte array containing the parameters to be incorporated into the formatted message.
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 PublicKeyEncryptorEngine.getAlgorithm() + "_OAEP".

Specified by:
getAlgorithm in interface BlockFormatterEngine
Returns:
A String representing 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: BlockFormatterEngine
Returns the length of an input block in bytes.

Specified by:
getInputBlockLength in 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.
Since:
BlackBerry API 3.6.0

getOutputBlockLength

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

Specified by:
getOutputBlockLength in 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.
Since:
BlackBerry API 3.6.0

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.

Specified by:
formatAndEncrypt in 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.
Since:
BlackBerry API 3.6.0

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.

Specified by:
formatAndEncrypt in 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.
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