--- a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java Tue Feb 12 15:19:25 2019 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java Tue Feb 12 13:36:15 2019 -0800
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.LinkedList;
import javax.crypto.SecretKey;
@@ -269,8 +270,13 @@
private final ByteArrayOutputStream baos;
S30HandshakeHash(CipherSuite cipherSuite) {
- this.mdMD5 = JsseJce.getMessageDigest("MD5");
- this.mdSHA = JsseJce.getMessageDigest("SHA");
+ try {
+ this.mdMD5 = MessageDigest.getInstance("MD5");
+ this.mdSHA = MessageDigest.getInstance("SHA");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm MD5 or SHA is not available", nsae);
+ }
boolean hasArchived = false;
if (mdMD5 instanceof Cloneable) {
@@ -379,7 +385,12 @@
"MessageDigest does no support clone operation");
}
} else {
- md5Clone = JsseJce.getMessageDigest("MD5");
+ try {
+ md5Clone = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm MD5 is not available", nsae);
+ }
md5Clone.update(md5.archived());
}
@@ -396,7 +407,12 @@
"MessageDigest does no support clone operation");
}
} else {
- shaClone = JsseJce.getMessageDigest("SHA");
+ try {
+ shaClone = MessageDigest.getInstance("SHA");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm SHA is not available", nsae);
+ }
shaClone.update(sha.archived());
}
@@ -447,8 +463,15 @@
private final ByteArrayOutputStream baos;
T10HandshakeHash(CipherSuite cipherSuite) {
- MessageDigest mdMD5 = JsseJce.getMessageDigest("MD5");
- MessageDigest mdSHA = JsseJce.getMessageDigest("SHA");
+ MessageDigest mdMD5;
+ MessageDigest mdSHA;
+ try {
+ mdMD5 = MessageDigest.getInstance("MD5");
+ mdSHA = MessageDigest.getInstance("SHA");
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm MD5 or SHA is not available", nsae);
+ }
boolean hasArchived = false;
if (mdMD5 instanceof Cloneable) {
@@ -514,8 +537,15 @@
private final ByteArrayOutputStream baos;
T12HandshakeHash(CipherSuite cipherSuite) {
- MessageDigest md =
- JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
+ MessageDigest md;
+ try {
+ md = MessageDigest.getInstance(cipherSuite.hashAlg.name);
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm " +
+ cipherSuite.hashAlg.name + " is not available", nsae);
+ }
+
if (md instanceof Cloneable) {
transcriptHash = new CloneableHash(md);
this.baos = new ByteArrayOutputStream();
@@ -552,8 +582,15 @@
private final TranscriptHash transcriptHash;
T13HandshakeHash(CipherSuite cipherSuite) {
- MessageDigest md =
- JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
+ MessageDigest md;
+ try {
+ md = MessageDigest.getInstance(cipherSuite.hashAlg.name);
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new RuntimeException(
+ "Hash algorithm " +
+ cipherSuite.hashAlg.name + " is not available", nsae);
+ }
+
if (md instanceof Cloneable) {
transcriptHash = new CloneableHash(md);
} else {