rpm  4.12.0.1
Data Structures | Macros | Typedefs | Enumerations | Functions
rpmpgp.h File Reference

OpenPGP constants and structures from RFC-2440. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <rpm/rpmtypes.h>
#include <rpm/rpmstring.h>
Include dependency graph for rpmpgp.h:

Go to the source code of this file.

Data Structures

struct  pgpPktPubkey_s
 5.1. More...
 
struct  pgpPktSigV3_s
 5.2.2. More...
 
struct  pgpPktSigV4_s
 5.2.3. More...
 
union  pgpPktSig_u
 5.2. More...
 
struct  pgpPktSymkey_s
 5.3. More...
 
struct  pgpPktOnepass_s
 5.4. More...
 
struct  pgpPktKeyV3_s
 5.5.1. More...
 
struct  pgpPktKeyV4_s
 The version 4 format is similar to the version 3 format except for the absence of a validity period. More...
 
union  pgpPktKey_u
 5.5.3. More...
 
struct  pgpPktCdata_s
 
struct  pgpPktEdata_s
 
struct  pgpPktLdata_s
 
struct  pgpPktTrust_s
 
struct  pgpPktUid_s
 
union  pgpPktPre_u
 

Macros

#define PGPARMOR_ERROR   PGPARMOR_ERR_NO_BEGIN_PGP
 

Typedefs

typedef struct DIGEST_CTX_s * DIGEST_CTX
 
typedef struct rpmDigestBundle_s * rpmDigestBundle
 
typedef struct pgpDig_s * pgpDig
 
typedef struct pgpDigParams_s * pgpDigParams
 
typedef uint8_t pgpKeyID_t [8]
 
typedef uint8_t pgpTime_t [4]
 
typedef enum pgpTag_e pgpTag
 4.3. More...
 
typedef struct pgpPktPubkey_s pgpPktPubkey
 5.1. More...
 
typedef enum pgpSigType_e pgpSigType
 5.2.1. More...
 
typedef enum pgpPubkeyAlgo_e pgpPubkeyAlgo
 9.1. More...
 
typedef enum pgpSymkeyAlgo_e pgpSymkeyAlgo
 9.2. More...
 
typedef enum pgpCompressAlgo_e pgpCompressAlgo
 9.3. More...
 
typedef enum pgpHashAlgo_e pgpHashAlgo
 9.4. More...
 
typedef struct pgpPktSigV3_spgpPktSigV3
 5.2.2. More...
 
typedef struct pgpPktSigV4_spgpPktSigV4
 5.2.3. More...
 
typedef enum pgpSubType_e pgpSubType
 5.2.3.1. More...
 
typedef union pgpPktSig_upgpPktSig
 5.2. More...
 
typedef struct pgpPktSymkey_s pgpPktSymkey
 5.3. More...
 
typedef struct pgpPktOnepass_spgpPktOnepass
 5.4. More...
 
typedef struct pgpPktKeyV3_spgpPktKeyV3
 5.5.1. More...
 
typedef struct pgpPktKeyV4_spgpPktKeyV4
 The version 4 format is similar to the version 3 format except for the absence of a validity period. More...
 
typedef union pgpPktKey_u pgpPktKey
 5.5.3. More...
 
typedef struct pgpPktCdata_s pgpPktCdata
 
typedef struct pgpPktEdata_s pgpPktEdata
 
typedef struct pgpPktLdata_s pgpPktLdata
 
typedef struct pgpPktTrust_s pgpPktTrust
 
typedef struct pgpPktUid_s pgpPktUid
 
typedef enum pgpArmor_e pgpArmor
 
typedef enum pgpArmorKey_e pgpArmorKey
 
typedef enum pgpValType_e pgpValType
 
typedef rpmFlags rpmDigestFlags
 

Enumerations

