rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions
signature.c File Reference
SIGNATURE.
`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmurl.h>`
`#include <rpmcb.h>`
`#include <rpmpgp.h>`
`#include <rpmmacro.h>`
`#include <rpmku.h>`
`#include <rpmtag.h>`
`#include "rpmdb.h"`
`#include <pkgio.h>`
`#include "legacy.h"`
`#include "signature.h"`
`#include "debug.h"`
Include dependency graph for signature.c:

Go to the source code of this file.

## Macros
#define | _RPMPGP_INTERNAL

## Functions
int | rpmTempFile (const char *prefix, const char **fnptr, void *fdptr)
| Return file handle for a temporaray file. More...
static int | makeGPGSignature (const char *file, rpmSigTag *sigTagp, rpmuint8_t **pktp, rpmuint32_t *pktlenp, const char *passPhrase)
| Generate GPG signature(s) for a header+payload file. More...
static int | makeHDRSignature (Header sigh, const char *file, rpmSigTag sigTag, const char *passPhrase)
| Generate header only signature(s) from a header+payload file. More...
int | rpmAddSignature (Header sigh, const char *file, rpmSigTag sigTag, const char *passPhrase)
| Generate signature(s) from a header+payload file, save in signature header. More...
int | rpmCheckPassPhrase (const char *passPhrase)
| Check for valid pass phrase by invoking a helper. More...
static const char * | rpmSigString (rpmRC res)
static rpmRC | verifySize (const pgpDig dig, char *t)
static rpmRC | verifyMD5 (pgpDig dig, char *t, DIGEST_CTX md5ctx)
static rpmRC | verifySHA1 (pgpDig dig, char *t, DIGEST_CTX shactx)
| Verify header immutable region SHA-1 digest. More...
static rpmRC | verifyRSA (pgpDig dig, char *t, DIGEST_CTX rsactx)
| Verify RSA signature. More...
static rpmRC | verifyDSA (pgpDig dig, char *t, DIGEST_CTX dsactx)
| Verify DSA signature. More...
rpmRC | rpmVerifySignature (void *_dig, char *result)
| Verify a signature from a package. More...

## Macro Definition Documentation

#define _RPMPGP_INTERNAL

Definition at line 10 of file signature.c.

## Function Documentation

static int makeGPGSignature | ( | const char * | file,
|  | rpmSigTag * | sigTagp,
|  | rpmuint8_t ** | pktp,
|  | rpmuint32_t * | pktlenp,
|  | const char * | passPhrase
| ) |  |
| static

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

Parameters

  file | header+payload file name

Return values

  *sigTagp | signature tag
  *pktp | signature packet(s)
  *pktlenp | signature packet(s) length

Parameters

  passPhrase | private key pass phrase

Returns
  0 on success, 1 on failure

Definition at line 146 of file signature.c.

References _, _free(), addMacro(), alloca(), D_, delMacro(), errno, EXIT_FAILURE, Fclose(), Ferror(), Fopen(), Fread(), pgpDigFree(), pgpDigNew(), pgpGetSignature(), pgpPrtPkts(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_RSA, rpmExpand(), rpmkuPassPhrase(), rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, RPMSIGTAG_DSA, RPMSIGTAG_MD5, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, setenv(), Stat(), stpcpy(), Unlink(), unsetenv(), and xmalloc().

Referenced by makeHDRSignature().

static int makeHDRSignature | ( | Header | sigh,
|  | const char * | file,
|  | rpmSigTag | sigTag,
|  | const char * | passPhrase
| ) |  |
| static

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

Parameters

  sigh | 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 297 of file signature.c.

References _free(), alloca(), _HE_s::c, Fclose(), Ferror(), Fopen(), headerFree(), headerGet(), headerGetMagic(), headerIsEntry(), headerPut(), makeGPGSignature(), _HE_s::p, PGPHASHALGO_SHA1, rpmDataType_u::ptr, RPM_BIN_TYPE, RPM_STRING_TYPE, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), rpmDigestUpdate(), rpmlog(), RPMLOG_ERR, rpmpkgRead(), rpmpkgWrite(), RPMRC_OK, RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, RPMTAG_HEADERIMMUTABLE, rpmTempFile(), rpmDataType_u::str, _HE_s::t, _HE_s::tag, and Unlink().

Referenced by rpmAddSignature().

int rpmCheckPassPhrase | ( | const char * | passPhrase | ) |

Check for valid pass phrase by invoking a helper.

Parameters

  passPhrase | pass phrase

Returns
  0 on valid, 1 on invalid

Definition at line 487 of file signature.c.

References _, _free(), errno, rpmExpand(), rpmIsVerbose, rpmkuPassPhrase(), rpmlog(), RPMLOG_ERR, setenv(), and unsetenv().

