For the latest news and information visit
The GNU Crypto project

gnu.crypto.mode
Class EAX

java.lang.Object
  extended by gnu.crypto.mode.EAX
All Implemented Interfaces:
IBlockCipher, IMac, IAuthenticatedMode, IMode, Cloneable

public class EAX
extends Object
implements IAuthenticatedMode

A conventional two-pass authenticated-encrypted mode, EAX. EAX is a Authenticated Encryption with Additional Data (AEAD) scheme, which provides protection and authentication for the message, and provides authentication of an (optional) header. EAX is composed of the counter mode (CTR) and the one-key CBC MAC (OMAC).

This class makes full use of the IAuthenticatedMode interface, that is, all methods of both IMode and IMac can be used as specified in the IAuthenticatedMode interface.

References:

  1. M. Bellare, P. Rogaway, and D. Wagner; A Conventional Authenticated-Encryption Mode.


Field Summary
 
Fields inherited from interface gnu.crypto.mode.IMode
DECRYPTION, ENCRYPTION, IV, MODE_BLOCK_SIZE, STATE
 
Fields inherited from interface gnu.crypto.cipher.IBlockCipher
CIPHER_BLOCK_SIZE, KEY_MATERIAL
 
Fields inherited from interface gnu.crypto.mac.IMac
MAC_KEY_MATERIAL, TRUNCATED_SIZE
 
Constructor Summary
EAX(IBlockCipher cipher, int cipherBlockSize)
           
 
Method Summary
 Iterator blockSizes()
          Returns an Iterator over the supported block sizes.
 Object clone()
          Returns a clone of this instance.
 int currentBlockSize()
          Returns the currently set block size for this instance.
 void decryptBlock(byte[] in, int inOff, byte[] out, int outOff)
          Decrypts exactly one block of ciphertext.
 int defaultBlockSize()
          Returns the default value, in bytes, of the algorithm's block size.
 int defaultKeySize()
          Returns the default value, in bytes, of the algorithm's key size.
 byte[] digest()
          Completes the MAC by performing final operations such as padding and resetting the instance.
 void digest(byte[] out, int outOffset)
           
 void encryptBlock(byte[] in, int inOff, byte[] out, int outOff)
          Encrypts exactly one block of plaintext.
 void init(Map attrib)
          Initialises the algorithm with designated attributes.
 Iterator keySizes()
          Returns an Iterator over the supported key sizes.
 int macSize()
          Returns the output length in bytes of this MAC algorithm.
 String name()
          Returns the canonical name of this instance.
 void reset()
          Resets the algorithm instance for re-initialisation and use with other characteristics.
 boolean selfTest()
          A correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes, as well as one (1) variable key Known Answer Test (KAT).
 void update(byte b)
          Continues a MAC operation using the input byte.
 void update(byte[] in, int inOff, byte[] out, int outOff)
          A convenience method.
 void update(byte[] buf, int off, int len)
          Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EAX

public EAX(IBlockCipher cipher,
           int cipherBlockSize)
Method Detail

clone

public Object clone()
Description copied from interface: IBlockCipher

Returns a clone of this instance.

Specified by:
clone in interface IBlockCipher
Specified by:
clone in interface IMac
Overrides:
clone in class Object
Returns:
a clone copy of this instance.

name

public String name()
Description copied from interface: IBlockCipher

Returns the canonical name of this instance.

Specified by:
name in interface IBlockCipher
Specified by:
name in interface IMac
Returns:
the canonical name of this instance.

defaultBlockSize

public int defaultBlockSize()
Description copied from interface: IBlockCipher

Returns the default value, in bytes, of the algorithm's block size.

Specified by:
defaultBlockSize in interface IBlockCipher
Returns:
the default value, in bytes, of the algorithm's block size.

defaultKeySize

public int defaultKeySize()
Description copied from interface: IBlockCipher

Returns the default value, in bytes, of the algorithm's key size.

Specified by:
defaultKeySize in interface IBlockCipher
Returns:
the default value, in bytes, of the algorithm's key size.

