Top Description Fields Constructors Methods
org.bouncycastle.tls.crypto.impl.jcajce

pack-priv Class JcaSSL3HMAC

extends Object
implements TlsHMAC
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.TlsHMAC, org.bouncycastle.tls.crypto.TlsMAC
Imports
org.bouncycastle.tls.TlsUtils, org.bouncycastle.tls.crypto.TlsHMAC, .TlsHash, org.bouncycastle.util.Arrays

HMAC implementation based on original internet draft for HMAC (RFC 2104)

The difference is that padding is concatenated versus XORed with the key

H(K + opad, H(K + ipad, text))

Field Summary

Modifier and TypeField and Description
private TlsHash
private final int
private final int
private static final byte[]
private static final byte
private static final byte[]
private static final byte
private int
private byte[]

Constructor Summary

AccessConstructor and Description
pack-priv
JcaSSL3HMAC(TlsHash
the digest.
digest
,
int
the digest size.
digestSize
,
int
the digest internal block size.
internalBlockSize
)

Base constructor for one of the standard digest algorithms for which the byteLength of the algorithm is known.

Method Summary

Modifier and TypeMethod and Description
public byte[]
calculateMAC()

Implements org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Return calculated MAC for any input passed in.

public void
calculateMAC(byte[]
output array to write the MAC to.
output
,
int
offset into the output array to write the MAC to.
outOff
)

Implements org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Write the calculated MAC to an output buffer.

private static byte[]
genPad(byte b, int count)

public int
getInternalBlockSize()

Implements org.bouncycastle.tls.crypto.TlsHMAC.getInternalBlockSize.

Return the internal block size for the message digest underlying this HMAC service.

public int
getMacLength()

Implements org.bouncycastle.tls.crypto.TlsMAC.getMacLength.

Return the length of the MAC generated by this service.

public void
reset()

Implements org.bouncycastle.tls.crypto.TlsMAC.reset.

Reset the mac generator.

public void
setKey(byte[]
array holding the MAC key.
key
,
int
offset into the array the key starts at.
keyOff
,
int
length of the key in the array.
keyLen
)

Implements org.bouncycastle.tls.crypto.TlsMAC.setKey.

Set the key to be used by the MAC implementation supporting this service.

public void
update(byte[]
input array containing the data.
in
,
int
offset into the input array the input starts at.
inOff
,
int
the length of the input data.
len
)

Implements org.bouncycastle.tls.crypto.TlsMAC.update.

Update the MAC with the passed in input.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

digestback to summary
private TlsHash digest
digestSizeback to summary
private final int digestSize
internalBlockSizeback to summary
private final int internalBlockSize
IPADback to summary
private static final byte[] IPAD
IPAD_BYTEback to summary
private static final byte IPAD_BYTE
OPADback to summary
private static final byte[] OPAD
OPAD_BYTEback to summary
private static final byte OPAD_BYTE
padLengthback to summary
private int padLength
secretback to summary
private byte[] secret

Constructor Detail

JcaSSL3HMACback to summary
pack-priv JcaSSL3HMAC(TlsHash digest, int digestSize, int internalBlockSize)

Base constructor for one of the standard digest algorithms for which the byteLength of the algorithm is known. Behaviour is undefined for digests other than MD5 or SHA1.

Parameters
digest:TlsHash

the digest.

digestSize:int

the digest size.

internalBlockSize:int

the digest internal block size.

Method Detail

calculateMACback to summary
public byte[] calculateMAC()

Implements org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Doc from org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Return calculated MAC for any input passed in.

Returns:byte[]

the MAC value.

calculateMACback to summary
public void calculateMAC(byte[] output, int outOff)

Implements org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Doc from org.bouncycastle.tls.crypto.TlsMAC.calculateMAC.

Write the calculated MAC to an output buffer.

Parameters
output:byte[]

output array to write the MAC to.

outOff:int

offset into the output array to write the MAC to.

genPadback to summary
private static byte[] genPad(byte b, int count)
getInternalBlockSizeback to summary
public int getInternalBlockSize()

Implements org.bouncycastle.tls.crypto.TlsHMAC.getInternalBlockSize.

Doc from org.bouncycastle.tls.crypto.TlsHMAC.getInternalBlockSize.

Return the internal block size for the message digest underlying this HMAC service.

Returns:int

the internal block size for the digest (in bytes).

getMacLengthback to summary
public int getMacLength()

Implements org.bouncycastle.tls.crypto.TlsMAC.getMacLength.

Doc from org.bouncycastle.tls.crypto.TlsMAC.getMacLength.

Return the length of the MAC generated by this service.

Returns:int

the MAC length.

resetback to summary
public void reset()

Implements org.bouncycastle.tls.crypto.TlsMAC.reset.

Reset the mac generator.

setKeyback to summary
public void setKey(byte[] key, int keyOff, int keyLen)

Implements org.bouncycastle.tls.crypto.TlsMAC.setKey.

Doc from org.bouncycastle.tls.crypto.TlsMAC.setKey.

Set the key to be used by the MAC implementation supporting this service.

Parameters
key:byte[]

array holding the MAC key.

keyOff:int

offset into the array the key starts at.

keyLen:int

length of the key in the array.

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

Implements org.bouncycastle.tls.crypto.TlsMAC.update.

Doc from org.bouncycastle.tls.crypto.TlsMAC.update.

Update the MAC with the passed in input.

Parameters
in:byte[]

input array containing the data.

inOff:int

offset into the input array the input starts at.

len:int

the length of the input data.