|
37 | 37 | import java.security.*;
|
38 | 38 | import java.util.function.Function;
|
39 | 39 |
|
| 40 | +import sun.security.jca.JCAUtil; |
40 | 41 | import sun.security.provider.SHAKE256;
|
41 | 42 | import sun.security.timestamp.*;
|
42 | 43 | import sun.security.util.*;
|
@@ -67,23 +68,6 @@ public class PKCS7 {
|
67 | 68 |
|
68 | 69 | private Principal[] certIssuerNames;
|
69 | 70 |
|
70 |
| - /* |
71 |
| - * Random number generator for creating nonce values |
72 |
| - * (Lazy initialization) |
73 |
| - */ |
74 |
| - private static class SecureRandomHolder { |
75 |
| - static final SecureRandom RANDOM; |
76 |
| - static { |
77 |
| - SecureRandom tmp = null; |
78 |
| - try { |
79 |
| - tmp = SecureRandom.getInstance("SHA1PRNG"); |
80 |
| - } catch (NoSuchAlgorithmException e) { |
81 |
| - // should not happen |
82 |
| - } |
83 |
| - RANDOM = tmp; |
84 |
| - } |
85 |
| - } |
86 |
| - |
87 | 71 | /**
|
88 | 72 | * Unmarshals a PKCS7 block from its encoded form, parsing the
|
89 | 73 | * encoded bytes from the InputStream.
|
@@ -1027,11 +1011,9 @@ public static byte[] generateTimestampToken(Timestamper tsa,
|
1027 | 1011 | }
|
1028 | 1012 |
|
1029 | 1013 | // Generate a nonce
|
1030 |
| - BigInteger nonce = null; |
1031 |
| - if (SecureRandomHolder.RANDOM != null) { |
1032 |
| - nonce = new BigInteger(64, SecureRandomHolder.RANDOM); |
1033 |
| - tsQuery.setNonce(nonce); |
1034 |
| - } |
| 1014 | + BigInteger nonce = new BigInteger(64, JCAUtil.getDefSecureRandom()); |
| 1015 | + tsQuery.setNonce(nonce); |
| 1016 | + |
1035 | 1017 | tsQuery.requestCertificate(true);
|
1036 | 1018 |
|
1037 | 1019 | TSResponse tsReply = tsa.generateTimestamp(tsQuery);
|
|
1 commit comments
openjdk-notifier[bot] commentedon Apr 27, 2023
Review
Issues