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

KDE's Doxygen guidelines are available online.