58 lines
2.3 KiB
Java
58 lines
2.3 KiB
Java
package org.bouncycastle.asn1;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class BERApplicationSpecific 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.writeTag(this.isConstructed ? 96 : 64, this.tag);
|
|
aSN1OutputStream.write(128);
|
|
aSN1OutputStream.write(this.octets);
|
|
aSN1OutputStream.write(0);
|
|
aSN1OutputStream.write(0);
|
|
}
|
|
|
|
private static byte[] getEncoding(boolean z, ASN1Encodable aSN1Encodable) throws IOException {
|
|
byte[] encoded = aSN1Encodable.toASN1Primitive().getEncoded(ASN1Encoding.BER);
|
|
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.BER));
|
|
} catch (IOException e) {
|
|
throw new ASN1ParsingException("malformed object: ".concat(String.valueOf(e)), e);
|
|
}
|
|
}
|
|
return byteArrayOutputStream.toByteArray();
|
|
}
|
|
|
|
BERApplicationSpecific(boolean z, int i, byte[] bArr) {
|
|
super(z, i, bArr);
|
|
}
|
|
|
|
public BERApplicationSpecific(boolean z, int i, ASN1Encodable aSN1Encodable) throws IOException {
|
|
super(z || aSN1Encodable.toASN1Primitive().isConstructed(), i, getEncoding(z, aSN1Encodable));
|
|
}
|
|
|
|
public BERApplicationSpecific(int i, ASN1EncodableVector aSN1EncodableVector) {
|
|
super(true, i, getEncodedVector(aSN1EncodableVector));
|
|
}
|
|
|
|
public BERApplicationSpecific(int i, ASN1Encodable aSN1Encodable) throws IOException {
|
|
this(true, i, aSN1Encodable);
|
|
}
|
|
}
|