enum  pgpTag_e {
  PGPTAG_RESERVED = 0, PGPTAG_PUBLIC_SESSION_KEY = 1, PGPTAG_SIGNATURE = 2, PGPTAG_SYMMETRIC_SESSION_KEY = 3,
  PGPTAG_ONEPASS_SIGNATURE = 4, PGPTAG_SECRET_KEY = 5, PGPTAG_PUBLIC_KEY = 6, PGPTAG_SECRET_SUBKEY = 7,
  PGPTAG_COMPRESSED_DATA = 8, PGPTAG_SYMMETRIC_DATA = 9, PGPTAG_MARKER = 10, PGPTAG_LITERAL_DATA = 11,
  PGPTAG_TRUST = 12, PGPTAG_USER_ID = 13, PGPTAG_PUBLIC_SUBKEY = 14, PGPTAG_COMMENT_OLD = 16,
  PGPTAG_PHOTOID = 17, PGPTAG_ENCRYPTED_MDC = 18, PGPTAG_MDC = 19, PGPTAG_PRIVATE_60 = 60,
  PGPTAG_COMMENT = 61, PGPTAG_PRIVATE_62 = 62, PGPTAG_CONTROL = 63
}
 4.3. More...
 
enum  pgpSigType_e {
  PGPSIGTYPE_BINARY = 0x00, PGPSIGTYPE_TEXT = 0x01, PGPSIGTYPE_STANDALONE = 0x02, PGPSIGTYPE_GENERIC_CERT = 0x10,
  PGPSIGTYPE_PERSONA_CERT = 0x11, PGPSIGTYPE_CASUAL_CERT = 0x12, PGPSIGTYPE_POSITIVE_CERT = 0x13, PGPSIGTYPE_SUBKEY_BINDING = 0x18,
  PGPSIGTYPE_SIGNED_KEY = 0x1F, PGPSIGTYPE_KEY_REVOKE = 0x20, PGPSIGTYPE_SUBKEY_REVOKE = 0x28, PGPSIGTYPE_CERT_REVOKE = 0x30,
  PGPSIGTYPE_TIMESTAMP = 0x40
}
 5.2.1. More...
 
enum  pgpPubkeyAlgo_e {
  PGPPUBKEYALGO_RSA = 1, PGPPUBKEYALGO_RSA_ENCRYPT = 2, PGPPUBKEYALGO_RSA_SIGN = 3, PGPPUBKEYALGO_ELGAMAL_ENCRYPT = 16,
  PGPPUBKEYALGO_DSA = 17, PGPPUBKEYALGO_EC = 18, PGPPUBKEYALGO_ECDSA = 19, PGPPUBKEYALGO_ELGAMAL = 20,
  PGPPUBKEYALGO_DH = 21
}
 9.1. More...
 
enum  pgpSymkeyAlgo_e {
  PGPSYMKEYALGO_PLAINTEXT = 0, PGPSYMKEYALGO_IDEA = 1, PGPSYMKEYALGO_TRIPLE_DES = 2, PGPSYMKEYALGO_CAST5 = 3,
  PGPSYMKEYALGO_BLOWFISH = 4, PGPSYMKEYALGO_SAFER = 5, PGPSYMKEYALGO_DES_SK = 6, PGPSYMKEYALGO_AES_128 = 7,
  PGPSYMKEYALGO_AES_192 = 8, PGPSYMKEYALGO_AES_256 = 9, PGPSYMKEYALGO_TWOFISH = 10, PGPSYMKEYALGO_NOENCRYPT = 110
}
 9.2. More...
 
enum  pgpCompressAlgo_e { PGPCOMPRESSALGO_NONE = 0, PGPCOMPRESSALGO_ZIP = 1, PGPCOMPRESSALGO_ZLIB = 2, PGPCOMPRESSALGO_BZIP2 = 3 }
 9.3. More...
 
enum  pgpHashAlgo_e {
  PGPHASHALGO_MD5 = 1, PGPHASHALGO_SHA1 = 2, PGPHASHALGO_RIPEMD160 = 3, PGPHASHALGO_MD2 = 5,
  PGPHASHALGO_TIGER192 = 6, PGPHASHALGO_HAVAL_5_160 = 7, PGPHASHALGO_SHA256 = 8, PGPHASHALGO_SHA384 = 9,
  PGPHASHALGO_SHA512 = 10, PGPHASHALGO_SHA224 = 11
}
 9.4. More...
 
