]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/gpgv.h
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Helpers to deal with gpgv better and more easily
7 ##################################################################### */
10 #define CONTRIB_GPGV_H
16 #define APT_noreturn __attribute__ ((noreturn))
18 #define APT_noreturn /* no support */
21 /** \brief generates and run the command to verify a file with gpgv
23 * If File and FileSig specify the same file it is assumed that we
24 * deal with a clear-signed message. In that case the file will be
25 * rewritten to be in a good-known format without uneeded whitespaces
26 * and additional messages (unsigned or signed).
28 * @param File is the message (unsigned or clear-signed)
29 * @param FileSig is the signature (detached or clear-signed)
31 void ExecGPGV(std::string
const &File
, std::string
const &FileSig
,
32 int const &statusfd
, int fd
[2]) APT_noreturn
;
33 inline void ExecGPGV(std::string
const &File
, std::string
const &FileSig
,
34 int const &statusfd
= -1) {
36 ExecGPGV(File
, FileSig
, statusfd
, fd
);
41 /** \brief Split an inline signature into message and signature
43 * Takes a clear-signed message and puts the first signed message
44 * in the content file and all signatures following it into the
45 * second. Unsigned messages, additional messages as well as
46 * whitespaces are discarded. The resulting files are suitable to
47 * be checked with gpgv.
49 * If one or all Fds are -1 they will not be used and the content
50 * which would have been written to them is discarded.
52 * The code doesn't support dash-encoded lines as these are not
53 * expected to be present in files we have to deal with.
55 * @param InFile is the clear-signed file
56 * @param ContentFile is the Fd the message will be written to
57 * @param ContentHeader is a list of all required Amored Headers for the message
58 * @param SignatureFile is the Fd all signatures will be written to
60 bool SplitClearSignedFile(std::string
const &InFile
, int const ContentFile
,
61 std::vector
<std::string
> * const ContentHeader
, int const SignatureFile
);
63 /** \brief recombines message and signature to an inline signature
65 * Reverses the splitting down by #SplitClearSignedFile by writing
66 * a well-formed clear-signed message without unsigned messages,
67 * additional signed messages or just trailing whitespaces
69 * @param OutFile will be clear-signed file
70 * @param ContentFile is the Fd the message will be read from
71 * @param ContentHeader is a list of all required Amored Headers for the message
72 * @param SignatureFile is the Fd all signatures will be read from
74 bool RecombineToClearSignedFile(std::string
const &OutFile
, int const ContentFile
,
75 std::vector
<std::string
> const &ContentHeader
, int const SignatureFile
);