Inline OpenPGP

Inline OpenPGP — Non-mutating discovery of independent inline-PGP blocks

Functions

Types and Values

Description

Discovery snapshots transfer-decoded bytes without charset conversion, flowed-text processing, cryptography, or key import. A document retains the entire source, including unprotected gaps and malformed candidates. Blocks and opened read-only streams can outlive the document and part.

Snapshots larger than 1 MiB spill to a private temporary file, removed when the last document, block, or stream releases it. This bounds snapshot memory, not disk usage or the per-block metadata. Temporary-file creation and I/O failures are reported, never replaced with truncated results.

Only exact, unquoted armor markers at line starts are recognized. LF, CRLF, and a final marker at EOF are supported. A new beginning interrupts an unfinished block, except for the signature within a clear-signed block. Unexpected end markers terminate a candidate as malformed. Unmatched end markers and unknown armor types remain ordinary source bytes.

Native verification/decryption are declared in gmime-gpgme.h. Protection applies only to each processed payload, not adjacent blocks, unprotected gaps, MIME headers, or the document as a whole.

Functions

g_mime_part_scan_openpgp ()

GMimeOpenPGPDocument *
g_mime_part_scan_openpgp (GMimePart *part,
                          GError **error);

Snapshots all transfer-decoded bytes and discovers independent blocks. Does not modify content or headers, but reading may reposition the backing content stream. No cryptographic operations or key imports are performed. Missing content and I/O failures are errors; no candidates is a successful, empty document whose source remains accessible.

Parameters

part

the part to inspect

 

error

return location for an error

 

Returns

a decoded document, or NULL on error.

[transfer full][nullable]


g_mime_openpgp_document_get_length ()

gint64
g_mime_openpgp_document_get_length (GMimeOpenPGPDocument *document);

Parameters

document

a decoded snapshot

 

Returns

the complete decoded source length in bytes.


g_mime_openpgp_document_get_count ()

guint
g_mime_openpgp_document_get_count (GMimeOpenPGPDocument *document);

Parameters

document

a decoded snapshot

 

Returns

the number of candidate blocks, including incomplete ones.


g_mime_openpgp_document_get_block ()

GMimeOpenPGPBlock *
g_mime_openpgp_document_get_block (GMimeOpenPGPDocument *document,
                                   guint index);

Parameters

document

a decoded snapshot

 

index

a zero-based block index

 

Returns

the block, or NULL if out of range. Reference it to retain it independently of document .

[transfer none][nullable]


g_mime_openpgp_document_open_stream ()

GMimeStream *
g_mime_openpgp_document_open_stream (GMimeOpenPGPDocument *document);

Opens an independently positioned, read-only view of the entire source. Use substreams to read unprotected gaps. The stream retains its storage; read failures are reported through errno, as for other GMime streams.

Parameters

document

a decoded snapshot

 

Returns

a stream positioned at zero.

[transfer full]


g_mime_openpgp_block_get_kind ()

GMimeOpenPGPBlockKind
g_mime_openpgp_block_get_kind (GMimeOpenPGPBlock *block);

Parameters

block

a candidate block

 

Returns

the observed armor kind.


g_mime_openpgp_block_get_status ()

GMimeOpenPGPBlockStatus
g_mime_openpgp_block_get_status (GMimeOpenPGPBlock *block);

Parameters

block

a candidate block

 

Returns

its structural discovery status, not cryptographic validity.


g_mime_openpgp_block_get_offset ()

gint64
g_mime_openpgp_block_get_offset (GMimeOpenPGPBlock *block);

Parameters

block

a candidate block

 

Returns

the byte offset in the complete transfer-decoded snapshot.


g_mime_openpgp_block_get_length ()

gint64
g_mime_openpgp_block_get_length (GMimeOpenPGPBlock *block);

Parameters

block

a candidate block

 

Returns

the byte length, including the end marker's newline, if present.


g_mime_openpgp_block_open_stream ()

GMimeStream *
g_mime_openpgp_block_open_stream (GMimeOpenPGPBlock *block);

Opens an independent read-only view, including original malformed bytes. Coordinates start at zero for this block, not at its document offset. Substreams use absolute coordinates within this view, as usual for GMime. The stream retains its storage independently of block .

Parameters

block

a candidate block

 

Returns

a stream positioned at zero.

[transfer full]

Types and Values

GMimeOpenPGPDocument

typedef struct _GMimeOpenPGPDocument GMimeOpenPGPDocument;

An immutable decoded snapshot, including unprotected gaps. Implements GListModel with GMimeOpenPGPBlock items in source order.


GMimeOpenPGPBlock

typedef struct _GMimeOpenPGPBlock GMimeOpenPGPBlock;

An immutable candidate block in a transfer-decoded snapshot.


enum GMimeOpenPGPBlockKind

The observed armor type, not a cryptographic assertion.

Members

GMIME_OPENPGP_BLOCK_MESSAGE

PGP MESSAGE armor, not necessarily encrypted.

 

GMIME_OPENPGP_BLOCK_SIGNED_MESSAGE

Clear-signed content and its signature.

 

GMIME_OPENPGP_BLOCK_PUBLIC_KEY

Public-key armor.

 

GMIME_OPENPGP_BLOCK_PRIVATE_KEY

Private-key armor.

 

GMIME_OPENPGP_BLOCK_SIGNATURE

Standalone signature armor.

 

enum GMimeOpenPGPBlockStatus

Structural discovery status. COMPLETE does not validate armor, packets, signatures, or trust.

Members

GMIME_OPENPGP_BLOCK_COMPLETE

Matching markers were found.

 

GMIME_OPENPGP_BLOCK_TRUNCATED

EOF before the expected marker.

 

GMIME_OPENPGP_BLOCK_INTERRUPTED

Another block began before completion.

 

GMIME_OPENPGP_BLOCK_MALFORMED

An unexpected end marker was found.