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 75
75
import java .nio .file .LinkOption ;
76
76
import java .security .NoSuchAlgorithmException ;
77
77
import java .security .SecureRandom ;
78
+ import java .security .Security ;
78
79
import java .text .MessageFormat ;
79
80
import java .util .ArrayDeque ;
80
81
import java .util .ArrayList ;
@@ -1510,18 +1511,14 @@ public SecureRandom getSecureRandom() {
1510
1511
assert !env .isPreInitialization ();
1511
1512
if (secureRandom == null ) {
1512
1513
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 );
1524
1519
}
1520
+ } else {
1521
+ secureRandom = new SecureRandom ();
1525
1522
}
1526
1523
}
1527
1524
return secureRandom ;
You can’t perform that action at this time.
0 commit comments