![JAR search and dependency download from the Maven repository](/logo.png)
org.bouncycastle.jcajce.provider.BaseMessageDigest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips-debug Show documentation
Show all versions of bc-fips-debug Show documentation
The FIPS 140-2 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-2 level 1. This jar contains the debug version JCE provider and low-level API for the BC-FJA version 1.0.2.3, FIPS Certificate #3514. Please note the debug jar is not certified.
package org.bouncycastle.jcajce.provider;
import java.security.MessageDigest;
import org.bouncycastle.crypto.OutputDigestCalculator;
import org.bouncycastle.crypto.Parameters;
import org.bouncycastle.crypto.UpdateOutputStream;
import org.bouncycastle.crypto.fips.FipsDigestOperatorFactory;
import org.bouncycastle.crypto.fips.FipsSHS;
final class BaseMessageDigest
extends MessageDigest
implements Cloneable
{
private static FipsDigestOperatorFactory fipsFactory = new FipsSHS.OperatorFactory();
private final OutputDigestCalculator digestCalculator;
private final UpdateOutputStream digestStream;
protected BaseMessageDigest(
FipsSHS.Parameters algorithm)
{
this(fipsFactory.createOutputDigestCalculator(algorithm));
}
BaseMessageDigest(OutputDigestCalculator digestCalculator)
{
super(((Parameters)digestCalculator.getParameters()).getAlgorithm().getName());
this.digestCalculator = digestCalculator;
this.digestStream = digestCalculator.getDigestStream();
}
protected void engineReset()
{
digestCalculator.reset();
}
protected void engineUpdate(
byte input)
{
digestStream.update(input);
}
protected void engineUpdate(
byte[] input,
int offset,
int len)
{
digestStream.update(input, offset, len);
}
protected byte[] engineDigest()
{
byte[] digestBytes = digestCalculator.getDigest();
engineReset();
return digestBytes;
}
protected int engineGetDigestLength()
{
return digestCalculator.getDigestSize();
}
public Object clone()
throws CloneNotSupportedException
{
return new BaseMessageDigest(digestCalculator.clone());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy