package org.bouncycastle.asn1.util; import java.io.IOException; import java.util.Enumeration; import org.bouncycastle.asn1.ASN1ApplicationSpecific; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.util.Strings; import org.bouncycastle.util.encoders.Hex; /* loaded from: classes6.dex */ public class ASN1Dump { private static final int SAMPLE_SIZE = 32; private static final String TAB = " "; private static String outputApplicationSpecific(String str, String str2, boolean z, ASN1Primitive aSN1Primitive, String str3) { ASN1ApplicationSpecific aSN1ApplicationSpecific = ASN1ApplicationSpecific.getInstance(aSN1Primitive); StringBuffer stringBuffer = new StringBuffer(); if (!aSN1ApplicationSpecific.isConstructed()) { StringBuilder sb = new StringBuilder(); sb.append(str2); sb.append(str); sb.append(" ApplicationSpecific["); sb.append(aSN1ApplicationSpecific.getApplicationTag()); sb.append("] ("); sb.append(Strings.fromByteArray(Hex.encode(aSN1ApplicationSpecific.getContents()))); sb.append(")"); sb.append(str3); return sb.toString(); } try { ASN1Sequence aSN1Sequence = ASN1Sequence.getInstance(aSN1ApplicationSpecific.getObject(16)); StringBuilder sb2 = new StringBuilder(); sb2.append(str2); sb2.append(str); sb2.append(" ApplicationSpecific["); sb2.append(aSN1ApplicationSpecific.getApplicationTag()); sb2.append("]"); sb2.append(str3); stringBuffer.append(sb2.toString()); Enumeration objects = aSN1Sequence.getObjects(); while (objects.hasMoreElements()) { StringBuilder sb3 = new StringBuilder(); sb3.append(str2); sb3.append(TAB); _dumpAsString(sb3.toString(), z, (ASN1Primitive) objects.nextElement(), stringBuffer); } } catch (IOException e) { stringBuffer.append(e); } return stringBuffer.toString(); } private static String dumpBinaryDataAsString(String str, byte[] bArr) { String calculateAscString; String lineSeparator = Strings.lineSeparator(); StringBuffer stringBuffer = new StringBuffer(); StringBuilder sb = new StringBuilder(); sb.append(str); sb.append(TAB); String obj = sb.toString(); stringBuffer.append(lineSeparator); for (int i = 0; i < bArr.length; i += 32) { int length = bArr.length; stringBuffer.append(obj); if (length - i > 32) { stringBuffer.append(Strings.fromByteArray(Hex.encode(bArr, i, 32))); stringBuffer.append(TAB); calculateAscString = calculateAscString(bArr, i, 32); } else { stringBuffer.append(Strings.fromByteArray(Hex.encode(bArr, i, bArr.length - i))); for (int length2 = bArr.length - i; length2 != 32; length2++) { stringBuffer.append(" "); } stringBuffer.append(TAB); calculateAscString = calculateAscString(bArr, i, bArr.length - i); } stringBuffer.append(calculateAscString); stringBuffer.append(lineSeparator); } return stringBuffer.toString(); } public static String dumpAsString(Object obj, boolean z) { ASN1Primitive aSN1Primitive; StringBuffer stringBuffer = new StringBuffer(); if (obj instanceof ASN1Primitive) { aSN1Primitive = (ASN1Primitive) obj; } else { if (!(obj instanceof ASN1Encodable)) { StringBuilder sb = new StringBuilder("unknown object type "); sb.append(obj.toString()); return sb.toString(); } aSN1Primitive = ((ASN1Encodable) obj).toASN1Primitive(); } _dumpAsString("", z, aSN1Primitive, stringBuffer); return stringBuffer.toString(); } public static String dumpAsString(Object obj) { return dumpAsString(obj, false); } private static String calculateAscString(byte[] bArr, int i, int i2) { StringBuffer stringBuffer = new StringBuffer(); for (int i3 = i; i3 != i + i2; i3++) { byte b = bArr[i3]; if (b >= 32 && b <= 126) { stringBuffer.append((char) b); } } return stringBuffer.toString(); } /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Code restructure failed: missing block: B:100:0x01ed, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:71:0x02f5, code lost: r5 = outputApplicationSpecific(r1, r5, r6, r7, r0); */ /* JADX WARN: Code restructure failed: missing block: B:76:0x02e2, code lost: r6.append(r5); r5 = ") "; */ /* JADX WARN: Code restructure failed: missing block: B:99:0x01ea, code lost: r8.append(r0); */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static void _dumpAsString(java.lang.String r5, boolean r6, org.bouncycastle.asn1.ASN1Primitive r7, java.lang.StringBuffer r8) { /* Method dump skipped, instructions count: 994 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.asn1.util.ASN1Dump._dumpAsString(java.lang.String, boolean, org.bouncycastle.asn1.ASN1Primitive, java.lang.StringBuffer):void"); } }