7145837: a little performance improvement on the usage of SecureRandom
Reviewed-by: chegar, wetmore
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Wed Feb 15 10:46:55 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Wed Feb 15 23:45:17 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import java.security.SecureRandom;
+import java.security.KeyManagementException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
@@ -423,6 +424,17 @@
// Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
final boolean isCBCMode;
+ // The secure random used to detect the cipher availability.
+ private final static SecureRandom secureRandom;
+
+ static {
+ try {
+ secureRandom = JsseJce.getSecureRandom();
+ } catch (KeyManagementException kme) {
+ throw new RuntimeException(kme);
+ }
+ }
+
BulkCipher(String transformation, int keySize,
int expandedKeySize, int ivSize, boolean allowed) {
this.transformation = transformation;
@@ -505,7 +517,7 @@
IvParameterSpec iv =
new IvParameterSpec(new byte[cipher.ivSize]);
cipher.newCipher(ProtocolVersion.DEFAULT,
- key, iv, null, true);
+ key, iv, secureRandom, true);
b = Boolean.TRUE;
} catch (NoSuchAlgorithmException e) {
b = Boolean.FALSE;