1 /*
2 * Copyright 2007-2023 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
12 #include <openssl/asn1t.h>
13
14 #include "cmp_local.h"
15
16 /* explicit #includes not strictly needed since implied by the above: */
17 #include <openssl/cmp.h>
18 #include <openssl/crmf.h>
19
20 /* ASN.1 declarations from RFC4210 */
21 ASN1_SEQUENCE(OSSL_CMP_REVANNCONTENT) = {
22 /* OSSL_CMP_PKISTATUS is effectively ASN1_INTEGER so it is used directly */
23 ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, status, ASN1_INTEGER),
24 ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, certId, OSSL_CRMF_CERTID),
25 ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, willBeRevokedAt, ASN1_GENERALIZEDTIME),
26 ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, badSinceDate, ASN1_GENERALIZEDTIME),
27 ASN1_OPT(OSSL_CMP_REVANNCONTENT, crlDetails, X509_EXTENSIONS)
28 } ASN1_SEQUENCE_END(OSSL_CMP_REVANNCONTENT)
29 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
30
31
32 ASN1_SEQUENCE(OSSL_CMP_CHALLENGE) = {
33 ASN1_OPT(OSSL_CMP_CHALLENGE, owf, X509_ALGOR),
34 ASN1_SIMPLE(OSSL_CMP_CHALLENGE, witness, ASN1_OCTET_STRING),
35 ASN1_SIMPLE(OSSL_CMP_CHALLENGE, challenge, ASN1_OCTET_STRING)
36 } ASN1_SEQUENCE_END(OSSL_CMP_CHALLENGE)
37 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
38
39
40 ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYCHALLCONTENT) =
41 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
42 OSSL_CMP_POPODECKEYCHALLCONTENT, OSSL_CMP_CHALLENGE)
43 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYCHALLCONTENT)
44
45
46 ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYRESPCONTENT) =
47 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
48 OSSL_CMP_POPODECKEYRESPCONTENT, ASN1_INTEGER)
49 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYRESPCONTENT)
50
51
52 ASN1_SEQUENCE(OSSL_CMP_CAKEYUPDANNCONTENT) = {
53 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
54 ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, oldWithNew, X509),
55 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
56 ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithOld, X509),
57 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
58 ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithNew, X509)
59 } ASN1_SEQUENCE_END(OSSL_CMP_CAKEYUPDANNCONTENT)
60 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
61
62
63 ASN1_SEQUENCE(OSSL_CMP_ERRORMSGCONTENT) = {
64 ASN1_SIMPLE(OSSL_CMP_ERRORMSGCONTENT, pKIStatusInfo, OSSL_CMP_PKISI),
65 ASN1_OPT(OSSL_CMP_ERRORMSGCONTENT, errorCode, ASN1_INTEGER),
66 /*
67 * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
68 * so it is used directly
69 *
70 */
71 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ERRORMSGCONTENT, errorDetails,
72 ASN1_UTF8STRING)
73 } ASN1_SEQUENCE_END(OSSL_CMP_ERRORMSGCONTENT)
74 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
75
76 ASN1_ADB_TEMPLATE(infotypeandvalue_default) = ASN1_OPT(OSSL_CMP_ITAV,
77 infoValue.other,
78 ASN1_ANY);
79 /* ITAV means InfoTypeAndValue */
80 ASN1_ADB(OSSL_CMP_ITAV) = {
81 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
82 ADB_ENTRY(NID_id_it_caProtEncCert, ASN1_OPT(OSSL_CMP_ITAV,
83 infoValue.caProtEncCert, X509)),
84 ADB_ENTRY(NID_id_it_signKeyPairTypes,
85 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
86 infoValue.signKeyPairTypes, X509_ALGOR)),
87 ADB_ENTRY(NID_id_it_encKeyPairTypes,
88 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
89 infoValue.encKeyPairTypes, X509_ALGOR)),
90 ADB_ENTRY(NID_id_it_preferredSymmAlg,
91 ASN1_OPT(OSSL_CMP_ITAV, infoValue.preferredSymmAlg,
92 X509_ALGOR)),
93 ADB_ENTRY(NID_id_it_caKeyUpdateInfo,
94 ASN1_OPT(OSSL_CMP_ITAV, infoValue.caKeyUpdateInfo,
95 OSSL_CMP_CAKEYUPDANNCONTENT)),
96 ADB_ENTRY(NID_id_it_currentCRL,
97 ASN1_OPT(OSSL_CMP_ITAV, infoValue.currentCRL, X509_CRL)),
98 ADB_ENTRY(NID_id_it_unsupportedOIDs,
99 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
100 infoValue.unsupportedOIDs, ASN1_OBJECT)),
101 ADB_ENTRY(NID_id_it_keyPairParamReq,
102 ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamReq,
103 ASN1_OBJECT)),
104 ADB_ENTRY(NID_id_it_keyPairParamRep,
105 ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamRep,
106 X509_ALGOR)),
107 ADB_ENTRY(NID_id_it_revPassphrase,
108 ASN1_OPT(OSSL_CMP_ITAV, infoValue.revPassphrase,
109 OSSL_CRMF_ENCRYPTEDVALUE)),
110 ADB_ENTRY(NID_id_it_implicitConfirm,
111 ASN1_OPT(OSSL_CMP_ITAV, infoValue.implicitConfirm,
112 ASN1_NULL)),
113 ADB_ENTRY(NID_id_it_confirmWaitTime,
114 ASN1_OPT(OSSL_CMP_ITAV, infoValue.confirmWaitTime,
115 ASN1_GENERALIZEDTIME)),
116 ADB_ENTRY(NID_id_it_origPKIMessage,
117 ASN1_OPT(OSSL_CMP_ITAV, infoValue.origPKIMessage,
118 OSSL_CMP_MSGS)),
119 ADB_ENTRY(NID_id_it_suppLangTags,
120 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, infoValue.suppLangTagsValue,
121 ASN1_UTF8STRING)),
122 } ASN1_ADB_END(OSSL_CMP_ITAV, 0, infoType, 0,
123 &infotypeandvalue_default_tt, NULL);
124
125
126 ASN1_SEQUENCE(OSSL_CMP_ITAV) = {
127 ASN1_SIMPLE(OSSL_CMP_ITAV, infoType, ASN1_OBJECT),
128 ASN1_ADB_OBJECT(OSSL_CMP_ITAV)
129 } ASN1_SEQUENCE_END(OSSL_CMP_ITAV)
130 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
131 IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
132
133 OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value)
134 {
135 OSSL_CMP_ITAV *itav;
136
137 if (type == NULL || (itav = OSSL_CMP_ITAV_new()) == NULL)
138 return NULL;
139 OSSL_CMP_ITAV_set0(itav, type, value);
140 return itav;
141 }
142
OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV * itav,ASN1_OBJECT * type,ASN1_TYPE * value)143 void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
144 ASN1_TYPE *value)
145 {
146 itav->infoType = type;
147 itav->infoValue.other = value;
148 }
149
OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV * itav)150 ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav)
151 {
152 if (itav == NULL)
153 return NULL;
154 return itav->infoType;
155 }
156
OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV * itav)157 ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav)
158 {
159 if (itav == NULL)
160 return NULL;
161 return itav->infoValue.other;
162 }
163
OSSL_CMP_ITAV_push0_stack_item(STACK_OF (OSSL_CMP_ITAV)** itav_sk_p,OSSL_CMP_ITAV * itav)164 int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
165 OSSL_CMP_ITAV *itav)
166 {
167 int created = 0;
168
169 if (itav_sk_p == NULL || itav == NULL) {
170 ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
171 goto err;
172 }
173
174 if (*itav_sk_p == NULL) {
175 if ((*itav_sk_p = sk_OSSL_CMP_ITAV_new_null()) == NULL)
176 goto err;
177 created = 1;
178 }
179 if (!sk_OSSL_CMP_ITAV_push(*itav_sk_p, itav))
180 goto err;
181 return 1;
182
183 err:
184 if (created != 0) {
185 sk_OSSL_CMP_ITAV_free(*itav_sk_p);
186 *itav_sk_p = NULL;
187 }
188 return 0;
189 }
190
191 /* get ASN.1 encoded integer, return -2 on error; -1 is valid for certReqId */
ossl_cmp_asn1_get_int(const ASN1_INTEGER * a)192 int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a)
193 {
194 int64_t res;
195
196 if (!ASN1_INTEGER_get_int64(&res, a)) {
197 ERR_raise(ERR_LIB_CMP, ASN1_R_INVALID_NUMBER);
198 return -2;
199 }
200 if (res < INT_MIN) {
201 ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_SMALL);
202 return -2;
203 }
204 if (res > INT_MAX) {
205 ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_LARGE);
206 return -2;
207 }
208 return (int)res;
209 }
210
ossl_cmp_msg_cb(int operation,ASN1_VALUE ** pval,const ASN1_ITEM * it,void * exarg)211 static int ossl_cmp_msg_cb(int operation, ASN1_VALUE **pval,
212 const ASN1_ITEM *it, void *exarg)
213 {
214 OSSL_CMP_MSG *msg = (OSSL_CMP_MSG *)*pval;
215
216 switch (operation) {
217 case ASN1_OP_FREE_POST:
218 OPENSSL_free(msg->propq);
219 break;
220
221 case ASN1_OP_DUP_POST:
222 {
223 OSSL_CMP_MSG *old = exarg;
224
225 if (!ossl_cmp_msg_set0_libctx(msg, old->libctx, old->propq))
226 return 0;
227 }
228 break;
229 case ASN1_OP_GET0_LIBCTX:
230 {
231 OSSL_LIB_CTX **libctx = exarg;
232
233 *libctx = msg->libctx;
234 }
235 break;
236 case ASN1_OP_GET0_PROPQ:
237 {
238 const char **propq = exarg;
239
240 *propq = msg->propq;
241 }
242 break;
243 default:
244 break;
245 }
246
247 return 1;
248 }
249
250 ASN1_CHOICE(OSSL_CMP_CERTORENCCERT) = {
251 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
252 ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.certificate, X509, 0),
253 ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.encryptedCert,
254 OSSL_CRMF_ENCRYPTEDVALUE, 1),
255 } ASN1_CHOICE_END(OSSL_CMP_CERTORENCCERT)
256 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
257
258
259 ASN1_SEQUENCE(OSSL_CMP_CERTIFIEDKEYPAIR) = {
260 ASN1_SIMPLE(OSSL_CMP_CERTIFIEDKEYPAIR, certOrEncCert,
261 OSSL_CMP_CERTORENCCERT),
262 ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, privateKey,
263 OSSL_CRMF_ENCRYPTEDVALUE, 0),
264 ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, publicationInfo,
265 OSSL_CRMF_PKIPUBLICATIONINFO, 1)
266 } ASN1_SEQUENCE_END(OSSL_CMP_CERTIFIEDKEYPAIR)
267 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
268
269
270 ASN1_SEQUENCE(OSSL_CMP_REVDETAILS) = {
271 ASN1_SIMPLE(OSSL_CMP_REVDETAILS, certDetails, OSSL_CRMF_CERTTEMPLATE),
272 ASN1_OPT(OSSL_CMP_REVDETAILS, crlEntryDetails, X509_EXTENSIONS)
273 } ASN1_SEQUENCE_END(OSSL_CMP_REVDETAILS)
274 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
275
276
277 ASN1_ITEM_TEMPLATE(OSSL_CMP_REVREQCONTENT) =
278 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_REVREQCONTENT,
279 OSSL_CMP_REVDETAILS)
280 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_REVREQCONTENT)
281
282
283 ASN1_SEQUENCE(OSSL_CMP_REVREPCONTENT) = {
284 ASN1_SEQUENCE_OF(OSSL_CMP_REVREPCONTENT, status, OSSL_CMP_PKISI),
285 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, revCerts, OSSL_CRMF_CERTID,
286 0),
287 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, crls, X509_CRL, 1)
288 } ASN1_SEQUENCE_END(OSSL_CMP_REVREPCONTENT)
289 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
290
291
292 ASN1_SEQUENCE(OSSL_CMP_KEYRECREPCONTENT) = {
293 ASN1_SIMPLE(OSSL_CMP_KEYRECREPCONTENT, status, OSSL_CMP_PKISI),
294 ASN1_EXP_OPT(OSSL_CMP_KEYRECREPCONTENT, newSigCert, X509, 0),
295 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, caCerts, X509, 1),
296 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, keyPairHist,
297 OSSL_CMP_CERTIFIEDKEYPAIR, 2)
298 } ASN1_SEQUENCE_END(OSSL_CMP_KEYRECREPCONTENT)
299 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
300
301
302 ASN1_ITEM_TEMPLATE(OSSL_CMP_PKISTATUS) =
303 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_UNIVERSAL, 0, status, ASN1_INTEGER)
304 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_PKISTATUS)
305
306 ASN1_SEQUENCE(OSSL_CMP_PKISI) = {
307 ASN1_SIMPLE(OSSL_CMP_PKISI, status, OSSL_CMP_PKISTATUS),
308 /*
309 * CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
310 * so it is used directly
311 */
312 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_PKISI, statusString, ASN1_UTF8STRING),
313 /*
314 * OSSL_CMP_PKIFAILUREINFO is effectively ASN1_BIT_STRING so used directly
315 */
316 ASN1_OPT(OSSL_CMP_PKISI, failInfo, ASN1_BIT_STRING)
317 } ASN1_SEQUENCE_END(OSSL_CMP_PKISI)
318 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
319 IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
320
321 ASN1_SEQUENCE(OSSL_CMP_CERTSTATUS) = {
322 ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certHash, ASN1_OCTET_STRING),
323 ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certReqId, ASN1_INTEGER),
324 ASN1_OPT(OSSL_CMP_CERTSTATUS, statusInfo, OSSL_CMP_PKISI)
325 } ASN1_SEQUENCE_END(OSSL_CMP_CERTSTATUS)
326 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
327
328 ASN1_ITEM_TEMPLATE(OSSL_CMP_CERTCONFIRMCONTENT) =
329 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_CERTCONFIRMCONTENT,
330 OSSL_CMP_CERTSTATUS)
331 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CERTCONFIRMCONTENT)
332
333 ASN1_SEQUENCE(OSSL_CMP_CERTRESPONSE) = {
334 ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, certReqId, ASN1_INTEGER),
335 ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, status, OSSL_CMP_PKISI),
336 ASN1_OPT(OSSL_CMP_CERTRESPONSE, certifiedKeyPair,
337 OSSL_CMP_CERTIFIEDKEYPAIR),
338 ASN1_OPT(OSSL_CMP_CERTRESPONSE, rspInfo, ASN1_OCTET_STRING)
339 } ASN1_SEQUENCE_END(OSSL_CMP_CERTRESPONSE)
340 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
341
342 ASN1_SEQUENCE(OSSL_CMP_POLLREQ) = {
343 ASN1_SIMPLE(OSSL_CMP_POLLREQ, certReqId, ASN1_INTEGER)
344 } ASN1_SEQUENCE_END(OSSL_CMP_POLLREQ)
345 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
346
347 ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREQCONTENT) =
348 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_POLLREQCONTENT,
349 OSSL_CMP_POLLREQ)
350 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREQCONTENT)
351
352 ASN1_SEQUENCE(OSSL_CMP_POLLREP) = {
353 ASN1_SIMPLE(OSSL_CMP_POLLREP, certReqId, ASN1_INTEGER),
354 ASN1_SIMPLE(OSSL_CMP_POLLREP, checkAfter, ASN1_INTEGER),
355 ASN1_SEQUENCE_OF_OPT(OSSL_CMP_POLLREP, reason, ASN1_UTF8STRING),
356 } ASN1_SEQUENCE_END(OSSL_CMP_POLLREP)
357 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
358
359 ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREPCONTENT) =
360 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
361 OSSL_CMP_POLLREPCONTENT,
362 OSSL_CMP_POLLREP)
363 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREPCONTENT)
364
365 ASN1_SEQUENCE(OSSL_CMP_CERTREPMESSAGE) = {
366 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
367 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_CERTREPMESSAGE, caPubs, X509, 1),
368 ASN1_SEQUENCE_OF(OSSL_CMP_CERTREPMESSAGE, response, OSSL_CMP_CERTRESPONSE)
369 } ASN1_SEQUENCE_END(OSSL_CMP_CERTREPMESSAGE)
370 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
371
372 ASN1_ITEM_TEMPLATE(OSSL_CMP_GENMSGCONTENT) =
373 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENMSGCONTENT,
374 OSSL_CMP_ITAV)
375 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENMSGCONTENT)
376
377 ASN1_ITEM_TEMPLATE(OSSL_CMP_GENREPCONTENT) =
378 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENREPCONTENT,
379 OSSL_CMP_ITAV)
380 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENREPCONTENT)
381
382 ASN1_ITEM_TEMPLATE(OSSL_CMP_CRLANNCONTENT) =
383 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
384 OSSL_CMP_CRLANNCONTENT, X509_CRL)
385 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CRLANNCONTENT)
386
387 ASN1_CHOICE(OSSL_CMP_PKIBODY) = {
388 ASN1_EXP(OSSL_CMP_PKIBODY, value.ir, OSSL_CRMF_MSGS, 0),
389 ASN1_EXP(OSSL_CMP_PKIBODY, value.ip, OSSL_CMP_CERTREPMESSAGE, 1),
390 ASN1_EXP(OSSL_CMP_PKIBODY, value.cr, OSSL_CRMF_MSGS, 2),
391 ASN1_EXP(OSSL_CMP_PKIBODY, value.cp, OSSL_CMP_CERTREPMESSAGE, 3),
392 ASN1_EXP(OSSL_CMP_PKIBODY, value.p10cr, X509_REQ, 4),
393 ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecc,
394 OSSL_CMP_POPODECKEYCHALLCONTENT, 5),
395 ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecr,
396 OSSL_CMP_POPODECKEYRESPCONTENT, 6),
397 ASN1_EXP(OSSL_CMP_PKIBODY, value.kur, OSSL_CRMF_MSGS, 7),
398 ASN1_EXP(OSSL_CMP_PKIBODY, value.kup, OSSL_CMP_CERTREPMESSAGE, 8),
399 ASN1_EXP(OSSL_CMP_PKIBODY, value.krr, OSSL_CRMF_MSGS, 9),
400 ASN1_EXP(OSSL_CMP_PKIBODY, value.krp, OSSL_CMP_KEYRECREPCONTENT, 10),
401 ASN1_EXP(OSSL_CMP_PKIBODY, value.rr, OSSL_CMP_REVREQCONTENT, 11),
402 ASN1_EXP(OSSL_CMP_PKIBODY, value.rp, OSSL_CMP_REVREPCONTENT, 12),
403 ASN1_EXP(OSSL_CMP_PKIBODY, value.ccr, OSSL_CRMF_MSGS, 13),
404 ASN1_EXP(OSSL_CMP_PKIBODY, value.ccp, OSSL_CMP_CERTREPMESSAGE, 14),
405 ASN1_EXP(OSSL_CMP_PKIBODY, value.ckuann, OSSL_CMP_CAKEYUPDANNCONTENT, 15),
406 ASN1_EXP(OSSL_CMP_PKIBODY, value.cann, X509, 16),
407 ASN1_EXP(OSSL_CMP_PKIBODY, value.rann, OSSL_CMP_REVANNCONTENT, 17),
408 ASN1_EXP(OSSL_CMP_PKIBODY, value.crlann, OSSL_CMP_CRLANNCONTENT, 18),
409 ASN1_EXP(OSSL_CMP_PKIBODY, value.pkiconf, ASN1_ANY, 19),
410 ASN1_EXP(OSSL_CMP_PKIBODY, value.nested, OSSL_CMP_MSGS, 20),
411 ASN1_EXP(OSSL_CMP_PKIBODY, value.genm, OSSL_CMP_GENMSGCONTENT, 21),
412 ASN1_EXP(OSSL_CMP_PKIBODY, value.genp, OSSL_CMP_GENREPCONTENT, 22),
413 ASN1_EXP(OSSL_CMP_PKIBODY, value.error, OSSL_CMP_ERRORMSGCONTENT, 23),
414 ASN1_EXP(OSSL_CMP_PKIBODY, value.certConf, OSSL_CMP_CERTCONFIRMCONTENT, 24),
415 ASN1_EXP(OSSL_CMP_PKIBODY, value.pollReq, OSSL_CMP_POLLREQCONTENT, 25),
416 ASN1_EXP(OSSL_CMP_PKIBODY, value.pollRep, OSSL_CMP_POLLREPCONTENT, 26),
417 } ASN1_CHOICE_END(OSSL_CMP_PKIBODY)
418 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
419
420 ASN1_SEQUENCE(OSSL_CMP_PKIHEADER) = {
421 ASN1_SIMPLE(OSSL_CMP_PKIHEADER, pvno, ASN1_INTEGER),
422 ASN1_SIMPLE(OSSL_CMP_PKIHEADER, sender, GENERAL_NAME),
423 ASN1_SIMPLE(OSSL_CMP_PKIHEADER, recipient, GENERAL_NAME),
424 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, messageTime, ASN1_GENERALIZEDTIME, 0),
425 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, protectionAlg, X509_ALGOR, 1),
426 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderKID, ASN1_OCTET_STRING, 2),
427 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipKID, ASN1_OCTET_STRING, 3),
428 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, transactionID, ASN1_OCTET_STRING, 4),
429 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderNonce, ASN1_OCTET_STRING, 5),
430 ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipNonce, ASN1_OCTET_STRING, 6),
431 /*
432 * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
433 * so it is used directly
434 */
435 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, freeText, ASN1_UTF8STRING, 7),
436 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, generalInfo,
437 OSSL_CMP_ITAV, 8)
438 } ASN1_SEQUENCE_END(OSSL_CMP_PKIHEADER)
439 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
440
441 ASN1_SEQUENCE(OSSL_CMP_PROTECTEDPART) = {
442 ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
443 ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY)
444 } ASN1_SEQUENCE_END(OSSL_CMP_PROTECTEDPART)
445 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PROTECTEDPART)
446
447 ASN1_SEQUENCE_cb(OSSL_CMP_MSG, ossl_cmp_msg_cb) = {
448 ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
449 ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY),
450 ASN1_EXP_OPT(OSSL_CMP_MSG, protection, ASN1_BIT_STRING, 0),
451 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
452 ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_MSG, extraCerts, X509, 1)
453 } ASN1_SEQUENCE_END_cb(OSSL_CMP_MSG, OSSL_CMP_MSG)
454 IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
455
456 ASN1_ITEM_TEMPLATE(OSSL_CMP_MSGS) =
457 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_MSGS,
458 OSSL_CMP_MSG)
459 ASN1_ITEM_TEMPLATE_END(OSSL_CMP_MSGS)
460