package org.bouncycastle.jcajce.provider.asymmetric.rsa; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.math.BigInteger; import java.security.interfaces.RSAPrivateKey; import java.security.spec.RSAPrivateKeySpec; import java.util.Enumeration; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.DERNull; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; import org.bouncycastle.crypto.params.RSAKeyParameters; import org.bouncycastle.jcajce.provider.asymmetric.util.KeyUtil; import org.bouncycastle.jcajce.provider.asymmetric.util.PKCS12BagAttributeCarrierImpl; import org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier; /* loaded from: classes6.dex */ public class BCRSAPrivateKey implements RSAPrivateKey, PKCS12BagAttributeCarrier { private static BigInteger ZERO = BigInteger.valueOf(0); static final long serialVersionUID = 5110188922551353628L; private transient PKCS12BagAttributeCarrierImpl attrCarrier = new PKCS12BagAttributeCarrierImpl(); protected BigInteger modulus; protected BigInteger privateExponent; @Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier public void setBagAttribute(ASN1ObjectIdentifier aSN1ObjectIdentifier, ASN1Encodable aSN1Encodable) { this.attrCarrier.setBagAttribute(aSN1ObjectIdentifier, aSN1Encodable); } public int hashCode() { return getModulus().hashCode() ^ getPrivateExponent().hashCode(); } @Override // java.security.interfaces.RSAPrivateKey public BigInteger getPrivateExponent() { return this.privateExponent; } @Override // java.security.interfaces.RSAKey public BigInteger getModulus() { return this.modulus; } @Override // java.security.Key public String getFormat() { return "PKCS#8"; } @Override // java.security.Key public byte[] getEncoded() { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE); BigInteger modulus = getModulus(); BigInteger bigInteger = ZERO; BigInteger privateExponent = getPrivateExponent(); BigInteger bigInteger2 = ZERO; return KeyUtil.getEncodedPrivateKeyInfo(algorithmIdentifier, new org.bouncycastle.asn1.pkcs.RSAPrivateKey(modulus, bigInteger, privateExponent, bigInteger2, bigInteger2, bigInteger2, bigInteger2, bigInteger2)); } @Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier public Enumeration getBagAttributeKeys() { return this.attrCarrier.getBagAttributeKeys(); } @Override // org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier public ASN1Encodable getBagAttribute(ASN1ObjectIdentifier aSN1ObjectIdentifier) { return this.attrCarrier.getBagAttribute(aSN1ObjectIdentifier); } @Override // java.security.Key public String getAlgorithm() { return "RSA"; } public boolean equals(Object obj) { if (!(obj instanceof RSAPrivateKey)) { return false; } if (obj == this) { return true; } RSAPrivateKey rSAPrivateKey = (RSAPrivateKey) obj; return getModulus().equals(rSAPrivateKey.getModulus()) && getPrivateExponent().equals(rSAPrivateKey.getPrivateExponent()); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); this.attrCarrier = new PKCS12BagAttributeCarrierImpl(); } /* JADX INFO: Access modifiers changed from: package-private */ public BCRSAPrivateKey(RSAKeyParameters rSAKeyParameters) { this.modulus = rSAKeyParameters.getModulus(); this.privateExponent = rSAKeyParameters.getExponent(); } /* JADX INFO: Access modifiers changed from: package-private */ public BCRSAPrivateKey(org.bouncycastle.asn1.pkcs.RSAPrivateKey rSAPrivateKey) { this.modulus = rSAPrivateKey.getModulus(); this.privateExponent = rSAPrivateKey.getPrivateExponent(); } /* JADX INFO: Access modifiers changed from: package-private */ public BCRSAPrivateKey(RSAPrivateKeySpec rSAPrivateKeySpec) { this.modulus = rSAPrivateKeySpec.getModulus(); this.privateExponent = rSAPrivateKeySpec.getPrivateExponent(); } /* JADX INFO: Access modifiers changed from: package-private */ public BCRSAPrivateKey(RSAPrivateKey rSAPrivateKey) { this.modulus = rSAPrivateKey.getModulus(); this.privateExponent = rSAPrivateKey.getPrivateExponent(); } /* JADX INFO: Access modifiers changed from: protected */ public BCRSAPrivateKey() { } }