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

Quick Search    Search Deep

cryptix.jce.provider.mac
Class HMAC  view HMAC download HMAC.java

java.lang.Object
  extended byjavax.crypto.MacSpi
      extended bycryptix.jce.provider.mac.HMAC
Direct Known Subclasses:
HMAC_MD2, HMAC_MD4, HMAC_MD5, HMAC_RIPEMD128, HMAC_RIPEMD160, HMAC_SHA0, HMAC_SHA1, HMAC_SHA256, HMAC_SHA384, HMAC_SHA512, HMAC_Tiger

class HMAC
extends javax.crypto.MacSpi

Abstract class implementing the methods common to an HMAC. Subclasses implement specifics (just the name of MessageDigest to use + size).

Version:
$Revision: 1.6 $

Field Summary
private static byte IPAD
          Inner and outer padding constants
private  byte[] iv_i
          Inner and outer IVs
private  byte[] iv_o
          Inner and outer IVs
private  java.security.MessageDigest md
          Underlying MessageDigest
private  int mdBlockSize
          Block size and length of underlying MessageDigest
private  int mdLen
          Block size and length of underlying MessageDigest
private static byte OPAD
          Inner and outer padding constants
 
Constructor Summary
private HMAC(java.security.MessageDigest md, int mdBlockSize, int mdLen, byte[] iv_i, byte[] iv_o)
          Private constructor used for cloning.
protected HMAC(java.lang.String mdName, int mdBlockSize, int mdLen)
          Construct an HMAC on top of a MessageDigest.
 
Method Summary
 java.lang.Object clone()
          Clone this HMAC object.
protected  byte[] engineDoFinal()
          Finalize the computation of this MAC and return the result as a byte array.
protected  int engineGetMacLength()
          Return the length of this Mac which equals the length of the underlying MessageDigest.
protected  void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
          Initialize (or re-initialize) this instance.
protected  void engineReset()
          Reset this instance.
protected  void engineUpdate(byte input)
          Update this MAC with a single byte.
protected  void engineUpdate(byte[] input, int offset, int len)
          Update this MAC with a portion of a byte array.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IPAD

private static final byte IPAD
Inner and outer padding constants

See Also:
Constant Field Values

OPAD

private static final byte OPAD
Inner and outer padding constants

See Also:
Constant Field Values

md

private final java.security.MessageDigest md
Underlying MessageDigest


mdBlockSize

private final int mdBlockSize
Block size and length of underlying MessageDigest


mdLen

private final int mdLen
Block size and length of underlying MessageDigest


iv_i

private final byte[] iv_i
Inner and outer IVs


iv_o

private final byte[] iv_o
Inner and outer IVs

Constructor Detail

HMAC

protected HMAC(java.lang.String mdName,
               int mdBlockSize,
               int mdLen)
Construct an HMAC on top of a MessageDigest.


HMAC

private HMAC(java.security.MessageDigest md,
             int mdBlockSize,
             int mdLen,
             byte[] iv_i,
             byte[] iv_o)
Private constructor used for cloning.

Method Detail

engineGetMacLength

protected final int engineGetMacLength()
Return the length of this Mac which equals the length of the underlying MessageDigest.


engineInit

protected final void engineInit(java.security.Key key,
                                java.security.spec.AlgorithmParameterSpec params)
                         throws java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException
Description copied from class: javax.crypto.MacSpi
Initialize (or re-initialize) this instance.


engineUpdate

protected final void engineUpdate(byte input)
Description copied from class: javax.crypto.MacSpi
Update this MAC with a single byte.


engineUpdate

protected final void engineUpdate(byte[] input,
                                  int offset,
                                  int len)
Description copied from class: javax.crypto.MacSpi
Update this MAC with a portion of a byte array.


engineDoFinal

protected final byte[] engineDoFinal()
Description copied from class: javax.crypto.MacSpi
Finalize the computation of this MAC and return the result as a byte array.


engineReset

protected final void engineReset()
Description copied from class: javax.crypto.MacSpi
Reset this instance. After this method succeeds, the state of this instance should be the same as it was before any data was input (possibly after a call to #init(java.security.Key,java.security.spec.AlgorithmParameterSpec), possibly not).


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this HMAC object. We support cloning if the underlying MessageDigest does support cloning.