5 * \file lib/signature.h
6 * Generate and verify signatures.
9 #include <rpm/header.h>
11 /** \ingroup signature
12 * Signature types stored in rpm lead.
14 typedef enum sigType_e {
15 RPMSIGTYPE_HEADERSIG= 5 /*!< Header style signature */
22 /** \ingroup signature
23 * Return new, empty (signature) header instance.
24 * @return signature header
26 Header rpmNewSignature(void);
28 /** \ingroup signature
29 * Read (and verify header+payload size) signature header.
30 * If an old-style signature is found, we emulate a new style one.
31 * @param fd file handle
32 * @retval sighp address of (signature) header (or NULL)
33 * @param sig_type type of signature header to read (from lead)
34 * @retval msg failure msg
35 * @return rpmRC return code
37 rpmRC rpmReadSignature(FD_t fd, Header *sighp, sigType sig_type, char ** msg);
39 /** \ingroup signature
40 * Write signature header.
41 * @param fd file handle
42 * @param h (signature) header
43 * @return 0 on success, 1 on error
45 int rpmWriteSignature(FD_t fd, Header h);
47 /** \ingroup signature
48 * Generate digest(s) from a header+payload file, save in signature header.
49 * @param sigh signature header
50 * @param file header+payload file name
51 * @param sigTag type of digest(s) to add
52 * @return 0 on success, -1 on failure
54 int rpmGenDigest(Header sigh, const char * file, rpmTagVal sigTag);
56 /** \ingroup signature
57 * Verify a signature from a package.
59 * @param keyring keyring handle
60 * @param sigtd signature tag data container
61 * @param sig signature/pubkey parameters
62 * @retval result detailed text result of signature verification
64 * @return result of signature verification
66 rpmRC rpmVerifySignature(rpmKeyring keyring, rpmtd sigtd, pgpDigParams sig,
67 DIGEST_CTX ctx, char ** result);
69 /** \ingroup signature
70 * Destroy signature header from package.
71 * @param h signature header
74 Header rpmFreeSignature(Header h);
76 /* Dumb wrapper around pgpPrtParams() to log some error messages on failure */
78 int parsePGPSig(rpmtd sigtd, const char *type, const char *fn,
85 #endif /* H_SIGNATURE */