org.bouncycastle.tls.crypto.impl.bc.BcTlsHash Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-lts8on Show documentation
Show all versions of bctls-lts8on Show documentation
The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC LTS provider but may also be used with other providers providing cryptographic services.
package org.bouncycastle.tls.crypto.impl.bc;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.tls.crypto.TlsHash;
final class BcTlsHash
implements TlsHash
{
private final BcTlsCrypto crypto;
private final int cryptoHashAlgorithm;
private final Digest digest;
BcTlsHash(BcTlsCrypto crypto, int cryptoHashAlgorithm)
{
this(crypto, cryptoHashAlgorithm, crypto.createDigest(cryptoHashAlgorithm));
}
private BcTlsHash(BcTlsCrypto crypto, int cryptoHashAlgorithm, Digest digest)
{
this.crypto = crypto;
this.cryptoHashAlgorithm = cryptoHashAlgorithm;
this.digest = digest;
}
public void update(byte[] data, int offSet, int length)
{
digest.update(data, offSet, length);
}
public byte[] calculateHash()
{
byte[] rv = new byte[digest.getDigestSize()];
digest.doFinal(rv, 0);
return rv;
}
public TlsHash cloneHash()
{
return new BcTlsHash(crypto, cryptoHashAlgorithm, crypto.cloneDigest(cryptoHashAlgorithm, digest));
}
public void reset()
{
digest.reset();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy