rpm
4.5
|
#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) |
Return type of signature needed for signing/building. More... | |
const char * | rpmDetectPGPVersion (pgpVersion *pgpVer) |
Return path to pgp executable of given type, or NULL when not found. More... | |
static rpmRC | printSize (FD_t fd, int siglen, int pad, size_t datalen) |
Print package size. More... | |
rpmRC | rpmReadSignature (FD_t fd, Header *sighp, sigType sig_type, const char **msg) |
Read (and verify header+payload size) signature header. More... | |
int | rpmWriteSignature (FD_t fd, Header sigh) |
Write signature header. More... | |
Header | rpmNewSignature (void) |
Return new, empty (signature) header instance. More... | |
Header | rpmFreeSignature (Header sigh) |
Destroy signature header from package. More... | |
static int | makePGPSignature (const char *file, int_32 *sigTagp, byte **pktp, int_32 *pktlenp, const char *passPhrase) |
Generate PGP signature(s) for a header+payload file. More... | |
static int | makeGPGSignature (const char *file, int_32 *sigTagp, byte **pktp, int_32 *pktlenp, const char *passPhrase) |
Generate GPG signature(s) for a header+payload file. More... | |
static int | makeHDRSignature (Header sigh, const char *file, int_32 sigTag, const char *passPhrase) |
Generate header only signature(s) from a header+payload file. More... | |
int | rpmAddSignature (Header sigh, const char *file, int_32 sigTag, const char *passPhrase) |
Generate signature(s) from a header+payload file, save in signature header. More... | |
static int | checkPassPhrase (const char *passPhrase, const int sigTag) |
char * | rpmGetPassPhrase (const char *prompt, const int sigTag) |
Read a pass phrase using getpass(3), confirm with gpg/pgp helper binaries. More... | |
static const char * | rpmSigString (rpmRC res) |
static rpmRC | verifySizeSignature (const rpmts ts, char *t) |
static rpmRC | verifyMD5Signature (const rpmts ts, char *t, DIGEST_CTX md5ctx) |
static rpmRC | verifySHA1Signature (const rpmts ts, char *t, DIGEST_CTX sha1ctx) |
Verify header immutable region SHA1 digest. More... | |
static unsigned char | nibble (char c) |
Convert hex to binary nibble. More... | |
static rpmRC | verifyRSASignature (rpmts ts, char *t, DIGEST_CTX md5ctx) |
Verify RSA signature. More... | |
static rpmRC | verifyDSASignature (rpmts ts, char *t, DIGEST_CTX sha1ctx) |
Verify DSA signature. More... | |
rpmRC | rpmVerifySignature (const rpmts ts, char *result) |
Verify a signature from a package. More... | |
Variables | |
static unsigned char | header_magic [8] |
|
static |
Definition at line 853 of file signature.c.
References _, dosetenv(), errno, PGP_2, PGP_5, PGP_NOTDETECTED, PGP_UNKNOWN, rpmDetectPGPVersion(), RPMERR_EXEC, RPMERR_SIGGEN, rpmError, rpmExpand(), rpmIsVerbose, RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, and unsetenv().
Referenced by rpmGetPassPhrase().
|
static |
Generate GPG signature(s) for a header+payload file.
file | header+payload file name |
*sigTagp | signature tag |
*pktp | signature packet(s) |
*pktlenp | signature packet(s) length |
passPhrase | private key pass phrase |
Definition at line 545 of file signature.c.
References _, _free(), addMacro(), alloca(), D_, delMacro(), dosetenv(), errno, Fclose(), Ferror(), Fopen(), pgpFreeDig(), pgpNewDig(), pgpPrtPkts(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_RSA, pgpDigParams_s::pubkey_algo, RPMERR_EXEC, RPMERR_SIGGEN, rpmError, rpmExpand(), RPMMESS_DEBUG, rpmMessage, RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, pgpDig_s::signature, stpcpy(), timedRead(), unsetenv(), and xmalloc().
Referenced by makeHDRSignature(), and rpmAddSignature().
|
static |
Generate header only signature(s) from a header+payload file.
sigh | signature header |
file | header+payload file name |
sigTag | type of signature(s) to add |
passPhrase | private key pass phrase |
Definition at line 696 of file signature.c.
References _free(), Fclose(), Ferror(), Fopen(), header_magic, HEADER_MAGIC_YES, headerAddEntry(), headerFree(), headerFreeData(), headerGetEntry(), headerIsEntry(), headerRead(), headerWrite(), makeGPGSignature(), makePGPSignature(), makeTempFile(), PGPHASHALGO_SHA1, RPM_BIN_TYPE, RPM_STRING_TYPE, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), rpmDigestUpdate(), RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, and RPMTAG_HEADERIMMUTABLE.
Referenced by rpmAddSignature().
|
static |
Generate PGP signature(s) for a header+payload file.
file | header+payload file name |
*sigTagp | signature tag |
*pktp | signature packet(s) |
*pktlenp | signature packet(s) length |
passPhrase | private key pass phrase |
Definition at line 395 of file signature.c.
References _, _free(), addMacro(), alloca(), D_, delMacro(), dosetenv(), errno, Fclose(), Ferror(), Fopen(), PGP_2, PGP_5, PGP_NOTDETECTED, PGP_UNKNOWN, pgpFreeDig(), pgpNewDig(), pgpPrtPkts(), rpmDetectPGPVersion(), RPMERR_EXEC, RPMERR_SIGGEN, rpmError, rpmExpand(), RPMMESS_DEBUG, rpmMessage, pgpDig_s::signature, stpcpy(), timedRead(), unsetenv(), and xmalloc().
Referenced by makeHDRSignature(), and rpmAddSignature().
|
inlinestatic |
Convert hex to binary nibble.
c | hex character |
Definition at line 1180 of file signature.c.
Referenced by verifyRSASignature().
Print package size.
fd | package file handle |
siglen | signature header size |
pad | signature padding |
datalen | length of header+payload |
Definition at line 118 of file signature.c.
References D_, Fileno(), RPMMESS_DEBUG, rpmMessage, RPMRC_FAIL, and RPMRC_OK.
Referenced by rpmReadSignature().
|
static |
Definition at line 1015 of file signature.c.
References RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTFOUND, RPMRC_NOTTRUSTED, and RPMRC_OK.
Referenced by verifyDSASignature(), verifyMD5Signature(), verifyRSASignature(), verifySHA1Signature(), and verifySizeSignature().
|
static |
Verify DSA signature.
ts | transaction set |
t | verbose success/failure text |
sha1ctx |
Definition at line 1392 of file signature.c.
References _, rpmop_s::count, pgpDig_s::g, pgpDigParams_s::hash, pgpDigParams_s::hash_algo, pgpDigParams_s::hashlen, pgpDig_s::hdrsha1ctx, pgpDig_s::hm, pgpDig_s::p, PGPHASHALGO_SHA1, pgpHexCvt(), PGPPUBKEYALGO_DSA, pgpDigParams_s::pubkey_algo, pgpDig_s::q, pgpDig_s::r, rpmDigestDup(), rpmDigestFinal(), rpmDigestUpdate(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), RPMSIGTAG_DSA, RPMSIGTAG_GPG, rpmswEnter(), rpmswExit(), RPMTS_OP_DIGEST, RPMTS_OP_SIGNATURE, rpmtsDig(), rpmtsFindPubkey(), rpmtsOp(), rpmtsSig(), rpmtsSiglen(), rpmtsSignature(), rpmtsSigtag(), pgpDig_s::s, pgpDig_s::sha1, pgpDig_s::sha1len, pgpDigParams_s::signhash16, pgpDigParams_s::signid, stpcpy(), pgpDigParams_s::version, and pgpDig_s::y.
Referenced by rpmVerifySignature().
|
static |
Definition at line 1069 of file signature.c.
References _, _free(), rpmop_s::count, pgpHexCvt(), rpmDigestDup(), rpmDigestFinal(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), rpmswEnter(), rpmswExit(), RPMTS_OP_DIGEST, rpmtsDig(), rpmtsOp(), rpmtsSig(), rpmtsSiglen(), and stpcpy().
Referenced by rpmVerifySignature().
|
static |
Verify RSA signature.
ts | transaction set |
t | verbose success/failure text |
md5ctx |
Definition at line 1201 of file signature.c.
References _, _free(), pgpDig_s::c, rpmop_s::count, pgpDigParams_s::hash, pgpDigParams_s::hash_algo, pgpDigParams_s::hashlen, pgpDig_s::hdrmd5ctx, pgpDig_s::md5, pgpDig_s::md5len, pgpDig_s::nbytes, nibble(), PGPHASHALGO_HAVAL_5_160, PGPHASHALGO_MD2, PGPHASHALGO_MD5, PGPHASHALGO_RIPEMD160, PGPHASHALGO_SHA1, PGPHASHALGO_SHA256, PGPHASHALGO_SHA384, PGPHASHALGO_SHA512, PGPHASHALGO_TIGER192, pgpHexCvt(), PGPPUBKEYALGO_RSA, PGPSIGTYPE_BINARY, pgpDigParams_s::pubkey_algo, rpmDigestDup(), rpmDigestFinal(), rpmDigestUpdate(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, rpmswEnter(), rpmswExit(), RPMTS_OP_DIGEST, RPMTS_OP_SIGNATURE, rpmtsDig(), rpmtsFindPubkey(), rpmtsOp(), rpmtsSig(), rpmtsSiglen(), rpmtsSignature(), rpmtsSigtag(), pgpDig_s::rsa_pk, pgpDig_s::rsahm, pgpDigParams_s::signhash16, pgpDigParams_s::signid, pgpDigParams_s::sigtype, stpcpy(), pgpDigParams_s::version, and xmalloc().
Referenced by rpmVerifySignature().
|
static |
Verify header immutable region SHA1 digest.
ts | transaction set |
t | verbose success/failure text |
sha1ctx |
Definition at line 1127 of file signature.c.
References _, _free(), rpmDigestDup(), rpmDigestFinal(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), rpmswEnter(), rpmswExit(), RPMTS_OP_DIGEST, rpmtsDig(), rpmtsOp(), rpmtsSig(), rpmtsSiglen(), and stpcpy().
Referenced by rpmVerifySignature().
Definition at line 1032 of file signature.c.
References _, pgpDig_s::nbytes, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_OK, rpmSigString(), rpmtsDig(), rpmtsSig(), and stpcpy().
Referenced by rpmVerifySignature().
|
static |
Definition at line 150 of file signature.c.
Referenced by makeHDRSignature(), and rpmReadSignature().