blockSizes

public Iterator blockSizes()
Description copied from interface: IBlockCipher

Returns an Iterator over the supported block sizes. Each element returned by this object is an Integer.

Specified by:
blockSizes in interface IBlockCipher
Returns:
an Iterator over the supported block sizes.

keySizes

public Iterator keySizes()
Description copied from interface: IBlockCipher

Returns an Iterator over the supported key sizes. Each element returned by this object is an Integer.

Specified by:
keySizes in interface IBlockCipher
Returns:
an Iterator over the supported key sizes.

init

public void init(Map attrib)
          throws InvalidKeyException
Description copied from interface: IBlockCipher

Initialises the algorithm with designated attributes. Permissible names and values are described in the class documentation above.

Specified by:
init in interface IBlockCipher
Specified by:
init in interface IMac
Parameters:
attrib - a set of name-value pairs that describes the desired future behaviour of this instance.
Throws:
InvalidKeyException - if the key data is invalid.
See Also:
IBlockCipher.KEY_MATERIAL, IBlockCipher.CIPHER_BLOCK_SIZE

currentBlockSize

public int currentBlockSize()
Description copied from interface: IBlockCipher

Returns the currently set block size for this instance.

Specified by:
currentBlockSize in interface IBlockCipher
Returns:
the current block size for this instance.

encryptBlock

public void encryptBlock(byte[] in,
                         int inOff,
                         byte[] out,
                         int outOff)
Description copied from interface: IBlockCipher

Encrypts exactly one block of plaintext.

Specified by:
encryptBlock in interface IBlockCipher
Parameters:
in - the plaintext.
inOff - index of in from which to start considering data.
out - the ciphertext.
outOff - index of out from which to store result.

decryptBlock

public void decryptBlock(byte[] in,
                         int inOff,
                         byte[] out,
                         int outOff)
Description copied from interface: IBlockCipher

Decrypts exactly one block of ciphertext.

Specified by:
decryptBlock in interface IBlockCipher
Parameters:
in - the plaintext.
inOff - index of in from which to start considering data.
out - the ciphertext.
outOff - index of out from which to store result.

update

public void update(byte[] in,
                   int inOff,
                   byte[] out,
                   int outOff)
Description copied from interface: IMode

A convenience method. Effectively invokes the encryptBlock() or decryptBlock() method depending on the operational state of the instance.

Specified by:
update in interface IMode
Parameters:
in - the plaintext.
inOff - index of in from which to start considering data.
out - the ciphertext.
outOff - index of out from which to store result.

reset

public void reset()
Description copied from interface: IBlockCipher

Resets the algorithm instance for re-initialisation and use with other characteristics. This method always succeeds.

Specified by:
reset in interface IBlockCipher
Specified by:
reset in interface IMac

selfTest

public boolean selfTest()
Description copied from interface: IBlockCipher

A correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes, as well as one (1) variable key Known Answer Test (KAT).

Specified by:
selfTest in interface IBlockCipher
Specified by:
selfTest in interface IMac
Returns:
true if the implementation passes simple correctness tests. Returns false otherwise.

macSize

public int macSize()
Description copied from interface: IMac

Returns the output length in bytes of this MAC algorithm.

Specified by:
macSize in interface IMac
Returns:
the output length in bytes of this MAC algorithm.

digest

public byte[] digest()
Description copied from interface: IMac

Completes the MAC by performing final operations such as padding and resetting the instance.

Specified by:
digest in interface IMac
Returns:
the array of bytes representing the MAC value.

digest

public void digest(byte[] out,
                   int outOffset)

update

public void update(byte b)
Description copied from interface: IMac

Continues a MAC operation using the input byte.

Specified by:
update in interface IMac
Parameters:
b - the input byte to digest.

update

public void update(byte[] buf,
                   int off,
                   int len)
Description copied from interface: IMac

Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.

Specified by:
update in interface IMac
Parameters:
buf - the input block.
off - start of meaningful bytes in input block.
len - number of bytes, in input block, to consider.

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.