|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.amx.duet.tools.security.AESCrypto
AESCrypto.java
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Optimised Java implementation of the AES(a.k.a. Rijndael) symmetric block cipher.
The AESCryto.java provides a "bare-bones" implementation of the AES algorithm suitable for J2ME or any other Java platform. This implementation meets the AES specification FIPS 197, found at http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
For more information on the AES Algorithm (Rijndael), see http://csrc.nist.gov/archive/aes/index.html
AES (Rijndael) Symmetric Block Cipher
The AES algorithm is a symmetric block cipher that can encrypt (encipher) and decrypt (decipher) information.
The AES algorithm is capable of using cryptographic keys of 128, 192, and 256 bits to encrypt and decrypt data in blocks of 128 bits.
This particular implementation of AES uses the Electronic Codebook (ECB) mode of encryption in which each block of data is encrypted individually. If a single bit of the cipher text block is mangled, the entire corresponding plain text block will also be mangled.
Field Summary | |
static int |
BLOCK_BITS
AES block size in bits |
static int |
BLOCK_SIZE
AES block size in bytes |
static int |
DIR_BOTH
Flag to setup both key schedules (encryption/decryption). |
static int |
DIR_DECRYPT
Flag to setup the decryption key schedule. |
static int |
DIR_ENCRYPT
Flag to setup the encryption key schedule. |
Constructor Summary | |
AESCrypto()
|
Method Summary | |
byte[] |
Decrypt(byte[] ciphertext)
Decrypts some text. |
void |
decrypt(byte[] ct,
byte[] pt)
Decrypt exactly one block (BLOCK_SIZE bytes) of ciphertext. |
void |
dispose()
Dispose of all sensitive information in this object. |
byte[] |
Encrypt(byte[] plaintext)
Encrypts some text. |
void |
encrypt(byte[] pt,
byte[] ct)
Encrypt exactly one block (BLOCK_SIZE bytes) of plaintext. |
boolean |
isDisposed()
If both the encryption and the decryption key schedules are null this method will return true otherwise false. |
void |
makeKey(byte[] cipherKey)
Setup the AES key schedule (any cipher direction). |
void |
makeKey(byte[] cipherKey,
int direction)
Setup the AES key schedule for encryption, decryption, or both. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DIR_ENCRYPT
public static final int DIR_DECRYPT
public static final int DIR_BOTH
public static final int BLOCK_BITS
public static final int BLOCK_SIZE
Constructor Detail |
public AESCrypto()
Method Detail |
public void makeKey(byte[] cipherKey, int direction) throws java.text.ParseException
cipherKey
- the cipher key (128, 192, or 256 bits).direction
- cipher direction (DIR_ENCRYPT, DIR_DECRYPT, or DIR_BOTH).
java.text.ParseException
- If the key does not meet the length requirement.public void makeKey(byte[] cipherKey) throws java.text.ParseException
cipherKey
- the cipher key (128, 192, or 256 bits).
java.text.ParseException
- If the key does not meet the length requirement.public void encrypt(byte[] pt, byte[] ct) throws java.lang.RuntimeException, java.text.ParseException
pt
- plaintext block.ct
- ciphertext block.
java.lang.RuntimeException
- If null encryption key schedule.
java.text.ParseException
- If the plaintext does not meet the length requirements.public byte[] Encrypt(byte[] plaintext) throws java.lang.RuntimeException
java.lang.RuntimeException
- if null encryption key schedule.public void decrypt(byte[] ct, byte[] pt) throws java.lang.RuntimeException, java.text.ParseException
ct
- ciphertext block.pt
- plaintext block.
java.lang.RuntimeException
- If null decryption key schedule.
java.text.ParseException
- If ciphertext does not meet the length requirement.public byte[] Decrypt(byte[] ciphertext) throws java.text.ParseException
ciphertext
-
java.text.ParseException
- If the ciphertext does not meet the length requirements.
java.lang.RuntimeException
- if null decryption key schedule.public final void dispose()
public final boolean isDisposed()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |