Sign in

    justinwongcn/moonpgp/packet does not have a README file

    AeadPacket

    pub(all) struct AeadPacket {
    version : Int
    cipher_algo : Int
    aead_algo : Int
    chunk_octet : Int
    iv : Bytes
    ciphertext : Bytes
    } derive(
    Debug
    )

    AEAD Encrypted Data Packet (tag 20) body, version 1 (draft-ietf-openpgp-rfc4880bis §5.16) — the shape GnuPG 2.4 produces under --force-aead. RFC 9580 reserves tag 20 in favour of SEIPD v2; this packet exists here for GnuPG interop and legacy data.

    AeadPacket::aead_algo

    fn AeadPacket::aead_algo(self : AeadPacket) -> Int

    AeadPacket::chunk_octet

    fn AeadPacket::chunk_octet(self : AeadPacket) -> Int

    AeadPacket::cipher_algo

    fn AeadPacket::cipher_algo(self : AeadPacket) -> Int

    AeadPacket::ciphertext

    fn AeadPacket::ciphertext(self : AeadPacket) -> Bytes

    AeadPacket::iv

    fn AeadPacket::iv(self : AeadPacket) -> Bytes

    AeadPacket::parse

    fn AeadPacket::parse(body : BytesView) -> AeadPacket raise

    AeadPacket::to_body

    fn AeadPacket::to_body(self : AeadPacket) -> Bytes raise

    AeadPacket::version

    fn AeadPacket::version(self : AeadPacket) -> Int

    CompressedPacket

    pub struct CompressedPacket {
    algo : Int
    data : Bytes
    } derive(
    Debug
    )

    Compressed data packet body (RFC 9580 §5.6): algorithm octet + data.

    CompressedPacket::parse

    fn CompressedPacket::parse(body : BytesView) -> CompressedPacket raise

    CompressedPacket::to_body

    fn CompressedPacket::to_body(self : CompressedPacket) -> Bytes

    LiteralPacket

    pub struct LiteralPacket {
    format : Char
    file_name : String
    date : Int
    data : Bytes
    } derive(
    Debug
    )

    Literal data packet body (RFC 9580 §5.9).

    LiteralPacket::binary

    fn LiteralPacket::binary(data : BytesView, file_name? : String) -> LiteralPacket

    Build a literal packet around raw data (text uses format 'b' to avoid any newline conversion unless the caller explicitly wants 'u').

    LiteralPacket::data

    fn LiteralPacket::data(self : LiteralPacket) -> Bytes

    LiteralPacket::date

    fn LiteralPacket::date(self : LiteralPacket) -> Int

    LiteralPacket::file_name

    fn LiteralPacket::file_name(self : LiteralPacket) -> String

    LiteralPacket::format

    fn LiteralPacket::format(self : LiteralPacket) -> Char

    LiteralPacket::parse

    fn LiteralPacket::parse(body : BytesView) -> LiteralPacket raise

    LiteralPacket::to_body

    fn LiteralPacket::to_body(self : LiteralPacket) -> Bytes raise

    OnePassSigPacket

    pub(all) struct OnePassSigPacket {
    version : Int
    sig_type : SigType
    hash_algo : Int
    pub_algo : PubKeyAlgo
    key_id : Bytes
    salt : Bytes
    fingerprint : Bytes
    nested : Bool
    } derive(
    Debug
    )

    A one-pass signature packet body: version 3 (RFC 9580 §5.4, what a v4 key emits) and version 6 (the same fields plus a hash salt and the 32-octet signing-key fingerprint, and with the 8-octet key id gone).

    OnePassSigPacket::fingerprint

    fn OnePassSigPacket::fingerprint(self : OnePassSigPacket) -> Bytes

    OnePassSigPacket::key_id

    fn OnePassSigPacket::key_id(self : OnePassSigPacket) -> Bytes

    OnePassSigPacket::parse

    fn OnePassSigPacket::parse(body : BytesView) -> OnePassSigPacket raise

    OnePassSigPacket::salt

    fn OnePassSigPacket::salt(self : OnePassSigPacket) -> Bytes

    OnePassSigPacket::to_body

    fn OnePassSigPacket::to_body(self : OnePassSigPacket) -> Bytes

    OnePassSigPacket::version

    fn OnePassSigPacket::version(self : OnePassSigPacket) -> Int

    PacketTag

    pub(all) enum PacketTag {
    Pkesk
    Skesk
    Signature
    OnePassSig
    SecretKey
    PublicKey
    SecretSubkey
    Compressed
    Sed
    Marker
    Literal
    Trust
    UserId
    PublicSubkey
    UserAttribute
    Seipd
    Mdc
    AeadEncData
    Unknown(Int)
    } derive(Eq,
    Debug
    )

    OpenPGP packet type IDs (RFC 9580 §5).

    PacketTag::equal

    fn PacketTag::equal(PacketTag, PacketTag) -> Bool

    PacketTag::not_equal

    fn PacketTag::not_equal(x : PacketTag, y : PacketTag) -> Bool

    PacketTag::number

    fn PacketTag::number(self : PacketTag) -> Int

    PkeskPacket

    pub(all) struct PkeskPacket {
    version : Int
    key_id : Bytes
    key_version : Int
    fingerprint : Bytes
    pub_algo : PubKeyAlgo
    encrypted : Bytes
    ecdh_ephemeral : Bytes
    } derive(
    Debug
    )

    PKESK packet body, versions 3 (RFC 9580 §5.1.1) and 6 (§5.1.2).

    PkeskPacket::ecdh_ephemeral

    fn PkeskPacket::ecdh_ephemeral(self : PkeskPacket) -> Bytes

    PkeskPacket::encrypted

    fn PkeskPacket::encrypted(self : PkeskPacket) -> Bytes

    PkeskPacket::fingerprint

    fn PkeskPacket::fingerprint(self : PkeskPacket) -> Bytes

    PkeskPacket::key_id

    fn PkeskPacket::key_id(self : PkeskPacket) -> Bytes

    PkeskPacket::key_version

    fn PkeskPacket::key_version(self : PkeskPacket) -> Int

    PkeskPacket::parse

    fn PkeskPacket::parse(body : BytesView) -> PkeskPacket raise

    PkeskPacket::pub_algo

    fn PkeskPacket::pub_algo(self : PkeskPacket) -> PubKeyAlgo

    PkeskPacket::to_body

    fn PkeskPacket::to_body(self : PkeskPacket) -> Bytes

    PkeskPacket::version

    fn PkeskPacket::version(self : PkeskPacket) -> Int

    PubKeyAlgo

    pub(all) enum PubKeyAlgo {
    RsaEncryptOrSign
    RsaEncryptOnly
    RsaSignOnly
    Dsa
    Ecdh
    Ecdsa
    EdDsaLegacy
    X25519
    Ed25519
    Unknown(Int)
    } derive(Eq,
    Debug
    )

    Public key algorithm IDs (RFC 9580 §9.2).

    PubKeyAlgo::equal

    fn PubKeyAlgo::equal(PubKeyAlgo, PubKeyAlgo) -> Bool

    PubKeyAlgo::is_rsa

    fn PubKeyAlgo::is_rsa(self : PubKeyAlgo) -> Bool

    PubKeyAlgo::not_equal

    fn PubKeyAlgo::not_equal(x : PubKeyAlgo, y : PubKeyAlgo) -> Bool

    PubKeyAlgo::number

    fn PubKeyAlgo::number(self : PubKeyAlgo) -> Int

    PublicKeyPacket

    pub(all) struct PublicKeyPacket {
    version : Int
    creation_time : Int
    algo : PubKeyAlgo
    params : Array[Bytes]
    } derive(
    Debug
    )

    A version 4 (or 5) public key packet body (RFC 9580 §5.5.2).

    PublicKeyPacket::algo

    PublicKeyPacket::creation_time

    fn PublicKeyPacket::creation_time(self : PublicKeyPacket) -> Int

    PublicKeyPacket::fingerprint

    fn PublicKeyPacket::fingerprint(self : PublicKeyPacket) -> Bytes raise

    Fingerprint: v4 = SHA-1 over 0x99, 2-octet length, key body (20 octets); v6 = SHA-256 over 0x9B, 4-octet length, key body (32 octets) (RFC 9580 §5.5.4.3).

    PublicKeyPacket::key_id

    fn PublicKeyPacket::key_id(self : PublicKeyPacket) -> Bytes raise

    The 8-octet (64-bit) key id derived from the fingerprint: the low 64 bits for v4, the HIGH 64 bits for v6 (RFC 9580 §5.5.4.3).

    PublicKeyPacket::params

    fn PublicKeyPacket::params(self : PublicKeyPacket) -> Array[Bytes]

    PublicKeyPacket::parse

    fn PublicKeyPacket::parse(body : BytesView) -> PublicKeyPacket raise

    PublicKeyPacket::to_body

    fn PublicKeyPacket::to_body(self : PublicKeyPacket) -> Bytes

    PublicKeyPacket::version

    fn PublicKeyPacket::version(self : PublicKeyPacket) -> Int

    RawPacket

    pub(all) struct RawPacket {
    tag : PacketTag
    body : Bytes
    } derive(
    Debug
    )

    One parsed packet: type plus the raw packet body (header stripped). Higher-level parsers decode bodies into typed structures.

    RawPacket::body

    fn RawPacket::body(self : RawPacket) -> Bytes

    RawPacket::tag

    fn RawPacket::tag(self : RawPacket) -> PacketTag

    Reader

    pub struct Reader {
    // private fields
    } derive(
    Debug
    )

    Big-endian byte reader over a BytesView, used by every packet parser.

    Reader::new

    fn Reader::new(buf : BytesView) -> Reader

    Reader::position

    fn Reader::position(self : Reader) -> Int

    Reader::read_bytes

    fn Reader::read_bytes(self : Reader, n : Int) -> Bytes raise

    Reader::read_mpi

    fn Reader::read_mpi(self : Reader) -> Bytes raise

    Read an OpenPGP multiprecision integer (RFC 9580 §3.2).

    Reader::read_rest

    fn Reader::read_rest(self : Reader) -> Bytes raise

    Reader::read_u16

    fn Reader::read_u16(self : Reader) -> Int raise

    Reader::read_u32

    fn Reader::read_u32(self : Reader) -> Int raise

    Read a big-endian u32 into a 32-bit Int (F09, documented convention): values ≥ 2³¹ arrive NEGATIVE. Length paths fail safe through the n >= 0 check in read_bytes, which reports the negative value as an invalid length; timestamp paths carry the correct two's-complement wire value, which Writer::u32 reproduces byte-exactly on re-serialization.

    Reader::read_u8

    fn Reader::read_u8(self : Reader) -> Int raise

    Reader::remaining

    fn Reader::remaining(self : Reader) -> Int

    Reader::to_repr

    Reader::view

    fn Reader::view(self : Reader) -> BytesView

    SecretKeyPacket

    pub(all) struct SecretKeyPacket {
    public : PublicKeyPacket
    s2k_usage : Int
    cipher_algo : Int
    aead_algo : Int
    s2k_spec : Bytes
    iv : Bytes
    secret_material : Bytes
    dummy : Bool
    } derive(
    Debug
    )

    A version 4 or 6 secret key packet: public part plus secret material. The secret material is kept in wire form; unlocking/locking happens at the key-management layer.

    SecretKeyPacket::parse

    fn SecretKeyPacket::parse(body : BytesView) -> SecretKeyPacket raise

    SecretKeyPacket::to_body

    fn SecretKeyPacket::to_body(self : SecretKeyPacket) -> Bytes

    Serialize: public body followed by the secret-material wire bytes.

    The caller is responsible for the RFC 9580 §5.5.3 generation rules that parse enforces (no usage 255 on a v6 packet, and a v6 S2K parameter block that fits its 1-octet count); api.lock_secret_key is the only producer of protected packets and validates them there.

    SeipdPacket

    pub(all) struct SeipdPacket {
    version : Int
    cipher_algo : Int
    aead_algo : Int
    chunk_octet : Int
    salt : Bytes
    ciphertext : Bytes
    } derive(
    Debug
    )

    SEIPD packet body: version 1 (RFC 9580 §5.13.1, the MDC-protected CFB shape) and version 2 (§5.13.2, the chunked AEAD shape).

    SeipdPacket::aead_algo

    fn SeipdPacket::aead_algo(self : SeipdPacket) -> Int

    SeipdPacket::chunk_octet

    fn SeipdPacket::chunk_octet(self : SeipdPacket) -> Int

    SeipdPacket::cipher_algo

    fn SeipdPacket::cipher_algo(self : SeipdPacket) -> Int

    SeipdPacket::parse

    fn SeipdPacket::parse(body : BytesView) -> SeipdPacket raise

    SeipdPacket::salt

    fn SeipdPacket::salt(self : SeipdPacket) -> Bytes

    SeipdPacket::to_body

    fn SeipdPacket::to_body(self : SeipdPacket) -> Bytes

    SeipdPacket::v1

    fn SeipdPacket::v1(ciphertext : BytesView) -> SeipdPacket

    A v1 SEIPD packet literal.

    SigSubpacket

    pub(all) struct SigSubpacket {
    critical : Bool
    sub_type : Int
    body : Bytes
    } derive(Eq,
    Debug
    )

    A raw signature subpacket: critical bit, type id, body.

    SigSubpacket::body

    fn SigSubpacket::body(self : SigSubpacket) -> Bytes

    SigSubpacket::critical

    fn SigSubpacket::critical(self : SigSubpacket) -> Bool

    SigSubpacket::equal

    SigSubpacket::not_equal

    fn SigSubpacket::not_equal(x : SigSubpacket, y : SigSubpacket) -> Bool

    SigSubpacket::sub_type

    fn SigSubpacket::sub_type(self : SigSubpacket) -> Int

    SigType

    pub(all) enum SigType {
    BinaryDocument
    CanonicalTextDocument
    Standalone
    GenericCertification
    PersonaCertification
    CasualCertification
    PositiveCertification
    SubkeyBinding
    PrimaryKeyBinding
    DirectSignature
    KeyRevocation
    SubkeyRevocation
    CertificationRevocation
    Timestamp
    ThirdPartyConfirmation
    Unknown(Int)
    } derive(Eq,
    Debug
    )

    Signature types (RFC 9580 §5.2.1).

    SigType::equal

    fn SigType::equal(SigType, SigType) -> Bool

    SigType::not_equal

    fn SigType::not_equal(x : SigType, y : SigType) -> Bool

    SigType::number

    fn SigType::number(self : SigType) -> Int

    SigType::to_repr

    SignaturePacket

    pub(all) struct SignaturePacket {
    version : Int
    sig_type : SigType
    pub_algo : PubKeyAlgo
    hash_algo : Int
    hashed_subpackets : Array[SigSubpacket]
    unhashed_subpackets : Array[SigSubpacket]
    raw_hashed_area : Bytes
    fast_hash : Int
    salt : Bytes
    sig_params : Array[Bytes]
    } derive(
    Debug
    )

    A version 4 or version 6 signature packet body (RFC 9580 §5.2.3). Version 6 differs in the subpacket-area length widths (4 octets), the trailing salt, the trailer's version octet, and raw (non-MPI) Ed25519 signature material.

    SignaturePacket::creation_time

    fn SignaturePacket::creation_time(self : SignaturePacket) -> Int?

    Signature creation time from the hashed subpackets (seconds since epoch).

    SignaturePacket::fast_hash

    fn SignaturePacket::fast_hash(self : SignaturePacket) -> Int

    SignaturePacket::features

    fn SignaturePacket::features(self : SignaturePacket) -> Bytes?

    The Features flags octet (RFC 9580 §5.2.3.32), when present.

    SignaturePacket::has_unknown_critical_subpacket

    fn SignaturePacket::has_unknown_critical_subpacket(self : SignaturePacket) -> Bool

    True when any hashed or unhashed subpacket is marked critical but not in the recognized set — the signature MUST be treated as in error.

    SignaturePacket::hash_algo

    fn SignaturePacket::hash_algo(self : SignaturePacket) -> Int

    SignaturePacket::hash_prefix

    fn SignaturePacket::hash_prefix(self : SignaturePacket) -> Bytes

    The hash prefix: version | type | pubalgo | hashalgo | hashed_len | hashed area (raw wire bytes when available). Version 6 uses a 4-octet subpacket-area length (RFC 9580 §5.2.3).

    SignaturePacket::hashed_subpackets

    fn SignaturePacket::hashed_subpackets(self : SignaturePacket) -> Array[SigSubpacket]

    SignaturePacket::issuer_key_id

    fn SignaturePacket::issuer_key_id(self : SignaturePacket) -> Bytes?

    Issuer key id, preferring the type 16 (Issuer Key ID) subpacket; falls back to the issuer-fingerprint subpacket's trailing key id.

    SignaturePacket::key_expiration_time

    fn SignaturePacket::key_expiration_time(self : SignaturePacket) -> Int

    The Key Expiration Time subpacket (RFC 9580 §5.2.3.6): seconds after the associated key's creation time; 0 = the key never expires.

    SignaturePacket::key_flags

    fn SignaturePacket::key_flags(self : SignaturePacket) -> Bytes?

    Key flags octets from the hashed subpackets.

    SignaturePacket::parse

    fn SignaturePacket::parse(body : BytesView) -> SignaturePacket raise

    SignaturePacket::preferred_aead

    fn SignaturePacket::preferred_aead(self : SignaturePacket) -> Array[(Int, Int)]?

    The Preferred AEAD Ciphersuites list as (cipher, AEAD) pairs, most preferred first (RFC 9580 §5.2.3.15). A trailing odd octet is ignored.

    SignaturePacket::pub_algo

    SignaturePacket::salt

    fn SignaturePacket::salt(self : SignaturePacket) -> Bytes

    SignaturePacket::sig_expiration_time

    fn SignaturePacket::sig_expiration_time(self : SignaturePacket) -> Int

    The Signature Expiration Time subpacket (RFC 9580 §5.2.3.10): seconds after the signature's creation time; 0 = the signature never expires.

    SignaturePacket::sig_params

    fn SignaturePacket::sig_params(self : SignaturePacket) -> Array[Bytes]

    SignaturePacket::sig_type

    fn SignaturePacket::sig_type(self : SignaturePacket) -> SigType

    SignaturePacket::supports_seipd_v2

    fn SignaturePacket::supports_seipd_v2(self : SignaturePacket) -> Bool

    True when the Features subpacket advertises the v2 SEIPD flag (RFC 9580 §5.2.3.32/§13.7).

    SignaturePacket::to_body

    fn SignaturePacket::to_body(self : SignaturePacket) -> Bytes

    SignaturePacket::unhashed_subpackets

    fn SignaturePacket::unhashed_subpackets(self : SignaturePacket) -> Array[SigSubpacket]

    SignaturePacket::version

    fn SignaturePacket::version(self : SignaturePacket) -> Int

    SkeskPacket

    pub(all) struct SkeskPacket {
    version : Int
    cipher_algo : Int
    aead_algo : Int
    s2k :
    S2k

    iv : Bytes
    encrypted_session_key : Bytes
    } derive(
    Debug
    )

    SKESK packet body, versions 4 (RFC 9580 §5.3.1), 5 (the 4880bis / crypto-refresh AEAD-wrapped session key GnuPG 2.4 emits under --force-aead) and 6 (§5.3.2). Version 5 adds the AEAD algorithm and a nonce and seals the session key with the S2K-derived key directly; version 6 adds the two count octets and the HKDF-SHA256 key separation (info/AD = tag | version | cipher | aead).

    SkeskPacket::aead_algo

    fn SkeskPacket::aead_algo(self : SkeskPacket) -> Int

    SkeskPacket::cipher_algo

    fn SkeskPacket::cipher_algo(self : SkeskPacket) -> Int

    SkeskPacket::encrypted_session_key

    fn SkeskPacket::encrypted_session_key(self : SkeskPacket) -> Bytes

    SkeskPacket::iv

    fn SkeskPacket::iv(self : SkeskPacket) -> Bytes

    SkeskPacket::parse

    fn SkeskPacket::parse(body : BytesView) -> SkeskPacket raise

    SkeskPacket::to_body

    fn SkeskPacket::to_body(self : SkeskPacket) -> Bytes raise

    SkeskPacket::version

    fn SkeskPacket::version(self : SkeskPacket) -> Int

    Writer

    pub struct Writer {
    // private fields
    } derive(
    Debug
    )

    Big-endian byte writer for packet serialization. The backing buffer is core's Buffer so bytes() can bulk-write views instead of pushing byte by byte (F12).

    Writer::bytes

    fn Writer::bytes(self : Writer, data : BytesView) -> Unit

    Writer::length

    fn Writer::length(self : Writer) -> Int

    Writer::mpi

    fn Writer::mpi(self : Writer, data : BytesView) -> Unit

    Writer::new

    fn Writer::new() -> Writer

    Writer::to_bytes

    fn Writer::to_bytes(self : Writer) -> Bytes

    Writer::to_repr

    Writer::u16

    fn Writer::u16(self : Writer, v : Int) -> Unit

    Writer::u32

    fn Writer::u32(self : Writer, v : Int) -> Unit

    Writer::u8

    fn Writer::u8(self : Writer, v : Int) -> Unit

    FEATURE_SEIPD_V1

    let FEATURE_SEIPD_V1 : Int

    The Features flags octet (RFC 9580 §5.2.3.32): 0x01 = v1 SEIPD, 0x08 = v2 SEIPD.

    FEATURE_SEIPD_V2

    let FEATURE_SEIPD_V2 : Int

    MAX_MPI_BITS

    let MAX_MPI_BITS : Int

    Defensive ceiling on an MPI's bit length (S16). RFC 9580 §3.2 imposes no per-algorithm maximum on parsers (its only MUST — the length consistency check — applies to v6 packets), so this is hardening beyond the RFC: no defined OpenPGP algorithm carries MPIs wider than 16384 bits, and capping here rejects malformed packets at the parse layer instead of letting oversized MPIs flow into semantic code.

    SIGSUB_CREATION_TIME

    let SIGSUB_CREATION_TIME : Int

    Signature subpacket type IDs (subset, RFC 9580 §5.2.3.1).

    SIGSUB_EMBEDDED_SIGNATURE

    let SIGSUB_EMBEDDED_SIGNATURE : Int

    SIGSUB_EXPORTABLE_CERTIFICATION

    let SIGSUB_EXPORTABLE_CERTIFICATION : Int

    SIGSUB_FEATURES

    let SIGSUB_FEATURES : Int

    SIGSUB_ISSUER_FINGERPRINT

    let SIGSUB_ISSUER_FINGERPRINT : Int

    SIGSUB_ISSUER_KEY_ID

    let SIGSUB_ISSUER_KEY_ID : Int

    SIGSUB_KEY_EXPIRATION_TIME

    let SIGSUB_KEY_EXPIRATION_TIME : Int

    SIGSUB_KEY_FLAGS

    let SIGSUB_KEY_FLAGS : Int

    SIGSUB_KEY_SERVER_PREFERENCES

    let SIGSUB_KEY_SERVER_PREFERENCES : Int

    SIGSUB_NOTATION_DATA

    let SIGSUB_NOTATION_DATA : Int

    SIGSUB_POLICY_URI

    let SIGSUB_POLICY_URI : Int

    SIGSUB_PREFERRED_AEAD

    let SIGSUB_PREFERRED_AEAD : Int

    Preferred AEAD Ciphersuites (RFC 9580 §5.2.3.15). Table 5 of RFC 9580 assigns type 39; type 34 is Reserved, so using it here made the preference invisible to every other implementation (and hid theirs from us) while our own round-trip tests stayed green.

    SIGSUB_PREFERRED_COMP_ALGOS

    let SIGSUB_PREFERRED_COMP_ALGOS : Int

    SIGSUB_PREFERRED_HASH_ALGOS

    let SIGSUB_PREFERRED_HASH_ALGOS : Int

    SIGSUB_PREFERRED_KEY_SERVER

    let SIGSUB_PREFERRED_KEY_SERVER : Int

    SIGSUB_PREFERRED_SYM_ALGOS

    let SIGSUB_PREFERRED_SYM_ALGOS : Int

    SIGSUB_PRIMARY_USER_ID

    let SIGSUB_PRIMARY_USER_ID : Int

    SIGSUB_REGULAR_EXPRESSION

    let SIGSUB_REGULAR_EXPRESSION : Int

    SIGSUB_REVOCABLE

    let SIGSUB_REVOCABLE : Int

    SIGSUB_REVOCATION_REASON

    let SIGSUB_REVOCATION_REASON : Int

    SIGSUB_SIGNATURE_TARGET

    let SIGSUB_SIGNATURE_TARGET : Int

    SIGSUB_SIGNER_USER_ID

    let SIGSUB_SIGNER_USER_ID : Int

    SIGSUB_SIG_EXPIRATION_TIME

    let SIGSUB_SIG_EXPIRATION_TIME : Int

    SIGSUB_TRUST_SIGNATURE

    let SIGSUB_TRUST_SIGNATURE : Int

    find_subpacket

    fn find_subpacket(subs : Array[SigSubpacket], t : Int) -> Bytes?

    First subpacket body of the given type from subs.

    is_known_sigsub_type

    fn is_known_sigsub_type(t : Int) -> Bool

    The signature subpacket types this implementation recognizes: exactly the set with constants defined above. RFC 9580 §5.2.3.6: an evaluator that encounters an unknown subpacket marked critical SHOULD consider the whole signature in error (the bit is honored in both the hashed and the unhashed area), so verifiers consult this set via SignaturePacket::has_unknown_critical_subpacket.

    parse_packets

    fn parse_packets(data : BytesView) -> Array[RawPacket] raise

    Parse a sequence of packet headers+bodies from data. Handles both old and new format headers and accumulates partial body lengths.

    pub_key_algo_of_number

    fn pub_key_algo_of_number(n : Int) -> PubKeyAlgo

    salt_size_of_hash

    fn salt_size_of_hash(hash_id : Int) -> Int raise

    RFC 9580 §9.5 Table 23: the v6 signature salt size for a hash algorithm. Only SHA-2/SHA-3 have v6 salt sizes (MD5/SHA-1/RIPEMD-160 are "N/A").

    serialize_packet

    fn serialize_packet(tag : PacketTag, body : BytesView) -> Bytes

    Serialize one packet with a new-format header.

    serialize_packet_old

    fn serialize_packet_old(tag : PacketTag, body : BytesView) -> Bytes

    Serialize one packet with an old-format header and fixed-length encoding.

    session_key_checksum

    fn session_key_checksum(key : BytesView) -> Int

    Session-key checksum (RFC 9580 §5.1): sum of octets mod 65536.

    sig_type_of_number

    fn sig_type_of_number(n : Int) -> SigType

    signature_trailer

    fn signature_trailer(version : Int, hashed_body_len : Int) -> Bytes

    The final trailer: 0x04|0x06 0xFF and the 4-octet length of everything hashed before it (RFC 9580 §5.2.4).

    tag_of_number

    fn tag_of_number(n : Int) -> PacketTag