use of com.icodici.crypto.rsaoaep.scrsa.NativeRSAEngine in project universa by UniversaBlockchain.
the class RSAEngineFactory method whetherShouldUseNative.
/**
* Perform a test to check whether we should use an optimized native implementation or default Java one.
*/
static boolean whetherShouldUseNative() {
// Sometimes NativeRSAEngine does not work; e.g. when GMP native binary is not available.
// Test once if it will work; if it doesn't, fallback to use default RSAEngine.
final RSAOAEPTestVectors oaepSpec = new RSAOAEPTestVectors();
final ParametersWithRandom param = new ParametersWithRandom(oaepSpec.pubParameters, oaepSpec.getRandSeed());
boolean errorOccured;
try {
final NativeRSAEngine nativeRSAEngine = new NativeRSAEngine();
nativeRSAEngine.init(true, param);
errorOccured = false;
} catch (Throwable e) {
errorOccured = true;
}
return !errorOccured;
}
Aggregations