what-the-bank/sources/org/bouncycastle/crypto/tls/DefaultTlsEncryptionCredent...

46 lines
1.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.tls;
import java.io.IOException;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.crypto.params.RSAKeyParameters;
/* loaded from: classes6.dex */
public class DefaultTlsEncryptionCredentials extends AbstractTlsEncryptionCredentials {
protected Certificate certificate;
protected TlsContext context;
protected AsymmetricKeyParameter privateKey;
@Override // org.bouncycastle.crypto.tls.TlsCredentials
public Certificate getCertificate() {
return this.certificate;
}
@Override // org.bouncycastle.crypto.tls.TlsEncryptionCredentials
public byte[] decryptPreMasterSecret(byte[] bArr) throws IOException {
return TlsRSAUtils.safeDecryptPreMasterSecret(this.context, (RSAKeyParameters) this.privateKey, bArr);
}
public DefaultTlsEncryptionCredentials(TlsContext tlsContext, Certificate certificate, AsymmetricKeyParameter asymmetricKeyParameter) {
if (certificate == null) {
throw new IllegalArgumentException("'certificate' cannot be null");
}
if (certificate.isEmpty()) {
throw new IllegalArgumentException("'certificate' cannot be empty");
}
if (asymmetricKeyParameter == null) {
throw new IllegalArgumentException("'privateKey' cannot be null");
}
if (!asymmetricKeyParameter.isPrivate()) {
throw new IllegalArgumentException("'privateKey' must be private");
}
if (!(asymmetricKeyParameter instanceof RSAKeyParameters)) {
StringBuilder sb = new StringBuilder("'privateKey' type not supported: ");
sb.append(asymmetricKeyParameter.getClass().getName());
throw new IllegalArgumentException(sb.toString());
}
this.context = tlsContext;
this.certificate = certificate;
this.privateKey = asymmetricKeyParameter;
}
}