package org.bouncycastle.bcpg;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/* JADX INFO: loaded from: classes3.dex */
public class TrustPacket extends ContainedPacket {
    byte[] levelAndTrustAmount;

    public TrustPacket(int i) {
        super(12);
        this.levelAndTrustAmount = new byte[1];
        this.levelAndTrustAmount[0] = (byte) i;
    }

    public TrustPacket(BCPGInputStream bCPGInputStream) throws IOException {
        this(bCPGInputStream, false);
    }

    public TrustPacket(BCPGInputStream bCPGInputStream, boolean z) throws IOException {
        super(12, z);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        while (true) {
            int i = bCPGInputStream.read();
            if (i < 0) {
                this.levelAndTrustAmount = byteArrayOutputStream.toByteArray();
                return;
            }
            byteArrayOutputStream.write(i);
        }
    }

    @Override // org.bouncycastle.bcpg.ContainedPacket
    public void encode(BCPGOutputStream bCPGOutputStream) throws IOException {
        bCPGOutputStream.writePacket(hasNewPacketFormat(), 12, this.levelAndTrustAmount);
    }

    public byte[] getLevelAndTrustAmount() {
        return this.levelAndTrustAmount;
    }
}
