Imported Upstream version 2.2.1
[platform/upstream/gpg2.git] / common / compliance.h
1 /* compliance.h - Definitions for compliance modi
2  * Copyright (C) 2017 g10 Code GmbH
3  * Copyright (C) 2017 Bundesamt für Sicherheit in der Informationstechnik
4  *
5  * This file is part of GnuPG.
6  *
7  * This file is free software; you can redistribute it and/or modify
8  * it under the terms of either
9  *
10  *   - the GNU Lesser General Public License as published by the Free
11  *     Software Foundation; either version 3 of the License, or (at
12  *     your option) any later version.
13  *
14  * or
15  *
16  *   - the GNU General Public License as published by the Free
17  *     Software Foundation; either version 2 of the License, or (at
18  *     your option) any later version.
19  *
20  * or both in parallel, as here.
21  *
22  * This file is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, see <https://www.gnu.org/licenses/>.
29  */
30
31 #ifndef GNUPG_COMMON_COMPLIANCE_H
32 #define GNUPG_COMMON_COMPLIANCE_H
33
34 #include <gcrypt.h>
35 #include "openpgpdefs.h"
36
37 void gnupg_initialize_compliance (int gnupg_module_name);
38
39 enum gnupg_compliance_mode
40   {
41     CO_GNUPG, CO_RFC4880, CO_RFC2440,
42     CO_PGP6, CO_PGP7, CO_PGP8, CO_DE_VS
43   };
44
45 enum pk_use_case
46   {
47     PK_USE_ENCRYPTION, PK_USE_DECRYPTION,
48     PK_USE_SIGNING, PK_USE_VERIFICATION,
49   };
50
51 int gnupg_pk_is_compliant (enum gnupg_compliance_mode compliance, int algo,
52                            gcry_mpi_t key[], unsigned int keylength,
53                            const char *curvename);
54 int gnupg_pk_is_allowed (enum gnupg_compliance_mode compliance,
55                          enum pk_use_case use, int algo, gcry_mpi_t key[],
56                          unsigned int keylength, const char *curvename);
57 int gnupg_cipher_is_compliant (enum gnupg_compliance_mode compliance,
58                                cipher_algo_t cipher,
59                                enum gcry_cipher_modes mode);
60 int gnupg_cipher_is_allowed (enum gnupg_compliance_mode compliance,
61                              int producer,
62                              cipher_algo_t cipher,
63                              enum gcry_cipher_modes mode);
64 int gnupg_digest_is_compliant (enum gnupg_compliance_mode compliance,
65                                digest_algo_t digest);
66 int gnupg_digest_is_allowed (enum gnupg_compliance_mode compliance,
67                              int producer,
68                              digest_algo_t digest);
69 int gnupg_rng_is_compliant (enum gnupg_compliance_mode compliance);
70
71 const char *gnupg_status_compliance_flag (enum gnupg_compliance_mode
72                                           compliance);
73
74 struct gnupg_compliance_option
75 {
76   const char *keyword;
77   int value;
78 };
79
80 int gnupg_parse_compliance_option (const char *string,
81                                    struct gnupg_compliance_option options[],
82                                    size_t length,
83                                    int quiet);
84 const char *gnupg_compliance_option_string (enum gnupg_compliance_mode
85                                             compliance);
86
87
88 #endif /*GNUPG_COMMON_COMPLIANCE_H*/