--- a/jdk/src/java.base/share/classes/sun/security/provider/HmacDrbg.java Mon Jun 06 16:46:54 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/provider/HmacDrbg.java Tue Jun 07 10:10:59 2016 +0800
@@ -27,7 +27,6 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@@ -36,14 +35,12 @@
public class HmacDrbg extends AbstractHashDrbg {
- private static final long serialVersionUID = 9L;
-
- private transient Mac mac;
+ private Mac mac;
private String macAlg;
- private transient byte[] v;
- private transient byte[] k;
+ private byte[] v;
+ private byte[] k;
public HmacDrbg(SecureRandomParameters params) {
mechName = "HMAC_DRBG";
@@ -101,6 +98,10 @@
protected void initEngine() {
macAlg = "HmacSHA" + algorithm.substring(4);
try {
+ /*
+ * Use the local SunJCE implementation to avoid native
+ * performance overhead.
+ */
mac = Mac.getInstance(macAlg, "SunJCE");
} catch (NoSuchProviderException | NoSuchAlgorithmException e) {
// Fallback to any available.
@@ -194,10 +195,4 @@
// Step 8. Return
}
-
- private void readObject(java.io.ObjectInputStream s)
- throws IOException, ClassNotFoundException {
- s.defaultReadObject ();
- initEngine();
- }
}