what-the-bank/sources/org/bouncycastle/asn1/DERApplicationSpecific.java

59 lines
2.3 KiB
Java

package org.bouncycastle.asn1;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/* loaded from: classes6.dex */
public class DERApplicationSpecific extends ASN1ApplicationSpecific {
/* JADX INFO: Access modifiers changed from: package-private */
@Override // org.bouncycastle.asn1.ASN1ApplicationSpecific, org.bouncycastle.asn1.ASN1Primitive
public void encode(ASN1OutputStream aSN1OutputStream) throws IOException {
aSN1OutputStream.writeEncoded(this.isConstructed ? 96 : 64, this.tag, this.octets);
}
private static byte[] getEncoding(boolean z, ASN1Encodable aSN1Encodable) throws IOException {
byte[] encoded = aSN1Encodable.toASN1Primitive().getEncoded(ASN1Encoding.DER);
if (z) {
return encoded;
}
int lengthOfHeader = getLengthOfHeader(encoded);
int length = encoded.length - lengthOfHeader;
byte[] bArr = new byte[length];
System.arraycopy(encoded, lengthOfHeader, bArr, 0, length);
return bArr;
}
private static byte[] getEncodedVector(ASN1EncodableVector aSN1EncodableVector) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
for (int i = 0; i != aSN1EncodableVector.size(); i++) {
try {
byteArrayOutputStream.write(((ASN1Object) aSN1EncodableVector.get(i)).getEncoded(ASN1Encoding.DER));
} catch (IOException e) {
throw new ASN1ParsingException("malformed object: ".concat(String.valueOf(e)), e);
}
}
return byteArrayOutputStream.toByteArray();
}
/* JADX INFO: Access modifiers changed from: package-private */
public DERApplicationSpecific(boolean z, int i, byte[] bArr) {
super(z, i, bArr);
}
public DERApplicationSpecific(boolean z, int i, ASN1Encodable aSN1Encodable) throws IOException {
super(z || aSN1Encodable.toASN1Primitive().isConstructed(), i, getEncoding(z, aSN1Encodable));
}
public DERApplicationSpecific(int i, byte[] bArr) {
this(false, i, bArr);
}
public DERApplicationSpecific(int i, ASN1EncodableVector aSN1EncodableVector) {
super(true, i, getEncodedVector(aSN1EncodableVector));
}
public DERApplicationSpecific(int i, ASN1Encodable aSN1Encodable) throws IOException {
this(true, i, aSN1Encodable);
}
}