Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.crypto.mode
Class EAX  view EAX download EAX.java

java.lang.Object
  extended bygnu.javax.crypto.mode.EAX
All Implemented Interfaces:
java.lang.Cloneable, IAuthenticatedMode, gnu.javax.crypto.cipher.IBlockCipher, gnu.javax.crypto.mac.IMac, IMode

public class EAX
extends java.lang.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 gnu.javax.crypto.mac.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
private  gnu.javax.crypto.cipher.IBlockCipher cipher
          The cipher.
private  int cipherBlockSize
          The cipher block size.
private  IMode ctr
          The CTR instance.
private  gnu.javax.crypto.mac.IMac headerOmac
          The header OMAC instance.
private  boolean init
          Whether we're initialized or not.
private  gnu.javax.crypto.mac.IMac msgOmac
          The message OMAC instance.
private  gnu.javax.crypto.mac.IMac nonceOmac
          The nonce OMAC instance.
private  int state
          The direction state (encrypting or decrypting).
private  byte[] t_n
          The [t]_n array.
private  int tagSize
          The tag size, in bytes.
private static boolean valid
           
 
Fields inherited from interface gnu.javax.crypto.mode.IMode
DECRYPTION, ENCRYPTION, IV, MODE_BLOCK_SIZE, STATE
 
Fields inherited from interface gnu.javax.crypto.cipher.IBlockCipher
CIPHER_BLOCK_SIZE, KEY_MATERIAL
 
Fields inherited from interface gnu.javax.crypto.mac.IMac
MAC_KEY_MATERIAL, TRUNCATED_SIZE
 
Constructor Summary
EAX(gnu.javax.crypto.cipher.IBlockCipher cipher, int cipherBlockSize)
           
 
Method Summary
 java.util.Iterator blockSizes()
          Returns an java.util.Iterator over the supported block sizes.
 java.lang.Object clone()
          Returns a clone copy 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(java.util.Map attrib)
          Initialises the algorithm with designated attributes.
 java.util.Iterator keySizes()
          Returns an java.util.Iterator over the supported key sizes.
 int macSize()
          Returns the output length in bytes of this MAC algorithm.
 java.lang.String name()
          Returns the canonical name of this algorithm.
 void reset()
          Resets the algorithm instance for re-initialisation and use with other characteristics.
 boolean selfTest()
          A basic test.
 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
 

Field Detail

tagSize

private int tagSize
The tag size, in bytes.


nonceOmac

private gnu.javax.crypto.mac.IMac nonceOmac
The nonce OMAC instance.


headerOmac

private gnu.javax.crypto.mac.IMac headerOmac
The header OMAC instance.


msgOmac

private gnu.javax.crypto.mac.IMac msgOmac
The message OMAC instance.


ctr

private IMode ctr
The CTR instance.


state

private int state
The direction state (encrypting or decrypting).


init

private boolean init
Whether we're initialized or not.


cipherBlockSize

private int cipherBlockSize
The cipher block size.


cipher

private gnu.javax.crypto.cipher.IBlockCipher cipher
The cipher.


t_n

private byte[] t_n
The [t]_n array.


valid

private static boolean valid
Constructor Detail

EAX

public EAX(gnu.javax.crypto.cipher.IBlockCipher cipher,
           int cipherBlockSize)
Method Detail

clone

public java.lang.Object clone()
Description copied from interface: gnu.javax.crypto.mac.IMac

Returns a clone copy of this instance.

Specified by:
clone in interface gnu.javax.crypto.cipher.IBlockCipher

name

public java.lang.String name()
Description copied from interface: gnu.javax.crypto.mac.IMac

Returns the canonical name of this algorithm.

Specified by:
name in interface gnu.javax.crypto.cipher.IBlockCipher

defaultBlockSize

public int defaultBlockSize()
Description copied from interface: gnu.javax.crypto.cipher.IBlockCipher

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

Specified by:
defaultBlockSize in interface gnu.javax.crypto.cipher.IBlockCipher

defaultKeySize

public int defaultKeySize()
Description copied from interface: gnu.javax.crypto.cipher.IBlockCipher

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

Specified by:
defaultKeySize in interface gnu.javax.crypto.cipher.IBlockCipher

blockSizes

public java.util.Iterator blockSizes()
Description copied from interface: gnu.javax.crypto.cipher.IBlockCipher

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

Specified by:
blockSizes in interface gnu.javax.crypto.cipher.IBlockCipher

keySizes

public java.util.Iterator keySizes()
Description copied from interface: gnu.javax.crypto.cipher.IBlockCipher

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

Specified by:
keySizes in interface gnu.javax.crypto.cipher.IBlockCipher

init

public void init(java.util.Map attrib)
          throws java.security.InvalidKeyException
Description copied from interface: gnu.javax.crypto.mac.IMac

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

Specified by:
init in interface gnu.javax.crypto.cipher.IBlockCipher

currentBlockSize

public int currentBlockSize()
Description copied from interface: gnu.javax.crypto.cipher.IBlockCipher

Returns the currently set block size for this instance.

Specified by:
currentBlockSize in interface gnu.javax.crypto.cipher.IBlockCipher

encryptBlock

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

Encrypts exactly one block of plaintext.

Specified by:
encryptBlock in interface gnu.javax.crypto.cipher.IBlockCipher

decryptBlock

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

Decrypts exactly one block of ciphertext.

Specified by:
decryptBlock in interface gnu.javax.crypto.cipher.IBlockCipher

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

reset

public void reset()
Description copied from interface: gnu.javax.crypto.mac.IMac

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

Specified by:
reset in interface gnu.javax.crypto.cipher.IBlockCipher

selfTest

public boolean selfTest()
Description copied from interface: gnu.javax.crypto.mac.IMac

A basic test. Ensures that the MAC of a pre-determined message is equal to a known pre-computed value.

Specified by:
selfTest in interface gnu.javax.crypto.cipher.IBlockCipher

macSize

public int macSize()
Description copied from interface: gnu.javax.crypto.mac.IMac

Returns the output length in bytes of this MAC algorithm.

Specified by:
macSize in interface gnu.javax.crypto.mac.IMac

digest

public byte[] digest()
Description copied from interface: gnu.javax.crypto.mac.IMac

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

Specified by:
digest in interface gnu.javax.crypto.mac.IMac

digest

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

update

public void update(byte b)
Description copied from interface: gnu.javax.crypto.mac.IMac

Continues a MAC operation using the input byte.

Specified by:
update in interface gnu.javax.crypto.mac.IMac

update

public void update(byte[] buf,
                   int off,
                   int len)
Description copied from interface: gnu.javax.crypto.mac.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 gnu.javax.crypto.mac.IMac