1996-09-29 10:29:09 +08:00
|
|
|
#ifndef H_SIGNATURE
|
1998-07-25 23:10:58 +08:00
|
|
|
#define H_SIGNATURE
|
1996-09-29 10:29:09 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
|
|
|
* \file lib/signature.h
|
2000-08-28 03:27:03 +08:00
|
|
|
* Generate and verify signatures.
|
|
|
|
*/
|
1996-02-19 10:32:11 +08:00
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#include <header.h>
|
|
|
|
|
2001-02-13 00:33:08 +08:00
|
|
|
/** \ingroup signature
|
|
|
|
* Signature types stored in rpm lead.
|
|
|
|
*/
|
|
|
|
typedef enum sigType_e {
|
2002-09-01 06:39:34 +08:00
|
|
|
RPMSIGTYPE_HEADERSIG= 5 /*!< Header style signature */
|
2001-02-13 00:33:08 +08:00
|
|
|
} sigType;
|
|
|
|
|
|
|
|
/** \ingroup signature
|
|
|
|
* Identify PGP versions.
|
|
|
|
* @note Greater than 0 is a valid PGP version.
|
|
|
|
*/
|
|
|
|
typedef enum pgpVersion_e {
|
|
|
|
PGP_NOTDETECTED = -1,
|
|
|
|
PGP_UNKNOWN = 0,
|
|
|
|
PGP_2 = 2,
|
|
|
|
PGP_5 = 5
|
|
|
|
} pgpVersion;
|
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
1996-07-08 06:19:32 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
|
|
|
* Return new, empty (signature) header instance.
|
2001-02-13 00:33:08 +08:00
|
|
|
* @return signature header
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2001-10-15 11:22:10 +08:00
|
|
|
Header rpmNewSignature(void)
|
|
|
|
/*@*/;
|
1996-07-08 06:19:32 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
2002-03-07 07:17:31 +08:00
|
|
|
* Read (and verify header+payload size) signature header.
|
2000-08-28 09:08:57 +08:00
|
|
|
* If an old-style signature is found, we emulate a new style one.
|
|
|
|
* @param fd file handle
|
2002-09-01 06:39:34 +08:00
|
|
|
* @retval sighp address of (signature) header (or NULL)
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param sig_type type of signature header to read (from lead)
|
2002-09-17 04:10:20 +08:00
|
|
|
* @retval msg failure msg
|
2001-02-13 03:02:15 +08:00
|
|
|
* @return rpmRC return code
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2002-09-01 06:39:34 +08:00
|
|
|
rpmRC rpmReadSignature(FD_t fd, /*@null@*/ /*@out@*/ Header *sighp,
|
2002-09-17 23:21:03 +08:00
|
|
|
sigType sig_type, /*@null@*/ /*@out@*/ const char ** msg)
|
2001-10-20 03:51:18 +08:00
|
|
|
/*@globals fileSystem @*/
|
2002-09-17 23:21:03 +08:00
|
|
|
/*@modifies fd, *sighp, *msg, fileSystem @*/;
|
2000-08-28 09:08:57 +08:00
|
|
|
|
|
|
|
/** \ingroup signature
|
|
|
|
* Write signature header.
|
|
|
|
* @param fd file handle
|
2001-05-04 05:00:18 +08:00
|
|
|
* @param h (signature) header
|
2000-08-28 09:08:57 +08:00
|
|
|
* @return 0 on success, 1 on error
|
|
|
|
*/
|
2001-05-04 05:00:18 +08:00
|
|
|
int rpmWriteSignature(FD_t fd, Header h)
|
2001-10-20 03:51:18 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fd, h, fileSystem @*/;
|
1996-02-19 10:32:11 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
2002-03-07 07:17:31 +08:00
|
|
|
* Generate signature(s) from a header+payload file, save in signature header.
|
2005-03-12 23:16:42 +08:00
|
|
|
* @param sigh signature header
|
2002-03-07 07:17:31 +08:00
|
|
|
* @param file header+payload file name
|
|
|
|
* @param sigTag type of signature(s) to add
|
|
|
|
* @param passPhrase private key pass phrase
|
|
|
|
* @return 0 on success, -1 on failure
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2005-03-12 23:16:42 +08:00
|
|
|
int rpmAddSignature(Header sigh, const char * file,
|
2001-05-04 05:00:18 +08:00
|
|
|
int_32 sigTag, /*@null@*/ const char * passPhrase)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2005-03-12 23:16:42 +08:00
|
|
|
/*@modifies sigh, rpmGlobalMacroContext, fileSystem, internalState @*/;
|
1996-07-08 06:19:32 +08:00
|
|
|
|
|
|
|
/******************************************************************/
|
1996-02-19 10:32:11 +08:00
|
|
|
|
2002-03-07 07:17:31 +08:00
|
|
|
/**
|
|
|
|
* Possible actions for rpmLookupSignatureType()
|
|
|
|
*/
|
2004-10-20 18:19:34 +08:00
|
|
|
#define RPMLOOKUPSIG_QUERY 0 /* Lookup type in effect */
|
|
|
|
#define RPMLOOKUPSIG_DISABLE 1 /* Disable (--sign was not given) */
|
|
|
|
#define RPMLOOKUPSIG_ENABLE 2 /* Re-enable %_signature */
|
1999-03-23 01:31:53 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
2002-03-07 07:17:31 +08:00
|
|
|
* Return type of signature needed for signing/building.
|
|
|
|
* @param action enable/disable/query action
|
|
|
|
* @return sigTag to use, 0 if none, -1 on error
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2001-05-04 05:00:18 +08:00
|
|
|
int rpmLookupSignatureType(int action)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
|
2001-10-20 03:51:18 +08:00
|
|
|
/*@modifies rpmGlobalMacroContext, internalState @*/;
|
1996-02-20 23:06:47 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
2002-03-07 07:17:31 +08:00
|
|
|
* Read a pass phrase using getpass(3), confirm with gpg/pgp helper binaries.
|
|
|
|
* @param prompt user prompt
|
|
|
|
* @param sigTag signature type/tag
|
|
|
|
* @return pass phrase
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@dependent@*/ /*@null@*/
|
|
|
|
char * rpmGetPassPhrase(/*@null@*/ const char * prompt,
|
2002-03-07 07:17:31 +08:00
|
|
|
const int sigTag)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2002-03-11 03:00:31 +08:00
|
|
|
/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
|
1999-09-11 07:48:56 +08:00
|
|
|
|
2000-08-28 09:08:57 +08:00
|
|
|
/** \ingroup signature
|
2002-03-07 07:17:31 +08:00
|
|
|
* Return path to pgp executable of given type, or NULL when not found.
|
|
|
|
* @retval pgpVer pgp version
|
|
|
|
* @return path to pgp executable
|
2000-08-28 09:08:57 +08:00
|
|
|
*/
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-exportlocal -redecl@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@null@*/ const char * rpmDetectPGPVersion(
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@null@*/ /*@out@*/ pgpVersion * pgpVer)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno @*/
|
2001-10-20 03:51:18 +08:00
|
|
|
/*@modifies *pgpVer, rpmGlobalMacroContext @*/;
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=exportlocal =redecl@*/
|
1999-03-22 02:43:22 +08:00
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-25 23:10:58 +08:00
|
|
|
#endif /* H_SIGNATURE */
|