All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.bcpg.Packet Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for the OpenPGP Protocol. The APIs are designed primarily to be used in conjunction with the BC LTS provider but may also be used with other providers providing cryptographic services.

The newest version!
package org.bouncycastle.bcpg;

/**
 */
public class Packet
    implements PacketTags
{
    private final int packetTag;
    private final boolean newPacketFormat;

    // for API compatibility
    public Packet()
    {
        this(RESERVED);
    }

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

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

    /**
     * Return the tag of the packet.
     *
     * @return packet tag
     */
    public final int getPacketTag()
    {
         return packetTag;
    }

    /**
     * Return true, if this instance of a packet was encoded using the new packet format.
     * If the packet was encoded using the old legacy format, return false instead.
     *
     * @return true if new packet format encoding is used
     */
    public boolean hasNewPacketFormat()
    {
        return newPacketFormat;
    }

    /**
     * Returns whether the packet is to be considered critical for v6 implementations.
     * Packets with tags less or equal to 39 are critical.
     * Tags 40 to 59 are reserved for unassigned, non-critical packets.
     * Tags 60 to 63 are non-critical private or experimental packets.
     *
     * @see 
     *     OpenPGP - Packet Tags
     * @return true if the packet is critical, false otherwise.
     */
    public boolean isCritical()
    {
        return getPacketTag() <= 39;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy