8214098: sun.security.ssl.HandshakeHash.T12HandshakeHash constructor check backwards.
authorascarpino
Mon, 10 Dec 2018 09:19:30 -0800
changeset 52928 d59955700113
parent 52927 226c451bd954
child 52929 72aba7acbeef
8214098: sun.security.ssl.HandshakeHash.T12HandshakeHash constructor check backwards. Reviewed-by: xuelei
src/java.base/share/classes/sun/security/ssl/HandshakeHash.java
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java	Mon Dec 10 19:34:53 2018 +0300
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java	Mon Dec 10 09:19:30 2018 -0800
@@ -518,10 +518,10 @@
                     JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
             if (md instanceof Cloneable) {
                 transcriptHash = new CloneableHash(md);
-                this.baos = null;
+                this.baos = new ByteArrayOutputStream();
             } else {
                 transcriptHash = new NonCloneableHash(md);
-                this.baos = new ByteArrayOutputStream();
+                this.baos = null;
             }
         }
 
@@ -550,26 +550,20 @@
 
     static final class T13HandshakeHash implements TranscriptHash {
         private final TranscriptHash transcriptHash;
-        private final ByteArrayOutputStream baos;
 
         T13HandshakeHash(CipherSuite cipherSuite) {
             MessageDigest md =
                     JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
             if (md instanceof Cloneable) {
                 transcriptHash = new CloneableHash(md);
-                this.baos = null;
             } else {
                 transcriptHash = new NonCloneableHash(md);
-                this.baos = new ByteArrayOutputStream();
             }
         }
 
         @Override
         public void update(byte[] input, int offset, int length) {
             transcriptHash.update(input, offset, length);
-            if (baos != null) {
-                baos.write(input, offset, length);
-            }
         }
 
         @Override
@@ -579,13 +573,9 @@
 
         @Override
         public byte[] archived() {
-            if (baos != null) {
-                return baos.toByteArray();
-            } else {
-                return transcriptHash.archived();
-            }
-
-            // throw new UnsupportedOperationException("Not supported yet.");
+            // This method is not necessary in T13
+            throw new UnsupportedOperationException(
+                    "TLS 1.3 does not require archived.");
         }
     }