File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 7575import java .nio .file .LinkOption ;
7676import java .security .NoSuchAlgorithmException ;
7777import java .security .SecureRandom ;
78+ import java .security .Security ;
7879import java .text .MessageFormat ;
7980import java .util .ArrayDeque ;
8081import java .util .ArrayList ;
@@ -1510,18 +1511,14 @@ public SecureRandom getSecureRandom() {
15101511 assert !env .isPreInitialization ();
15111512 if (secureRandom == null ) {
15121513 CompilerDirectives .transferToInterpreterAndInvalidate ();
1513- try {
1514- secureRandom = SecureRandom .getInstance ("NativePRNGNonBlocking" );
1515- } catch (NoSuchAlgorithmException e ) {
1516- if (getPythonOS () == PLATFORM_WIN32 ) {
1517- try {
1518- secureRandom = SecureRandom .getInstanceStrong ();
1519- } catch (NoSuchAlgorithmException e2 ) {
1520- throw new RuntimeException ("Unable to obtain entropy source for random number generation (NativePRNGNonBlocking)" , e2 );
1521- }
1522- } else {
1523- throw new RuntimeException ("Unable to obtain entropy source for random number generation (NativePRNGNonBlocking)" , e );
1514+ if (Security .getAlgorithms ("SecureRandom" ).contains ("NATIVEPRNGNONBLOCKING" )) {
1515+ try {
1516+ secureRandom = SecureRandom .getInstance ("NATIVEPRNGNONBLOCKING" );
1517+ } catch (NoSuchAlgorithmException e ) {
1518+ throw CompilerDirectives .shouldNotReachHere (e );
15241519 }
1520+ } else {
1521+ secureRandom = new SecureRandom ();
15251522 }
15261523 }
15271524 return secureRandom ;
You can’t perform that action at this time.
0 commit comments