Main Page Modules Data Structures File List Data Fields Globals Related Pages

# lib/signature.c File Reference

More...

`#include "system.h"`
`#include "rpmio_internal.h"`
`#include <rpmlib.h>`
`#include <rpmmacro.h>`
`#include "rpmdb.h"`
`#include "rpmts.h"`
`#include "misc.h"`
`#include "legacy.h"`
`#include "rpmlead.h"`
`#include "signature.h"`
`#include "header_internal.h"`
`#include "debug.h"`

Go to the source code of this file.

## Functions

int | rpmLookupSignatureType (int action)
const char * | rpmDetectPGPVersion (pgpVersion *pgpVer)
rpmRC | printSize (FD_t fd, int siglen, int pad, int datalen)
| Print package size. More...
rpmRC | rpmReadSignature (FD_t fd, Header *sighp, sigType sig_type)
int | rpmWriteSignature (FD_t fd, Header h)
Header | rpmNewSignature (void)
Header | rpmFreeSignature (Header h)
int | makePGPSignature (const char *file, byte **pkt, int_32 *pktlen, const char *passPhrase)
| Generate PGP (aka RSA/MD5) signature(s) for a header+payload file. More...
int | makeGPGSignature (const char *file, byte **pkt, int_32 *pktlen, const char *passPhrase)
| Generate GPG (aka DSA) signature(s) for a header+payload file. More...
int | makeHDRSignature (Header sig, const char *file, int_32 sigTag, const char *passPhrase)
| Generate header only signature(s) from a header+payload file. More...
int | rpmAddSignature (Header sig, const char *file, int_32 sigTag, const char *passPhrase)
int | checkPassPhrase (const char *passPhrase, const int sigTag)
char * | rpmGetPassPhrase (const char *prompt, const int sigTag)
const char * | rpmSigString (rpmRC res)
rpmRC | verifySizeSignature (const rpmts ts, char *t)
rpmRC | verifyMD5Signature (const rpmts ts, char *t, DIGEST_CTX md5ctx)
rpmRC | verifySHA1Signature (const rpmts ts, char *t, DIGEST_CTX sha1ctx)
| Verify header immutable region SHA1 digest. More...
unsigned char | nibble (char c)
| Convert hex to binary nibble. More...
rpmRC | verifyPGPSignature (rpmts ts, char *t, DIGEST_CTX md5ctx)
| Verify PGP (aka RSA/MD5) signature. More...
rpmRC | verifyGPGSignature (rpmts ts, char *t, DIGEST_CTX sha1ctx)
| Verify GPG (aka DSA) signature. More...
rpmRC | rpmVerifySignature (const rpmts ts, char *result)

## Variables

char ** | environ = NULL
unsigned char | header_magic [8]

## Detailed Description

Definition in file signature.c.

## Function Documentation

int checkPassPhrase | ( | const char * | passPhrase,
|  | const int | sigTag
| ) | `[static]`

| Definition at line 668 of file signature.c. References _, dosetenv, environ, errno, PGP_2, PGP_5, PGP_NOTDETECTED, PGP_UNKNOWN, pgpVersion, poptParseArgvString, rpmDetectPGPVersion, rpmExpand, strerror, and unsetenv. Referenced by rpmGetPassPhrase.

int makeGPGSignature | ( | const char * | file,
|  | byte ** | pkt,
|  | int_32 * | pktlen,
|  | const char * | passPhrase
| ) | `[static]`

Generate GPG (aka DSA) signature(s) for a header+payload file.

Parameters:

  file | header+payload file name

Return values:

  pkt | signature packet(s)
  pktlen | signature packet(s) length

Parameters:

  passPhrase | private key pass phrase

Returns:
  0 on success, 1 on failure

Definition at line 396 of file signature.c.

References _, _free, addMacro, alloca, delMacro, dosetenv, environ, errno, Fclose, Ferror, Fopen, int_32, poptParseArgvString, rpmExpand, stpcpy, strerror, timedRead, unsetenv, and xmalloc.

Referenced by makeHDRSignature, and rpmAddSignature.

int makeHDRSignature | ( | Header | sig,
|  | const char * | file,
|  | int_32 | sigTag,
|  | const char * | passPhrase
| ) | `[static]`

Generate header only signature(s) from a header+payload file.

Parameters:

  sig | signature header
  file | header+payload file name
  sigTag | type of signature(s) to add
  passPhrase | private key pass phrase

Returns:
  0 on success, -1 on failure

Definition at line 511 of file signature.c.

References _free, Fclose, Ferror, Fopen, header_magic, HEADER_MAGIC_YES, headerAddEntry, headerFree, headerFreeData, headerGetEntry, headerIsEntry, headerRead, headerWrite, int_32, makeGPGSignature, makePGPSignature, makeTempFile, PGPHASHALGO_SHA1, RPM_BIN_TYPE, RPM_STRING_TYPE, RPMDIGEST_NONE, rpmDigestFinal, rpmDigestInit, rpmDigestUpdate, and RPMTAG_HEADERIMMUTABLE.

Referenced by rpmAddSignature.

int makePGPSignature | ( | const char * | file,
|  | byte ** | pkt,
|  | int_32 * | pktlen,
|  | const char * | passPhrase
| ) | `[static]`

Generate PGP (aka RSA/MD5) signature(s) for a header+payload file.

Parameters:

  file | header+payload file name

Return values:

  pkt | signature packet(s)
  pktlen | signature packet(s) length

Parameters:

  passPhrase | private key pass phrase

Returns:
  0 on success, 1 on failure

Definition at line 261 of file signature.c.

References _, _free, addMacro, alloca, delMacro, dosetenv, environ, errno, Fclose, Ferror, Fopen, int_32, PGP_2, PGP_5, PGP_NOTDETECTED, PGP_UNKNOWN, pgpVersion, poptParseArgvString, rpmDetectPGPVersion, rpmExpand, stpcpy, strerror, timedRead, unsetenv, and xmalloc.

Referenced by makeHDRSignature, and rpmAddSignature.

unsigned char nibble | ( | char | c | ) | `[inline, static]`

Convert hex to binary nibble.

Parameters:

  c | hex character

Returns:
  binary nibble

Definition at line 993 of file signature.c.

rpmRC printSize | ( | FD_t | fd,
|  | int | siglen,
|  | int | pad,
|  | int | datalen
| ) | `[inline, static]`

Print package size.

Todo:
  rpmio: use fdSize rather than fstat(2) to get file size.

Parameters:

  fd | package file handle
  siglen | signature header size
  pad | signature padding
  datalen | length of header+payload

Returns:
  rpmRC return code

Definition at line 120 of file signature.c.

References _, Fileno, rpmRC, RPMRC_FAIL, and RPMRC_OK.

Referenced by rpmReadSignature.

Header rpmFreeSignature | ( | Header | h | ) |

| Definition at line 248 of file signature.c. References headerFree. Referenced by rpmReadPackageFile, rpmReSign, rpmVerifySignatures, and writeRPM.

const char* rpmSigString | ( | rpmRC | res | ) | `[static]`

| Definition at line 833 of file signature.c. References rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTFOUND, RPMRC_NOTTRUSTED, and RPMRC_OK. Referenced by verifyGPGSignature, verifyMD5Signature, verifyPGPSignature, verifySHA1Signature, and verifySizeSignature.

rpmRC rpmVerifySignature | ( | const rpmts | ts,
|  | char * | result
| ) |

| Definition at line 1218 of file signature.c. References _, pgpDig_s::hdrsha1ctx, int_32, pgpDig_s::md5ctx, rpmRC, RPMRC_NOTFOUND, rpmts, rpmtsDig, rpmtsSig, rpmtsSiglen, rpmtsSigtag, pgpDig_s::sha1ctx, verifyGPGSignature, verifyMD5Signature, verifyPGPSignature, verifySHA1Signature, and verifySizeSignature. Referenced by headerCheck, rpmReadPackageFile, and rpmVerifySignatures.

rpmRC verifyGPGSignature | ( | rpmts | ts,
|  | char * | t,
|  | DIGEST_CTX | sha1ctx
| ) | `[static]`

Verify GPG (aka DSA) signature.

Parameters:

  ts | transaction set

Return values:

  t | verbose success/failure text

Parameters:

  sha1ctx |

Returns:
  RPMRC_OK on success

Definition at line 1130 of file signature.c.

References _, mp32number::data, pgpDig_s::g, pgpDigParams_s::hash, pgpDigParams_s::hash_algo, pgpDigParams_s::hashlen, pgpDig_s::hdrsha1ctx, pgpDig_s::hm, int_32, mp32nsethex, mp32nzero, pgpDig_s::nbytes, pgpDig_s::p, PGPHASHALGO_SHA1, pgpHexCvt, PGPPUBKEYALGO_DSA, pgpDigParams_s::pubkey_algo, pgpDig_s::q, pgpDig_s::r, rpmDigestDup, rpmDigestFinal, rpmDigestUpdate, rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString, rpmts, rpmtsDig, rpmtsFindPubkey, rpmtsSig, rpmtsSiglen, rpmtsSignature, rpmtsSigtag, pgpDig_s::s, pgpDig_s::sha1, pgpDig_s::sha1len, pgpDigParams_s::signhash16, pgpDigParams_s::signid, pgpDigParams_s::sigtype, stpcpy, and pgpDig_s::y.

Referenced by rpmVerifySignature.

rpmRC verifyMD5Signature | ( | const rpmts | ts,
|  | char * | t,
|  | DIGEST_CTX | md5ctx
| ) | `[static]`

| Definition at line 887 of file signature.c. References _, _free, int_32, pgpHexCvt, rpmDigestDup, rpmDigestFinal, rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString, rpmts, rpmtsDig, rpmtsSig, rpmtsSiglen, and stpcpy. Referenced by rpmVerifySignature.

rpmRC verifyPGPSignature | ( | rpmts | ts,
|  | char * | t,
|  | DIGEST_CTX | md5ctx
| ) | `[static]`

Verify PGP (aka RSA/MD5) signature.

Parameters:

  ts | transaction set

Return values:

  t | verbose success/failure text

Parameters:

  md5ctx |

Returns:
  RPMRC_OK on success

Definition at line 1014 of file signature.c.

References _, _free, pgpDig_s::c, pgpDigParams_s::hash, pgpDigParams_s::hash_algo, pgpDigParams_s::hashlen, int_32, pgpDig_s::md5, pgpDig_s::md5len, mp32nsethex, mp32nzero, pgpDig_s::nbytes, nibble, PGPHASHALGO_MD5, pgpHexCvt, PGPPUBKEYALGO_RSA, pgpDigParams_s::pubkey_algo, rpmDigestDup, rpmDigestFinal, rpmDigestUpdate, rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString, rpmts, rpmtsDig, rpmtsFindPubkey, rpmtsSig, rpmtsSiglen, rpmtsSignature, rpmtsSigtag, pgpDig_s::rsa_pk, pgpDig_s::rsahm, rsavrfy, pgpDigParams_s::signhash16, pgpDigParams_s::signid, pgpDigParams_s::sigtype, stpcpy, and xmalloc.

Referenced by rpmVerifySignature.

rpmRC verifySHA1Signature | ( | const rpmts | ts,
|  | char * | t,
|  | DIGEST_CTX | sha1ctx
| ) | `[static]`

Verify header immutable region SHA1 digest.

Parameters:

  ts | transaction set

Return values:

  t | verbose success/failure text

Parameters:

  sha1ctx |

Returns:
  RPMRC_OK on success

Definition at line 942 of file signature.c.

References _, _free, int_32, rpmDigestDup, rpmDigestFinal, rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString, rpmts, rpmtsDig, rpmtsSig, rpmtsSiglen, and stpcpy.

Referenced by rpmVerifySignature.

rpmRC verifySizeSignature | ( | const rpmts | ts,
|  | char * | t
| ) | `[static]`

| Definition at line 850 of file signature.c. References _, int_32, pgpDig_s::nbytes, rpmRC, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString, rpmts, rpmtsDig, rpmtsSig, and stpcpy. Referenced by rpmVerifySignature.

## Variable Documentation

char** environ = NULL

| Definition at line 28 of file signature.c. Referenced by checkPassPhrase, main, makeGPGSignature, makePGPSignature, open_dso, and xcalloc.

unsigned char header_magic[8]`[static]`

Initial value:

     {
        0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
    }

Definition at line 142 of file signature.c.

Referenced by makeHDRSignature, and rpmReadSignature.