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

public Class JceTlsHMAC

extends Object
implements TlsHMAC
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.TlsHMAC, org.bouncycastle.tls.crypto.TlsMAC
Imports
java.security.InvalidKeyException, javax.crypto.Mac, .ShortBufferException, javax.crypto.spec.SecretKeySpec, org.bouncycastle.tls.crypto.TlsCryptoUtils, .TlsHMAC

Wrapper class for a JCE MAC based on HMAC to provide the necessary operations for TLS.

Field Summary

Modifier and TypeField and Description
private final String
private final Mac
private final int

Constructor Summary

AccessConstructor and Description
public
JceTlsHMAC(int
the hash algorithm underlying the MAC implementation
cryptoHashAlgorithm
,
Mac
MAC implementation.
hmac
,
String
algorithm name to use for keys and to get the internal block size.
algorithm
)

Base constructor.

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.
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 underlying this service.
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.
input
,
int
offset into the input array the input starts at.
inOff
,
int
the length of the input data.
length
)

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

Update the MAC with the passed in input.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
hmacback to summary
private final Mac hmac
internalBlockSizeback to summary
private final int internalBlockSize

Constructor Detail

JceTlsHMACback to summary
public JceTlsHMAC(int cryptoHashAlgorithm, Mac hmac, String algorithm)

Base constructor.

Parameters
cryptoHashAlgorithm:int

the hash algorithm underlying the MAC implementation

hmac:Mac

MAC implementation.

algorithm:String

algorithm name to use for keys and to get the 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.

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.

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

Reset the MAC underlying this service.

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[] input, int inOff, int length)

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

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

Update the MAC with the passed in input.

Parameters
input:byte[]

input array containing the data.

inOff:int

offset into the input array the input starts at.

length:int

the length of the input data.