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; } }