org.bouncycastle.tls.crypto.impl.bc.BcTlsHMAC Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-debug-jdk15to18 Show documentation
Show all versions of bctls-debug-jdk15to18 Show documentation
The Bouncy Castle Java APIs for TLS and DTLS, including a provider for the JSSE.
The newest version!
package org.bouncycastle.tls.crypto.impl.bc;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.macs.HMac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.tls.crypto.TlsHMAC;
final class BcTlsHMAC
implements TlsHMAC
{
private final HMac hmac;
BcTlsHMAC(HMac hmac)
{
this.hmac = hmac;
}
public void setKey(byte[] key, int keyOff, int keyLen)
{
hmac.init(new KeyParameter(key, keyOff, keyLen));
}
public void update(byte[] input, int inOff, int length)
{
hmac.update(input, inOff, length);
}
public byte[] calculateMAC()
{
byte[] rv = new byte[hmac.getMacSize()];
hmac.doFinal(rv, 0);
return rv;
}
public void calculateMAC(byte[] output, int outOff)
{
hmac.doFinal(output, outOff);
}
public int getInternalBlockSize()
{
return ((ExtendedDigest)hmac.getUnderlyingDigest()).getByteLength();
}
public int getMacLength()
{
return hmac.getMacSize();
}
public void reset()
{
hmac.reset();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy