Data Structures | Defines | Functions | Variables

# rpmio/rpmpgp.c File Reference

Routines to handle RFC-2440 detached signatures. More...

`#include "system.h"`
`#include "rpmio_internal.h"`
`#include <rpmbc.h>`
`#include "debug.h"`
Include dependency graph for rpmpgp.c:

Go to the source code of this file.

## Data Structures
struct | pgpPkt_s
## Defines
#define | _RPMPGP_INTERNAL
#define | TOKEQ(_s, _tok) (!strncmp((_s), (_tok), sizeof(_tok)-1))
## Functions
static void | pgpPrtNL (void)
static void | pgpPrtInt (const char *pre, int i)
static void | pgpPrtStr (const char *pre, const char *s)
static void | pgpPrtHex (const char *pre, const uint8_t *p, size_t plen)
void | pgpPrtVal (const char *pre, pgpValTbl vs, uint8_t val)
| Print an OpenPGP value.
int | pgpPrtSubType (const uint8_t *h, size_t hlen, pgpSigType sigtype)
| Print/parse an OpenPGP subtype packet.
static int | pgpPrtSigParams (const pgpPkt pp, uint8_t pubkey_algo, uint8_t sigtype, const uint8_t *p)
int | pgpPrtSig (const pgpPkt pp)
| Print/parse an OpenPGP signature packet.
static const uint8_t * | pgpPrtPubkeyParams (const pgpPkt pp, uint8_t pubkey_algo, const uint8_t *p)
static const uint8_t * | pgpPrtSeckeyParams (const pgpPkt pp, uint8_t pubkey_algo, const uint8_t *p)
int | pgpPrtKey (const pgpPkt pp)
| Print/parse an OpenPGP key packet.
int | pgpPrtUserID (const pgpPkt pp)
| Print/parse an OpenPGP userid packet.
int | pgpPrtComment (const pgpPkt pp)
| Print/parse an OpenPGP comment packet.
int | pgpPktLen (const uint8_t *pkt, size_t pleft, pgpPkt pp)
| Return lenth of a OpenPGP packet.
int | pgpPubkeyFingerprint (const uint8_t *pkt, size_t pktlen, uint8_t *keyid)
| Calculate OpenPGP public key fingerprint.
int | pgpExtractPubkeyFingerprint (const char *b64pkt, uint8_t *keyid)
| Extract OpenPGP public key fingerprint from base64 encoded packet.
int | pgpPrtPkt (const uint8_t *pkt, size_t pleft)
| Print/parse next OpenPGP packet.
pgpDig | XpgpDigUnlink (pgpDig dig, const char *msg, const char *fn, unsigned ln)
pgpDig | XpgpDigLink (pgpDig dig, const char *msg, const char *fn, unsigned ln)
void | pgpDigClean (pgpDig dig)
| Release (malloc'd) data from container.
pgpDig | pgpDigFree (pgpDig dig)
| Destroy a container for parsed OpenPGP packates.
pgpDig | pgpDigNew (pgpVSFlags vsflags)
| Create a container for parsed OpenPGP packates.
pgpDigParams | pgpGetSignature (pgpDig dig)
| Return OpenPGP signature parameters.
pgpDigParams | pgpGetPubkey (pgpDig dig)
| Return OpenPGP pubkey parameters.
uint32_t | pgpGetSigtag (pgpDig dig)
| Get signature tag.
uint32_t | pgpGetSigtype (pgpDig dig)
| Get signature tag type.
const void * | pgpGetSig (pgpDig dig)
| Get signature tag data, i.e.
uint32_t | pgpGetSiglen (pgpDig dig)
| Get signature tag data length, i.e.
int | pgpSetSig (pgpDig dig, uint32_t sigtag, uint32_t sigtype, const void *sig, uint32_t siglen)
| Set signature tag info, i.e.
void * | pgpStatsAccumulator (pgpDig dig, int opx)
| Return pgpDig container accumulator structure.
int | pgpSetFindPubkey (pgpDig dig, int(*findPubkey)(void *ts, void *dig), void *_ts)
| Set find pubkey vector.
int | pgpFindPubkey (pgpDig dig)
| Call find pubkey vector.
static int | pgpGrabPkts (const uint8_t *pkts, size_t pktlen, uint8_t ***pppkts, int *pnpkts)
int | pgpPrtPkts (const uint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
| Print/parse a OpenPGP packet(s).
pgpArmor | pgpReadPkts (const char *fn, const uint8_t **pkt, size_t *pktlen)
| Parse armored OpenPGP packets from a file.
char * | pgpArmorWrap (int atype, const unsigned char *s, size_t ns)
| Wrap a OpenPGP packets in ascii armor for transport.
int | pgpHashAlgoStringToNumber (const char *name, size_t name_len)
| Convert a hash algorithm <name> to the internal PGPHASHALGO_<name> number.
## Variables
int | _pgp_debug = 0
int | _pgp_print = 0
pgpImplVecs_t * | pgpImplVecs
static pgpDig | _dig = NULL
static pgpDigParams | _digp = NULL
struct pgpValTbl_s | pgpSigTypeTbl []
struct pgpValTbl_s | pgpPubkeyTbl []
struct pgpValTbl_s | pgpSymkeyTbl []
| Symmetric key (string, value) pairs.
struct pgpValTbl_s | pgpCompressionTbl []
| Compression (string, value) pairs.
struct pgpValTbl_s | pgpHashTbl []
| Hash (string, value) pairs.
struct pgpValTbl_s | pgpKeyServerPrefsTbl []
struct pgpValTbl_s | pgpSubTypeTbl []
| Subtype (string, value) pairs.
struct pgpValTbl_s | pgpTagTbl []
struct pgpValTbl_s | pgpArmorTbl []
| Armor (string, value) pairs.
struct pgpValTbl_s | pgpArmorKeyTbl []
| Armor key (string, value) pairs.
static const char * | pgpSigRSA []
static const char * | pgpSigDSA []
static const char * | pgpPublicRSA []
static const char * | pgpPublicDSA []
static const char * | pgpPublicELGAMAL []
pgpVSFlags | pgpDigVSFlags
| Disabler bits(s) for signature/digest checking.

## Detailed Description

Routines to handle RFC-2440 detached signatures.

Definition in file rpmpgp.c.

## Define Documentation

#define _RPMPGP_INTERNAL

Definition at line 8 of file rpmpgp.c.

#define TOKEQ | ( |  | _s,
|  |  | _tok
| ) |  | (!strncmp((_s), (_tok), sizeof(_tok)-1))

Referenced by pgpReadPkts().

## Function Documentation

static int pgpGrabPkts | ( | const uint8_t * | pkts,
|  | size_t | pktlen,
|  | uint8_t *** | pppkts,
|  | int * | pnpkts
| ) |  | `[static]`

Definition at line 1178 of file rpmpgp.c.

References _free(), alloca(), pgpPktLen(), pgpPkt_s::pktlen, and xcalloc().

Referenced by pgpPrtPkts().

static void pgpPrtHex | ( | const char * | pre,
|  | const uint8_t * | p,
|  | size_t | plen
| ) |  | `[static]`

Definition at line 234 of file rpmpgp.c.

References _pgp_print, and pgpHexStr().

Referenced by pgpPrtComment(), pgpPrtPkt(), pgpPrtSeckeyParams(), pgpPrtSig(), and pgpPrtSubType().

static void pgpPrtInt | ( | const char * | pre,
|  | int | i
| ) |  | `[static]`

Definition at line 214 of file rpmpgp.c.

References _pgp_print.

Referenced by pgpPrtSeckeyParams().

static void pgpPrtNL | ( | void | ) | `[static]`

Definition at line 206 of file rpmpgp.c.

References _pgp_print.

Referenced by pgpPrtComment(), pgpPrtKey(), pgpPrtPkt(), pgpPrtPubkeyParams(), pgpPrtSeckeyParams(), pgpPrtSig(), pgpPrtSigParams(), pgpPrtSubType(), and pgpPrtUserID().

static const uint8_t* pgpPrtPubkeyParams | ( | const pgpPkt | pp,
|  | uint8_t | pubkey_algo,
|  | const uint8_t * | p
| ) |  | `[static]`

Definition at line 586 of file rpmpgp.c.

References _dig, _pgp_print, pgpPkt_s::h, pgpPkt_s::hlen, pgpImplMpiItem(), pgpMpiLen(), pgpMpiStr(), pgpPrtNL(), pgpPrtStr(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_ELGAMAL_ENCRYPT, PGPPUBKEYALGO_RSA, pgpPublicDSA, pgpPublicELGAMAL, and pgpPublicRSA.

Referenced by pgpPrtKey().

static const uint8_t* pgpPrtSeckeyParams | ( | const pgpPkt | pp,
|  | uint8_t | pubkey_algo,
|  | const uint8_t * | p
| ) |  | `[static]`

Definition at line 644 of file rpmpgp.c.

References _pgp_print, pgpPkt_s::h, pgpPkt_s::hlen, pgpMpiLen(), pgpMpiStr(), pgpPrtHex(), pgpPrtInt(), pgpPrtNL(), pgpPrtStr(), pgpPrtVal(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_ELGAMAL_ENCRYPT, and PGPPUBKEYALGO_RSA.

Referenced by pgpPrtKey().

static int pgpPrtSigParams | ( | const pgpPkt | pp,
|  | uint8_t | pubkey_algo,
|  | uint8_t | sigtype,
|  | const uint8_t * | p
| ) |  | `[static]`

Definition at line 368 of file rpmpgp.c.

References _dig, _pgp_print, pgpPkt_s::h, pgpPkt_s::hlen, pgpImplMpiItem(), pgpMpiLen(), pgpMpiStr(), pgpPrtNL(), pgpPrtStr(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_RSA, pgpSigDSA, pgpSigRSA, PGPSIGTYPE_BINARY, and PGPSIGTYPE_TEXT.

Referenced by pgpPrtSig().

static void pgpPrtStr | ( | const char * | pre,
|  | const char * | s
| ) |  | `[static]`

Definition at line 224 of file rpmpgp.c.

References _pgp_print.

Referenced by pgpPrtPubkeyParams(), pgpPrtSeckeyParams(), and pgpPrtSigParams().

pgpDig XpgpDigLink | ( | pgpDig | dig,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln
| ) |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 999 of file rpmpgp.c.

References _pgp_debug.

pgpDig XpgpDigUnlink | ( | pgpDig | dig,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln
| ) |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 988 of file rpmpgp.c.

References _pgp_debug.

## Variable Documentation

pgpDig _dig = NULL`[static]`

Definition at line 34 of file rpmpgp.c.

Referenced by pgpPrtPkts(), pgpPrtPubkeyParams(), pgpPrtSigParams(), and rpmVerifySignature().

pgpDigParams _digp = NULL`[static]`

Definition at line 37 of file rpmpgp.c.

Referenced by pgpPrtKey(), pgpPrtPkt(), pgpPrtPkts(), pgpPrtSig(), pgpPrtSubType(), and pgpPrtUserID().

int _pgp_debug = 0

Definition at line 20 of file rpmpgp.c.

Referenced by pgpPrtSig(), XpgpDigLink(), and XpgpDigUnlink().

int _pgp_print = 0

Definition at line 23 of file rpmpgp.c.

Referenced by pgpPrtComment(), pgpPrtHex(), pgpPrtInt(), pgpPrtKey(), pgpPrtNL(), pgpPrtPkts(), pgpPrtPubkeyParams(), pgpPrtSeckeyParams(), pgpPrtSig(), pgpPrtSigParams(), pgpPrtStr(), pgpPrtSubType(), pgpPrtUserID(), and pgpPrtVal().

pgpVSFlags pgpDigVSFlags

Disabler bits(s) for signature/digest checking.

Definition at line 986 of file rpmpgp.c.

Referenced by headerCheck(), pgpDigNew(), rpmcliAllArgCallback(), rpmReadPackageFile(), rpmtsSetVSFlags(), and rpmtsVSFlags().

pgpImplVecs_t* pgpImplVecs

Initial value:

            &rpmbcImplVecs

Definition at line 26 of file rpmpgp.c.

Referenced by rpmcliAllArgCallback().

struct pgpValTbl_s pgpKeyServerPrefsTbl[]

Initial value:

     {
        { 0x80,                     "No-modify" },
        { -1,                       "Unknown key server preference" },
    }

Definition at line 115 of file rpmpgp.c.

const char* pgpPublicDSA[]`[static]`

Initial value:

     {
        "    p =",
        "    q =",
        "    g =",
        "    y =",
        NULL,
    }

Definition at line 553 of file rpmpgp.c.

Referenced by pgpPrtPubkeyParams().

const char* pgpPublicELGAMAL[]`[static]`

Initial value:

     {
        "    p =",
        "    g =",
        "    y =",
        NULL,
    }

Definition at line 570 of file rpmpgp.c.

Referenced by pgpPrtPubkeyParams().

const char* pgpPublicRSA[]`[static]`

Initial value:

     {
        "    n =",
        "    e =",
        NULL,
    }

Definition at line 535 of file rpmpgp.c.

Referenced by pgpPrtPubkeyParams().

const char* pgpSigDSA[]`[static]`

Initial value:

     {
        "    r =",
        "    s =",
        NULL,
    }

Definition at line 361 of file rpmpgp.c.

Referenced by pgpPrtSigParams().

const char* pgpSigRSA[]`[static]`

Initial value:

     {
        " m**d =",
        NULL,
    }

Definition at line 355 of file rpmpgp.c.

Referenced by pgpPrtSigParams().