diff --git a/jdk/src/share/classes/java/security/SecureRandom.java b/jdk/src/share/classes/java/security/SecureRandom.java index 5afec7b0797..b9ae7220b38 100644 --- a/jdk/src/share/classes/java/security/SecureRandom.java +++ b/jdk/src/share/classes/java/security/SecureRandom.java @@ -578,39 +578,30 @@ public class SecureRandom extends java.util.Random { /** * Returns a {@code SecureRandom} object that was selected by using * the algorithms/providers specified in the {@code - * securerandom.strongAlgorithms} Security property. + * securerandom.strongAlgorithms} {@link Security} property. *
* Some situations require strong random values, such as when * creating high-value/long-lived secrets like RSA public/private * keys. To help guide applications in selecting a suitable strong - * {@code SecureRandom} implementation, Java distributions should + * {@code SecureRandom} implementation, Java distributions * include a list of known strong {@code SecureRandom} * implementations in the {@code securerandom.strongAlgorithms} * Security property. - * - *
- * SecureRandom sr = SecureRandom.getStrongSecureRandom(); - * - * if (sr == null) { - * // Decide if this is a problem, and whether to recover. - * sr = new SecureRandom(); - * if (!goodEnough(sr)) { - * return; - * } - * } - * - * keyPairGenerator.initialize(2048, sr); - *+ *
+ * Every implementation of the Java platform is required to
+ * support at least one strong {@code SecureRandom} implementation.
*
* @return a strong {@code SecureRandom} implementation as indicated
- * by the {@code securerandom.strongAlgorithms} Security property, or
- * null if none are available.
+ * by the {@code securerandom.strongAlgorithms} Security property
+ *
+ * @throws NoSuchAlgorithmException if no algorithm is available
*
* @see Security#getProperty(String)
*
* @since 1.8
*/
- public static SecureRandom getStrongSecureRandom() {
+ public static SecureRandom getInstanceStrong()
+ throws NoSuchAlgorithmException {
String property = AccessController.doPrivileged(
new PrivilegedAction