You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Submitted for consideration is a fix for Aes.SunPKCS11CipherFactory for JDK 11+.
/** * Implements {@link CipherFactory} using Sun PKCS#11. * * @author Lyubomir Marinov */publicstaticclassSunPKCS11CipherFactoryextendsCipherFactory {
/** * The {@link Provider} instance (to be) employed for an (optimized) AES * implementation. */privatestaticProviderprovider;
/** * The indicator which determines whether {@link #provider} is to be * used. If {@code true}, an attempt will be made to initialize a {@link * Provider} instance. If the attempt fails, {@code false} will be * assigned in order to not repeatedly attempt the initialization which * is known to have failed. */privatestaticbooleanuseProvider = true;
/** * Gets the {@code java.security.Provider} instance (to be) employed * for an (optimized) AES implementation. * * @return the {@code java.security.Provider} instance (to be) employed * for an (optimized) AES implementation */publicstaticProvidergetProvider() throwsException {
Providerprovider = SunPKCS11CipherFactory.provider;
if (provider == null && useProvider) {
try {
// The SunPKCS11 Config name should be unique in order// to avoid repeated initialization exceptions.Stringname = null;
Packagepkg = Aes.class.getPackage();
if (pkg != null) {
name = pkg.getName();
}
if (name == null || name.length() == 0) {
name = "org.jitsi.srtp";
}
Stringconfig = "--name=" + name + "\\n" + "nssDbMode=noDb\\n" + "attributes=compatibility";
Providerprototype = Security.getProvider("SunPKCS11");
Class<?> sunPkcs11ProviderClass = Class.forName("sun.security.pkcs11.SunPKCS11");
MethodconfigureMethod = sunPkcs11ProviderClass.getMethod("configure", String.class);
provider = (Provider) configureMethod.invoke(prototype, config);
} finally {
if (provider == null) {
useProvider = false;
} else {
SunPKCS11CipherFactory.provider = provider;
}
}
}
returnprovider;
}
/** * Initializes a new instance of this class. * * @throws Exception if anything goes wrong while initializing a new * instance */publicSunPKCS11CipherFactory() throwsException {
super(getProvider());
logger.info("Created SunPKCS11 provider");
}
}
The text was updated successfully, but these errors were encountered:
This is a fix for the SunPKCS11 provider not being created nor added to the providers list when using JDK11 or newer; its an easy verification, but I would assume that if earlier JDK's are to be supported, you all would need to add version checks.
Submitted for consideration is a fix for
Aes.SunPKCS11CipherFactory
for JDK 11+.The text was updated successfully, but these errors were encountered: