net.rim.device.api.crypto
Class ElGamalEncryptorEngine

java.lang.Object
  extended by net.rim.device.api.crypto.ElGamalEncryptorEngine
All Implemented Interfaces:
BlockEncryptorEngine, PublicKeyEncryptorEngine

public final class ElGamalEncryptorEngine
extends Object
implements PublicKeyEncryptorEngine

In ElGamal encryption, two parts are generated and both are required to decrypt data. The first part is the ciphertext. The ciphertext is stored in a byte array and is passed into the encryptor engine as the parameter ciphertext.

The next part is the ephemeral key. The ephemeral key is acquired by calling the getEphmeralKey() method and sent to the recipient along with the ciphertext. Without the ephemeral key the ciphertext cannot be decrypted.

The version of ElGamal that we implemented can be found in "Applied Cryptography", by Bruce Schneier, in section 19.6 ( 1996 ).

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:
BlackBerry API 3.6.0

Constructor Summary
Category: Signed ElGamalEncryptorEngine(DHPublicKey remoteKey)
          Creates an ElGamalEncryptorEngine object using the specified ElGamal public key.
Category: Signed ElGamalEncryptorEngine(DHPublicKey remoteKey, DHKeyPair localEphemeralKeyPairPair)
          Creates an ElGamalEncryptorEngine object.
 
Method Summary
Category: Signed  void encrypt(byte[] plaintext, int plaintextOffset, byte[] ciphertext, int ciphertextOffset)
          Encrypts the plaintext with the ElGamal algorithm.
Category: Signed  String getAlgorithm()
          Returns the name of the algoritm used to encrypt the data.
Category: Signed  int getBlockLength()
          Return the block length of the encrypted data.
Category: Signed  DHPublicKey getEphemeralKey()
          Returns the ephemeral key used to encrypt the data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

ElGamalEncryptorEngine

public ElGamalEncryptorEngine(DHPublicKey remoteKey)
                       throws CryptoTokenException,
                              CryptoUnsupportedOperationException
Creates an ElGamalEncryptorEngine object using the specified ElGamal public key.

Parameters:
remoteKey - The remote key to use for encrypting.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
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

ElGamalEncryptorEngine

public ElGamalEncryptorEngine(DHPublicKey remoteKey,
                              DHKeyPair localEphemeralKeyPairPair)
                       throws CryptoTokenException,
                              CryptoUnsupportedOperationException
Creates an ElGamalEncryptorEngine object.

Parameters:
remoteKey - The key to encrypt the data with.
localPair - The local key pair to encrypt with, if null this is the same as the first constructor.
Throws:
CryptoTokenException - Thrown if an error occurs with a crypto token or the crypto token is invalid.
CryptoUnsupportedOperationException - Thrown if a call is made to an unsupported operation.
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 algoritm used to encrypt the data.

This method will always return the String "ElGamal".

Specified by:
getAlgorithm in interface BlockEncryptorEngine
Returns:
The name of the algorithm used, ie "ElGamal".
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

public void encrypt(byte[] plaintext,
                    int plaintextOffset,
                    byte[] ciphertext,
                    int ciphertextOffset)
             throws CryptoTokenException
Encrypts the plaintext with the ElGamal algorithm. Can only be called once per object

Specified by:
encrypt in interface BlockEncryptorEngine
Parameters:
plaintext - The text to be encoded.
plaintextOffset - The offset, or start position of the plaintext data, within the array.
ciphertext - The byte array to hold the ciphertext.
ciphertextOffset - The offset, or start position, of the ciphertext within the array.
Throws:
CryptoTokenException - Thrown if an error 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

getEphemeralKey

public DHPublicKey getEphemeralKey()
Returns the ephemeral key used to encrypt the data.

Returns:
The ephemeral key required for decryption.
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

getBlockLength

public int getBlockLength()
Return the block length of the encrypted data.

The block length corresponds to the amount of data that is encrypted at one time.

Specified by:
getBlockLength in interface BlockEncryptorEngine
Returns:
The required length of blocks to be passed through the encryptor.
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.