in src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java [60:90]
public OpenSslJnaCryptoRandom(final Properties props) //NOPMD
throws GeneralSecurityException {
if (!OpenSslJna.isEnabled()) {
throw new GeneralSecurityException("Could not enable JNA access", OpenSslJna.initialisationError());
}
boolean rdrandLoaded = false;
try {
OpenSslNativeJna.ENGINE_load_rdrand();
rdrandEngine = OpenSslNativeJna.ENGINE_by_id("rdrand");
if (rdrandEngine != null) {
final int rc = OpenSslNativeJna.ENGINE_init(rdrandEngine);
if (rc != 0) {
final int rc2 = OpenSslNativeJna.ENGINE_set_default(rdrandEngine, ENGINE_METHOD_RAND);
if (rc2 != 0) {
rdrandLoaded = true;
}
}
}
} catch (final Exception e) {
throw new NoSuchAlgorithmException();
}
rdrandEnabled = rdrandLoaded;
if (!rdrandLoaded) {
closeRdrandEngine(false);
}
}