enum  pgpSubType_e {
  PGPSUBTYPE_NONE = 0, PGPSUBTYPE_SIG_CREATE_TIME = 2, PGPSUBTYPE_SIG_EXPIRE_TIME = 3, PGPSUBTYPE_EXPORTABLE_CERT = 4,
  PGPSUBTYPE_TRUST_SIG = 5, PGPSUBTYPE_REGEX = 6, PGPSUBTYPE_REVOCABLE = 7, PGPSUBTYPE_KEY_EXPIRE_TIME = 9,
  PGPSUBTYPE_ARR = 10, PGPSUBTYPE_PREFER_SYMKEY = 11, PGPSUBTYPE_REVOKE_KEY = 12, PGPSUBTYPE_ISSUER_KEYID = 16,
  PGPSUBTYPE_NOTATION = 20, PGPSUBTYPE_PREFER_HASH = 21, PGPSUBTYPE_PREFER_COMPRESS = 22, PGPSUBTYPE_KEYSERVER_PREFERS = 23,
  PGPSUBTYPE_PREFER_KEYSERVER = 24, PGPSUBTYPE_PRIMARY_USERID = 25, PGPSUBTYPE_POLICY_URL = 26, PGPSUBTYPE_KEY_FLAGS = 27,
  PGPSUBTYPE_SIGNER_USERID = 28, PGPSUBTYPE_REVOKE_REASON = 29, PGPSUBTYPE_FEATURES = 30, PGPSUBTYPE_EMBEDDED_SIG = 32,
  PGPSUBTYPE_INTERNAL_100 = 100, PGPSUBTYPE_INTERNAL_101 = 101, PGPSUBTYPE_INTERNAL_102 = 102, PGPSUBTYPE_INTERNAL_103 = 103,
  PGPSUBTYPE_INTERNAL_104 = 104, PGPSUBTYPE_INTERNAL_105 = 105, PGPSUBTYPE_INTERNAL_106 = 106, PGPSUBTYPE_INTERNAL_107 = 107,
  PGPSUBTYPE_INTERNAL_108 = 108, PGPSUBTYPE_INTERNAL_109 = 109, PGPSUBTYPE_INTERNAL_110 = 110, PGPSUBTYPE_CRITICAL = 128
}
 5.2.3.1. More...
 
enum  pgpArmor_e {
  PGPARMOR_ERR_CRC_CHECK = -7, PGPARMOR_ERR_BODY_DECODE = -6, PGPARMOR_ERR_CRC_DECODE = -5, PGPARMOR_ERR_NO_END_PGP = -4,
  PGPARMOR_ERR_UNKNOWN_PREAMBLE_TAG = -3, PGPARMOR_ERR_UNKNOWN_ARMOR_TYPE = -2, PGPARMOR_ERR_NO_BEGIN_PGP = -1, PGPARMOR_NONE = 0,
  PGPARMOR_MESSAGE = 1, PGPARMOR_PUBKEY = 2, PGPARMOR_SIGNATURE = 3, PGPARMOR_SIGNED_MESSAGE = 4,
  PGPARMOR_FILE = 5, PGPARMOR_PRIVKEY = 6, PGPARMOR_SECKEY = 7
}
 
enum  pgpArmorKey_e {
  PGPARMORKEY_VERSION = 1, PGPARMORKEY_COMMENT = 2, PGPARMORKEY_MESSAGEID = 3, PGPARMORKEY_HASH = 4,
  PGPARMORKEY_CHARSET = 5
}
 
