Add EVP_MAC_provider()
[openssl.git] / include / openssl / cmp.h
1 /*-
2  * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
3  * Copyright Nokia 2007-2019
4  * Copyright Siemens AG 2015-2019
5  *
6  * Licensed under the Apache License 2.0 (the "License").  You may not use
7  * this file except in compliance with the License.  You can obtain a copy
8  * in the file LICENSE in the source distribution or at
9  * https://www.openssl.org/source/license.html
10  *
11  * CMP (RFC 4210) implementation by M. Peylo, M. Viljanen, and D. von Oheimb.
12  */
13
14 #ifndef OSSL_HEADER_CMP_H
15 # define OSSL_HEADER_CMP_H
16
17 # include <openssl/opensslconf.h>
18 # ifndef OPENSSL_NO_CMP
19
20 #  include <openssl/crmf.h>
21 #  include <openssl/cmperr.h>
22
23 /* explicit #includes not strictly needed since implied by the above: */
24 #  include <openssl/ossl_typ.h>
25 #  include <openssl/safestack.h>
26 #  include <openssl/x509.h>
27 #  include <openssl/x509v3.h>
28
29 #  ifdef  __cplusplus
30 extern "C" {
31 #  endif
32
33 #  define OSSL_CMP_PVNO 2
34
35 /*-
36  *   PKIFailureInfo ::= BIT STRING {
37  *   -- since we can fail in more than one way!
38  *   -- More codes may be added in the future if/when required.
39  *       badAlg              (0),
40  *       -- unrecognized or unsupported Algorithm Identifier
41  *       badMessageCheck     (1),
42  *       -- integrity check failed (e.g., signature did not verify)
43  *       badRequest          (2),
44  *       -- transaction not permitted or supported
45  *       badTime             (3),
46  *       -- messageTime was not sufficiently close to the system time,
47  *       -- as defined by local policy
48  *       badCertId           (4),
49  *       -- no certificate could be found matching the provided criteria
50  *       badDataFormat       (5),
51  *       -- the data submitted has the wrong format
52  *       wrongAuthority      (6),
53  *       -- the authority indicated in the request is different from the
54  *       -- one creating the response token
55  *       incorrectData       (7),
56  *       -- the requester's data is incorrect (for notary services)
57  *       missingTimeStamp    (8),
58  *       -- when the timestamp is missing but should be there
59  *       -- (by policy)
60  *       badPOP              (9),
61  *       -- the proof-of-possession failed
62  *       certRevoked         (10),
63  *          -- the certificate has already been revoked
64  *       certConfirmed       (11),
65  *          -- the certificate has already been confirmed
66  *       wrongIntegrity      (12),
67  *          -- invalid integrity, password based instead of signature or
68  *          -- vice versa
69  *       badRecipientNonce   (13),
70  *          -- invalid recipient nonce, either missing or wrong value
71  *       timeNotAvailable    (14),
72  *          -- the TSA's time source is not available
73  *       unacceptedPolicy    (15),
74  *          -- the requested TSA policy is not supported by the TSA.
75  *       unacceptedExtension (16),
76  *          -- the requested extension is not supported by the TSA.
77  *       addInfoNotAvailable (17),
78  *          -- the additional information requested could not be
79  *          -- understood or is not available
80  *       badSenderNonce      (18),
81  *          -- invalid sender nonce, either missing or wrong size
82  *       badCertTemplate     (19),
83  *          -- invalid cert. template or missing mandatory information
84  *       signerNotTrusted    (20),
85  *          -- signer of the message unknown or not trusted
86  *       transactionIdInUse  (21),
87  *          -- the transaction identifier is already in use
88  *       unsupportedVersion  (22),
89  *          -- the version of the message is not supported
90  *       notAuthorized       (23),
91  *          -- the sender was not authorized to make the preceding
92  *          -- request or perform the preceding action
93  *       systemUnavail       (24),
94  *       -- the request cannot be handled due to system unavailability
95  *       systemFailure       (25),
96  *       -- the request cannot be handled due to system failure
97  *       duplicateCertReq    (26)
98  *       -- certificate cannot be issued because a duplicate
99  *       -- certificate already exists
100  *   }
101  */
102 #  define OSSL_CMP_PKIFAILUREINFO_badAlg 0
103 #  define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1
104 #  define OSSL_CMP_PKIFAILUREINFO_badRequest 2
105 #  define OSSL_CMP_PKIFAILUREINFO_badTime 3
106 #  define OSSL_CMP_PKIFAILUREINFO_badCertId 4
107 #  define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5
108 #  define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6
109 #  define OSSL_CMP_PKIFAILUREINFO_incorrectData 7
110 #  define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8
111 #  define OSSL_CMP_PKIFAILUREINFO_badPOP 9
112 #  define OSSL_CMP_PKIFAILUREINFO_certRevoked 10
113 #  define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11
114 #  define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12
115 #  define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13
116 #  define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14
117 #  define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15
118 #  define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16
119 #  define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17
120 #  define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18
121 #  define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19
122 #  define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20
123 #  define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21
124 #  define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22
125 #  define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23
126 #  define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24
127 #  define OSSL_CMP_PKIFAILUREINFO_systemFailure 25
128 #  define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26
129 #  define OSSL_CMP_PKIFAILUREINFO_MAX 26
130 #  define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN \
131     ( (1<<(OSSL_CMP_PKIFAILUREINFO_MAX+1)) - 1)
132 #  if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX
133 #   error  CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int
134 #  endif
135
136 typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO;
137
138 #  define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0)
139 #  define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1)
140 #  define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2)
141 #  define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3)
142 #  define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4)
143 #  define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5)
144 #  define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6)
145 #  define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7)
146 #  define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8)
147 #  define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9)
148 #  define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10)
149 #  define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11)
150 #  define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12)
151 #  define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13)
152 #  define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14)
153 #  define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15)
154 #  define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16)
155 #  define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17)
156 #  define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18)
157 #  define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19)
158 #  define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20)
159 #  define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21)
160 #  define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22)
161 #  define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23)
162 #  define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24)
163 #  define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25)
164 #  define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26)
165
166 /*-
167  *   PKIStatus ::= INTEGER {
168  *       accepted                (0),
169  *       -- you got exactly what you asked for
170  *       grantedWithMods        (1),
171  *       -- you got something like what you asked for; the
172  *       -- requester is responsible for ascertaining the differences
173  *       rejection              (2),
174  *       -- you don't get it, more information elsewhere in the message
175  *       waiting                (3),
176  *       -- the request body part has not yet been processed; expect to
177  *       -- hear more later (note: proper handling of this status
178  *       -- response MAY use the polling req/rep PKIMessages specified
179  *       -- in Section 5.3.22; alternatively, polling in the underlying
180  *       -- transport layer MAY have some utility in this regard)
181  *       revocationWarning      (4),
182  *       -- this message contains a warning that a revocation is
183  *       -- imminent
184  *       revocationNotification (5),
185  *       -- notification that a revocation has occurred
186  *       keyUpdateWarning       (6)
187  *       -- update already done for the oldCertId specified in
188  *       -- CertReqMsg
189  *   }
190  */
191 #  define OSSL_CMP_PKISTATUS_accepted 0
192 #  define OSSL_CMP_PKISTATUS_grantedWithMods 1
193 #  define OSSL_CMP_PKISTATUS_rejection 2
194 #  define OSSL_CMP_PKISTATUS_waiting 3
195 #  define OSSL_CMP_PKISTATUS_revocationWarning 4
196 #  define OSSL_CMP_PKISTATUS_revocationNotification 5
197 #  define OSSL_CMP_PKISTATUS_keyUpdateWarning 6
198
199 typedef ASN1_INTEGER OSSL_CMP_PKISTATUS;
200 DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS)
201
202 #  define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0
203 #  define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1
204
205 /* data type declarations */
206 typedef struct OSSL_cmp_ctx_st OSSL_CMP_CTX;
207 typedef struct OSSL_cmp_pkiheader_st OSSL_CMP_PKIHEADER;
208 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
209 typedef struct OSSL_cmp_msg_st OSSL_CMP_MSG;
210 DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG)
211 typedef struct OSSL_cmp_certstatus_st OSSL_CMP_CERTSTATUS;
212 DEFINE_STACK_OF(OSSL_CMP_CERTSTATUS)
213 typedef struct OSSL_cmp_itav_st OSSL_CMP_ITAV;
214 DEFINE_STACK_OF(OSSL_CMP_ITAV)
215 typedef struct OSSL_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT;
216 typedef struct OSSL_cmp_pkisi_st OSSL_CMP_PKISI;
217 DEFINE_STACK_OF(OSSL_CMP_PKISI)
218 typedef struct OSSL_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE;
219 DEFINE_STACK_OF(OSSL_CMP_CERTREPMESSAGE)
220 typedef struct OSSL_cmp_pollrep_st OSSL_CMP_POLLREP;
221 typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT;
222 typedef struct OSSL_cmp_certresponse_st OSSL_CMP_CERTRESPONSE;
223 DEFINE_STACK_OF(OSSL_CMP_CERTRESPONSE)
224 typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT;
225
226 /* from cmp_asn.c */
227 OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
228 void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
229                         ASN1_TYPE *value);
230 ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
231 ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
232 int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
233                                    OSSL_CMP_ITAV *itav);
234 void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav);
235 void OSSL_CMP_MSG_free(OSSL_CMP_MSG *msg);
236 void OSSL_CMP_PKISI_free(OSSL_CMP_PKISI *si);
237 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
238
239 #   ifdef  __cplusplus
240 }
241 #   endif
242 # endif /* !defined OPENSSL_NO_CMP */
243 #endif /* !defined OSSL_HEADER_CMP_H */