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

Quick Search    Search Deep

gnu.javax.net.ssl.provider
Class SSLHMac  view SSLHMac download SSLHMac.java

java.lang.Object
  extended bygnu.javax.net.ssl.provider.SSLHMac
All Implemented Interfaces:
java.lang.Cloneable, gnu.javax.crypto.mac.IMac

class SSLHMac
extends java.lang.Object
implements gnu.javax.crypto.mac.IMac, java.lang.Cloneable

The MAC function in SSLv3. This mac is defined as:

 hash(MAC_write_secret, pad_2 +
      hash(MAC_write_secret + pad_1 + data));

hash is e.g. MD5 or SHA-1, pad_1 is the value 0x36 48 times for MD5 and 40 times for SHA-1, and pad_2 is the value 0x5c repeated similarly.


Field Summary
protected  byte[] key
           
protected  gnu.java.security.hash.IMessageDigest md
           
protected  byte[] pad1
           
(package private) static byte PAD1
           
protected  byte[] pad2
           
(package private) static byte PAD2
           
 
Fields inherited from interface gnu.javax.crypto.mac.IMac
MAC_KEY_MATERIAL, TRUNCATED_SIZE
 
Constructor Summary
(package private) SSLHMac(java.lang.String mdName)
           
 
Method Summary
 java.lang.Object clone()
          Returns a clone copy of this instance.
 byte[] digest()
          Completes the MAC by performing final operations such as padding and resetting the instance.
 void init(java.util.Map attributes)
          Initialises the algorithm with designated attributes.
 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[] 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

PAD1

static final byte PAD1
See Also:
Constant Field Values

PAD2

static final byte PAD2
See Also:
Constant Field Values

md

protected gnu.java.security.hash.IMessageDigest md

key

protected byte[] key

pad1

protected final byte[] pad1

pad2

protected final byte[] pad2
Constructor Detail

SSLHMac

SSLHMac(java.lang.String mdName)
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.mac.IMac

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.mac.IMac

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

init

public void init(java.util.Map attributes)
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.mac.IMac

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.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

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

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.mac.IMac