enum  pgpValType_e {
  PGPVAL_TAG = 1, PGPVAL_ARMORBLOCK = 2, PGPVAL_ARMORKEY = 3, PGPVAL_SIGTYPE = 4,
  PGPVAL_SUBTYPE = 5, PGPVAL_PUBKEYALGO = 6, PGPVAL_SYMKEYALGO = 7, PGPVAL_COMPRESSALGO = 8,
  PGPVAL_HASHALGO = 9, PGPVAL_SERVERPREFS = 10
}
 
enum  rpmDigestFlags_e { RPMDIGEST_NONE = 0 }
 Bit(s) to control digest operation. More...
 

Functions

const char * pgpValString (pgpValType type, uint8_t val)
 Return string representation of am OpenPGP value. More...
 
static unsigned int pgpGrab (const uint8_t *s, size_t nbytes)
 Return (native-endian) integer from big-endian representation. More...
 
char * pgpHexStr (const uint8_t *p, size_t plen)
 Return hex formatted representation of bytes. More...
 
int pgpPubkeyFingerprint (const uint8_t *pkt, size_t pktlen, pgpKeyID_t keyid)
 Calculate OpenPGP public key fingerprint. More...
 
int pgpExtractPubkeyFingerprint (const char *b64pkt, pgpKeyID_t keyid)
 Extract OpenPGP public key fingerprint from base64 encoded packet. More...
 
int pgpPrtParams (const uint8_t *pkts, size_t pktlen, unsigned int pkttype, pgpDigParams *ret)
 Parse a OpenPGP packet(s). More...
 
