Defines | Functions

rpmdb/signature.c File Reference

#include "system.h"
#include <rpmio.h>
#include <rpmurl.h>
#include <rpmcb.h>
#include <rpmpgp.h>
#include <rpmtag.h>
#include <rpmmacro.h>
#include "rpmdb.h"
#include "legacy.h"
#include <pkgio.h>
#include "signature.h"
#include "debug.h"
Include dependency graph for signature.c:

Go to the source code of this file.

Defines

#define _RPMPGP_INTERNAL

Functions

int rpmTempFile (const char *prefix, const char **fnptr, void *fdptr)
 Return file handle for a temporaray file.
static int makeGPGSignature (const char *file, uint32_t *sigTagp, uint8_t **pktp, uint32_t *pktlenp, const char *passPhrase)
 Generate GPG signature(s) for a header+payload file.
static int makeHDRSignature (Header sigh, const char *file, uint32_t sigTag, const char *passPhrase)
 Generate header only signature(s) from a header+payload file.
int rpmAddSignature (Header sigh, const char *file, uint32_t sigTag, const char *passPhrase)
 Generate signature(s) from a header+payload file, save in signature header.
int rpmCheckPassPhrase (const char *passPhrase)
 Check for valid pass phrase by invoking a helper.
static const char * rpmSigString (rpmRC res)
static rpmRC verifySizeSignature (const pgpDig dig, char *t)
static rpmRC verifyMD5Signature (const pgpDig dig, char *t, DIGEST_CTX md5ctx)
static rpmRC verifySHA1Signature (const pgpDig dig, char *t, DIGEST_CTX sha1ctx)
 Verify header immutable region SHA1 digest.
static rpmRC verifyRSASignature (pgpDig dig, char *t, DIGEST_CTX md5ctx)
 Verify RSA signature.
static rpmRC verifyDSASignature (pgpDig dig, char *t, DIGEST_CTX sha1ctx)
 Verify DSA signature.
rpmRC rpmVerifySignature (void *_dig, char *result)
 Verify a signature from a package.

Define Documentation

#define _RPMPGP_INTERNAL

Definition at line 13 of file signature.c.


Function Documentation

static int makeGPGSignature ( const char *  file,
uint32_t *  sigTagp,
uint8_t **  pktp,
uint32_t *  pktlenp,
const char *  passPhrase 
) [static]

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

Parameters:
fileheader+payload file name
Return values:
*sigTagpsignature tag
*pktpsignature packet(s)
*pktlenpsignature packet(s) length
Parameters:
passPhraseprivate key pass phrase
Returns:
0 on success, 1 on failure

Definition at line 145 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(), 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,
uint32_t  sigTag,
const char *  passPhrase 
) [static]

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

Parameters:
sighsignature header
fileheader+payload file name
sigTagtype of signature(s) to add
passPhraseprivate key pass phrase
Returns:
0 on success, -1 on failure

Definition at line 306 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:
passPhrasepass phrase
Returns:
0 on valid, 1 on invalid

Definition at line 490 of file signature.c.

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

Referenced by main().

static const char* rpmSigString ( rpmRC  res ) [static]
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:
prefixleading part of temp file path
Return values:
*fnptrtemp file name (or NULL)
*fdptrtemp file handle
Returns:
0 on success

Definition at line 30 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 verifyDSASignature ( pgpDig  dig,
char *  t,
DIGEST_CTX  sha1ctx 
) [static]

Verify DSA signature.

Parameters:
digcontainer
Return values:
tverbose success/failure text
Parameters:
sha1ctx
Returns:
RPMRC_OK on success

Definition at line 861 of file signature.c.

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

Referenced by rpmVerifySignature().

static rpmRC verifyMD5Signature ( const pgpDig  dig,
char *  t,
DIGEST_CTX  md5ctx 
) [static]
static rpmRC verifyRSASignature ( pgpDig  dig,
char *  t,
DIGEST_CTX  md5ctx 
) [static]
static rpmRC verifySHA1Signature ( const pgpDig  dig,
char *  t,
DIGEST_CTX  sha1ctx 
) [static]

Verify header immutable region SHA1 digest.

Parameters:
digcontainer
Return values:
tverbose success/failure text
Parameters:
sha1ctx
Returns:
RPMRC_OK on success

Definition at line 680 of file signature.c.

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

Referenced by rpmVerifySignature().

static rpmRC verifySizeSignature ( const pgpDig  dig,
char *  t 
) [static]

Definition at line 591 of file signature.c.

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

Referenced by rpmVerifySignature().