![JAR search and dependency download from the Maven repository](/logo.png)
org.bouncycastle.crypto.general.SelfTestExecutor 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.crypto.general;
import org.bouncycastle.crypto.Algorithm;
import org.bouncycastle.crypto.internal.test.BasicKatTest;
import org.bouncycastle.crypto.internal.test.ConsistencyTest;
class SelfTestExecutor
{
static T validate(Algorithm algorithm, T engine, BasicKatTest test)
{
try
{
if (!test.hasTestPassed(engine))
{
throw new OperationError("Self test failed: " + algorithm.getName());
}
return engine;
}
catch (Exception e)
{
throw new OperationError("Exception on self test: " + algorithm.getName(), e);
}
}
static T validate(Algorithm algorithm, T parameters, ConsistencyTest test)
{
try
{
if (!test.hasTestPassed(parameters))
{
throw new OperationError("Consistency test failed: " + algorithm.getName());
}
return parameters;
}
catch (Exception e)
{
throw new OperationError("Consistency test exception: " + algorithm.getName(), e);
}
}
static T validate(Algorithm algorithm, T engine, VariantKatTest test)
{
try
{
test.evaluate(engine);
return engine;
}
catch (TestFailedException e)
{
throw new OperationError(e.getMessage() + ": " + algorithm.getName());
}
catch (Exception e)
{
throw new OperationError("Exception on self test: " + algorithm.getName(), e);
}
}
static class TestFailedException
extends RuntimeException
{
public TestFailedException(String message)
{
super(message);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy