]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/gpgv.h
* apt-pkg/sourcelist.cc:
[apt.git] / apt-pkg / contrib / gpgv.h
CommitLineData
2f5b6151
DK
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Helpers to deal with gpgv better and more easily
6
7 ##################################################################### */
8 /*}}}*/
9#ifndef CONTRIB_GPGV_H
10#define CONTRIB_GPGV_H
11
12#include <string>
2d3fe9cf 13#include <vector>
2f5b6151 14
f1828b69
DK
15#include <apt-pkg/fileutl.h>
16
99ed26d3
DK
17#if __GNUC__ >= 4
18 #define APT_noreturn __attribute__ ((noreturn))
19#else
20 #define APT_noreturn /* no support */
21#endif
2f5b6151 22
99ed26d3
DK
23/** \brief generates and run the command to verify a file with gpgv
24 *
25 * If File and FileSig specify the same file it is assumed that we
2d3fe9cf
DK
26 * deal with a clear-signed message. In that case the file will be
27 * rewritten to be in a good-known format without uneeded whitespaces
28 * and additional messages (unsigned or signed).
99ed26d3
DK
29 *
30 * @param File is the message (unsigned or clear-signed)
31 * @param FileSig is the signature (detached or clear-signed)
32 */
33void ExecGPGV(std::string const &File, std::string const &FileSig,
34 int const &statusfd, int fd[2]) APT_noreturn;
35inline void ExecGPGV(std::string const &File, std::string const &FileSig,
2f5b6151
DK
36 int const &statusfd = -1) {
37 int fd[2];
99ed26d3
DK
38 ExecGPGV(File, FileSig, statusfd, fd);
39};
40
41#undef APT_noreturn
2f5b6151 42
2d3fe9cf
DK
43/** \brief Split an inline signature into message and signature
44 *
45 * Takes a clear-signed message and puts the first signed message
46 * in the content file and all signatures following it into the
47 * second. Unsigned messages, additional messages as well as
48 * whitespaces are discarded. The resulting files are suitable to
49 * be checked with gpgv.
50 *
b408e4ad
DK
51 * If a FileFd pointers is NULL it will not be used and the content
52 * which would have been written to it is silently discarded.
2d3fe9cf 53 *
f1828b69
DK
54 * The content of the split files is undefined if the splitting was
55 * unsuccessful.
56 *
57 * Note that trying to split an unsigned file will fail, but
58 * not generate an error message.
59 *
2d3fe9cf 60 * @param InFile is the clear-signed file
b408e4ad 61 * @param ContentFile is the FileFd the message will be written to
2d3fe9cf 62 * @param ContentHeader is a list of all required Amored Headers for the message
b408e4ad 63 * @param SignatureFile is the FileFd all signatures will be written to
f1828b69 64 * @return true if the splitting was successful, false otherwise
2d3fe9cf 65 */
b408e4ad
DK
66bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
67 std::vector<std::string> * const ContentHeader, FileFd * const SignatureFile);
2d3fe9cf 68
f1828b69
DK
69/** \brief open a file which might be clear-signed
70 *
71 * This method tries to extract the (signed) message of a file.
72 * If the file isn't signed it will just open the given filename.
73 * Otherwise the message is extracted to a temporary file which
74 * will be opened instead.
75 *
76 * @param ClearSignedFileName is the name of the file to open
77 * @param[out] MessageFile is the FileFd in which the file will be opened
78 * @return true if opening was successful, otherwise false
79 */
80bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &MessageFile);
81
2f5b6151 82#endif