74 lines
3.2 KiB
Java
74 lines
3.2 KiB
Java
package org.bouncycastle.crypto.tls;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.security.SecureRandom;
|
|
import java.util.Hashtable;
|
|
import java.util.Vector;
|
|
import org.bouncycastle.util.Arrays;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public abstract class DTLSProtocol {
|
|
protected final SecureRandom secureRandom;
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public void processFinished(byte[] bArr, byte[] bArr2) throws IOException {
|
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
|
|
byte[] readFully = TlsUtils.readFully(bArr2.length, byteArrayInputStream);
|
|
TlsProtocol.assertEmpty(byteArrayInputStream);
|
|
if (!Arrays.constantTimeAreEqual(bArr2, readFully)) {
|
|
throw new TlsFatalAlert((short) 40);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public static void validateSelectedCipherSuite(int i, short s) throws IOException {
|
|
int encryptionAlgorithm = TlsUtils.getEncryptionAlgorithm(i);
|
|
if (encryptionAlgorithm == 1 || encryptionAlgorithm == 2) {
|
|
throw new TlsFatalAlert(s);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public static byte[] generateSupplementalData(Vector vector) throws IOException {
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
TlsProtocol.writeSupplementalData(byteArrayOutputStream, vector);
|
|
return byteArrayOutputStream.toByteArray();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public static byte[] generateCertificate(Certificate certificate) throws IOException {
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
certificate.encode(byteArrayOutputStream);
|
|
return byteArrayOutputStream.toByteArray();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public static short evaluateMaxFragmentLengthExtension(boolean z, Hashtable hashtable, Hashtable hashtable2, short s) throws IOException {
|
|
short maxFragmentLengthExtension = TlsExtensionsUtils.getMaxFragmentLengthExtension(hashtable2);
|
|
if (maxFragmentLengthExtension < 0 || (MaxFragmentLength.isValid(maxFragmentLengthExtension) && (z || maxFragmentLengthExtension == TlsExtensionsUtils.getMaxFragmentLengthExtension(hashtable)))) {
|
|
return maxFragmentLengthExtension;
|
|
}
|
|
throw new TlsFatalAlert(s);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public static void applyMaxFragmentLengthExtension(DTLSRecordLayer dTLSRecordLayer, short s) throws IOException {
|
|
if (s >= 0) {
|
|
if (!MaxFragmentLength.isValid(s)) {
|
|
throw new TlsFatalAlert((short) 80);
|
|
}
|
|
dTLSRecordLayer.setPlaintextLimit(1 << (s + 8));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public DTLSProtocol(SecureRandom secureRandom) {
|
|
if (secureRandom == null) {
|
|
throw new IllegalArgumentException("'secureRandom' cannot be null");
|
|
}
|
|
this.secureRandom = secureRandom;
|
|
}
|
|
}
|