package org.bouncycastle.asn1; import java.io.ByteArrayOutputStream; import java.io.IOException; import org.bouncycastle.util.Encodable; /* loaded from: classes6.dex */ public abstract class ASN1Object implements ASN1Encodable, Encodable { @Override // org.bouncycastle.asn1.ASN1Encodable public abstract ASN1Primitive toASN1Primitive(); public ASN1Primitive toASN1Object() { return toASN1Primitive(); } public int hashCode() { return toASN1Primitive().hashCode(); } public byte[] getEncoded(String str) throws IOException { ByteArrayOutputStream byteArrayOutputStream; ASN1OutputStream dLOutputStream; if (str.equals(ASN1Encoding.DER)) { byteArrayOutputStream = new ByteArrayOutputStream(); dLOutputStream = new DEROutputStream(byteArrayOutputStream); } else { if (!str.equals(ASN1Encoding.DL)) { return getEncoded(); } byteArrayOutputStream = new ByteArrayOutputStream(); dLOutputStream = new DLOutputStream(byteArrayOutputStream); } dLOutputStream.writeObject(this); return byteArrayOutputStream.toByteArray(); } @Override // org.bouncycastle.util.Encodable public byte[] getEncoded() throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); new ASN1OutputStream(byteArrayOutputStream).writeObject(this); return byteArrayOutputStream.toByteArray(); } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ASN1Encodable) { return toASN1Primitive().equals(((ASN1Encodable) obj).toASN1Primitive()); } return false; } public static boolean hasEncodedTagValue(Object obj, int i) { return (obj instanceof byte[]) && ((byte[]) obj)[0] == i; } }