147 lines
4.2 KiB
Java
147 lines
4.2 KiB
Java
package org.bouncycastle.asn1;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class ASN1OutputStream {
|
|
private OutputStream os;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void writeTag(int i, int i2) throws IOException {
|
|
if (i2 < 31) {
|
|
write(i | i2);
|
|
return;
|
|
}
|
|
write(i | 31);
|
|
if (i2 < 128) {
|
|
write(i2);
|
|
return;
|
|
}
|
|
byte[] bArr = new byte[5];
|
|
int i3 = 4;
|
|
bArr[4] = (byte) (i2 & 127);
|
|
do {
|
|
i2 >>= 7;
|
|
i3--;
|
|
bArr[i3] = (byte) ((i2 & 127) | 128);
|
|
} while (i2 > 127);
|
|
write(bArr, i3, 5 - i3);
|
|
}
|
|
|
|
public void writeObject(ASN1Encodable aSN1Encodable) throws IOException {
|
|
if (aSN1Encodable == null) {
|
|
throw new IOException("null object detected");
|
|
}
|
|
aSN1Encodable.toASN1Primitive().encode(this);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public void writeNull() throws IOException {
|
|
this.os.write(5);
|
|
this.os.write(0);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void writeLength(int i) throws IOException {
|
|
if (i <= 127) {
|
|
write((byte) i);
|
|
return;
|
|
}
|
|
int i2 = i;
|
|
int i3 = 1;
|
|
while (true) {
|
|
i2 >>>= 8;
|
|
if (i2 == 0) {
|
|
break;
|
|
} else {
|
|
i3++;
|
|
}
|
|
}
|
|
write((byte) (i3 | 128));
|
|
for (int i4 = (i3 - 1) << 3; i4 >= 0; i4 -= 8) {
|
|
write((byte) (i >> i4));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void writeImplicitObject(ASN1Primitive aSN1Primitive) throws IOException {
|
|
if (aSN1Primitive == null) {
|
|
throw new IOException("null object detected");
|
|
}
|
|
aSN1Primitive.encode(new ImplicitOutputStream(this, this.os));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void writeEncoded(int i, byte[] bArr) throws IOException {
|
|
write(i);
|
|
writeLength(bArr.length);
|
|
write(bArr);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void writeEncoded(int i, int i2, byte[] bArr) throws IOException {
|
|
writeTag(i, i2);
|
|
writeLength(bArr.length);
|
|
write(bArr);
|
|
}
|
|
|
|
void write(byte[] bArr, int i, int i2) throws IOException {
|
|
this.os.write(bArr, i, i2);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void write(byte[] bArr) throws IOException {
|
|
this.os.write(bArr);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void write(int i) throws IOException {
|
|
this.os.write(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ASN1OutputStream getDLSubStream() {
|
|
return new DLOutputStream(this.os);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ASN1OutputStream getDERSubStream() {
|
|
return new DEROutputStream(this.os);
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
class ImplicitOutputStream extends ASN1OutputStream {
|
|
private boolean first;
|
|
final ASN1OutputStream this$0;
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1OutputStream
|
|
public void write(int i) throws IOException {
|
|
if (this.first) {
|
|
this.first = false;
|
|
} else {
|
|
super.write(i);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public ImplicitOutputStream(ASN1OutputStream aSN1OutputStream, OutputStream outputStream) {
|
|
super(outputStream);
|
|
this.this$0 = aSN1OutputStream;
|
|
this.first = true;
|
|
}
|
|
}
|
|
|
|
public void flush() throws IOException {
|
|
this.os.flush();
|
|
}
|
|
|
|
public void close() throws IOException {
|
|
this.os.close();
|
|
}
|
|
|
|
public ASN1OutputStream(OutputStream outputStream) {
|
|
this.os = outputStream;
|
|
}
|
|
}
|