org.bouncycastle.crypto.modes

Class CCMBlockCipher

Implemented Interfaces:
AEADBlockCipher

public class CCMBlockCipher
extends java.lang.Object
implements AEADBlockCipher

Implements the Counter with Cipher Block Chaining mode (CCM) detailed in NIST Special Publication 800-38C.

Note: this mode is a packet mode - it needs all the data up front.

Constructor Summary

CCMBlockCipher(BlockCipher c)
Basic constructor.

Method Summary

int
doFinal(byte[] out, int outOff)
String
getAlgorithmName()
byte[]
getMac()
Returns a byte array containing the mac calculated as part of the last encrypt or decrypt operation.
int
getOutputSize(int len)
BlockCipher
getUnderlyingCipher()
return the underlying block cipher that we are wrapping.
int
getUpdateOutputSize(int len)
void
init(boolean forEncryption, CipherParameters params)
int
processByte(byte in, byte[] out, int outOff)
int
processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff)
byte[]
processPacket(byte[] in, int inOff, int inLen)
void
reset()

Constructor Details

CCMBlockCipher

public CCMBlockCipher(BlockCipher c)
Basic constructor.
Parameters:
c - the block cipher to be used.

Method Details

doFinal

public int doFinal(byte[] out,
                   int outOff)
            throws IllegalStateException,
                   InvalidCipherTextException
Specified by:
doFinal in interface AEADBlockCipher

getAlgorithmName

public String getAlgorithmName()
Specified by:
getAlgorithmName in interface AEADBlockCipher

getMac

public byte[] getMac()
Returns a byte array containing the mac calculated as part of the last encrypt or decrypt operation.
Specified by:
getMac in interface AEADBlockCipher
Returns:
the last mac calculated.

getOutputSize

public int getOutputSize(int len)
Specified by:
getOutputSize in interface AEADBlockCipher

getUnderlyingCipher

public BlockCipher getUnderlyingCipher()
return the underlying block cipher that we are wrapping.
Specified by:
getUnderlyingCipher in interface AEADBlockCipher
Returns:
the underlying block cipher that we are wrapping.

getUpdateOutputSize

public int getUpdateOutputSize(int len)
Specified by:
getUpdateOutputSize in interface AEADBlockCipher

init

public void init(boolean forEncryption,
                 CipherParameters params)
            throws IllegalArgumentException
Specified by:
init in interface AEADBlockCipher

processByte

public int processByte(byte in,
                       byte[] out,
                       int outOff)
            throws DataLengthException,
                   IllegalStateException
Specified by:
processByte in interface AEADBlockCipher

processBytes

public int processBytes(byte[] in,
                        int inOff,
                        int inLen,
                        byte[] out,
                        int outOff)
            throws DataLengthException,
                   IllegalStateException
Specified by:
processBytes in interface AEADBlockCipher

processPacket

public byte[] processPacket(byte[] in,
                            int inOff,
                            int inLen)
            throws IllegalStateException,
                   InvalidCipherTextException

reset

public void reset()
Specified by:
reset in interface AEADBlockCipher