Libkleo

gnupg.h
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  utils/gnupg.h
3 
4  This file is part of Kleopatra, the KDE keymanager
5  SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
6  SPDX-FileCopyrightText: 2020-2022 g10 Code GmbH
7  SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
8 
9  SPDX-License-Identifier: GPL-2.0-or-later
10 */
11 
12 #pragma once
13 
14 #include "kleo_export.h"
15 
16 #include <QStringList>
17 
18 #include <gpgme++/engineinfo.h>
19 #include <gpgme++/key.h>
20 
21 class QString;
22 class QByteArray;
23 
24 namespace Kleo
25 {
26 
27 KLEO_EXPORT QString gnupgHomeDirectory();
28 KLEO_EXPORT QString gnupgPrivateKeysDirectory();
29 
30 KLEO_EXPORT QString gpgConfPath();
31 KLEO_EXPORT QString gpgSmPath();
32 KLEO_EXPORT QString gpgPath();
33 
34 KLEO_EXPORT QString gpgConfListDir(const char *which);
35 KLEO_EXPORT QString gpg4winInstallPath();
36 KLEO_EXPORT QString gnupgInstallPath();
37 KLEO_EXPORT const QString &paperKeyInstallPath();
38 
39 /**
40  * Verify \p filePath using gpgv. If \p sigPath is provided it uses
41  * this signature, otherwise it adds .sig to the \p filePath. If
42  * \p keyring is provided that is the keyring where the signature is
43  * checked against. Otherwise it uses the default of gpgv.
44  * \p additionalSearchPaths can be used to specify where gpgv is
45  * searched for first.
46  *
47  * Blocks until the verification is done which can be indefinetly to
48  * allow for very large files.
49  *
50  * Returns true if the verification was successful, false if any problem
51  * occured. */
52 KLEO_EXPORT bool gpgvVerify(const QString &filePath, const QString &sigPath = {}, const QString &keyring = {}, const QStringList &additionalSearchPaths = {});
53 
54 /**
55  * Returns a list of filename globs of files in one of the whitelisted folders
56  * to watch for changes.
57  * \sa gnupgFolderWhitelist, Kleo::FileSystemWatcher
58  */
59 KLEO_EXPORT QStringList gnupgFileWhitelist();
60 /**
61  * Returns a list of absolute paths of folders to watch for changes.
62  * \sa gnupgFileWhitelist, Kleo::FileSystemWatcher
63  */
64 KLEO_EXPORT QStringList gnupgFolderWhitelist();
65 KLEO_EXPORT int makeGnuPGError(int code);
66 
67 KLEO_EXPORT bool engineIsVersion(int major, int minor, int patch, GpgME::Engine = GpgME::GpgConfEngine);
68 
69 /** Returns true, if GnuPG knows which keyserver to use for keyserver
70  * operations.
71  *
72  * Since GnuPG 2.2.42/2.4.4 dirmngr supports the special value "none"
73  * to disable usage of the default keyserver. If this value is configured
74  * and GnuPG is new enough then this function returns false.
75  * Since version 2.1.19 GnuPG has a builtin default keyserver, so that this
76  * function always returns true (unless the above applies).
77  * For older versions of GnuPG it checks if a keyserver has been configured.
78  */
79 KLEO_EXPORT bool haveKeyserverConfigured();
80 
81 /** Returns the configured keyserver or an empty string if no keyserver is
82  * configured. The special value "none" indicates that no keyserver shall
83  * be used.
84  *
85  * Note: Since GnuPG 2.1.19 gpg/dirmngr uses a default keyserver if no
86  * keyserver is configured.
87  * Since GnuPG 2.2.42/2.4.4 dirmngr supports the special value "none"
88  * to disable usage of the default keyserver.
89  */
90 KLEO_EXPORT QString keyserver();
91 
92 /** Returns true, if GnuPG knows which server to use for directory service
93  * operations for X.509 certificates.
94  */
95 KLEO_EXPORT bool haveX509DirectoryServerConfigured();
96 
97 /* Use gnupgUsesDeVsCompliance() or gnupgIsDeVsCompliant() instead. */
98 KLEO_DEPRECATED_EXPORT bool gpgComplianceP(const char *mode);
99 
100 /**
101  * Use Kleo::DeVSCompliance::isActive() instead.
102  */
103 KLEO_DEPRECATED_EXPORT bool gnupgUsesDeVsCompliance();
104 
105 /**
106  * Use Kleo::DeVSCompliance::isCompliant() instead.
107  */
108 KLEO_DEPRECATED_EXPORT bool gnupgIsDeVsCompliant();
109 
110 /* Convert GnuPG output to a QString with proper encoding.
111  * Takes Gpg Quirks into account and might handle future
112  * changes in GnuPG Output. */
113 KLEO_EXPORT QString stringFromGpgOutput(const QByteArray &ba);
114 
115 /* Check if a minimum version is there. Strings should be in the format:
116  * 1.2.3 */
117 KLEO_EXPORT bool versionIsAtLeast(const char *minimum, const char *actual);
118 
119 /** Returns a list of component names (e.g. GnuPG, libgcrypt) followed by
120  * version numbers. This is meant for displaying in the About dialog.
121  */
122 KLEO_EXPORT QStringList backendVersionInfo();
123 
124 /** Launch the GnuPG agent if it is not already running. */
125 KLEO_EXPORT void launchGpgAgent();
126 
127 /** Shut down all GnuPG daemons. They will be restarted automatically when
128  * needed.
129  */
130 KLEO_EXPORT void killDaemons();
131 
132 /**
133  * Returns a static list of the available algorithms.
134  */
135 KLEO_EXPORT const std::vector<std::string> &availableAlgorithms();
136 
137 /**
138  * Returns a static list of the preferred algorithms with decreasing preference.
139  */
140 KLEO_EXPORT const std::vector<std::string> &preferredAlgorithms();
141 
142 /**
143  * Returns a static list of algorithms that are explicitly not supported.
144  */
145 KLEO_EXPORT const std::vector<std::string> &ignoredAlgorithms();
146 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:56:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.