int pgpPrtPkts (const uint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
 Print/parse a OpenPGP packet(s). More...
 
pgpArmor pgpReadPkts (const char *fn, uint8_t **pkt, size_t *pktlen)
 Parse armored OpenPGP packets from a file. More...
 
pgpArmor pgpParsePkts (const char *armor, uint8_t **pkt, size_t *pktlen)
 Parse armored OpenPGP packets from memory. More...
 
char * pgpArmorWrap (int atype, const unsigned char *s, size_t ns)
 Wrap a OpenPGP packets in ascii armor for transport. More...
 
pgpDig pgpNewDig (void)
 Create a container for parsed OpenPGP packet(s). More...
 
void pgpCleanDig (pgpDig dig)
 Release (malloc'd) data from container. More...
 
pgpDig pgpFreeDig (pgpDig dig)
 Destroy a container for parsed OpenPGP packet(s). More...
 
pgpDigParams pgpDigGetParams (pgpDig dig, unsigned int pkttype)
 Retrieve parameters for parsed OpenPGP packet(s). More...
 
int pgpDigParamsCmp (pgpDigParams p1, pgpDigParams p2)
 Compare OpenPGP packet parameters param p1 1st parameter container param p2 2nd parameter container return 1 if the parameters differ, 0 otherwise. More...
 
unsigned int pgpDigParamsAlgo (pgpDigParams digp, unsigned int algotype)
 Retrieve OpenPGP algorithm parameters param digp parameter container param algotype PGPVAL_HASHALGO / PGPVAL_PUBKEYALGO return algorithm value, 0 on error. More...
 
pgpDigParams pgpDigParamsFree (pgpDigParams digp)
 Destroy parsed OpenPGP packet parameter(s). More...
 
rpmRC pgpVerifySignature (pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)
 Verify a PGP signature. More...
 
rpmRC pgpVerifySig (pgpDig dig, DIGEST_CTX hashctx)
 Verify a PGP signature. More...
 
char * pgpIdentItem (pgpDigParams digp)
 Return a string identification of a PGP signature/pubkey. More...
 
int rpmInitCrypto (void)
 Perform cryptography initialization. More...
 
int rpmFreeCrypto (void)
 Shutdown cryptography. More...
 
DIGEST_CTX rpmDigestDup (DIGEST_CTX octx)
 Duplicate a digest context. More...
 
size_t rpmDigestLength (int hashalgo)
 Obtain digest length in bytes. More...
 
DIGEST_CTX rpmDigestInit (int hashalgo, rpmDigestFlags flags)
 Initialize digest. More...
 
int rpmDigestUpdate (DIGEST_CTX ctx, const void *data, size_t len)
 Update context with next plain text buffer. More...
 
int rpmDigestFinal (DIGEST_CTX ctx, void **datap, size_t *lenp, int asAscii)
 Return digest and destroy context. More...
 
rpmDigestBundle rpmDigestBundleNew (void)
 Create a new digest bundle. More...
 
rpmDigestBundle rpmDigestBundleFree (rpmDigestBundle bundle)
 Free a digest bundle and all contained digest contexts. More...
 
int rpmDigestBundleAdd (rpmDigestBundle bundle, int algo, rpmDigestFlags flags)
 Add a new type of digest to a bundle. More...
 
int rpmDigestBundleUpdate (rpmDigestBundle bundle, const void *data, size_t len)
 Update contexts within bundle with next plain text buffer. More...
 
int rpmDigestBundleFinal (rpmDigestBundle bundle, int algo, void **datap, size_t *lenp, int asAscii)
 Return digest from a bundle and destroy context, see rpmDigestFinal(). More...
 
DIGEST_CTX rpmDigestBundleDupCtx (rpmDigestBundle bundle, int algo)
 Duplicate a digest context from a bundle. More...
 

Detailed Description

OpenPGP constants and structures from RFC-2440.

Text from RFC-2440 in comments is Copyright (C) The Internet Society (1998). All Rights Reserved.

Definition in file rpmpgp.h.

Macro Definition Documentation

#define PGPARMOR_ERROR   PGPARMOR_ERR_NO_BEGIN_PGP

Definition at line 896 of file rpmpgp.h.

Typedef Documentation

typedef uint8_t pgpKeyID_t[8]

Definition at line 36 of file rpmpgp.h.

typedef struct pgpPktCdata_s pgpPktCdata
typedef struct pgpPktEdata_s pgpPktEdata
typedef struct pgpPktLdata_s pgpPktLdata
typedef struct pgpPktSymkey_s pgpPktSymkey

5.3.

Symmetric-Key Encrypted Session-Key Packets (Tag 3)

The Symmetric-Key Encrypted Session Key packet holds the symmetric- key encryption of a session key used to encrypt a message. Zero or more Encrypted Session Key packets and/or Symmetric-Key Encrypted Session Key packets may precede a Symmetrically Encrypted Data Packet that holds an encrypted message. The message is encrypted with a session key, and the session key is itself encrypted and stored in the Encrypted Session Key packet or the Symmetric-Key Encrypted Session Key packet.

If the Symmetrically Encrypted Data Packet is preceded by one or more Symmetric-Key Encrypted Session Key packets, each specifies a passphrase that may be used to decrypt the message. This allows a message to be encrypted to a number of public keys, and also to one or more pass phrases. This packet type is new, and is not generated by PGP 2.x or PGP 5.0.

The body of this packet consists of:

  • A one-octet version number. The only currently defined version is 4.
  • A one-octet number describing the symmetric algorithm used.
  • A string-to-key (S2K) specifier, length as defined above.
  • Optionally, the encrypted session key itself, which is decrypted with the string-to-key object.
typedef struct pgpPktTrust_s pgpPktTrust
typedef struct pgpPktUid_s pgpPktUid
typedef uint8_t pgpTime_t[4]

Definition at line 37 of file rpmpgp.h.

typedef enum pgpValType_e pgpValType
typedef struct rpmDigestBundle_s* rpmDigestBundle

Definition at line 26 of file rpmpgp.h.

Definition at line 937 of file rpmpgp.h.

Enumeration Type Documentation

Enumerator
PGPVAL_TAG 
PGPVAL_ARMORBLOCK 
PGPVAL_ARMORKEY 
PGPVAL_SIGTYPE 
PGPVAL_SUBTYPE 
PGPVAL_PUBKEYALGO 
PGPVAL_SYMKEYALGO 
PGPVAL_COMPRESSALGO 
PGPVAL_HASHALGO 
PGPVAL_SERVERPREFS 

Definition at line 917 of file rpmpgp.h.