package org.bouncycastle.openpgp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.bouncycastle.bcpg.BCPGInputStream;

/* JADX INFO: loaded from: classes.dex */
class Util {
    Util() {
    }

    static BCPGInputStream createBCPGInputStream(InputStream inputStream, int i) throws IOException {
        BCPGInputStream bCPGInputStreamWrap = BCPGInputStream.wrap(inputStream);
        int iNextPacketTag = bCPGInputStreamWrap.nextPacketTag();
        if (iNextPacketTag == i) {
            return bCPGInputStreamWrap;
        }
        throw new IOException("unexpected tag " + iNextPacketTag + " encountered");
    }

    static BCPGInputStream createBCPGInputStream(InputStream inputStream, int i, int i2) throws IOException {
        BCPGInputStream bCPGInputStreamWrap = BCPGInputStream.wrap(inputStream);
        int iNextPacketTag = bCPGInputStreamWrap.nextPacketTag();
        if (iNextPacketTag == i || iNextPacketTag == i2) {
            return bCPGInputStreamWrap;
        }
        throw new IOException("unexpected tag " + iNextPacketTag + " encountered");
    }

    static void encodePGPSignatures(OutputStream outputStream, List<PGPSignature> list, boolean z) throws IOException {
        for (int i = 0; i != list.size(); i++) {
            list.get(i).encode(outputStream, z);
        }
    }
}
