src/java.base/share/classes/sun/security/ssl/SSLCipher.java
branchJDK-8145252-TLS13-branch
changeset 56715 b152d06ed6a9
parent 56542 56aaa6cb3693
child 56784 6210466cf1ac
--- a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java	Sat Jun 09 08:08:12 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java	Sat Jun 09 13:38:27 2018 -0700
@@ -468,8 +468,7 @@
         // shipped with the SunJCE  provider.  However, AES/256 is unavailable
         // when the default JCE policy jurisdiction files are installed because
         // of key length restrictions.
-        this.isAvailable =
-                allowed ? isUnlimited(keySize, transformation) : false;
+        this.isAvailable = allowed && isUnlimited(keySize, transformation);
 
         this.readCipherGenerators = readCipherGenerators;
         this.writeCipherGenerators = writeCipherGenerators;
@@ -525,17 +524,6 @@
         return null;
     }
 
-    public static final String getDefaultType() {
-        String prop = AccessController.doPrivileged(
-                new PrivilegedAction<String>() {
-            @Override
-            public String run() {
-                return Security.getProperty("jdk.tls.KeyLimits");
-            }
-        });
-        return prop;
-    }
-
     /**
      * Test if this bulk cipher is available. For use by CipherSuite.
      */
@@ -838,7 +826,7 @@
                     }
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -931,7 +919,7 @@
                     }
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -1024,7 +1012,7 @@
 
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -1180,7 +1168,7 @@
 
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -1296,7 +1284,7 @@
 
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -1474,7 +1462,7 @@
 
                     if (bb.position() != dup.position()) {
                         throw new RuntimeException(
-                                "Unexpected Bytebuffer position");
+                                "Unexpected ByteBuffer position");
                     }
                 } catch (ShortBufferException sbe) {
                     // catch BouncyCastle buffering error
@@ -1602,8 +1590,7 @@
 
                 // DON'T decrypt the nonce_explicit for AEAD mode. The buffer
                 // position has moved out of the nonce_explicit range.
-                int len = bb.remaining();
-                int pos = bb.position();
+                int len, pos = bb.position();
                 ByteBuffer dup = bb.duplicate();
                 try {
                     len = cipher.doFinal(dup, bb);
@@ -1617,7 +1604,7 @@
                     throw new RuntimeException("Cipher buffering error in " +
                         "JCE provider " + cipher.getProvider().getName(), sbe);
                 }
-                // reset the limit to the end of the decryted data
+                // reset the limit to the end of the decrypted data
                 bb.position(pos);
                 bb.limit(pos + len);
 
@@ -1718,8 +1705,7 @@
                 bb.put(nonce);
 
                 // DON'T encrypt the nonce for AEAD mode.
-                int len = bb.remaining();
-                int pos = bb.position();
+                int len, pos = bb.position();
                 if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
                     SSLLogger.fine(
                             "Plaintext before ENCRYPTION",
@@ -1868,8 +1854,7 @@
                                         contentType, bb.remaining(), sn);
                 cipher.updateAAD(aad);
 
-                int len = bb.remaining();
-                int pos = bb.position();
+                int len, pos = bb.position();
                 ByteBuffer dup = bb.duplicate();
                 try {
                     len = cipher.doFinal(dup, bb);
@@ -1883,7 +1868,7 @@
                     throw new RuntimeException("Cipher buffering error in " +
                         "JCE provider " + cipher.getProvider().getName(), sbe);
                 }
-                // reset the limit to the end of the decryted data
+                // reset the limit to the end of the decrypted data
                 bb.position(pos);
                 bb.limit(pos + len);
 
@@ -2000,8 +1985,7 @@
                                         contentType, outputSize, sn);
                 cipher.updateAAD(aad);
 
-                int len = bb.remaining();
-                int pos = bb.position();
+                int len, pos = bb.position();
                 if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
                     SSLLogger.fine(
                             "Plaintext before ENCRYPTION",
@@ -2205,8 +2189,8 @@
 
         // The caller ensures there are enough bytes available in the buffer.
         // So we won't need to check the remaining of the buffer.
-        for (int i = 0; i < tag.length; i++) {
-            if (bb.get() != tag[i]) {
+        for (byte t : tag) {
+            if (bb.get() != t) {
                 results[0]++;       // mismatched bytes
             } else {
                 results[1]++;       // matched bytes