From 48892c12b0b0bef41db414543d5e5675214108dd Mon Sep 17 00:00:00 2001 From: John Jiang Date: Mon, 5 Feb 2024 16:19:29 +0800 Subject: [PATCH] TKSS-672: Remove TLCPAuthenticator --- .../kona/sun/security/ssl/Authenticator.java | 12 +-- .../sun/security/ssl/TLCPAuthenticator.java | 97 ------------------- 2 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/TLCPAuthenticator.java diff --git a/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/Authenticator.java b/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/Authenticator.java index fb5d41dc..7b4a369c 100644 --- a/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/Authenticator.java +++ b/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/Authenticator.java @@ -62,11 +62,9 @@ static Authenticator valueOf(ProtocolVersion protocolVersion) { return new DTLS10Authenticator(protocolVersion); } } else { - if (protocolVersion.isTLCP11()) { - return new TLCPAuthenticator.TLCP11Authenticator(protocolVersion); - } else if (protocolVersion.useTLS13PlusSpec()) { + if (protocolVersion.useTLS13PlusSpec()) { return new TLS13Authenticator(protocolVersion); - } else if (protocolVersion.useTLS10PlusSpec()) { + } else if (protocolVersion.useTLS10PlusSpec() || protocolVersion.isTLCP11()) { return new TLS10Authenticator(protocolVersion); } else { return new SSL30Authenticator(); @@ -86,11 +84,9 @@ static Authenticator valueOf(ProtocolVersion protocolVersion) { return (T)(new DTLS10Mac(protocolVersion, macAlg, key)); } } else { - if (protocolVersion.isTLCP11()) { - return (T)(new TLCPAuthenticator.TLCP11Mac(protocolVersion, macAlg, key)); - } else if (protocolVersion.useTLS13PlusSpec()) { + if (protocolVersion.useTLS13PlusSpec()) { throw new RuntimeException("No MacAlg used in TLS 1.3"); - } else if (protocolVersion.useTLS10PlusSpec()) { + } else if (protocolVersion.useTLS10PlusSpec() || protocolVersion.isTLCP11()) { return (T)(new TLS10Mac(protocolVersion, macAlg, key)); } else { return (T)(new SSL30Mac(protocolVersion, macAlg, key)); diff --git a/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/TLCPAuthenticator.java b/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/TLCPAuthenticator.java deleted file mode 100644 index 6fafeb6a..00000000 --- a/kona-ssl/src/main/java/com/tencent/kona/sun/security/ssl/TLCPAuthenticator.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2012, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.tencent.kona.sun.security.ssl; - -import javax.crypto.SecretKey; -import java.nio.ByteBuffer; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import com.tencent.kona.sun.security.ssl.Authenticator.SSLAuthenticator; -import com.tencent.kona.sun.security.ssl.Authenticator.MAC; -import com.tencent.kona.sun.security.ssl.CipherSuite.MacAlg; - -final class TLCPAuthenticator { - - static class TLCP11Authenticator extends SSLAuthenticator { - - // Block size of TLCP: - // sequence number(8) + record type(1) + protocol version(2) + record length(2) - private static final int BLOCK_SIZE = 13; - - TLCP11Authenticator(ProtocolVersion protocolVersion) { - super(new byte[BLOCK_SIZE]); - block[9] = protocolVersion.major; - block[10] = protocolVersion.minor; - } - - @Override - byte[] acquireAuthenticationBytes( - byte type, int length, byte[] sequence) { - byte[] ad = block.clone(); - if (sequence != null) { - if (sequence.length != 8) { - throw new RuntimeException( - "Insufficient explicit sequence number bytes"); - } - - System.arraycopy(sequence, 0, ad, 0, sequence.length); - } else { // Otherwise, use the implicit sequence number. - // Increase the implicit sequence number in the block array. - increaseSequenceNumber(); - } - - ad[8] = type; - ad[11] = (byte) (length >> 8); - ad[12] = (byte) (length); - - return ad; - } - } - - static final class TLCP11Mac extends TLCP11Authenticator implements MAC { - - private final MacImpl macImpl; - - TLCP11Mac(ProtocolVersion protocolVersion, - MacAlg macAlg, SecretKey key) throws NoSuchAlgorithmException, - InvalidKeyException { - super(protocolVersion); - this.macImpl = new MacImpl(protocolVersion, macAlg, key); - } - - @Override - public MacAlg macAlg() { - return macImpl.macAlg; - } - - @Override - public byte[] compute(byte type, ByteBuffer bb, - byte[] sequence, boolean isSimulated) { - return macImpl.compute(type, bb, sequence, isSimulated); - } - } -}