package org.bouncycastle.asn1; import java.io.IOException; import java.util.Enumeration; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public class LazyEncodedSequence extends ASN1Sequence { private byte[] encoded; /* JADX INFO: Access modifiers changed from: package-private */ @Override // org.bouncycastle.asn1.ASN1Sequence, org.bouncycastle.asn1.ASN1Primitive public ASN1Primitive toDLObject() { if (this.encoded != null) { parse(); } return super.toDLObject(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // org.bouncycastle.asn1.ASN1Sequence, org.bouncycastle.asn1.ASN1Primitive public ASN1Primitive toDERObject() { if (this.encoded != null) { parse(); } return super.toDERObject(); } @Override // org.bouncycastle.asn1.ASN1Sequence public int size() { int size; synchronized (this) { if (this.encoded != null) { parse(); } size = super.size(); } return size; } @Override // org.bouncycastle.asn1.ASN1Sequence public Enumeration getObjects() { synchronized (this) { byte[] bArr = this.encoded; if (bArr == null) { return super.getObjects(); } return new LazyConstructionEnumeration(bArr); } } @Override // org.bouncycastle.asn1.ASN1Sequence public ASN1Encodable getObjectAt(int i) { ASN1Encodable objectAt; synchronized (this) { if (this.encoded != null) { parse(); } objectAt = super.getObjectAt(i); } return objectAt; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // org.bouncycastle.asn1.ASN1Primitive public int encodedLength() throws IOException { byte[] bArr = this.encoded; return bArr != null ? StreamUtil.calculateBodyLength(bArr.length) + 1 + this.encoded.length : super.toDLObject().encodedLength(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // org.bouncycastle.asn1.ASN1Sequence, org.bouncycastle.asn1.ASN1Primitive public void encode(ASN1OutputStream aSN1OutputStream) throws IOException { byte[] bArr = this.encoded; if (bArr != null) { aSN1OutputStream.writeEncoded(48, bArr); } else { super.toDLObject().encode(aSN1OutputStream); } } private void parse() { LazyConstructionEnumeration lazyConstructionEnumeration = new LazyConstructionEnumeration(this.encoded); while (lazyConstructionEnumeration.hasMoreElements()) { this.seq.addElement(lazyConstructionEnumeration.nextElement()); } this.encoded = null; } /* JADX INFO: Access modifiers changed from: package-private */ public LazyEncodedSequence(byte[] bArr) throws IOException { this.encoded = bArr; } }