提交 d3ddc5ce 编写于 作者: X xuelei

7145837: a little performance improvement on the usage of SecureRandom

Reviewed-by: chegar, wetmore
上级 e7a72e23
/*
* 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.util.*;
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 @@ final class CipherSuite implements Comparable<CipherSuite> {
// 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 @@ final class CipherSuite implements Comparable<CipherSuite> {
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册