package org.bouncycastle.asn1; import java.io.IOException; import java.io.InputStream; import org.bouncycastle.util.io.Streams; /* loaded from: classes6.dex */ public class BEROctetStringParser implements ASN1OctetStringParser { private ASN1StreamParser _parser; @Override // org.bouncycastle.asn1.ASN1Encodable public ASN1Primitive toASN1Primitive() { try { return getLoadedObject(); } catch (IOException e) { StringBuilder sb = new StringBuilder("IOException converting stream to byte array: "); sb.append(e.getMessage()); throw new ASN1ParsingException(sb.toString(), e); } } @Override // org.bouncycastle.asn1.ASN1OctetStringParser public InputStream getOctetStream() { return new ConstructedOctetStream(this._parser); } @Override // org.bouncycastle.asn1.InMemoryRepresentable public ASN1Primitive getLoadedObject() throws IOException { return new BEROctetString(Streams.readAll(getOctetStream())); } /* JADX INFO: Access modifiers changed from: package-private */ public BEROctetStringParser(ASN1StreamParser aSN1StreamParser) { this._parser = aSN1StreamParser; } }