2331 lines
93 KiB
Java
2331 lines
93 KiB
Java
|
package org.bouncycastle.crypto.tls;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import io.flutter.embedding.android.KeyboardMap;
|
||
|
import java.io.ByteArrayInputStream;
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
import java.io.EOFException;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.io.OutputStream;
|
||
|
import java.util.Hashtable;
|
||
|
import java.util.Vector;
|
||
|
import okhttp3.internal.ws.WebSocketProtocol;
|
||
|
import org.bouncycastle.asn1.ASN1Encoding;
|
||
|
import org.bouncycastle.asn1.ASN1InputStream;
|
||
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||
|
import org.bouncycastle.asn1.ASN1Primitive;
|
||
|
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
|
||
|
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
|
||
|
import org.bouncycastle.asn1.x509.Extensions;
|
||
|
import org.bouncycastle.asn1.x509.KeyUsage;
|
||
|
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
|
||
|
import org.bouncycastle.crypto.Digest;
|
||
|
import org.bouncycastle.crypto.digests.MD5Digest;
|
||
|
import org.bouncycastle.crypto.digests.SHA1Digest;
|
||
|
import org.bouncycastle.crypto.digests.SHA224Digest;
|
||
|
import org.bouncycastle.crypto.digests.SHA256Digest;
|
||
|
import org.bouncycastle.crypto.digests.SHA384Digest;
|
||
|
import org.bouncycastle.crypto.digests.SHA512Digest;
|
||
|
import org.bouncycastle.crypto.macs.HMac;
|
||
|
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
||
|
import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
|
||
|
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||
|
import org.bouncycastle.crypto.params.KeyParameter;
|
||
|
import org.bouncycastle.crypto.params.RSAKeyParameters;
|
||
|
import org.bouncycastle.crypto.util.PublicKeyFactory;
|
||
|
import org.bouncycastle.util.Arrays;
|
||
|
import org.bouncycastle.util.Integers;
|
||
|
import org.bouncycastle.util.Strings;
|
||
|
import org.bouncycastle.util.io.Streams;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class TlsUtils {
|
||
|
public static final byte[] EMPTY_BYTES = new byte[0];
|
||
|
public static final short[] EMPTY_SHORTS = new short[0];
|
||
|
public static final int[] EMPTY_INTS = new int[0];
|
||
|
public static final long[] EMPTY_LONGS = new long[0];
|
||
|
public static final Integer EXT_signature_algorithms = Integers.valueOf(13);
|
||
|
static final byte[] SSL_CLIENT = {67, 76, 78, 84};
|
||
|
static final byte[] SSL_SERVER = {83, 82, 86, 82};
|
||
|
static final byte[][] SSL3_CONST = genSSL3Const();
|
||
|
|
||
|
public static boolean hasSigningCapability(short s) {
|
||
|
return s == 1 || s == 2 || s == 64;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint16(int i) {
|
||
|
return (65535 & i) == i;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint16(long j) {
|
||
|
return (WebSocketProtocol.PAYLOAD_SHORT_MAX & j) == j;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint24(int i) {
|
||
|
return (16777215 & i) == i;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint24(long j) {
|
||
|
return (16777215 & j) == j;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint32(long j) {
|
||
|
return (KeyboardMap.kValueMask & j) == j;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint48(long j) {
|
||
|
return (281474976710655L & j) == j;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint64(long j) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint8(int i) {
|
||
|
return (i & 255) == i;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint8(long j) {
|
||
|
return (255 & j) == j;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidUint8(short s) {
|
||
|
return (s & 255) == s;
|
||
|
}
|
||
|
|
||
|
public static void writeVersion(ProtocolVersion protocolVersion, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) protocolVersion.getMajorVersion();
|
||
|
bArr[i + 1] = (byte) protocolVersion.getMinorVersion();
|
||
|
}
|
||
|
|
||
|
public static void writeVersion(ProtocolVersion protocolVersion, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write(protocolVersion.getMajorVersion());
|
||
|
outputStream.write(protocolVersion.getMinorVersion());
|
||
|
}
|
||
|
|
||
|
public static void writeUint8ArrayWithUint8Length(short[] sArr, byte[] bArr, int i) throws IOException {
|
||
|
checkUint8(sArr.length);
|
||
|
writeUint8(sArr.length, bArr, i);
|
||
|
writeUint8Array(sArr, bArr, i + 1);
|
||
|
}
|
||
|
|
||
|
public static void writeUint8ArrayWithUint8Length(short[] sArr, OutputStream outputStream) throws IOException {
|
||
|
checkUint8(sArr.length);
|
||
|
writeUint8(sArr.length, outputStream);
|
||
|
writeUint8Array(sArr, outputStream);
|
||
|
}
|
||
|
|
||
|
public static void writeUint8Array(short[] sArr, byte[] bArr, int i) throws IOException {
|
||
|
for (short s : sArr) {
|
||
|
writeUint8(s, bArr, i);
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void writeUint8Array(short[] sArr, OutputStream outputStream) throws IOException {
|
||
|
for (short s : sArr) {
|
||
|
writeUint8(s, outputStream);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void writeUint8(short s, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) s;
|
||
|
}
|
||
|
|
||
|
public static void writeUint8(short s, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write(s);
|
||
|
}
|
||
|
|
||
|
public static void writeUint8(int i, byte[] bArr, int i2) {
|
||
|
bArr[i2] = (byte) i;
|
||
|
}
|
||
|
|
||
|
public static void writeUint8(int i, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write(i);
|
||
|
}
|
||
|
|
||
|
public static void writeUint64(long j, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) (j >>> 56);
|
||
|
bArr[i + 1] = (byte) (j >>> 48);
|
||
|
bArr[i + 2] = (byte) (j >>> 40);
|
||
|
bArr[i + 3] = (byte) (j >>> 32);
|
||
|
bArr[i + 4] = (byte) (j >>> 24);
|
||
|
bArr[i + 5] = (byte) (j >>> 16);
|
||
|
bArr[i + 6] = (byte) (j >>> 8);
|
||
|
bArr[i + 7] = (byte) j;
|
||
|
}
|
||
|
|
||
|
public static void writeUint64(long j, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write((byte) (j >>> 56));
|
||
|
outputStream.write((byte) (j >>> 48));
|
||
|
outputStream.write((byte) (j >>> 40));
|
||
|
outputStream.write((byte) (j >>> 32));
|
||
|
outputStream.write((byte) (j >>> 24));
|
||
|
outputStream.write((byte) (j >>> 16));
|
||
|
outputStream.write((byte) (j >>> 8));
|
||
|
outputStream.write((byte) j);
|
||
|
}
|
||
|
|
||
|
public static void writeUint48(long j, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) (j >>> 40);
|
||
|
bArr[i + 1] = (byte) (j >>> 32);
|
||
|
bArr[i + 2] = (byte) (j >>> 24);
|
||
|
bArr[i + 3] = (byte) (j >>> 16);
|
||
|
bArr[i + 4] = (byte) (j >>> 8);
|
||
|
bArr[i + 5] = (byte) j;
|
||
|
}
|
||
|
|
||
|
public static void writeUint48(long j, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write((byte) (j >>> 40));
|
||
|
outputStream.write((byte) (j >>> 32));
|
||
|
outputStream.write((byte) (j >>> 24));
|
||
|
outputStream.write((byte) (j >>> 16));
|
||
|
outputStream.write((byte) (j >>> 8));
|
||
|
outputStream.write((byte) j);
|
||
|
}
|
||
|
|
||
|
public static void writeUint32(long j, byte[] bArr, int i) {
|
||
|
bArr[i] = (byte) (j >>> 24);
|
||
|
bArr[i + 1] = (byte) (j >>> 16);
|
||
|
bArr[i + 2] = (byte) (j >>> 8);
|
||
|
bArr[i + 3] = (byte) j;
|
||
|
}
|
||
|
|
||
|
public static void writeUint32(long j, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write((byte) (j >>> 24));
|
||
|
outputStream.write((byte) (j >>> 16));
|
||
|
outputStream.write((byte) (j >>> 8));
|
||
|
outputStream.write((byte) j);
|
||
|
}
|
||
|
|
||
|
public static void writeUint24(int i, byte[] bArr, int i2) {
|
||
|
bArr[i2] = (byte) (i >>> 16);
|
||
|
bArr[i2 + 1] = (byte) (i >>> 8);
|
||
|
bArr[i2 + 2] = (byte) i;
|
||
|
}
|
||
|
|
||
|
public static void writeUint24(int i, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write((byte) (i >>> 16));
|
||
|
outputStream.write((byte) (i >>> 8));
|
||
|
outputStream.write((byte) i);
|
||
|
}
|
||
|
|
||
|
public static void writeUint16ArrayWithUint16Length(int[] iArr, byte[] bArr, int i) throws IOException {
|
||
|
int length = iArr.length << 1;
|
||
|
checkUint16(length);
|
||
|
writeUint16(length, bArr, i);
|
||
|
writeUint16Array(iArr, bArr, i + 2);
|
||
|
}
|
||
|
|
||
|
public static void writeUint16ArrayWithUint16Length(int[] iArr, OutputStream outputStream) throws IOException {
|
||
|
int length = iArr.length << 1;
|
||
|
checkUint16(length);
|
||
|
writeUint16(length, outputStream);
|
||
|
writeUint16Array(iArr, outputStream);
|
||
|
}
|
||
|
|
||
|
public static void writeUint16Array(int[] iArr, byte[] bArr, int i) throws IOException {
|
||
|
for (int i2 : iArr) {
|
||
|
writeUint16(i2, bArr, i);
|
||
|
i += 2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void writeUint16Array(int[] iArr, OutputStream outputStream) throws IOException {
|
||
|
for (int i : iArr) {
|
||
|
writeUint16(i, outputStream);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void writeUint16(int i, byte[] bArr, int i2) {
|
||
|
bArr[i2] = (byte) (i >>> 8);
|
||
|
bArr[i2 + 1] = (byte) i;
|
||
|
}
|
||
|
|
||
|
public static void writeUint16(int i, OutputStream outputStream) throws IOException {
|
||
|
outputStream.write(i >>> 8);
|
||
|
outputStream.write(i);
|
||
|
}
|
||
|
|
||
|
public static void writeOpaque8(byte[] bArr, OutputStream outputStream) throws IOException {
|
||
|
checkUint8(bArr.length);
|
||
|
writeUint8(bArr.length, outputStream);
|
||
|
outputStream.write(bArr);
|
||
|
}
|
||
|
|
||
|
public static void writeOpaque24(byte[] bArr, OutputStream outputStream) throws IOException {
|
||
|
checkUint24(bArr.length);
|
||
|
writeUint24(bArr.length, outputStream);
|
||
|
outputStream.write(bArr);
|
||
|
}
|
||
|
|
||
|
public static void writeOpaque16(byte[] bArr, OutputStream outputStream) throws IOException {
|
||
|
checkUint16(bArr.length);
|
||
|
writeUint16(bArr.length, outputStream);
|
||
|
outputStream.write(bArr);
|
||
|
}
|
||
|
|
||
|
public static void writeGMTUnixTime(byte[] bArr, int i) {
|
||
|
int currentTimeMillis = (int) (System.currentTimeMillis() / 1000);
|
||
|
bArr[i] = (byte) (currentTimeMillis >>> 24);
|
||
|
bArr[i + 1] = (byte) (currentTimeMillis >>> 16);
|
||
|
bArr[i + 2] = (byte) (currentTimeMillis >>> 8);
|
||
|
bArr[i + 3] = (byte) currentTimeMillis;
|
||
|
}
|
||
|
|
||
|
public static void verifySupportedSignatureAlgorithm(Vector vector, SignatureAndHashAlgorithm signatureAndHashAlgorithm) throws IOException {
|
||
|
if (vector == null || vector.size() <= 0 || vector.size() >= 32768) {
|
||
|
throw new IllegalArgumentException("'supportedSignatureAlgorithms' must have length from 1 to (2^15 - 1)");
|
||
|
}
|
||
|
if (signatureAndHashAlgorithm == null) {
|
||
|
throw new IllegalArgumentException("'signatureAlgorithm' cannot be null");
|
||
|
}
|
||
|
if (signatureAndHashAlgorithm.getSignature() != 0) {
|
||
|
for (int i = 0; i < vector.size(); i++) {
|
||
|
SignatureAndHashAlgorithm signatureAndHashAlgorithm2 = (SignatureAndHashAlgorithm) vector.elementAt(i);
|
||
|
if (signatureAndHashAlgorithm2.getHash() == signatureAndHashAlgorithm.getHash() && signatureAndHashAlgorithm2.getSignature() == signatureAndHashAlgorithm.getSignature()) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
throw new TlsFatalAlert((short) 47);
|
||
|
}
|
||
|
|
||
|
private static Vector vectorOfOne(Object obj) {
|
||
|
Vector vector = new Vector(1);
|
||
|
vector.addElement(obj);
|
||
|
return vector;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static void validateKeyUsage(org.bouncycastle.asn1.x509.Certificate certificate, int i) throws IOException {
|
||
|
KeyUsage fromExtensions;
|
||
|
Extensions extensions = certificate.getTBSCertificate().getExtensions();
|
||
|
if (extensions != null && (fromExtensions = KeyUsage.fromExtensions(extensions)) != null && (fromExtensions.getBytes()[0] & UnsignedBytes.MAX_VALUE & i) != i) {
|
||
|
throw new TlsFatalAlert((short) 46);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static void trackHashAlgorithms(TlsHandshakeHash tlsHandshakeHash, Vector vector) {
|
||
|
if (vector != null) {
|
||
|
for (int i = 0; i < vector.size(); i++) {
|
||
|
short hash = ((SignatureAndHashAlgorithm) vector.elementAt(i)).getHash();
|
||
|
if (!HashAlgorithm.isPrivate(hash)) {
|
||
|
tlsHandshakeHash.trackHashAlgorithm(hash);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int readVersionRaw(byte[] bArr, int i) throws IOException {
|
||
|
return bArr[i + 1] | (bArr[i] << 8);
|
||
|
}
|
||
|
|
||
|
public static int readVersionRaw(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
int read2 = inputStream.read();
|
||
|
if (read2 >= 0) {
|
||
|
return read2 | (read << 8);
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static ProtocolVersion readVersion(byte[] bArr, int i) throws IOException {
|
||
|
return ProtocolVersion.get(bArr[i] & UnsignedBytes.MAX_VALUE, bArr[i + 1] & UnsignedBytes.MAX_VALUE);
|
||
|
}
|
||
|
|
||
|
public static ProtocolVersion readVersion(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
int read2 = inputStream.read();
|
||
|
if (read2 >= 0) {
|
||
|
return ProtocolVersion.get(read, read2);
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static short[] readUint8Array(int i, InputStream inputStream) throws IOException {
|
||
|
short[] sArr = new short[i];
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
sArr[i2] = readUint8(inputStream);
|
||
|
}
|
||
|
return sArr;
|
||
|
}
|
||
|
|
||
|
public static short readUint8(byte[] bArr, int i) {
|
||
|
return (short) (bArr[i] & UnsignedBytes.MAX_VALUE);
|
||
|
}
|
||
|
|
||
|
public static short readUint8(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
if (read >= 0) {
|
||
|
return (short) read;
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static long readUint48(byte[] bArr, int i) {
|
||
|
return (readUint24(bArr, i + 3) & KeyboardMap.kValueMask) | ((readUint24(bArr, i) & KeyboardMap.kValueMask) << 24);
|
||
|
}
|
||
|
|
||
|
public static long readUint48(InputStream inputStream) throws IOException {
|
||
|
return ((readUint24(inputStream) & KeyboardMap.kValueMask) << 24) | (KeyboardMap.kValueMask & readUint24(inputStream));
|
||
|
}
|
||
|
|
||
|
public static long readUint32(byte[] bArr, int i) {
|
||
|
return ((bArr[i + 3] & UnsignedBytes.MAX_VALUE) | ((bArr[i] & UnsignedBytes.MAX_VALUE) << 24) | ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 16) | ((bArr[i + 2] & UnsignedBytes.MAX_VALUE) << 8)) & KeyboardMap.kValueMask;
|
||
|
}
|
||
|
|
||
|
public static long readUint32(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
int read2 = inputStream.read();
|
||
|
int read3 = inputStream.read();
|
||
|
if (inputStream.read() >= 0) {
|
||
|
return (r4 | (read << 24) | (read2 << 16) | (read3 << 8)) & KeyboardMap.kValueMask;
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static int readUint24(byte[] bArr, int i) {
|
||
|
return (bArr[i + 2] & UnsignedBytes.MAX_VALUE) | ((bArr[i] & UnsignedBytes.MAX_VALUE) << 16) | ((bArr[i + 1] & UnsignedBytes.MAX_VALUE) << 8);
|
||
|
}
|
||
|
|
||
|
public static int readUint24(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
int read2 = inputStream.read();
|
||
|
int read3 = inputStream.read();
|
||
|
if (read3 >= 0) {
|
||
|
return read3 | (read << 16) | (read2 << 8);
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static int[] readUint16Array(int i, InputStream inputStream) throws IOException {
|
||
|
int[] iArr = new int[i];
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
iArr[i2] = readUint16(inputStream);
|
||
|
}
|
||
|
return iArr;
|
||
|
}
|
||
|
|
||
|
public static int readUint16(byte[] bArr, int i) {
|
||
|
return (bArr[i + 1] & UnsignedBytes.MAX_VALUE) | ((bArr[i] & UnsignedBytes.MAX_VALUE) << 8);
|
||
|
}
|
||
|
|
||
|
public static int readUint16(InputStream inputStream) throws IOException {
|
||
|
int read = inputStream.read();
|
||
|
int read2 = inputStream.read();
|
||
|
if (read2 >= 0) {
|
||
|
return read2 | (read << 8);
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static Vector readSignatureAlgorithmsExtension(byte[] bArr) throws IOException {
|
||
|
if (bArr == null) {
|
||
|
throw new IllegalArgumentException("'extensionData' cannot be null");
|
||
|
}
|
||
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
|
||
|
Vector parseSupportedSignatureAlgorithms = parseSupportedSignatureAlgorithms(false, byteArrayInputStream);
|
||
|
TlsProtocol.assertEmpty(byteArrayInputStream);
|
||
|
return parseSupportedSignatureAlgorithms;
|
||
|
}
|
||
|
|
||
|
public static byte[] readOpaque8(InputStream inputStream) throws IOException {
|
||
|
return readFully(readUint8(inputStream), inputStream);
|
||
|
}
|
||
|
|
||
|
public static byte[] readOpaque24(InputStream inputStream) throws IOException {
|
||
|
return readFully(readUint24(inputStream), inputStream);
|
||
|
}
|
||
|
|
||
|
public static byte[] readOpaque16(InputStream inputStream) throws IOException {
|
||
|
return readFully(readUint16(inputStream), inputStream);
|
||
|
}
|
||
|
|
||
|
public static byte[] readFully(int i, InputStream inputStream) throws IOException {
|
||
|
if (i <= 0) {
|
||
|
return EMPTY_BYTES;
|
||
|
}
|
||
|
byte[] bArr = new byte[i];
|
||
|
if (i == Streams.readFully(inputStream, bArr)) {
|
||
|
return bArr;
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static void readFully(byte[] bArr, InputStream inputStream) throws IOException {
|
||
|
int length = bArr.length;
|
||
|
if (length > 0 && length != Streams.readFully(inputStream, bArr)) {
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static ASN1Primitive readDERObject(byte[] bArr) throws IOException {
|
||
|
ASN1Primitive readASN1Object = readASN1Object(bArr);
|
||
|
if (Arrays.areEqual(readASN1Object.getEncoded(ASN1Encoding.DER), bArr)) {
|
||
|
return readASN1Object;
|
||
|
}
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
|
||
|
public static byte[] readAllOrNothing(int i, InputStream inputStream) throws IOException {
|
||
|
if (i <= 0) {
|
||
|
return EMPTY_BYTES;
|
||
|
}
|
||
|
byte[] bArr = new byte[i];
|
||
|
int readFully = Streams.readFully(inputStream, bArr);
|
||
|
if (readFully == 0) {
|
||
|
return null;
|
||
|
}
|
||
|
if (readFully == i) {
|
||
|
return bArr;
|
||
|
}
|
||
|
throw new EOFException();
|
||
|
}
|
||
|
|
||
|
public static ASN1Primitive readASN1Object(byte[] bArr) throws IOException {
|
||
|
ASN1InputStream aSN1InputStream = new ASN1InputStream(bArr);
|
||
|
ASN1Primitive readObject = aSN1InputStream.readObject();
|
||
|
if (readObject == null) {
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
if (aSN1InputStream.readObject() == null) {
|
||
|
return readObject;
|
||
|
}
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
|
||
|
public static Vector parseSupportedSignatureAlgorithms(boolean z, InputStream inputStream) throws IOException {
|
||
|
int readUint16 = readUint16(inputStream);
|
||
|
if (readUint16 < 2 || (readUint16 & 1) != 0) {
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
int i = readUint16 / 2;
|
||
|
Vector vector = new Vector(i);
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
SignatureAndHashAlgorithm parse = SignatureAndHashAlgorithm.parse(inputStream);
|
||
|
if (!z && parse.getSignature() == 0) {
|
||
|
throw new TlsFatalAlert((short) 47);
|
||
|
}
|
||
|
vector.addElement(parse);
|
||
|
}
|
||
|
return vector;
|
||
|
}
|
||
|
|
||
|
public static boolean isValidCipherSuiteForVersion(int i, ProtocolVersion protocolVersion) {
|
||
|
return getMinimumVersion(i).isEqualOrEarlierVersionOf(protocolVersion.getEquivalentTLSVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isTLSv12(TlsContext tlsContext) {
|
||
|
return isTLSv12(tlsContext.getServerVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isTLSv12(ProtocolVersion protocolVersion) {
|
||
|
return ProtocolVersion.TLSv12.isEqualOrEarlierVersionOf(protocolVersion.getEquivalentTLSVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isTLSv11(TlsContext tlsContext) {
|
||
|
return isTLSv11(tlsContext.getServerVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isTLSv11(ProtocolVersion protocolVersion) {
|
||
|
return ProtocolVersion.TLSv11.isEqualOrEarlierVersionOf(protocolVersion.getEquivalentTLSVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isStreamCipherSuite(int i) throws IOException {
|
||
|
return getCipherType(i) == 0;
|
||
|
}
|
||
|
|
||
|
public static boolean isSignatureAlgorithmsExtensionAllowed(ProtocolVersion protocolVersion) {
|
||
|
return ProtocolVersion.TLSv12.isEqualOrEarlierVersionOf(protocolVersion.getEquivalentTLSVersion());
|
||
|
}
|
||
|
|
||
|
public static boolean isSSL(TlsContext tlsContext) {
|
||
|
return tlsContext.getServerVersion().isSSL();
|
||
|
}
|
||
|
|
||
|
public static boolean isBlockCipherSuite(int i) throws IOException {
|
||
|
return 1 == getCipherType(i);
|
||
|
}
|
||
|
|
||
|
public static boolean isAEADCipherSuite(int i) throws IOException {
|
||
|
return 2 == getCipherType(i);
|
||
|
}
|
||
|
|
||
|
public static TlsSession importSession(byte[] bArr, SessionParameters sessionParameters) {
|
||
|
return new TlsSessionImpl(bArr, sessionParameters);
|
||
|
}
|
||
|
|
||
|
static void hmac_hash(Digest digest, byte[] bArr, byte[] bArr2, byte[] bArr3) {
|
||
|
HMac hMac = new HMac(digest);
|
||
|
hMac.init(new KeyParameter(bArr));
|
||
|
int digestSize = digest.getDigestSize();
|
||
|
int length = ((bArr3.length + digestSize) - 1) / digestSize;
|
||
|
int macSize = hMac.getMacSize();
|
||
|
byte[] bArr4 = new byte[macSize];
|
||
|
byte[] bArr5 = new byte[hMac.getMacSize()];
|
||
|
byte[] bArr6 = bArr2;
|
||
|
int i = 0;
|
||
|
while (i < length) {
|
||
|
hMac.update(bArr6, 0, bArr6.length);
|
||
|
hMac.doFinal(bArr4, 0);
|
||
|
hMac.update(bArr4, 0, macSize);
|
||
|
hMac.update(bArr2, 0, bArr2.length);
|
||
|
hMac.doFinal(bArr5, 0);
|
||
|
int i2 = digestSize * i;
|
||
|
System.arraycopy(bArr5, 0, bArr3, i2, Math.min(digestSize, bArr3.length - i2));
|
||
|
i++;
|
||
|
bArr6 = bArr4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static boolean hasExpectedEmptyExtensionData(Hashtable hashtable, Integer num, short s) throws IOException {
|
||
|
byte[] extensionData = getExtensionData(hashtable, num);
|
||
|
if (extensionData == null) {
|
||
|
return false;
|
||
|
}
|
||
|
if (extensionData.length == 0) {
|
||
|
return true;
|
||
|
}
|
||
|
throw new TlsFatalAlert(s);
|
||
|
}
|
||
|
|
||
|
public static SignatureAndHashAlgorithm getSignatureAndHashAlgorithm(TlsContext tlsContext, TlsSignerCredentials tlsSignerCredentials) throws IOException {
|
||
|
if (!isTLSv12(tlsContext)) {
|
||
|
return null;
|
||
|
}
|
||
|
SignatureAndHashAlgorithm signatureAndHashAlgorithm = tlsSignerCredentials.getSignatureAndHashAlgorithm();
|
||
|
if (signatureAndHashAlgorithm != null) {
|
||
|
return signatureAndHashAlgorithm;
|
||
|
}
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
|
||
|
public static Vector getSignatureAlgorithmsExtension(Hashtable hashtable) throws IOException {
|
||
|
byte[] extensionData = getExtensionData(hashtable, EXT_signature_algorithms);
|
||
|
if (extensionData == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return readSignatureAlgorithmsExtension(extensionData);
|
||
|
}
|
||
|
|
||
|
public static ASN1ObjectIdentifier getOIDForHashAlgorithm(short s) {
|
||
|
switch (s) {
|
||
|
case 1:
|
||
|
return PKCSObjectIdentifiers.md5;
|
||
|
case 2:
|
||
|
return X509ObjectIdentifiers.id_SHA1;
|
||
|
case 3:
|
||
|
return NISTObjectIdentifiers.id_sha224;
|
||
|
case 4:
|
||
|
return NISTObjectIdentifiers.id_sha256;
|
||
|
case 5:
|
||
|
return NISTObjectIdentifiers.id_sha384;
|
||
|
case 6:
|
||
|
return NISTObjectIdentifiers.id_sha512;
|
||
|
default:
|
||
|
throw new IllegalArgumentException("unknown HashAlgorithm");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static ProtocolVersion getMinimumVersion(int i) {
|
||
|
switch (i) {
|
||
|
case 59:
|
||
|
case 60:
|
||
|
case 61:
|
||
|
case 62:
|
||
|
case 63:
|
||
|
case 64:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case 103:
|
||
|
case 104:
|
||
|
case 105:
|
||
|
case 106:
|
||
|
case 107:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256 /* 156 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384 /* 157 */:
|
||
|
case 158:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 /* 159 */:
|
||
|
case 160:
|
||
|
case CipherSuite.TLS_DH_RSA_WITH_AES_256_GCM_SHA384 /* 161 */:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 /* 162 */:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 /* 163 */:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_AES_128_GCM_SHA256 /* 164 */:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_AES_256_GCM_SHA384 /* 165 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_128_GCM_SHA256 /* 168 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_256_GCM_SHA384 /* 169 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 /* 170 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 /* 171 */:
|
||
|
case CipherSuite.TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 /* 172 */:
|
||
|
case CipherSuite.TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 /* 173 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 /* 186 */:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 /* 187 */:
|
||
|
case 188:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 /* 189 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 /* 190 */:
|
||
|
case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 /* 191 */:
|
||
|
case 192:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 /* 193 */:
|
||
|
case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 /* 194 */:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 /* 195 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 /* 196 */:
|
||
|
case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 /* 197 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 /* 49187 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 /* 49188 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 /* 49189 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 /* 49190 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 /* 49191 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 /* 49192 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 /* 49193 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 /* 49194 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 /* 49195 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 /* 49196 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 /* 49197 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 /* 49198 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 /* 49199 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 /* 49200 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 /* 49201 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 /* 49202 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 /* 49266 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 /* 49267 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 /* 49268 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 /* 49269 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 /* 49270 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 /* 49271 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 /* 49272 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 /* 49273 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49274 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49275 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49276 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49277 */:
|
||
|
case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49278 */:
|
||
|
case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49279 */:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 /* 49280 */:
|
||
|
case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 /* 49281 */:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 /* 49282 */:
|
||
|
case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 /* 49283 */:
|
||
|
case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 /* 49284 */:
|
||
|
case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 /* 49285 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49286 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49287 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49288 */:
|
||
|
case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49289 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49290 */:
|
||
|
case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49291 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 /* 49292 */:
|
||
|
case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 /* 49293 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 /* 49294 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 /* 49295 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 /* 49296 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 /* 49297 */:
|
||
|
case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 /* 49298 */:
|
||
|
case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 /* 49299 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.DRAFT_TLS_PSK_WITH_AES_128_OCB /* 65296 */:
|
||
|
case CipherSuite.DRAFT_TLS_PSK_WITH_AES_256_OCB /* 65297 */:
|
||
|
case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_128_OCB /* 65298 */:
|
||
|
case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_256_OCB /* 65299 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_128_OCB /* 65300 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_256_OCB /* 65301 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_128_CCM /* 49308 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_256_CCM /* 49309 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM /* 49310 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM /* 49311 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_128_CCM_8 /* 49312 */:
|
||
|
case CipherSuite.TLS_RSA_WITH_AES_256_CCM_8 /* 49313 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM_8 /* 49314 */:
|
||
|
case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM_8 /* 49315 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_128_CCM /* 49316 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_256_CCM /* 49317 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CCM /* 49318 */:
|
||
|
case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CCM /* 49319 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_128_CCM_8 /* 49320 */:
|
||
|
case CipherSuite.TLS_PSK_WITH_AES_256_CCM_8 /* 49321 */:
|
||
|
case CipherSuite.TLS_PSK_DHE_WITH_AES_128_CCM_8 /* 49322 */:
|
||
|
case CipherSuite.TLS_PSK_DHE_WITH_AES_256_CCM_8 /* 49323 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM /* 49324 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM /* 49325 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 /* 49326 */:
|
||
|
case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 /* 49327 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 /* 52392 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 /* 52393 */:
|
||
|
case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 /* 52394 */:
|
||
|
case CipherSuite.DRAFT_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 /* 52395 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 /* 52396 */:
|
||
|
case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 /* 52397 */:
|
||
|
case CipherSuite.DRAFT_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 /* 52398 */:
|
||
|
break;
|
||
|
default:
|
||
|
switch (i) {
|
||
|
case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB /* 65280 */:
|
||
|
case 65281:
|
||
|
case 65282:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_256_OCB /* 65283 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_128_OCB /* 65284 */:
|
||
|
case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_256_OCB /* 65285 */:
|
||
|
break;
|
||
|
default:
|
||
|
return ProtocolVersion.SSLv3;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return ProtocolVersion.TLSv12;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:19:0x0020. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:20:0x0023. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:21:0x0026. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:22:0x0029. Please report as an issue. */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:53:0x005a A[FALL_THROUGH, RETURN] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static int getMACAlgorithm(int r3) throws java.io.IOException {
|
||
|
/*
|
||
|
r0 = 1
|
||
|
if (r3 == r0) goto L5b
|
||
|
r1 = 2
|
||
|
if (r3 == r1) goto L5a
|
||
|
r2 = 4
|
||
|
if (r3 == r2) goto L5b
|
||
|
r0 = 5
|
||
|
if (r3 == r0) goto L5a
|
||
|
r0 = 10
|
||
|
if (r3 == r0) goto L5a
|
||
|
r0 = 13
|
||
|
if (r3 == r0) goto L5a
|
||
|
r0 = 16
|
||
|
if (r3 == r0) goto L5a
|
||
|
r0 = 19
|
||
|
if (r3 == r0) goto L5a
|
||
|
r0 = 22
|
||
|
if (r3 == r0) goto L5a
|
||
|
switch(r3) {
|
||
|
case 168: goto L58;
|
||
|
case 169: goto L58;
|
||
|
case 170: goto L58;
|
||
|
case 171: goto L58;
|
||
|
case 172: goto L58;
|
||
|
case 173: goto L58;
|
||
|
case 174: goto L56;
|
||
|
case 175: goto L55;
|
||
|
case 176: goto L56;
|
||
|
case 177: goto L55;
|
||
|
case 178: goto L56;
|
||
|
case 179: goto L55;
|
||
|
case 180: goto L56;
|
||
|
case 181: goto L55;
|
||
|
case 182: goto L56;
|
||
|
case 183: goto L55;
|
||
|
case 184: goto L56;
|
||
|
case 185: goto L55;
|
||
|
case 186: goto L56;
|
||
|
case 187: goto L56;
|
||
|
case 188: goto L56;
|
||
|
case 189: goto L56;
|
||
|
case 190: goto L56;
|
||
|
default: goto L23;
|
||
|
}
|
||
|
L23:
|
||
|
switch(r3) {
|
||
|
case 192: goto L56;
|
||
|
case 193: goto L56;
|
||
|
case 194: goto L56;
|
||
|
case 195: goto L56;
|
||
|
case 196: goto L56;
|
||
|
default: goto L26;
|
||
|
}
|
||
|
L26:
|
||
|
switch(r3) {
|
||
|
case 49153: goto L5a;
|
||
|
case 49154: goto L5a;
|
||
|
case 49155: goto L5a;
|
||
|
case 49156: goto L5a;
|
||
|
case 49157: goto L5a;
|
||
|
case 49158: goto L5a;
|
||
|
case 49159: goto L5a;
|
||
|
case 49160: goto L5a;
|
||
|
case 49161: goto L5a;
|
||
|
case 49162: goto L5a;
|
||
|
case 49163: goto L5a;
|
||
|
case 49164: goto L5a;
|
||
|
case 49165: goto L5a;
|
||
|
case 49166: goto L5a;
|
||
|
case 49167: goto L5a;
|
||
|
case 49168: goto L5a;
|
||
|
case 49169: goto L5a;
|
||
|
case 49170: goto L5a;
|
||
|
case 49171: goto L5a;
|
||
|
case 49172: goto L5a;
|
||
|
case 49173: goto L5a;
|
||
|
case 49174: goto L5a;
|
||
|
case 49175: goto L5a;
|
||
|
case 49176: goto L5a;
|
||
|
case 49177: goto L5a;
|
||
|
case 49178: goto L5a;
|
||
|
case 49179: goto L5a;
|
||
|
case 49180: goto L5a;
|
||
|
case 49181: goto L5a;
|
||
|
case 49182: goto L5a;
|
||
|
case 49183: goto L5a;
|
||
|
case 49184: goto L5a;
|
||
|
case 49185: goto L5a;
|
||
|
case 49186: goto L5a;
|
||
|
case 49187: goto L56;
|
||
|
case 49188: goto L55;
|
||
|
case 49189: goto L56;
|
||
|
case 49190: goto L55;
|
||
|
case 49191: goto L56;
|
||
|
case 49192: goto L55;
|
||
|
case 49193: goto L56;
|
||
|
case 49194: goto L55;
|
||
|
case 49195: goto L58;
|
||
|
case 49196: goto L58;
|
||
|
case 49197: goto L58;
|
||
|
case 49198: goto L58;
|
||
|
case 49199: goto L58;
|
||
|
case 49200: goto L58;
|
||
|
case 49201: goto L58;
|
||
|
case 49202: goto L58;
|
||
|
case 49203: goto L5a;
|
||
|
case 49204: goto L5a;
|
||
|
case 49205: goto L5a;
|
||
|
case 49206: goto L5a;
|
||
|
case 49207: goto L56;
|
||
|
case 49208: goto L55;
|
||
|
case 49209: goto L5a;
|
||
|
case 49210: goto L56;
|
||
|
case 49211: goto L55;
|
||
|
default: goto L29;
|
||
|
}
|
||
|
L29:
|
||
|
switch(r3) {
|
||
|
case 49266: goto L56;
|
||
|
case 49267: goto L55;
|
||
|
case 49268: goto L56;
|
||
|
case 49269: goto L55;
|
||
|
case 49270: goto L56;
|
||
|
case 49271: goto L55;
|
||
|
case 49272: goto L56;
|
||
|
case 49273: goto L55;
|
||
|
case 49274: goto L58;
|
||
|
case 49275: goto L58;
|
||
|
case 49276: goto L58;
|
||
|
case 49277: goto L58;
|
||
|
case 49278: goto L58;
|
||
|
case 49279: goto L58;
|
||
|
case 49280: goto L58;
|
||
|
case 49281: goto L58;
|
||
|
case 49282: goto L58;
|
||
|
case 49283: goto L58;
|
||
|
default: goto L2c;
|
||
|
}
|
||
|
L2c:
|
||
|
switch(r3) {
|
||
|
case 49286: goto L58;
|
||
|
case 49287: goto L58;
|
||
|
case 49288: goto L58;
|
||
|
case 49289: goto L58;
|
||
|
case 49290: goto L58;
|
||
|
case 49291: goto L58;
|
||
|
case 49292: goto L58;
|
||
|
case 49293: goto L58;
|
||
|
case 49294: goto L58;
|
||
|
case 49295: goto L58;
|
||
|
case 49296: goto L58;
|
||
|
case 49297: goto L58;
|
||
|
case 49298: goto L58;
|
||
|
case 49299: goto L58;
|
||
|
case 49300: goto L56;
|
||
|
case 49301: goto L55;
|
||
|
case 49302: goto L56;
|
||
|
case 49303: goto L55;
|
||
|
case 49304: goto L56;
|
||
|
case 49305: goto L55;
|
||
|
case 49306: goto L56;
|
||
|
case 49307: goto L55;
|
||
|
case 49308: goto L58;
|
||
|
case 49309: goto L58;
|
||
|
case 49310: goto L58;
|
||
|
case 49311: goto L58;
|
||
|
case 49312: goto L58;
|
||
|
case 49313: goto L58;
|
||
|
case 49314: goto L58;
|
||
|
case 49315: goto L58;
|
||
|
case 49316: goto L58;
|
||
|
case 49317: goto L58;
|
||
|
case 49318: goto L58;
|
||
|
case 49319: goto L58;
|
||
|
case 49320: goto L58;
|
||
|
case 49321: goto L58;
|
||
|
case 49322: goto L58;
|
||
|
case 49323: goto L58;
|
||
|
case 49324: goto L58;
|
||
|
case 49325: goto L58;
|
||
|
case 49326: goto L58;
|
||
|
case 49327: goto L58;
|
||
|
default: goto L2f;
|
||
|
}
|
||
|
L2f:
|
||
|
switch(r3) {
|
||
|
case 52392: goto L58;
|
||
|
case 52393: goto L58;
|
||
|
case 52394: goto L58;
|
||
|
case 52395: goto L58;
|
||
|
case 52396: goto L58;
|
||
|
case 52397: goto L58;
|
||
|
case 52398: goto L58;
|
||
|
default: goto L32;
|
||
|
}
|
||
|
L32:
|
||
|
switch(r3) {
|
||
|
case 65280: goto L58;
|
||
|
case 65281: goto L58;
|
||
|
case 65282: goto L58;
|
||
|
case 65283: goto L58;
|
||
|
case 65284: goto L58;
|
||
|
case 65285: goto L58;
|
||
|
default: goto L35;
|
||
|
}
|
||
|
L35:
|
||
|
switch(r3) {
|
||
|
case 65296: goto L58;
|
||
|
case 65297: goto L58;
|
||
|
case 65298: goto L58;
|
||
|
case 65299: goto L58;
|
||
|
case 65300: goto L58;
|
||
|
case 65301: goto L58;
|
||
|
default: goto L38;
|
||
|
}
|
||
|
L38:
|
||
|
switch(r3) {
|
||
|
case 44: goto L5a;
|
||
|
case 45: goto L5a;
|
||
|
case 46: goto L5a;
|
||
|
case 47: goto L5a;
|
||
|
case 48: goto L5a;
|
||
|
case 49: goto L5a;
|
||
|
case 50: goto L5a;
|
||
|
case 51: goto L5a;
|
||
|
default: goto L3b;
|
||
|
}
|
||
|
L3b:
|
||
|
switch(r3) {
|
||
|
case 53: goto L5a;
|
||
|
case 54: goto L5a;
|
||
|
case 55: goto L5a;
|
||
|
case 56: goto L5a;
|
||
|
case 57: goto L5a;
|
||
|
default: goto L3e;
|
||
|
}
|
||
|
L3e:
|
||
|
switch(r3) {
|
||
|
case 59: goto L56;
|
||
|
case 60: goto L56;
|
||
|
case 61: goto L56;
|
||
|
case 62: goto L56;
|
||
|
case 63: goto L56;
|
||
|
case 64: goto L56;
|
||
|
case 65: goto L5a;
|
||
|
case 66: goto L5a;
|
||
|
case 67: goto L5a;
|
||
|
case 68: goto L5a;
|
||
|
case 69: goto L5a;
|
||
|
default: goto L41;
|
||
|
}
|
||
|
L41:
|
||
|
switch(r3) {
|
||
|
case 103: goto L56;
|
||
|
case 104: goto L56;
|
||
|
case 105: goto L56;
|
||
|
case 106: goto L56;
|
||
|
case 107: goto L56;
|
||
|
default: goto L44;
|
||
|
}
|
||
|
L44:
|
||
|
switch(r3) {
|
||
|
case 132: goto L5a;
|
||
|
case 133: goto L5a;
|
||
|
case 134: goto L5a;
|
||
|
case 135: goto L5a;
|
||
|
case 136: goto L5a;
|
||
|
default: goto L47;
|
||
|
}
|
||
|
L47:
|
||
|
switch(r3) {
|
||
|
case 138: goto L5a;
|
||
|
case 139: goto L5a;
|
||
|
case 140: goto L5a;
|
||
|
case 141: goto L5a;
|
||
|
case 142: goto L5a;
|
||
|
case 143: goto L5a;
|
||
|
case 144: goto L5a;
|
||
|
case 145: goto L5a;
|
||
|
case 146: goto L5a;
|
||
|
case 147: goto L5a;
|
||
|
case 148: goto L5a;
|
||
|
case 149: goto L5a;
|
||
|
case 150: goto L5a;
|
||
|
case 151: goto L5a;
|
||
|
case 152: goto L5a;
|
||
|
case 153: goto L5a;
|
||
|
case 154: goto L5a;
|
||
|
default: goto L4a;
|
||
|
}
|
||
|
L4a:
|
||
|
switch(r3) {
|
||
|
case 156: goto L58;
|
||
|
case 157: goto L58;
|
||
|
case 158: goto L58;
|
||
|
case 159: goto L58;
|
||
|
case 160: goto L58;
|
||
|
case 161: goto L58;
|
||
|
case 162: goto L58;
|
||
|
case 163: goto L58;
|
||
|
case 164: goto L58;
|
||
|
case 165: goto L58;
|
||
|
default: goto L4d;
|
||
|
}
|
||
|
L4d:
|
||
|
org.bouncycastle.crypto.tls.TlsFatalAlert r3 = new org.bouncycastle.crypto.tls.TlsFatalAlert
|
||
|
r0 = 80
|
||
|
r3.<init>(r0)
|
||
|
throw r3
|
||
|
L55:
|
||
|
return r2
|
||
|
L56:
|
||
|
r3 = 3
|
||
|
return r3
|
||
|
L58:
|
||
|
r3 = 0
|
||
|
return r3
|
||
|
L5a:
|
||
|
return r1
|
||
|
L5b:
|
||
|
return r0
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.tls.TlsUtils.getMACAlgorithm(int):int");
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:19:0x0020. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:20:0x0023. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:21:0x0026. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:22:0x0029. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:23:0x002c. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:24:0x002f. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:25:0x0032. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:26:0x0035. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:27:0x0038. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:28:0x003b. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:29:0x003e. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:30:0x0041. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:31:0x0044. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:32:0x0047. Please report as an issue. */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:84:0x0062 A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:87:0x0069 A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:93:0x0070 A[RETURN] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static int getKeyExchangeAlgorithm(int r6) throws java.io.IOException {
|
||
|
/*
|
||
|
r0 = 1
|
||
|
if (r6 == r0) goto L79
|
||
|
r1 = 2
|
||
|
if (r6 == r1) goto L79
|
||
|
r1 = 4
|
||
|
if (r6 == r1) goto L79
|
||
|
r1 = 5
|
||
|
if (r6 == r1) goto L79
|
||
|
r2 = 10
|
||
|
if (r6 == r2) goto L79
|
||
|
r2 = 13
|
||
|
if (r6 == r2) goto L77
|
||
|
r3 = 16
|
||
|
if (r6 == r3) goto L74
|
||
|
r4 = 19
|
||
|
if (r6 == r4) goto L72
|
||
|
r5 = 22
|
||
|
if (r6 == r5) goto L71
|
||
|
switch(r6) {
|
||
|
case 168: goto L70;
|
||
|
case 169: goto L70;
|
||
|
case 170: goto L6d;
|
||
|
case 171: goto L6d;
|
||
|
case 172: goto L6a;
|
||
|
case 173: goto L6a;
|
||
|
case 174: goto L70;
|
||
|
case 175: goto L70;
|
||
|
case 176: goto L70;
|
||
|
case 177: goto L70;
|
||
|
case 178: goto L6d;
|
||
|
case 179: goto L6d;
|
||
|
case 180: goto L6d;
|
||
|
case 181: goto L6d;
|
||
|
case 182: goto L6a;
|
||
|
case 183: goto L6a;
|
||
|
case 184: goto L6a;
|
||
|
case 185: goto L6a;
|
||
|
case 186: goto L79;
|
||
|
case 187: goto L77;
|
||
|
case 188: goto L74;
|
||
|
case 189: goto L72;
|
||
|
case 190: goto L71;
|
||
|
default: goto L23;
|
||
|
}
|
||
|
L23:
|
||
|
switch(r6) {
|
||
|
case 192: goto L79;
|
||
|
case 193: goto L77;
|
||
|
case 194: goto L74;
|
||
|
case 195: goto L72;
|
||
|
case 196: goto L71;
|
||
|
default: goto L26;
|
||
|
}
|
||
|
L26:
|
||
|
switch(r6) {
|
||
|
case 49153: goto L69;
|
||
|
case 49154: goto L69;
|
||
|
case 49155: goto L69;
|
||
|
case 49156: goto L69;
|
||
|
case 49157: goto L69;
|
||
|
case 49158: goto L66;
|
||
|
case 49159: goto L66;
|
||
|
case 49160: goto L66;
|
||
|
case 49161: goto L66;
|
||
|
case 49162: goto L66;
|
||
|
case 49163: goto L63;
|
||
|
case 49164: goto L63;
|
||
|
case 49165: goto L63;
|
||
|
case 49166: goto L63;
|
||
|
case 49167: goto L63;
|
||
|
case 49168: goto L62;
|
||
|
case 49169: goto L62;
|
||
|
case 49170: goto L62;
|
||
|
case 49171: goto L62;
|
||
|
case 49172: goto L62;
|
||
|
case 49173: goto L5f;
|
||
|
case 49174: goto L5f;
|
||
|
case 49175: goto L5f;
|
||
|
case 49176: goto L5f;
|
||
|
case 49177: goto L5f;
|
||
|
case 49178: goto L5c;
|
||
|
case 49179: goto L59;
|
||
|
case 49180: goto L58;
|
||
|
case 49181: goto L5c;
|
||
|
case 49182: goto L59;
|
||
|
case 49183: goto L58;
|
||
|
case 49184: goto L5c;
|
||
|
case 49185: goto L59;
|
||
|
case 49186: goto L58;
|
||
|
case 49187: goto L66;
|
||
|
case 49188: goto L66;
|
||
|
case 49189: goto L69;
|
||
|
case 49190: goto L69;
|
||
|
case 49191: goto L62;
|
||
|
case 49192: goto L62;
|
||
|
case 49193: goto L63;
|
||
|
case 49194: goto L63;
|
||
|
case 49195: goto L66;
|
||
|
case 49196: goto L66;
|
||
|
case 49197: goto L69;
|
||
|
case 49198: goto L69;
|
||
|
case 49199: goto L62;
|
||
|
case 49200: goto L62;
|
||
|
case 49201: goto L63;
|
||
|
case 49202: goto L63;
|
||
|
case 49203: goto L55;
|
||
|
case 49204: goto L55;
|
||
|
case 49205: goto L55;
|
||
|
case 49206: goto L55;
|
||
|
case 49207: goto L55;
|
||
|
case 49208: goto L55;
|
||
|
case 49209: goto L55;
|
||
|
case 49210: goto L55;
|
||
|
case 49211: goto L55;
|
||
|
default: goto L29;
|
||
|
}
|
||
|
L29:
|
||
|
switch(r6) {
|
||
|
case 49266: goto L66;
|
||
|
case 49267: goto L66;
|
||
|
case 49268: goto L69;
|
||
|
case 49269: goto L69;
|
||
|
case 49270: goto L62;
|
||
|
case 49271: goto L62;
|
||
|
case 49272: goto L63;
|
||
|
case 49273: goto L63;
|
||
|
case 49274: goto L79;
|
||
|
case 49275: goto L79;
|
||
|
case 49276: goto L71;
|
||
|
case 49277: goto L71;
|
||
|
case 49278: goto L74;
|
||
|
case 49279: goto L74;
|
||
|
case 49280: goto L72;
|
||
|
case 49281: goto L72;
|
||
|
case 49282: goto L77;
|
||
|
case 49283: goto L77;
|
||
|
default: goto L2c;
|
||
|
}
|
||
|
L2c:
|
||
|
switch(r6) {
|
||
|
case 49286: goto L66;
|
||
|
case 49287: goto L66;
|
||
|
case 49288: goto L69;
|
||
|
case 49289: goto L69;
|
||
|
case 49290: goto L62;
|
||
|
case 49291: goto L62;
|
||
|
case 49292: goto L63;
|
||
|
case 49293: goto L63;
|
||
|
case 49294: goto L70;
|
||
|
case 49295: goto L70;
|
||
|
case 49296: goto L6d;
|
||
|
case 49297: goto L6d;
|
||
|
case 49298: goto L6a;
|
||
|
case 49299: goto L6a;
|
||
|
case 49300: goto L70;
|
||
|
case 49301: goto L70;
|
||
|
case 49302: goto L6d;
|
||
|
case 49303: goto L6d;
|
||
|
case 49304: goto L6a;
|
||
|
case 49305: goto L6a;
|
||
|
case 49306: goto L55;
|
||
|
case 49307: goto L55;
|
||
|
case 49308: goto L79;
|
||
|
case 49309: goto L79;
|
||
|
case 49310: goto L71;
|
||
|
case 49311: goto L71;
|
||
|
case 49312: goto L79;
|
||
|
case 49313: goto L79;
|
||
|
case 49314: goto L71;
|
||
|
case 49315: goto L71;
|
||
|
case 49316: goto L70;
|
||
|
case 49317: goto L70;
|
||
|
case 49318: goto L6d;
|
||
|
case 49319: goto L6d;
|
||
|
case 49320: goto L70;
|
||
|
case 49321: goto L70;
|
||
|
case 49322: goto L6d;
|
||
|
case 49323: goto L6d;
|
||
|
case 49324: goto L66;
|
||
|
case 49325: goto L66;
|
||
|
case 49326: goto L66;
|
||
|
case 49327: goto L66;
|
||
|
default: goto L2f;
|
||
|
}
|
||
|
L2f:
|
||
|
switch(r6) {
|
||
|
case 52392: goto L62;
|
||
|
case 52393: goto L66;
|
||
|
case 52394: goto L71;
|
||
|
case 52395: goto L70;
|
||
|
case 52396: goto L55;
|
||
|
case 52397: goto L6d;
|
||
|
case 52398: goto L6a;
|
||
|
default: goto L32;
|
||
|
}
|
||
|
L32:
|
||
|
switch(r6) {
|
||
|
case 65280: goto L71;
|
||
|
case 65281: goto L71;
|
||
|
case 65282: goto L62;
|
||
|
case 65283: goto L62;
|
||
|
case 65284: goto L66;
|
||
|
case 65285: goto L66;
|
||
|
default: goto L35;
|
||
|
}
|
||
|
L35:
|
||
|
switch(r6) {
|
||
|
case 65296: goto L70;
|
||
|
case 65297: goto L70;
|
||
|
case 65298: goto L6d;
|
||
|
case 65299: goto L6d;
|
||
|
case 65300: goto L55;
|
||
|
case 65301: goto L55;
|
||
|
default: goto L38;
|
||
|
}
|
||
|
L38:
|
||
|
switch(r6) {
|
||
|
case 44: goto L70;
|
||
|
case 45: goto L6d;
|
||
|
case 46: goto L6a;
|
||
|
case 47: goto L79;
|
||
|
case 48: goto L77;
|
||
|
case 49: goto L74;
|
||
|
case 50: goto L72;
|
||
|
case 51: goto L71;
|
||
|
default: goto L3b;
|
||
|
}
|
||
|
L3b:
|
||
|
switch(r6) {
|
||
|
case 53: goto L79;
|
||
|
case 54: goto L77;
|
||
|
case 55: goto L74;
|
||
|
case 56: goto L72;
|
||
|
case 57: goto L71;
|
||
|
default: goto L3e;
|
||
|
}
|
||
|
L3e:
|
||
|
switch(r6) {
|
||
|
case 59: goto L79;
|
||
|
case 60: goto L79;
|
||
|
case 61: goto L79;
|
||
|
case 62: goto L77;
|
||
|
case 63: goto L74;
|
||
|
case 64: goto L72;
|
||
|
case 65: goto L79;
|
||
|
case 66: goto L77;
|
||
|
case 67: goto L74;
|
||
|
case 68: goto L72;
|
||
|
case 69: goto L71;
|
||
|
default: goto L41;
|
||
|
}
|
||
|
L41:
|
||
|
switch(r6) {
|
||
|
case 103: goto L71;
|
||
|
case 104: goto L77;
|
||
|
case 105: goto L74;
|
||
|
case 106: goto L72;
|
||
|
case 107: goto L71;
|
||
|
default: goto L44;
|
||
|
}
|
||
|
L44:
|
||
|
switch(r6) {
|
||
|
case 132: goto L79;
|
||
|
case 133: goto L77;
|
||
|
case 134: goto L74;
|
||
|
case 135: goto L72;
|
||
|
case 136: goto L71;
|
||
|
default: goto L47;
|
||
|
}
|
||
|
L47:
|
||
|
switch(r6) {
|
||
|
case 138: goto L70;
|
||
|
case 139: goto L70;
|
||
|
case 140: goto L70;
|
||
|
case 141: goto L70;
|
||
|
case 142: goto L6d;
|
||
|
case 143: goto L6d;
|
||
|
case 144: goto L6d;
|
||
|
case 145: goto L6d;
|
||
|
case 146: goto L6a;
|
||
|
case 147: goto L6a;
|
||
|
case 148: goto L6a;
|
||
|
case 149: goto L6a;
|
||
|
case 150: goto L79;
|
||
|
case 151: goto L77;
|
||
|
case 152: goto L74;
|
||
|
case 153: goto L72;
|
||
|
case 154: goto L71;
|
||
|
default: goto L4a;
|
||
|
}
|
||
|
L4a:
|
||
|
switch(r6) {
|
||
|
case 156: goto L79;
|
||
|
case 157: goto L79;
|
||
|
case 158: goto L71;
|
||
|
case 159: goto L71;
|
||
|
case 160: goto L74;
|
||
|
case 161: goto L74;
|
||
|
case 162: goto L72;
|
||
|
case 163: goto L72;
|
||
|
case 164: goto L77;
|
||
|
case 165: goto L77;
|
||
|
default: goto L4d;
|
||
|
}
|
||
|
L4d:
|
||
|
org.bouncycastle.crypto.tls.TlsFatalAlert r6 = new org.bouncycastle.crypto.tls.TlsFatalAlert
|
||
|
r0 = 80
|
||
|
r6.<init>(r0)
|
||
|
throw r6
|
||
|
L55:
|
||
|
r6 = 24
|
||
|
return r6
|
||
|
L58:
|
||
|
return r5
|
||
|
L59:
|
||
|
r6 = 23
|
||
|
return r6
|
||
|
L5c:
|
||
|
r6 = 21
|
||
|
return r6
|
||
|
L5f:
|
||
|
r6 = 20
|
||
|
return r6
|
||
|
L62:
|
||
|
return r4
|
||
|
L63:
|
||
|
r6 = 18
|
||
|
return r6
|
||
|
L66:
|
||
|
r6 = 17
|
||
|
return r6
|
||
|
L69:
|
||
|
return r3
|
||
|
L6a:
|
||
|
r6 = 15
|
||
|
return r6
|
||
|
L6d:
|
||
|
r6 = 14
|
||
|
return r6
|
||
|
L70:
|
||
|
return r2
|
||
|
L71:
|
||
|
return r1
|
||
|
L72:
|
||
|
r6 = 3
|
||
|
return r6
|
||
|
L74:
|
||
|
r6 = 9
|
||
|
return r6
|
||
|
L77:
|
||
|
r6 = 7
|
||
|
return r6
|
||
|
L79:
|
||
|
return r0
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.tls.TlsUtils.getKeyExchangeAlgorithm(int):int");
|
||
|
}
|
||
|
|
||
|
public static short getHashAlgorithmForPRFAlgorithm(int i) {
|
||
|
if (i == 0) {
|
||
|
throw new IllegalArgumentException("legacy PRF not a valid algorithm");
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
return (short) 4;
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
return (short) 5;
|
||
|
}
|
||
|
throw new IllegalArgumentException("unknown PRFAlgorithm");
|
||
|
}
|
||
|
|
||
|
public static byte[] getExtensionData(Hashtable hashtable, Integer num) {
|
||
|
if (hashtable == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return (byte[]) hashtable.get(num);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:22:0x0027. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:23:0x002a. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:24:0x002d. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:25:0x0030. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:26:0x0033. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:27:0x0036. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:28:0x0039. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:29:0x003c. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:30:0x003f. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:31:0x0042. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:32:0x0045. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:33:0x0048. Please report as an issue. */
|
||
|
/* JADX WARN: Failed to find 'out' block for switch in B:34:0x004b. Please report as an issue. */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:64:0x0077 A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:70:0x0079 A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:71:0x007a A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:75:0x0084 A[RETURN] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static int getEncryptionAlgorithm(int r7) throws java.io.IOException {
|
||
|
/*
|
||
|
r0 = 1
|
||
|
r1 = 0
|
||
|
if (r7 == r0) goto L88
|
||
|
r0 = 2
|
||
|
if (r7 == r0) goto L88
|
||
|
r2 = 4
|
||
|
if (r7 == r2) goto L87
|
||
|
r2 = 5
|
||
|
if (r7 == r2) goto L87
|
||
|
r2 = 10
|
||
|
if (r7 == r2) goto L85
|
||
|
r3 = 13
|
||
|
if (r7 == r3) goto L85
|
||
|
r4 = 16
|
||
|
if (r7 == r4) goto L85
|
||
|
r5 = 19
|
||
|
if (r7 == r5) goto L85
|
||
|
r6 = 22
|
||
|
if (r7 == r6) goto L85
|
||
|
r6 = 24
|
||
|
if (r7 == r6) goto L87
|
||
|
r6 = 12
|
||
|
switch(r7) {
|
||
|
case 168: goto L84;
|
||
|
case 169: goto L81;
|
||
|
case 170: goto L84;
|
||
|
case 171: goto L81;
|
||
|
case 172: goto L84;
|
||
|
case 173: goto L81;
|
||
|
case 174: goto L7e;
|
||
|
case 175: goto L7b;
|
||
|
case 176: goto L7a;
|
||
|
case 177: goto L7a;
|
||
|
case 178: goto L7e;
|
||
|
case 179: goto L7b;
|
||
|
case 180: goto L7a;
|
||
|
case 181: goto L7a;
|
||
|
case 182: goto L7e;
|
||
|
case 183: goto L7b;
|
||
|
case 184: goto L7a;
|
||
|
case 185: goto L7a;
|
||
|
case 186: goto L79;
|
||
|
case 187: goto L79;
|
||
|
case 188: goto L79;
|
||
|
case 189: goto L79;
|
||
|
case 190: goto L79;
|
||
|
default: goto L2a;
|
||
|
}
|
||
|
L2a:
|
||
|
switch(r7) {
|
||
|
case 192: goto L78;
|
||
|
case 193: goto L78;
|
||
|
case 194: goto L78;
|
||
|
case 195: goto L78;
|
||
|
case 196: goto L78;
|
||
|
default: goto L2d;
|
||
|
}
|
||
|
L2d:
|
||
|
switch(r7) {
|
||
|
case 49153: goto L88;
|
||
|
case 49154: goto L87;
|
||
|
case 49155: goto L85;
|
||
|
case 49156: goto L7e;
|
||
|
case 49157: goto L7b;
|
||
|
case 49158: goto L88;
|
||
|
case 49159: goto L87;
|
||
|
case 49160: goto L85;
|
||
|
case 49161: goto L7e;
|
||
|
case 49162: goto L7b;
|
||
|
case 49163: goto L88;
|
||
|
case 49164: goto L87;
|
||
|
case 49165: goto L85;
|
||
|
case 49166: goto L7e;
|
||
|
case 49167: goto L7b;
|
||
|
case 49168: goto L88;
|
||
|
case 49169: goto L87;
|
||
|
case 49170: goto L85;
|
||
|
case 49171: goto L7e;
|
||
|
case 49172: goto L7b;
|
||
|
case 49173: goto L88;
|
||
|
case 49174: goto L87;
|
||
|
case 49175: goto L85;
|
||
|
case 49176: goto L7e;
|
||
|
case 49177: goto L7b;
|
||
|
case 49178: goto L85;
|
||
|
case 49179: goto L85;
|
||
|
case 49180: goto L85;
|
||
|
case 49181: goto L7e;
|
||
|
case 49182: goto L7e;
|
||
|
case 49183: goto L7e;
|
||
|
case 49184: goto L7b;
|
||
|
case 49185: goto L7b;
|
||
|
case 49186: goto L7b;
|
||
|
case 49187: goto L7e;
|
||
|
case 49188: goto L7b;
|
||
|
case 49189: goto L7e;
|
||
|
case 49190: goto L7b;
|
||
|
case 49191: goto L7e;
|
||
|
case 49192: goto L7b;
|
||
|
case 49193: goto L7e;
|
||
|
case 49194: goto L7b;
|
||
|
case 49195: goto L84;
|
||
|
case 49196: goto L81;
|
||
|
case 49197: goto L84;
|
||
|
case 49198: goto L81;
|
||
|
case 49199: goto L84;
|
||
|
case 49200: goto L81;
|
||
|
case 49201: goto L84;
|
||
|
case 49202: goto L81;
|
||
|
case 49203: goto L87;
|
||
|
case 49204: goto L85;
|
||
|
case 49205: goto L7e;
|
||
|
case 49206: goto L7b;
|
||
|
case 49207: goto L7e;
|
||
|
case 49208: goto L7b;
|
||
|
case 49209: goto L88;
|
||
|
case 49210: goto L7a;
|
||
|
case 49211: goto L7a;
|
||
|
default: goto L30;
|
||
|
}
|
||
|
L30:
|
||
|
switch(r7) {
|
||
|
case 49266: goto L79;
|
||
|
case 49267: goto L78;
|
||
|
case 49268: goto L79;
|
||
|
case 49269: goto L78;
|
||
|
case 49270: goto L79;
|
||
|
case 49271: goto L78;
|
||
|
case 49272: goto L79;
|
||
|
case 49273: goto L78;
|
||
|
case 49274: goto L77;
|
||
|
case 49275: goto L74;
|
||
|
case 49276: goto L77;
|
||
|
case 49277: goto L74;
|
||
|
case 49278: goto L77;
|
||
|
case 49279: goto L74;
|
||
|
case 49280: goto L77;
|
||
|
case 49281: goto L74;
|
||
|
case 49282: goto L77;
|
||
|
case 49283: goto L74;
|
||
|
default: goto L33;
|
||
|
}
|
||
|
L33:
|
||
|
switch(r7) {
|
||
|
case 49286: goto L77;
|
||
|
case 49287: goto L74;
|
||
|
case 49288: goto L77;
|
||
|
case 49289: goto L74;
|
||
|
case 49290: goto L77;
|
||
|
case 49291: goto L74;
|
||
|
case 49292: goto L77;
|
||
|
case 49293: goto L74;
|
||
|
case 49294: goto L77;
|
||
|
case 49295: goto L74;
|
||
|
case 49296: goto L77;
|
||
|
case 49297: goto L74;
|
||
|
case 49298: goto L77;
|
||
|
case 49299: goto L74;
|
||
|
case 49300: goto L79;
|
||
|
case 49301: goto L78;
|
||
|
case 49302: goto L79;
|
||
|
case 49303: goto L78;
|
||
|
case 49304: goto L79;
|
||
|
case 49305: goto L78;
|
||
|
case 49306: goto L79;
|
||
|
case 49307: goto L78;
|
||
|
case 49308: goto L71;
|
||
|
case 49309: goto L6e;
|
||
|
case 49310: goto L71;
|
||
|
case 49311: goto L6e;
|
||
|
case 49312: goto L6d;
|
||
|
case 49313: goto L6a;
|
||
|
case 49314: goto L6d;
|
||
|
case 49315: goto L6a;
|
||
|
case 49316: goto L71;
|
||
|
case 49317: goto L6e;
|
||
|
case 49318: goto L71;
|
||
|
case 49319: goto L6e;
|
||
|
case 49320: goto L6d;
|
||
|
case 49321: goto L6a;
|
||
|
case 49322: goto L6d;
|
||
|
case 49323: goto L6a;
|
||
|
case 49324: goto L71;
|
||
|
case 49325: goto L6e;
|
||
|
case 49326: goto L6d;
|
||
|
case 49327: goto L6a;
|
||
|
default: goto L36;
|
||
|
}
|
||
|
L36:
|
||
|
switch(r7) {
|
||
|
case 52392: goto L67;
|
||
|
case 52393: goto L67;
|
||
|
case 52394: goto L67;
|
||
|
case 52395: goto L67;
|
||
|
case 52396: goto L67;
|
||
|
case 52397: goto L67;
|
||
|
case 52398: goto L67;
|
||
|
default: goto L39;
|
||
|
}
|
||
|
L39:
|
||
|
switch(r7) {
|
||
|
case 65280: goto L64;
|
||
|
case 65281: goto L61;
|
||
|
case 65282: goto L64;
|
||
|
case 65283: goto L61;
|
||
|
case 65284: goto L64;
|
||
|
case 65285: goto L61;
|
||
|
default: goto L3c;
|
||
|
}
|
||
|
L3c:
|
||
|
switch(r7) {
|
||
|
case 65296: goto L64;
|
||
|
case 65297: goto L61;
|
||
|
case 65298: goto L64;
|
||
|
case 65299: goto L61;
|
||
|
case 65300: goto L64;
|
||
|
case 65301: goto L61;
|
||
|
default: goto L3f;
|
||
|
}
|
||
|
L3f:
|
||
|
switch(r7) {
|
||
|
case 44: goto L88;
|
||
|
case 45: goto L88;
|
||
|
case 46: goto L88;
|
||
|
case 47: goto L7e;
|
||
|
case 48: goto L7e;
|
||
|
case 49: goto L7e;
|
||
|
case 50: goto L7e;
|
||
|
case 51: goto L7e;
|
||
|
default: goto L42;
|
||
|
}
|
||
|
L42:
|
||
|
switch(r7) {
|
||
|
case 53: goto L7b;
|
||
|
case 54: goto L7b;
|
||
|
case 55: goto L7b;
|
||
|
case 56: goto L7b;
|
||
|
case 57: goto L7b;
|
||
|
default: goto L45;
|
||
|
}
|
||
|
L45:
|
||
|
switch(r7) {
|
||
|
case 59: goto L7a;
|
||
|
case 60: goto L7e;
|
||
|
case 61: goto L7b;
|
||
|
case 62: goto L7e;
|
||
|
case 63: goto L7e;
|
||
|
case 64: goto L7e;
|
||
|
case 65: goto L5c;
|
||
|
case 66: goto L5c;
|
||
|
case 67: goto L5c;
|
||
|
case 68: goto L5c;
|
||
|
case 69: goto L5c;
|
||
|
default: goto L48;
|
||
|
}
|
||
|
L48:
|
||
|
switch(r7) {
|
||
|
case 103: goto L7e;
|
||
|
case 104: goto L7b;
|
||
|
case 105: goto L7b;
|
||
|
case 106: goto L7b;
|
||
|
case 107: goto L7b;
|
||
|
default: goto L4b;
|
||
|
}
|
||
|
L4b:
|
||
|
switch(r7) {
|
||
|
case 132: goto L5d;
|
||
|
case 133: goto L5d;
|
||
|
case 134: goto L5d;
|
||
|
case 135: goto L5d;
|
||
|
case 136: goto L5d;
|
||
|
default: goto L4e;
|
||
|
}
|
||
|
L4e:
|
||
|
switch(r7) {
|
||
|
case 138: goto L87;
|
||
|
case 139: goto L85;
|
||
|
case 140: goto L7e;
|
||
|
case 141: goto L7b;
|
||
|
case 142: goto L87;
|
||
|
case 143: goto L85;
|
||
|
case 144: goto L7e;
|
||
|
case 145: goto L7b;
|
||
|
case 146: goto L87;
|
||
|
case 147: goto L85;
|
||
|
case 148: goto L7e;
|
||
|
case 149: goto L7b;
|
||
|
case 150: goto L5e;
|
||
|
case 151: goto L5e;
|
||
|
case 152: goto L5e;
|
||
|
case 153: goto L5e;
|
||
|
case 154: goto L5e;
|
||
|
default: goto L51;
|
||
|
}
|
||
|
L51:
|
||
|
switch(r7) {
|
||
|
case 156: goto L84;
|
||
|
case 157: goto L81;
|
||
|
case 158: goto L84;
|
||
|
case 159: goto L81;
|
||
|
case 160: goto L84;
|
||
|
case 161: goto L81;
|
||
|
case 162: goto L84;
|
||
|
case 163: goto L81;
|
||
|
case 164: goto L84;
|
||
|
case 165: goto L81;
|
||
|
default: goto L54;
|
||
|
}
|
||
|
L54:
|
||
|
org.bouncycastle.crypto.tls.TlsFatalAlert r7 = new org.bouncycastle.crypto.tls.TlsFatalAlert
|
||
|
r0 = 80
|
||
|
r7.<init>(r0)
|
||
|
throw r7
|
||
|
L5c:
|
||
|
return r6
|
||
|
L5d:
|
||
|
return r3
|
||
|
L5e:
|
||
|
r7 = 14
|
||
|
return r7
|
||
|
L61:
|
||
|
r7 = 104(0x68, float:1.46E-43)
|
||
|
return r7
|
||
|
L64:
|
||
|
r7 = 103(0x67, float:1.44E-43)
|
||
|
return r7
|
||
|
L67:
|
||
|
r7 = 102(0x66, float:1.43E-43)
|
||
|
return r7
|
||
|
L6a:
|
||
|
r7 = 18
|
||
|
return r7
|
||
|
L6d:
|
||
|
return r4
|
||
|
L6e:
|
||
|
r7 = 17
|
||
|
return r7
|
||
|
L71:
|
||
|
r7 = 15
|
||
|
return r7
|
||
|
L74:
|
||
|
r7 = 20
|
||
|
return r7
|
||
|
L77:
|
||
|
return r5
|
||
|
L78:
|
||
|
return r3
|
||
|
L79:
|
||
|
return r6
|
||
|
L7a:
|
||
|
return r1
|
||
|
L7b:
|
||
|
r7 = 9
|
||
|
return r7
|
||
|
L7e:
|
||
|
r7 = 8
|
||
|
return r7
|
||
|
L81:
|
||
|
r7 = 11
|
||
|
return r7
|
||
|
L84:
|
||
|
return r2
|
||
|
L85:
|
||
|
r7 = 7
|
||
|
return r7
|
||
|
L87:
|
||
|
return r0
|
||
|
L88:
|
||
|
return r1
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.crypto.tls.TlsUtils.getEncryptionAlgorithm(int):int");
|
||
|
}
|
||
|
|
||
|
public static Vector getDefaultSupportedSignatureAlgorithms() {
|
||
|
short[] sArr = {2, 3, 4, 5, 6};
|
||
|
short[] sArr2 = {1, 2, 3};
|
||
|
Vector vector = new Vector();
|
||
|
for (int i = 0; i < 3; i++) {
|
||
|
for (int i2 = 0; i2 < 5; i2++) {
|
||
|
vector.addElement(new SignatureAndHashAlgorithm(sArr[i2], sArr2[i]));
|
||
|
}
|
||
|
}
|
||
|
return vector;
|
||
|
}
|
||
|
|
||
|
public static Vector getDefaultRSASignatureAlgorithms() {
|
||
|
return vectorOfOne(new SignatureAndHashAlgorithm((short) 2, (short) 1));
|
||
|
}
|
||
|
|
||
|
public static Vector getDefaultECDSASignatureAlgorithms() {
|
||
|
return vectorOfOne(new SignatureAndHashAlgorithm((short) 2, (short) 3));
|
||
|
}
|
||
|
|
||
|
public static Vector getDefaultDSSSignatureAlgorithms() {
|
||
|
return vectorOfOne(new SignatureAndHashAlgorithm((short) 2, (short) 2));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static short getClientCertificateType(Certificate certificate, Certificate certificate2) throws IOException {
|
||
|
if (certificate.isEmpty()) {
|
||
|
return (short) -1;
|
||
|
}
|
||
|
org.bouncycastle.asn1.x509.Certificate certificateAt = certificate.getCertificateAt(0);
|
||
|
try {
|
||
|
AsymmetricKeyParameter createKey = PublicKeyFactory.createKey(certificateAt.getSubjectPublicKeyInfo());
|
||
|
if (createKey.isPrivate()) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
if (createKey instanceof RSAKeyParameters) {
|
||
|
validateKeyUsage(certificateAt, 128);
|
||
|
return (short) 1;
|
||
|
}
|
||
|
if (createKey instanceof DSAPublicKeyParameters) {
|
||
|
validateKeyUsage(certificateAt, 128);
|
||
|
return (short) 2;
|
||
|
}
|
||
|
if (!(createKey instanceof ECPublicKeyParameters)) {
|
||
|
throw new TlsFatalAlert((short) 43);
|
||
|
}
|
||
|
validateKeyUsage(certificateAt, 128);
|
||
|
return (short) 64;
|
||
|
} catch (Exception e) {
|
||
|
throw new TlsFatalAlert((short) 43, e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int getCipherType(int i) throws IOException {
|
||
|
int encryptionAlgorithm = getEncryptionAlgorithm(i);
|
||
|
switch (encryptionAlgorithm) {
|
||
|
case 1:
|
||
|
case 2:
|
||
|
return 0;
|
||
|
case 3:
|
||
|
case 4:
|
||
|
case 5:
|
||
|
case 6:
|
||
|
case 7:
|
||
|
case 8:
|
||
|
case 9:
|
||
|
case 12:
|
||
|
case 13:
|
||
|
case 14:
|
||
|
return 1;
|
||
|
case 10:
|
||
|
case 11:
|
||
|
case 15:
|
||
|
case 16:
|
||
|
case 17:
|
||
|
case 18:
|
||
|
case 19:
|
||
|
case 20:
|
||
|
return 2;
|
||
|
default:
|
||
|
switch (encryptionAlgorithm) {
|
||
|
case 102:
|
||
|
case 103:
|
||
|
case 104:
|
||
|
return 2;
|
||
|
default:
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static byte[][] genSSL3Const() {
|
||
|
byte[][] bArr = new byte[10];
|
||
|
int i = 0;
|
||
|
while (i < 10) {
|
||
|
int i2 = i + 1;
|
||
|
byte[] bArr2 = new byte[i2];
|
||
|
Arrays.fill(bArr2, (byte) (i + 65));
|
||
|
bArr[i] = bArr2;
|
||
|
i = i2;
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] encodeUint8ArrayWithUint8Length(short[] sArr) throws IOException {
|
||
|
byte[] bArr = new byte[sArr.length + 1];
|
||
|
writeUint8ArrayWithUint8Length(sArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static byte[] encodeUint16ArrayWithUint16Length(int[] iArr) throws IOException {
|
||
|
byte[] bArr = new byte[(iArr.length << 1) + 2];
|
||
|
writeUint16ArrayWithUint16Length(iArr, bArr, 0);
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static void encodeSupportedSignatureAlgorithms(Vector vector, boolean z, OutputStream outputStream) throws IOException {
|
||
|
if (vector == null || vector.size() <= 0 || vector.size() >= 32768) {
|
||
|
throw new IllegalArgumentException("'supportedSignatureAlgorithms' must have length from 1 to (2^15 - 1)");
|
||
|
}
|
||
|
int size = vector.size() << 1;
|
||
|
checkUint16(size);
|
||
|
writeUint16(size, outputStream);
|
||
|
for (int i = 0; i < vector.size(); i++) {
|
||
|
SignatureAndHashAlgorithm signatureAndHashAlgorithm = (SignatureAndHashAlgorithm) vector.elementAt(i);
|
||
|
if (!z && signatureAndHashAlgorithm.getSignature() == 0) {
|
||
|
throw new IllegalArgumentException("SignatureAlgorithm.anonymous MUST NOT appear in the signature_algorithms extension");
|
||
|
}
|
||
|
signatureAndHashAlgorithm.encode(outputStream);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static byte[] encodeOpaque8(byte[] bArr) throws IOException {
|
||
|
checkUint8(bArr.length);
|
||
|
return Arrays.prepend(bArr, (byte) bArr.length);
|
||
|
}
|
||
|
|
||
|
public static TlsSigner createTlsSigner(short s) {
|
||
|
if (s == 1) {
|
||
|
return new TlsRSASigner();
|
||
|
}
|
||
|
if (s == 2) {
|
||
|
return new TlsDSSSigner();
|
||
|
}
|
||
|
if (s == 64) {
|
||
|
return new TlsECDSASigner();
|
||
|
}
|
||
|
throw new IllegalArgumentException("'clientCertificateType' is not a type with signing capability");
|
||
|
}
|
||
|
|
||
|
public static byte[] createSignatureAlgorithmsExtension(Vector vector) throws IOException {
|
||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||
|
encodeSupportedSignatureAlgorithms(vector, false, byteArrayOutputStream);
|
||
|
return byteArrayOutputStream.toByteArray();
|
||
|
}
|
||
|
|
||
|
public static Digest createPRFHash(int i) {
|
||
|
return i != 0 ? createHash(getHashAlgorithmForPRFAlgorithm(i)) : new CombinedHash();
|
||
|
}
|
||
|
|
||
|
public static Digest createHash(short s) {
|
||
|
switch (s) {
|
||
|
case 1:
|
||
|
return new MD5Digest();
|
||
|
case 2:
|
||
|
return new SHA1Digest();
|
||
|
case 3:
|
||
|
return new SHA224Digest();
|
||
|
case 4:
|
||
|
return new SHA256Digest();
|
||
|
case 5:
|
||
|
return new SHA384Digest();
|
||
|
case 6:
|
||
|
return new SHA512Digest();
|
||
|
default:
|
||
|
throw new IllegalArgumentException("unknown HashAlgorithm");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static Digest createHash(SignatureAndHashAlgorithm signatureAndHashAlgorithm) {
|
||
|
return signatureAndHashAlgorithm == null ? new CombinedHash() : createHash(signatureAndHashAlgorithm.getHash());
|
||
|
}
|
||
|
|
||
|
static byte[] concat(byte[] bArr, byte[] bArr2) {
|
||
|
byte[] bArr3 = new byte[bArr.length + bArr2.length];
|
||
|
System.arraycopy(bArr, 0, bArr3, 0, bArr.length);
|
||
|
System.arraycopy(bArr2, 0, bArr3, bArr.length, bArr2.length);
|
||
|
return bArr3;
|
||
|
}
|
||
|
|
||
|
public static Digest clonePRFHash(int i, Digest digest) {
|
||
|
return i != 0 ? cloneHash(getHashAlgorithmForPRFAlgorithm(i), digest) : new CombinedHash((CombinedHash) digest);
|
||
|
}
|
||
|
|
||
|
public static Digest cloneHash(short s, Digest digest) {
|
||
|
switch (s) {
|
||
|
case 1:
|
||
|
return new MD5Digest((MD5Digest) digest);
|
||
|
case 2:
|
||
|
return new SHA1Digest((SHA1Digest) digest);
|
||
|
case 3:
|
||
|
return new SHA224Digest((SHA224Digest) digest);
|
||
|
case 4:
|
||
|
return new SHA256Digest((SHA256Digest) digest);
|
||
|
case 5:
|
||
|
return new SHA384Digest((SHA384Digest) digest);
|
||
|
case 6:
|
||
|
return new SHA512Digest((SHA512Digest) digest);
|
||
|
default:
|
||
|
throw new IllegalArgumentException("unknown HashAlgorithm");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint8(short s) throws IOException {
|
||
|
if (!isValidUint8(s)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint8(long j) throws IOException {
|
||
|
if (!isValidUint8(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint8(int i) throws IOException {
|
||
|
if (!isValidUint8(i)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint64(long j) throws IOException {
|
||
|
if (!isValidUint64(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint48(long j) throws IOException {
|
||
|
if (!isValidUint48(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint32(long j) throws IOException {
|
||
|
if (!isValidUint32(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint24(long j) throws IOException {
|
||
|
if (!isValidUint24(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint24(int i) throws IOException {
|
||
|
if (!isValidUint24(i)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint16(long j) throws IOException {
|
||
|
if (!isValidUint16(j)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void checkUint16(int i) throws IOException {
|
||
|
if (!isValidUint16(i)) {
|
||
|
throw new TlsFatalAlert((short) 80);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static byte[] calculateVerifyData(TlsContext tlsContext, String str, byte[] bArr) {
|
||
|
if (isSSL(tlsContext)) {
|
||
|
return bArr;
|
||
|
}
|
||
|
SecurityParameters securityParameters = tlsContext.getSecurityParameters();
|
||
|
return PRF(tlsContext, securityParameters.getMasterSecret(), str, bArr, securityParameters.getVerifyDataLength());
|
||
|
}
|
||
|
|
||
|
static byte[] calculateMasterSecret_SSL(byte[] bArr, byte[] bArr2) {
|
||
|
Digest createHash = createHash((short) 1);
|
||
|
Digest createHash2 = createHash((short) 2);
|
||
|
int digestSize = createHash.getDigestSize();
|
||
|
int digestSize2 = createHash2.getDigestSize();
|
||
|
byte[] bArr3 = new byte[digestSize2];
|
||
|
byte[] bArr4 = new byte[digestSize * 3];
|
||
|
int i = 0;
|
||
|
for (int i2 = 0; i2 < 3; i2++) {
|
||
|
byte[] bArr5 = SSL3_CONST[i2];
|
||
|
createHash2.update(bArr5, 0, bArr5.length);
|
||
|
createHash2.update(bArr, 0, bArr.length);
|
||
|
createHash2.update(bArr2, 0, bArr2.length);
|
||
|
createHash2.doFinal(bArr3, 0);
|
||
|
createHash.update(bArr, 0, bArr.length);
|
||
|
createHash.update(bArr3, 0, digestSize2);
|
||
|
createHash.doFinal(bArr4, i);
|
||
|
i += digestSize;
|
||
|
}
|
||
|
return bArr4;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static byte[] calculateMasterSecret(TlsContext tlsContext, byte[] bArr) {
|
||
|
SecurityParameters securityParameters = tlsContext.getSecurityParameters();
|
||
|
byte[] sessionHash = securityParameters.extendedMasterSecret ? securityParameters.getSessionHash() : concat(securityParameters.getClientRandom(), securityParameters.getServerRandom());
|
||
|
if (isSSL(tlsContext)) {
|
||
|
return calculateMasterSecret_SSL(bArr, sessionHash);
|
||
|
}
|
||
|
return PRF(tlsContext, bArr, securityParameters.extendedMasterSecret ? ExporterLabel.extended_master_secret : "master secret", sessionHash, 48);
|
||
|
}
|
||
|
|
||
|
static byte[] calculateKeyBlock_SSL(byte[] bArr, byte[] bArr2, int i) {
|
||
|
Digest createHash = createHash((short) 1);
|
||
|
Digest createHash2 = createHash((short) 2);
|
||
|
int digestSize = createHash.getDigestSize();
|
||
|
int digestSize2 = createHash2.getDigestSize();
|
||
|
byte[] bArr3 = new byte[digestSize2];
|
||
|
byte[] bArr4 = new byte[i + digestSize];
|
||
|
int i2 = 0;
|
||
|
int i3 = 0;
|
||
|
while (i2 < i) {
|
||
|
byte[] bArr5 = SSL3_CONST[i3];
|
||
|
createHash2.update(bArr5, 0, bArr5.length);
|
||
|
createHash2.update(bArr, 0, bArr.length);
|
||
|
createHash2.update(bArr2, 0, bArr2.length);
|
||
|
createHash2.doFinal(bArr3, 0);
|
||
|
createHash.update(bArr, 0, bArr.length);
|
||
|
createHash.update(bArr3, 0, digestSize2);
|
||
|
createHash.doFinal(bArr4, i2);
|
||
|
i2 += digestSize;
|
||
|
i3++;
|
||
|
}
|
||
|
return Arrays.copyOfRange(bArr4, 0, i);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static byte[] calculateKeyBlock(TlsContext tlsContext, int i) {
|
||
|
SecurityParameters securityParameters = tlsContext.getSecurityParameters();
|
||
|
byte[] masterSecret = securityParameters.getMasterSecret();
|
||
|
byte[] concat = concat(securityParameters.getServerRandom(), securityParameters.getClientRandom());
|
||
|
return isSSL(tlsContext) ? calculateKeyBlock_SSL(masterSecret, concat, i) : PRF(tlsContext, masterSecret, "key expansion", concat, i);
|
||
|
}
|
||
|
|
||
|
public static void addSignatureAlgorithmsExtension(Hashtable hashtable, Vector vector) throws IOException {
|
||
|
hashtable.put(EXT_signature_algorithms, createSignatureAlgorithmsExtension(vector));
|
||
|
}
|
||
|
|
||
|
static byte[] PRF_legacy(byte[] bArr, byte[] bArr2, byte[] bArr3, int i) {
|
||
|
int length = (bArr.length + 1) / 2;
|
||
|
byte[] bArr4 = new byte[length];
|
||
|
byte[] bArr5 = new byte[length];
|
||
|
System.arraycopy(bArr, 0, bArr4, 0, length);
|
||
|
System.arraycopy(bArr, bArr.length - length, bArr5, 0, length);
|
||
|
byte[] bArr6 = new byte[i];
|
||
|
byte[] bArr7 = new byte[i];
|
||
|
hmac_hash(createHash((short) 1), bArr4, bArr3, bArr6);
|
||
|
hmac_hash(createHash((short) 2), bArr5, bArr3, bArr7);
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
bArr6[i2] = (byte) (bArr6[i2] ^ bArr7[i2]);
|
||
|
}
|
||
|
return bArr6;
|
||
|
}
|
||
|
|
||
|
public static byte[] PRF_legacy(byte[] bArr, String str, byte[] bArr2, int i) {
|
||
|
byte[] byteArray = Strings.toByteArray(str);
|
||
|
return PRF_legacy(bArr, byteArray, concat(byteArray, bArr2), i);
|
||
|
}
|
||
|
|
||
|
public static byte[] PRF(TlsContext tlsContext, byte[] bArr, String str, byte[] bArr2, int i) {
|
||
|
if (tlsContext.getServerVersion().isSSL()) {
|
||
|
throw new IllegalStateException("No PRF available for SSLv3 session");
|
||
|
}
|
||
|
byte[] byteArray = Strings.toByteArray(str);
|
||
|
byte[] concat = concat(byteArray, bArr2);
|
||
|
int prfAlgorithm = tlsContext.getSecurityParameters().getPrfAlgorithm();
|
||
|
if (prfAlgorithm == 0) {
|
||
|
return PRF_legacy(bArr, byteArray, concat, i);
|
||
|
}
|
||
|
byte[] bArr3 = new byte[i];
|
||
|
hmac_hash(createPRFHash(prfAlgorithm), bArr, concat, bArr3);
|
||
|
return bArr3;
|
||
|
}
|
||
|
}
|