org.clazzes.optional.sec
Interface AEADBlockCipher

All Superinterfaces:
BlockCipher
All Known Implementing Classes:
GCMCipher

public interface AEADBlockCipher
extends BlockCipher

A block cipher mode that includes authenticated encryption with a streaming mode and optional associated data. Copied from bouncycastle.


Method Summary
 int doFinal(byte[] out, int outOff)
          Finish the operation either appending or verifying the MAC at the end of the data.
 byte[] getMac()
          Return the value of the MAC associated with the last stream processed.
 int getOutputSize(int len)
           
 void init(byte[] aad, int macBits, byte[] iv, boolean forEncryption)
          Initialize the block cipher.
 int processBytes(byte[] in, int in_off, int in_len, byte[] out, int out_off)
          Proceed the next block of in_len bytes from the input.
 
Methods inherited from interface org.clazzes.optional.sec.BlockCipher
getAlgorithmName, getBlockSize, getUnderlyingCipher, init, processBlock, reset
 

Method Detail

init

void init(byte[] aad,
          int macBits,
          byte[] iv,
          boolean forEncryption)
Initialize the block cipher.

Parameters:
aad - The additional authenticated data or null, if no additional authenticated data is needed.
macBits - The length of the calculated myac in bits.
iv - The initialization (nonce) vector or null, if no initialization vector is needed.
forEncryption - Whether we want to encrypt. false means to set up this cipher for decryption.

processBytes

int processBytes(byte[] in,
                 int in_off,
                 int in_len,
                 byte[] out,
                 int out_off)
Proceed the next block of in_len bytes from the input. This complements the functionality of BlockCipher.processBlock(byte[], int, byte[], int), because AEAD ciphers may process arbitrary data length.

Parameters:
in - The buffer where the input is stored. BlockCipher.getBlockSize() bytes starting with in_off will be consumed.
in_off - The offset at which the input data starts.
in_len - The length of the input data to process.
out - The buffer where the output is stored. BlockCipher.getBlockSize() bytes starting with out_off will be written.
out_off - The offset at which the output will be stored.
Returns:
The block size aka the number of bytes written.

doFinal

int doFinal(byte[] out,
            int outOff)
            throws InvalidCipherTextException
Finish the operation either appending or verifying the MAC at the end of the data.

Parameters:
out - space for any resulting output data.
outOff - offset into out to start copying the data at.
Returns:
number of bytes written into out.
Throws:
InvalidCipherTextException - if the MAC fails to match.

getMac

byte[] getMac()
Return the value of the MAC associated with the last stream processed.

Returns:
MAC for plaintext data.

getOutputSize

int getOutputSize(int len)
Parameters:
len - The length of the input data.
Returns:
The length of the generated output data.


Copyright © 2010. All Rights Reserved.