what-the-bank/sources/org/bouncycastle/jce/provider/PEMUtil.java

103 lines
3.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.jce.provider;
import java.io.IOException;
import java.io.InputStream;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.util.encoders.Base64;
/* loaded from: classes6.dex */
public class PEMUtil {
private final String _footer1;
private final String _footer2;
private final String _header1;
private final String _header2;
/* JADX INFO: Access modifiers changed from: package-private */
public ASN1Sequence readPEMObject(InputStream inputStream) throws IOException {
String readLine;
StringBuffer stringBuffer = new StringBuffer();
do {
readLine = readLine(inputStream);
if (readLine == null || readLine.startsWith(this._header1)) {
break;
}
} while (!readLine.startsWith(this._header2));
while (true) {
String readLine2 = readLine(inputStream);
if (readLine2 == null || readLine2.startsWith(this._footer1) || readLine2.startsWith(this._footer2)) {
break;
}
stringBuffer.append(readLine2);
}
if (stringBuffer.length() == 0) {
return null;
}
ASN1Primitive readObject = new ASN1InputStream(Base64.decode(stringBuffer.toString())).readObject();
if (readObject instanceof ASN1Sequence) {
return (ASN1Sequence) readObject;
}
throw new IOException("malformed PEM data encountered");
}
/* JADX WARN: Code restructure failed: missing block: B:10:0x0020, code lost:
if (r0.length() == 0) goto L26;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private java.lang.String readLine(java.io.InputStream r5) throws java.io.IOException {
/*
r4 = this;
java.lang.StringBuffer r0 = new java.lang.StringBuffer
r0.<init>()
L5:
int r1 = r5.read()
r2 = 13
if (r1 == r2) goto L1a
r3 = 10
if (r1 == r3) goto L1a
if (r1 < 0) goto L1a
if (r1 == r2) goto L5
char r1 = (char) r1
r0.append(r1)
goto L5
L1a:
if (r1 < 0) goto L22
int r2 = r0.length()
if (r2 == 0) goto L5
L22:
if (r1 >= 0) goto L26
r5 = 0
return r5
L26:
java.lang.String r5 = r0.toString()
return r5
*/
throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.jce.provider.PEMUtil.readLine(java.io.InputStream):java.lang.String");
}
/* JADX INFO: Access modifiers changed from: package-private */
public PEMUtil(String str) {
StringBuilder sb = new StringBuilder("-----BEGIN ");
sb.append(str);
sb.append("-----");
this._header1 = sb.toString();
StringBuilder sb2 = new StringBuilder("-----BEGIN X509 ");
sb2.append(str);
sb2.append("-----");
this._header2 = sb2.toString();
StringBuilder sb3 = new StringBuilder("-----END ");
sb3.append(str);
sb3.append("-----");
this._footer1 = sb3.toString();
StringBuilder sb4 = new StringBuilder("-----END X509 ");
sb4.append(str);
sb4.append("-----");
this._footer2 = sb4.toString();
}
}