org.bouncycastle.jcajce.provider.GcmSpecUtil 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.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.IvParameterSpec;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.internal.asn1.cms.GCMParameters;
import org.bouncycastle.jcajce.spec.AEADParameterSpec;
import org.bouncycastle.util.Integers;
class GcmSpecUtil
{
static final Class gcmSpecClass = ClassUtil.lookup("javax.crypto.spec.GCMParameterSpec");
static final Method tLen;
static final Method iv;
static
{
if (gcmSpecClass != null)
{
tLen = ClassUtil.extractMethod(gcmSpecClass, "getTLen");
iv = ClassUtil.extractMethod(gcmSpecClass, "getIV");
}
else
{
tLen = null;
iv = null;
}
}
static boolean gcmSpecExists()
{
return gcmSpecClass != null;
}
static boolean isGcmSpec(AlgorithmParameterSpec paramSpec)
{
return gcmSpecClass != null && gcmSpecClass.isInstance(paramSpec);
}
static boolean isGcmSpec(Class paramSpecClass)
{
return gcmSpecClass == paramSpecClass;
}
static Class[] getCipherSpecClasses()
{
if (gcmSpecExists())
{
return new Class[]{GcmSpecUtil.gcmSpecClass, IvParameterSpec.class};
}
else
{
return new Class[]{AEADParameterSpec.class,IvParameterSpec.class};
}
}
static AlgorithmParameterSpec extractGcmSpec(final ASN1Primitive spec)
throws InvalidParameterSpecException
{
Object rv = AccessController.doPrivileged(new PrivilegedAction
© 2015 - 2025 Weber Informatics LLC | Privacy Policy