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.
40 */
41KLEO_EXPORT bool isCompliant();
42
43/**
44 * Returns true, if the given algorithm is compliant with compliance mode
45 * "de-vs". Always returns true, if compliance mode "de-vs" is not active.
46 */
47KLEO_EXPORT bool algorithmIsCompliant(std::string_view algo);
48
49/**
50 * Returns true, if all usable subkeys of the key \p key are compliant with
51 * compliance mode "de-vs". Usable subkeys are those that are neither revoked
52 * nor expired. If the key doesn't have any usable subkeys, then false is
53 * returned.
54 * Always returns true, if compliance mode "de-vs" is not active.
55 */
56KLEO_EXPORT bool allSubkeysAreCompliant(const GpgME::Key &key);
57
58/**
59 * Returns true, if the key \p key is compliant with compliance mode "de-vs".
60 * This function behaves like DeVSCompliance::keyIsCompliant, but only considers
61 * user id \p id; all other user ids are ignored.
62 * \see keyIsCompliant
63 */
64bool userIDIsCompliant(const GpgME::UserID &id);
65
66/**
67 * Returns true, if the key \p key is compliant with compliance mode "de-vs".
68 * A key is considered compliant if all usable subkeys are compliant and if
69 * all not revoked user IDs have at least full validity. The second condition
70 * requires that the key has been validated.
71 * Always returns true, if compliance mode "de-vs" is not active.
72 *
73 * \see allSubkeysAreCompliant
74 */
75KLEO_EXPORT bool keyIsCompliant(const GpgME::Key &key);
76
77/**
78 * Returns a static list of the available compliant algorithms.
79 */
80KLEO_EXPORT const std::vector<std::string> &compliantAlgorithms();
81
82/**
83 * Returns a static list of the preferred compliant algorithms with decreasing
84 * preference.
85 * Can be used to determine the default algorithm for generating new keys.
86 */
87KLEO_EXPORT const std::vector<std::string> &preferredCompliantAlgorithms();
88
89/**
90 * \overload
91 *
92 * Sets the appropriate icon and, unless high-contrast mode is active, the
93 * appropriate background color of \p button depending on the state of
94 * compliance.
95 */
96KLEO_EXPORT void decorate(QPushButton *button);
97
98/**
99 * Sets the appropriate icon and, unless high-contrast mode is active, the
100 * appropriate background color of \p button depending on the value of
101 * \p compliant.
102 */
103KLEO_EXPORT void decorate(QPushButton *button, bool compliant);
104
105/**
106 * \overload
107 *
108 * Returns a localized name for the compliance or non-compliance depending on
109 * the state of compliance.
110 */
111KLEO_EXPORT QString name();
112
113/**
114 * Returns a localized name for the compliance or non-compliance depending on
115 * the value of \p compliant.
116 *
117 * \note The localized name is taken from the de-vs-filter filter resp. the
118 * not-de-vs-filter. This allows the customization of the name for different
119 * users because VS-NfD compliance is called differently in different
120 * environments, e.g. NATO RESTRICTED or EU RESTRICTED.
121 */
122KLEO_EXPORT QString name(bool compliant);
123}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.