FileDocCategorySizeDatePackage
HMACT64.javaAPI DocJCIFS 1.3.17 API3593Tue Oct 18 15:26:24 BST 2011jcifs.util

HMACT64

public class HMACT64 extends MessageDigest implements Cloneable
This is an implementation of the HMACT64 keyed hashing algorithm. HMACT64 is defined by Luke Leighton as a modified HMAC-MD5 (RFC 2104) in which the key is truncated at 64 bytes (rather than being hashed via MD5).

Fields Summary
private static final int
BLOCK_LENGTH
private static final byte
IPAD
private static final byte
OPAD
private MessageDigest
md5
private byte[]
ipad
private byte[]
opad
Constructors Summary
public HMACT64(byte[] key)
Creates an HMACT64 instance which uses the given secret key material.

param
key The key material to use in hashing.


                             
       
        super("HMACT64");
        int length = Math.min(key.length, BLOCK_LENGTH);
        for (int i = 0; i < length; i++) {
            ipad[i] = (byte) (key[i] ^ IPAD);
            opad[i] = (byte) (key[i] ^ OPAD);
        }
        for (int i = length; i < BLOCK_LENGTH; i++) {
            ipad[i] = IPAD;
            opad[i] = OPAD;
        }
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception ex) {
            throw new IllegalStateException(ex.getMessage());
        }
        engineReset();
    
private HMACT64(HMACT64 hmac)

        super("HMACT64");
        this.ipad = hmac.ipad;
        this.opad = hmac.opad;
        this.md5 = (MessageDigest) hmac.md5.clone();
    
Methods Summary
public java.lang.Objectclone()

        try {
            return new HMACT64(this);
        } catch (CloneNotSupportedException ex) {
            throw new IllegalStateException(ex.getMessage());
        }
    
protected byte[]engineDigest()

        byte[] digest = md5.digest();
        md5.update(opad);
        return md5.digest(digest);
    
protected intengineDigest(byte[] buf, int offset, int len)

        byte[] digest = md5.digest();
        md5.update(opad);
        md5.update(digest);
        try {
            return md5.digest(buf, offset, len);
        } catch (Exception ex) {
            throw new IllegalStateException();
        }
    
protected intengineGetDigestLength()

        return md5.getDigestLength();
    
protected voidengineReset()

        md5.reset();
        md5.update(ipad);
    
protected voidengineUpdate(byte b)

        md5.update(b);
    
protected voidengineUpdate(byte[] input, int offset, int len)

        md5.update(input, offset, len);