7145837: a little performance improvement on the usage of SecureRandom
Reviewed-by: chegar, wetmore
This commit is contained in:
parent
a1429e482e
commit
4c5ba0d841
@ -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.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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user