
org.bouncycastle.tls.crypto.impl.jcajce.GCMFipsUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-fips Show documentation
Show all versions of bctls-fips 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 FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
The newest version!
package org.bouncycastle.tls.crypto.impl.jcajce;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.bouncycastle.tls.crypto.impl.AEADNonceGenerator;
import org.bouncycastle.tls.crypto.impl.AEADNonceGeneratorFactory;
import org.bouncycastle.tls.crypto.impl.TlsAEADCipher;
class GCMFipsUtil
{
static AEADNonceGeneratorFactory getDefaultFipsGCMNonceGeneratorFactory()
{
return getBcFipsNonceGeneratorFactory();
}
private static final Class fipsNonceGeneratorClass = lookup("org.bouncycastle.crypto.fips.FipsNonceGenerator");
private static AEADNonceGeneratorFactory getBcFipsNonceGeneratorFactory()
{
if (fipsNonceGeneratorClass != null)
{
return new AEADNonceGeneratorFactory()
{
@Override
public AEADNonceGenerator create(byte[] baseNonce, int counterSizeInBits)
{
return new BCFipsAEADNonceGenerator(baseNonce, counterSizeInBits);
}
};
}
return null;
}
static Class lookup(final String className)
{
if (null == className)
{
return null;
}
return AccessController.doPrivileged(new PrivilegedAction>()
{
public Class> run()
{
try
{
ClassLoader classLoader = TlsAEADCipher.class.getClassLoader();
Class> clazz = (null == classLoader)
? Class.forName(className)
: classLoader.loadClass(className);
return clazz;
}
catch (Exception e)
{
}
return null;
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy