changeset 5054:45804d661008

7145837: a little performance improvement on the usage of SecureRandom Reviewed-by: chegar, wetmore
author xuelei
date Wed, 15 Feb 2012 23:45:17 -0800
parents 20d39a0e6fdc
children b971b51bec01
files src/share/classes/sun/security/ssl/CipherSuite.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/ssl/CipherSuite.java	Wed Feb 15 10:46:55 2012 -0800
+++ b/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;