net.rim.device.api.crypto
Class AESEncryptorEngine

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

public final class AESEncryptorEngine
extends Object
implements SymmetricKeyEncryptorEngine

Creates an Advanced Encryption Standard (AES) encryption engine. AES is also known as Rijndael. For more information visit the NIST web page. The implementation of AES we give is defined in FIPS 197.

The AES cipher has a variable key length of 128, 192 or 256 bits. The block length is also variable but defaults to 128 bits. The other valid block lengths are 192 and 256 bits.

For a code sample using the AES encryptor engine, click here.

For information on cryptographic algorithms, see Crypto Algorithms.

See Also:
AESDecryptorEngine, AESKey
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
Category: Signed static int BLOCK_LENGTH_DEFAULT
          This is the default block length of a AES key
 
Constructor Summary
Category: Signed AESEncryptorEngine(AESKey key)
          Creates an instance of the AESEncryptorEngine class given the AES key with a default block length of 16 bytes.
Category: Signed AESEncryptorEngine(AESKey key, int blockLength)
          Creates an instance of the AESEncryptorEngine class given the AES key.
Category: Signed AESEncryptorEngine(AESKey key, int blockLength, boolean inECMMode)
          Creates an instance of the AESEncryptorEngine class given the AES key.
 
Method Summary
Category: Signed  void encrypt(byte[] plaintext, int plaintextOffset, byte[] ciphertext, int ciphertextOffset)
          Encrypts the data given a byte array containing the plaintext, a byte array to hold the ciphertext, and their associated offsets.
Category: Signed  String getAlgorithm()
          Returns the name of the algorithm with with key and block lengths, ie "AES_128_128" ("AES_" + keyBitLength + "_" + blockBitLength).
Category: Signed  int getBlockLength()
          Returns the block length of the encrypted data.
Category: Signed  int getKeyLength()
          Returns the length of the key in bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

BLOCK_LENGTH_DEFAULT

public static final int BLOCK_LENGTH_DEFAULT
This is the default block length of a AES key

See Also:
Constant Field Values
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.3.0


Constructor Detail

AESEncryptorEngine

public AESEncryptorEngine(AESKey key)
                   throws CryptoTokenException,
                          CryptoUnsupportedOperationException
Creates an instance of the AESEncryptorEngine class given the AES key with a default block length of 16 bytes.

Parameters:
key - The AESKey that will be used by the cipher to encrypt data.
Throws:
CryptoTokenException - Thrown when a problem 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

AESEncryptorEngine

public AESEncryptorEngine(AESKey key,
                          int blockLength)
                   throws CryptoTokenException,
                          CryptoUnsupportedOperationException
Creates an instance of the AESEncryptorEngine class given the AES key.

Parameters:
key - The AESKey that will be used by the cipher to encrpyt data.
blockLength - The block length of the cipher in bytes ( the valid lengths are 16, 24 and 32 ).
Throws:
CryptoTokenException - Thrown when a problem 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

AESEncryptorEngine

public AESEncryptorEngine(AESKey key,
                          int blockLength,
                          boolean inECMMode)
                   throws CryptoTokenException,
                          CryptoUnsupportedOperationException
Creates an instance of the AESEncryptorEngine class given the AES key.

Parameters:
key - The AESKey that will be used by the cipher to encrpyt data.
blockLength - The block length of the cipher in bytes ( the valid lengths are 16, 24 and 32 ).
inECMMode - If true, then use a strong, but slow, AES implementation (including many electromagnetic countermeasures); otherwise, use a faster implementation that is not as strong (including fewer electromagnetic countermeasures).
Throws:
CryptoTokenException - Thrown when a problem 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 4.3.0


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of the algorithm with with key and block lengths, ie "AES_128_128" ("AES_" + keyBitLength + "_" + blockBitLength).

Specified by:
getAlgorithm in interface BlockEncryptorEngine
Returns:
A string representing the algorithm 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

getKeyLength

public int getKeyLength()
Returns the length of the key in bytes.

Returns:
An integer representing the length of the key 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

getBlockLength

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

Specified by:
getBlockLength in interface BlockEncryptorEngine
Returns:
An integer representing the 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

encrypt

public void encrypt(byte[] plaintext,
                    int plaintextOffset,
                    byte[] ciphertext,
                    int ciphertextOffset)
             throws CryptoTokenException
Encrypts the data given a byte array containing the plaintext, a byte array to hold the ciphertext, and their associated offsets.

Specified by:
encrypt in interface BlockEncryptorEngine
Parameters:
plaintext - A byte array containing the plaintext.
plaintextOffset - The offset, or position of the first bit, of the plaintext.
ciphertext - A byte array containing the ciphertext.
ciphertextOffset - The offset, or position of the first bit, of the ciphertext.
Throws:
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.