anon.crypto
Class MyAES

java.lang.Object
  extended by anon.crypto.MyAES

public class MyAES
extends java.lang.Object

This class is a wrapper for doing AES encryption stuff.


Field Summary
private  org.bouncycastle.crypto.engines.AESFastEngine m_AES
          Stores the used AES encryption algorithm.
private  byte[] m_arCounter
          Same variables for CTR mode
private  byte[] m_arCounterOut
           
private  int m_posCTR
           
 
Constructor Summary
MyAES()
          Creates a new instance of Aes.
 
Method Summary
 void init(boolean bEncrypt, byte[] a_aesKey)
          Initialises instance of Aes for encryption or decryption.
 void init(boolean bEncrypt, byte[] a_aesKey, int off, int len)
          Initialises instance of Aes for encryption or decryption.
 byte[] processBlockECB(byte[] a_plainData)
          Encrypts/Decrypts one single plain data block and returns the cipher data block.
 void processBlockECB(byte[] a_InData, byte[] a_OutData)
          Encrypts/Decrypts one single plain data block and returns the cipher data block.
 void processBytesCTR(byte[] in, int inOff, byte[] out, int outOff, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_AES

private org.bouncycastle.crypto.engines.AESFastEngine m_AES
Stores the used AES encryption algorithm.


m_arCounter

private byte[] m_arCounter
Same variables for CTR mode


m_arCounterOut

private byte[] m_arCounterOut

m_posCTR

private int m_posCTR
Constructor Detail

MyAES

public MyAES()
Creates a new instance of Aes.

Method Detail

init

public void init(boolean bEncrypt,
                 byte[] a_aesKey)
          throws java.lang.Exception
Initialises instance of Aes for encryption or decryption. The size of the key must be 16 bytes (128 bit), 24 bytes (192 bit) or 32 bytes (256 bit). If the key size doesn't fit, an exception is thrown.

Parameters:
a_aesKey - The 128 bit or 192 bit or 256 bit AES key.
Throws:
java.lang.Exception

init

public void init(boolean bEncrypt,
                 byte[] a_aesKey,
                 int off,
                 int len)
          throws java.lang.Exception
Initialises instance of Aes for encryption or decryption. The size of the key must be 16 bytes (128 bit), 24 bytes (192 bit) or 32 bytes (256 bit). If the key size doesn't fit, an exception is thrown.

Parameters:
a_aesKey - The 128 bit or 192 bit or 256 bit AES key.
Throws:
java.lang.Exception

processBlockECB

public void processBlockECB(byte[] a_InData,
                            byte[] a_OutData)
                     throws java.lang.Exception
Encrypts/Decrypts one single plain data block and returns the cipher data block. The blocksize is always 16 bytes (128 bit). If the plain data block is shorter than 16 bytes, an exception is thrown, if it is longer, only the first 16 bytes are encrypted and returned in the cipher block.

Parameters:
a_plainData - The plain data block.
Throws:
java.lang.Exception

processBlockECB

public byte[] processBlockECB(byte[] a_plainData)
                       throws java.lang.Exception
Encrypts/Decrypts one single plain data block and returns the cipher data block. The blocksize is always 16 bytes (128 bit). If the plain data block is shorter than 16 bytes, an exception is thrown, if it is longer, only the first 16 bytes are encrypted and returned in the cipher block.

Parameters:
a_plainData - The plain data block.
Returns:
The cipher data block. The length is always 16 bytes.
Throws:
java.lang.Exception

processBytesCTR

public void processBytesCTR(byte[] in,
                            int inOff,
                            byte[] out,
                            int outOff,
                            int len)
                     throws java.lang.Exception
Throws:
java.lang.Exception