AES_CBCpublic class AES_CBC extends AES_ECB
Fields Summary |
---|
private byte[] | scratchPadInternal buffer. | private byte[] | savedStateSaved internal buffer. |
Constructors Summary |
---|
public AES_CBC()Constructor.
super();
scratchPad = new byte[BLOCK_SIZE];
|
Methods Summary |
---|
public int | doFinal(byte[] inBuff, int inOffset, int inLength, byte[] outBuff, int outOffset)Encrypts or decrypts data in a single-part operation, or finishes a
multiple-part operation. The data is encrypted or decrypted,
depending on how this cipher was initialized.
int result = super.doFinal(inBuff, inOffset, inLength,
outBuff, outOffset);
System.arraycopy(IV, 0, state, 0, BLOCK_SIZE);
return result;
| public void | init(int mode, Key key, CryptoParameter params)Initializes this cipher with a key and a set of algorithm
parameters.
doInit(mode, "AES", key, true, params);
System.arraycopy(IV, 0, state, 0, BLOCK_SIZE);
| protected void | processBlock(byte[] out, int offset)Depending on the mode, either encrypts or decrypts one block.
if (mode == Cipher.ENCRYPT_MODE) {
Util.xorArrays(holdData, state);
cipherBlock();
System.arraycopy(state, 0, out, offset, BLOCK_SIZE);
} else {
System.arraycopy(state, 0, scratchPad, 0, BLOCK_SIZE);
decipherBlock();
Util.xorArrays(state, scratchPad);
System.arraycopy(state, 0, out, offset, BLOCK_SIZE);
System.arraycopy(holdData, 0, state, 0, BLOCK_SIZE);
}
holdCount = 0;
| protected void | restoreState()Restores internal state.
super.restoreState();
state = savedState;
| protected void | saveState()Saves internal state.
super.saveState();
savedState = Util.cloneArray(state);
|
|