what-the-bank/sources/org/bouncycastle/crypto/tls/PSKTlsServer.java

70 lines
2.6 KiB
Java

package org.bouncycastle.crypto.tls;
import java.io.IOException;
import org.bouncycastle.crypto.agreement.DHStandardGroups;
import org.bouncycastle.crypto.params.DHParameters;
/* loaded from: classes6.dex */
public class PSKTlsServer extends AbstractTlsServer {
protected TlsPSKIdentityManager pskIdentityManager;
protected TlsEncryptionCredentials getRSAEncryptionCredentials() throws IOException {
throw new TlsFatalAlert((short) 80);
}
@Override // org.bouncycastle.crypto.tls.TlsServer
public TlsKeyExchange getKeyExchange() throws IOException {
int keyExchangeAlgorithm = TlsUtils.getKeyExchangeAlgorithm(this.selectedCipherSuite);
if (keyExchangeAlgorithm != 24) {
switch (keyExchangeAlgorithm) {
case 13:
case 14:
case 15:
break;
default:
throw new TlsFatalAlert((short) 80);
}
}
return createPSKKeyExchange(keyExchangeAlgorithm);
}
protected DHParameters getDHParameters() {
return DHStandardGroups.rfc5114_2048_256;
}
@Override // org.bouncycastle.crypto.tls.TlsServer
public TlsCredentials getCredentials() throws IOException {
int keyExchangeAlgorithm = TlsUtils.getKeyExchangeAlgorithm(this.selectedCipherSuite);
if (keyExchangeAlgorithm == 24) {
return null;
}
switch (keyExchangeAlgorithm) {
case 13:
case 14:
return null;
case 15:
return getRSAEncryptionCredentials();
default:
throw new TlsFatalAlert((short) 80);
}
}
@Override // org.bouncycastle.crypto.tls.AbstractTlsServer
protected int[] getCipherSuites() {
return new int[]{CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA};
}
protected TlsKeyExchange createPSKKeyExchange(int i) {
return new TlsPSKKeyExchange(i, this.supportedSignatureAlgorithms, null, this.pskIdentityManager, getDHParameters(), this.namedCurves, this.clientECPointFormats, this.serverECPointFormats);
}
public PSKTlsServer(TlsPSKIdentityManager tlsPSKIdentityManager) {
this(new DefaultTlsCipherFactory(), tlsPSKIdentityManager);
}
public PSKTlsServer(TlsCipherFactory tlsCipherFactory, TlsPSKIdentityManager tlsPSKIdentityManager) {
super(tlsCipherFactory);
this.pskIdentityManager = tlsPSKIdentityManager;
}
}