Horde_Crypt_Pgp_Parse
in package
Provides methods to parse PGP armored text data.
Tags
Table of Contents
- ARMOR_MESSAGE = 1
- Armor Header Lines - From RFC 2440:
- ARMOR_PRIVATE_KEY = 4
- ARMOR_PUBLIC_KEY = 3
- ARMOR_SIGNATURE = 5
- ARMOR_SIGNED_MESSAGE = 2
- ARMOR_TEXT = 6
- PGP_ARMOR = 'pgp_armor'
- Metadata names for data.
- SIG_CHARSET = 'pgp_sig_charset'
- SIG_RAW = 'pgp_sig_raw'
- $_armor : array<string|int, mixed>
- Strings in armor header lines used to distinguish between the different types of PGP decryption/encryption.
- parse() : array<string|int, mixed>
- Parses a message into text and PGP components.
- parseToPart() : mixed
- Parses an armored message into a Horde_Mime_Part object.
Constants
ARMOR_MESSAGE
Armor Header Lines - From RFC 2440:
public
mixed
ARMOR_MESSAGE
= 1
An Armor Header Line consists of the appropriate header line text surrounded by five (5) dashes ('-', 0x2D) on either side of the header line text. The header line text is chosen based upon the type of data that is being encoded in Armor, and how it is being encoded.
All Armor Header Lines are prefixed with 'PGP'.
The Armor Tail Line is composed in the same manner as the Armor Header Line, except the string "BEGIN" is replaced by the string "END."
ARMOR_PRIVATE_KEY
public
mixed
ARMOR_PRIVATE_KEY
= 4
ARMOR_PUBLIC_KEY
public
mixed
ARMOR_PUBLIC_KEY
= 3
ARMOR_SIGNATURE
public
mixed
ARMOR_SIGNATURE
= 5
ARMOR_SIGNED_MESSAGE
public
mixed
ARMOR_SIGNED_MESSAGE
= 2
ARMOR_TEXT
public
mixed
ARMOR_TEXT
= 6
PGP_ARMOR
Metadata names for data.
public
mixed
PGP_ARMOR
= 'pgp_armor'
SIG_CHARSET
public
mixed
SIG_CHARSET
= 'pgp_sig_charset'
SIG_RAW
public
mixed
SIG_RAW
= 'pgp_sig_raw'
Properties
$_armor
Strings in armor header lines used to distinguish between the different types of PGP decryption/encryption.
protected
array<string|int, mixed>
$_armor
= array('MESSAGE' => self::ARMOR_MESSAGE, 'SIGNED MESSAGE' => self::ARMOR_SIGNED_MESSAGE, 'PUBLIC KEY BLOCK' => self::ARMOR_PUBLIC_KEY, 'PRIVATE KEY BLOCK' => self::ARMOR_PRIVATE_KEY, 'SIGNATURE' => self::ARMOR_SIGNATURE)
Methods
parse()
Parses a message into text and PGP components.
public
parse(mixed $text) : array<string|int, mixed>
Parameters
- $text : mixed
-
Either the text to parse or a Horde_Stream object.
Return values
array<string|int, mixed> —An array with the parsed text, returned in blocks of text corresponding to their actual order. Keys:
- data: (array) The data for each section. Each line has been stripped of EOL characters. - type: (integer) The type of data contained in block. Valid types are the class ARMOR_* constants.
parseToPart()
Parses an armored message into a Horde_Mime_Part object.
public
parseToPart(mixed $text[, mixed $charset = 'UTF-8' ]) : mixed
Parameters
- $text : mixed
-
Either the text to parse or a Horde_Stream object.
- $charset : mixed = 'UTF-8'
Return values
mixed —Either null if no PGP data was found, or a Horde_Mime_Part object. For detached signature data: the full contents of the armored text (data + sig) is contained in the SIG_RAW metadata, and the charset is contained in the SIG_CHARSET metadata, within the application/pgp-signature part.