Referenced by main().

static const char* rpmSigString | ( | rpmRC | res | ) |
| static

Definition at line 559 of file signature.c.

References RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTFOUND, RPMRC_NOTTRUSTED, and RPMRC_OK.

Referenced by verifyDSA(), verifyMD5(), verifyRSA(), verifySHA1(), and verifySize().

int rpmTempFile | ( | const char * | prefix,
|  | const char ** | fnptr,
|  | void * | fdptr
| ) |  |

Return file handle for a temporaray file.

A unique temporaray file path will be generated using rpmGenPath(prefix, "%{_tmppath}/", "rpm-tmp.XXXXX") where "XXXXXX" is filled in using rand(3). The file is opened, and the link count and (dev,ino) location are verified after opening. The file name and the open file handle are returned.

Parameters

  prefix | leading part of temp file path

Return values

  *fnptr | temp file name (or NULL)
  *fdptr | temp file handle

Returns
  0 on success

Definition at line 29 of file signature.c.

References _, _free(), errno, Fclose(), Ferror(), Fileno(), Fopen(), rpmGenPath(), rpmioMkpath(), rpmlog(), RPMLOG_ERR, S_ISLNK, URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by makeHDRSignature(), manageFile(), runScript(), and writeRPM().

static rpmRC verifyDSA | ( | pgpDig | dig,
|  | char * | t,
|  | DIGEST_CTX | dsactx
| ) |  |
| static

Verify DSA signature.

Parameters

  dig | container

Return values

  t | verbose success/failure text

Parameters

  dsactx | DSA digest context

Returns
  RPMRC_OK on success

Definition at line 830 of file signature.c.

References _, rpmop_s::count, pgpFindPubkey(), pgpGetSig(), pgpGetSiglen(), pgpGetSignature(), pgpGetSigtag(), pgpHexCvt(), pgpImplSetDSA(), pgpImplVerifyDSA(), PGPPUBKEYALGO_DSA, pgpStatsAccumulator(), rpmDigestAlgo(), rpmDigestDup(), rpmDigestName(), rpmDigestUpdate(), RPMRC_FAIL, RPMRC_OK, rpmSigString(), RPMSIGTAG_DSA, rpmswEnter(), rpmswExit(), and stpcpy().

Referenced by rpmVerifySignature().

static rpmRC verifyMD5 | ( | pgpDig | dig,
|  | char * | t,
|  | DIGEST_CTX | md5ctx
| ) |  |
| static

Definition at line 608 of file signature.c.

References _, _free(), rpmop_s::count, pgpGetSig(), pgpGetSiglen(), pgpHexCvt(), pgpStatsAccumulator(), rpmDigestDup(), rpmDigestFinal(), rpmDigestName(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), rpmswEnter(), rpmswExit(), and stpcpy().

Referenced by rpmVerifySignature().

static rpmRC verifyRSA | ( | pgpDig | dig,
|  | char * | t,
|  | DIGEST_CTX | rsactx
| ) |  |
| static

Verify RSA signature.

Parameters

  dig | container

Return values

  t | verbose success/failure text

Parameters

  rsactx | RSA digest context

Returns
  RPMRC_OK on success

Definition at line 732 of file signature.c.

References _, rpmop_s::count, pgpFindPubkey(), pgpGetSig(), pgpGetSiglen(), pgpGetSignature(), pgpGetSigtag(), pgpHexCvt(), pgpImplSetRSA(), pgpImplVerifyRSA(), PGPPUBKEYALGO_RSA, pgpStatsAccumulator(), rpmDigestAlgo(), rpmDigestDup(), rpmDigestName(), rpmDigestUpdate(), RPMRC_FAIL, RPMRC_OK, rpmSigString(), RPMSIGTAG_RSA, rpmswEnter(), rpmswExit(), and stpcpy().

Referenced by rpmVerifySignature().

static rpmRC verifySHA1 | ( | pgpDig | dig,
|  | char * | t,
|  | DIGEST_CTX | shactx
| ) |  |
| static

Verify header immutable region SHA-1 digest.

Parameters

  dig | container

Return values

  t | verbose success/failure text

Parameters

  shactx | SHA-1 digest context

Returns
  RPMRC_OK on success

Definition at line 670 of file signature.c.

References _, _free(), pgpGetSig(), pgpGetSiglen(), pgpStatsAccumulator(), rpmDigestDup(), rpmDigestFinal(), rpmDigestName(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), rpmswEnter(), rpmswExit(), and stpcpy().

Referenced by rpmVerifySignature().

static rpmRC verifySize | ( | const pgpDig | dig,
|  | char * | t
| ) |  |
| static

Definition at line 575 of file signature.c.

References _, pgpGetSig(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), and stpcpy().

Referenced by rpmVerifySignature().