Top Description Fields Constructors Methods
com.ongres.scram.common.bouncycastle.pbkdf2

public Class HMac

extends Object
implements Mac
Class Inheritance
All Implemented Interfaces
com.ongres.scram.common.bouncycastle.pbkdf2.Mac
Imports
java.util.Hashtable

HMAC implementation based on RFC2104 H(K XOR opad, H(K XOR ipad, text))

Field Summary

Modifier and TypeField and Description
private int
private static Hashtable<String, Integer>
private Digest
private int
private byte[]
private static final byte
private Memoable
private static final byte
private Memoable
private byte[]

Constructor Summary

AccessConstructor and Description
public
HMac(Digest
the digest.
digest
)

Base constructor for one of the standard digest algorithms that the byteLength of the algorithm is know for.

private
HMac(Digest digest, int byteLength)

Method Summary

Modifier and TypeMethod and Description
public int
doFinal(byte[]
the array the MAC is to be output to.
out
,
int
the offset into the out buffer the output is to start at.
outOff
)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.doFinal.

Compute the final stage of the MAC writing the output to the out parameter.
public String
getAlgorithmName()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getAlgorithmName.

Return the name of the algorithm the MAC implements.
private static int
public int
getMacSize()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getMacSize.

Return the block size for this MAC (in bytes).
public Digest
public void
init(CipherParameters
the key and other data required by the MAC.
params
)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.init.

Initialise the MAC.
public void
reset()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.reset.

Reset the mac generator.
public void
update(byte
the byte to be processed.
in
)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

add a single byte to the mac for processing.
public void
update(byte[]
the array containing the input.
in
,
int
the index in the array the data begins at.
inOff
,
int
the length of the input starting at inOff.
len
)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

private static void
xorPad(byte[] pad, int len, byte n)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockLengthback to summary
private int blockLength
blockLengthsback to summary
private static Hashtable<String, Integer> blockLengths
digestback to summary
private Digest digest
digestSizeback to summary
private int digestSize
inputPadback to summary
private byte[] inputPad
IPADback to summary
private static final byte IPAD
ipadStateback to summary
private Memoable ipadState
OPADback to summary
private static final byte OPAD
opadStateback to summary
private Memoable opadState
outputBufback to summary
private byte[] outputBuf

Constructor Detail

HMacback to summary
public HMac(Digest digest)

Base constructor for one of the standard digest algorithms that the byteLength of the algorithm is know for.

Parameters
digest:Digest

the digest.

HMacback to summary
private HMac(Digest digest, int byteLength)

Method Detail

doFinalback to summary
public int doFinal(byte[] out, int outOff)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.doFinal.

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.doFinal.

Compute the final stage of the MAC writing the output to the out parameter.

doFinal leaves the MAC in the same state it was after the last init.

Parameters
out:byte[]

the array the MAC is to be output to.

outOff:int

the offset into the out buffer the output is to start at.

getAlgorithmNameback to summary
public String getAlgorithmName()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getAlgorithmName.

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getAlgorithmName.

Return the name of the algorithm the MAC implements.

Returns:String

the name of the algorithm the MAC implements.

getByteLengthback to summary
private static int getByteLength(Digest digest)
getMacSizeback to summary
public int getMacSize()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getMacSize.

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.getMacSize.

Return the block size for this MAC (in bytes).

Returns:int

the block size for this MAC in bytes.

getUnderlyingDigestback to summary
public Digest getUnderlyingDigest()
initback to summary
public void init(CipherParameters params)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.init.

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.init.

Initialise the MAC.

Parameters
params:CipherParameters

the key and other data required by the MAC.

resetback to summary
public void reset()

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.reset.

Reset the mac generator.

updateback to summary
public void update(byte in)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

add a single byte to the mac for processing.

Parameters
in:byte

the byte to be processed.

updateback to summary
public void update(byte[] in, int inOff, int len)

Implements com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

Parameters
in:byte[]

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

the array containing the input.

inOff:int

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

the index in the array the data begins at.

len:int

Doc from com.ongres.scram.common.bouncycastle.pbkdf2.Mac.update.

the length of the input starting at inOff.

xorPadback to summary
private static void xorPad(byte[] pad, int len, byte n)