Libkleo

compliance.h
1/* -*- mode: c++; c-basic-offset:4 -*-
2 utils/compliance.h
3
4 This file is part of libkleopatra
5 SPDX-FileCopyrightText: 2022 g10 Code GmbH
6 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "kleo_export.h"
14
15#include <string>
16#include <string_view>
17#include <vector>
18
19class QPushButton;
20class QString;
21
22namespace GpgME
23{
24class Key;
25class UserID;
26}
27
28namespace Kleo::DeVSCompliance
29{
30
31/**
32 * Returns true, if compliance mode "de-vs" is configured for GnuPG.
33 * Note: It does not check whether the used GnuPG is actually compliant.
34 */
35KLEO_EXPORT bool isActive();
36
37/**
38 * Returns true, if compliance mode "de-vs" is configured for GnuPG and if
39 * GnuPG passes a basic compliance check, i.e. at least libgcrypt and the used
40 * RNG are compliant. Also returns true if compliance shall be assumed (e.g.
41 * for beta testing).
42 */
43KLEO_EXPORT bool isCompliant();
44
45/**
46 * Returns true, if compliance mode "de-vs" is configured for GnuPG and if
47 * compliance of GnuPG shall be assumed (e.g. for beta testing).
48 */
49KLEO_EXPORT bool isBetaCompliance();
50
51/**
52 * Returns true, if the given algorithm is compliant with compliance mode
53 * "de-vs". Always returns true, if compliance mode "de-vs" is not active.
54 */
55KLEO_EXPORT bool algorithmIsCompliant(std::string_view algo);
56
57/**
58 * Returns true, if all usable subkeys of the key \p key are compliant with
59 * compliance mode "de-vs". Usable subkeys are those that are neither revoked
60 * nor expired. If the key doesn't have any usable subkeys, then false is
61 * returned.
62 * Always returns true, if compliance mode "de-vs" is not active.
63 */
64KLEO_EXPORT bool allSubkeysAreCompliant(const GpgME::Key &key);
65
66/**
67 * Returns true, if the key \p key is compliant with compliance mode "de-vs".
68 * This function behaves like DeVSCompliance::keyIsCompliant, but only considers
69 * user id \p id; all other user ids are ignored.
70 * \see keyIsCompliant
71 */
72KLEO_EXPORT bool userIDIsCompliant(const GpgME::UserID &id);
73
74/**
75 * Returns true, if the key \p key is compliant with compliance mode "de-vs".
76 * A key is considered compliant if all usable subkeys are compliant and if
77 * all not revoked user IDs have at least full validity. The second condition
78 * requires that the key has been validated.
79 * Always returns true, if compliance mode "de-vs" is not active.
80 *
81 * \see allSubkeysAreCompliant
82 */
83KLEO_EXPORT bool keyIsCompliant(const GpgME::Key &key);
84
85/**
86 * Returns a static list of the available compliant algorithms.
87 */
88KLEO_EXPORT const std::vector<std::string> &compliantAlgorithms();
89
90/**
91 * Returns a static list of the preferred compliant algorithms with decreasing
92 * preference.
93 * Can be used to determine the default algorithm for generating new keys.
94 */
95KLEO_EXPORT const std::vector<std::string> &preferredCompliantAlgorithms();
96
97/**
98 * \overload
99 *
100 * Sets the appropriate icon and, unless high-contrast mode is active, the
101 * appropriate background color of \p button depending on the state of
102 * compliance.
103 */
104KLEO_EXPORT void decorate(QPushButton *button);
105
106/**
107 * Sets the appropriate icon and, unless high-contrast mode is active, the
108 * appropriate background color of \p button depending on the value of
109 * \p compliant.
110 */
111KLEO_EXPORT void decorate(QPushButton *button, bool compliant);
112
113/**
114 * \overload
115 *
116 * Returns a localized name for the compliance or non-compliance depending on
117 * the state of compliance.
118 */
119KLEO_EXPORT QString name();
120
121/**
122 * Returns a localized name for the compliance or non-compliance depending on
123 * the value of \p compliant.
124 *
125 * \note The localized name is taken from the de-vs-filter filter resp. the
126 * not-de-vs-filter. This allows the customization of the name for different
127 * users because VS-NfD compliance is called differently in different
128 * environments, e.g. NATO RESTRICTED or EU RESTRICTED.
129 */
130KLEO_EXPORT QString name(bool compliant);
131}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.