package org.bouncycastle.bcpg;

/* JADX INFO: loaded from: classes3.dex */
public class Packet implements PacketTags {
    private final boolean newPacketFormat;
    private final int packetTag;

    public Packet() {
        this(0);
    }

    Packet(int i) {
        this(i, false);
    }

    Packet(int i, boolean z) {
        this.packetTag = i;
        this.newPacketFormat = z;
    }

    static int sanitizeLength(int i, int i2, String str) throws MalformedPacketException {
        if (i < 0) {
            throw new MalformedPacketException(str + " cannot be negative.");
        }
        if (i <= i2) {
            return i;
        }
        throw new MalformedPacketException(str + " (" + i + ") exceeds limit (" + i2 + ").");
    }

    public final int getPacketTag() {
        return this.packetTag;
    }

    public boolean hasNewPacketFormat() {
        return this.newPacketFormat;
    }

    public boolean isCritical() {
        return getPacketTag() <= 39;
    }
}
