Rename CMP_PROTECTEDPART to OSSL_CMP_PROTECTEDPART for consistency
[openssl.git] / crypto / cmp / cmp_local.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
12 #ifndef OSSL_CRYPTO_CMP_LOCAL_H
13 # define OSSL_CRYPTO_CMP_LOCAL_H
14
15 # include "internal/cryptlib.h"
16
17 # include <openssl/cmp.h>
18 # include <openssl/err.h>
19
20 /* explicit #includes not strictly needed since implied by the above: */
21 # include <openssl/crmf.h>
22 # include <openssl/types.h>
23 # include <openssl/safestack.h>
24 # include <openssl/x509.h>
25 # include <openssl/x509v3.h>
26
27 /*
28  * this structure is used to store the context for CMP sessions
29  */
30 struct ossl_cmp_ctx_st {
31     OSSL_CMP_log_cb_t log_cb; /* log callback for error/debug/etc. output */
32     OSSL_CMP_severity log_verbosity; /* level of verbosity of log output */
33
34     /* message transfer */
35     OSSL_CMP_transfer_cb_t transfer_cb; /* default: OSSL_CMP_MSG_http_perform */
36     void *transfer_cb_arg; /* allows to store optional argument to cb */
37     /* HTTP-based transfer */
38     char *serverPath;
39     char *server;
40     int serverPort;
41     char *proxy;
42     char *no_proxy;
43     int msg_timeout; /* max seconds to wait for each CMP message round trip */
44     int total_timeout; /* max number of seconds an enrollment may take, incl. */
45     /* attempts polling for a response if a 'waiting' PKIStatus is received */
46     time_t end_time; /* session start time + totaltimeout */
47     OSSL_HTTP_bio_cb_t http_cb;
48     void *http_cb_arg; /* allows to store optional argument to cb */
49
50     /* server authentication */
51     /*
52      * unprotectedErrors may be set as workaround for broken server responses:
53      * accept missing or invalid protection of regular error messages, negative
54      * certificate responses (ip/cp/kup), revocation responses (rp), and PKIConf
55      */
56     int unprotectedErrors;
57     X509 *srvCert; /* certificate used to identify the server */
58     X509 *validatedSrvCert; /* caches any already validated server cert */
59     X509_NAME *expected_sender; /* expected sender in header of response */
60     X509_STORE *trusted; /* trust store maybe w CRLs and cert verify callback */
61     STACK_OF(X509) *untrusted_certs; /* untrusted (intermediate) certs */
62     int ignore_keyusage; /* ignore key usage entry when validating certs */
63     /*
64      * permitTAInExtraCertsForIR allows use of root certs in extracerts
65      * when validating message protection; this is used for 3GPP-style E.7
66      */
67     int permitTAInExtraCertsForIR;
68
69     /* client authentication */
70     int unprotectedSend; /* send unprotected PKI messages */
71     X509 *clCert; /* client cert used to identify and sign for MSG_SIG_ALG */
72     EVP_PKEY *pkey; /* the key pair corresponding to clCert */
73     ASN1_OCTET_STRING *referenceValue; /* optional user name for MSG_MAC_ALG */
74     ASN1_OCTET_STRING *secretValue; /* password/shared secret for MSG_MAC_ALG */
75     /* PBMParameters for MSG_MAC_ALG */
76     size_t pbm_slen; /* currently fixed to 16 */
77     int pbm_owf; /* NID of one-way function (OWF), default: SHA256 */
78     int pbm_itercnt; /* currently fixed to 500 */
79     int pbm_mac; /* NID of MAC algorithm, default: HMAC-SHA1 as per RFC 4210 */
80
81     /* CMP message header and extra certificates */
82     X509_NAME *recipient; /* to set in recipient in pkiheader */
83     int digest; /* NID of digest used in MSG_SIG_ALG and POPO, default SHA256 */
84     ASN1_OCTET_STRING *transactionID; /* the current transaction ID */
85     ASN1_OCTET_STRING *senderNonce; /* last nonce sent */
86     ASN1_OCTET_STRING *recipNonce; /* last nonce received */
87     ASN1_UTF8STRING *freeText; /* optional string to include each msg */
88     STACK_OF(OSSL_CMP_ITAV) *geninfo_ITAVs;
89     int implicitConfirm; /* set implicitConfirm in IR/KUR/CR messages */
90     int disableConfirm; /* disable certConf in IR/KUR/CR for broken servers */
91     STACK_OF(X509) *extraCertsOut; /* to be included in request messages */
92
93     /* certificate template */
94     EVP_PKEY *newPkey; /* explicit new private/public key for cert enrollment */
95     int newPkey_priv; /* flag indicating if newPkey contains private key */
96     X509_NAME *issuer; /* issuer name to used in cert template */
97     int days; /* Number of days new certificates are asked to be valid for */
98     X509_NAME *subjectName; /* subject name to be used in cert template */
99     STACK_OF(GENERAL_NAME) *subjectAltNames; /* to add to the cert template */
100     int SubjectAltName_nodefault;
101     int setSubjectAltNameCritical;
102     X509_EXTENSIONS *reqExtensions; /* exts to be added to cert template */
103     CERTIFICATEPOLICIES *policies; /* policies to be included in extensions */
104     int setPoliciesCritical;
105     int popoMethod; /* Proof-of-possession mechanism; default: signature */
106     X509 *oldCert; /* cert to be updated (via KUR) or to be revoked (via RR) */
107     X509_REQ *p10CSR; /* for P10CR: PKCS#10 CSR to be sent */
108
109     /* misc body contents */
110     int revocationReason; /* revocation reason code to be included in RR */
111     STACK_OF(OSSL_CMP_ITAV) *genm_ITAVs; /* content of general message */
112
113     /* result returned in responses */
114     int status; /* PKIStatus of last received IP/CP/KUP/RP/error or -1 */
115     /* TODO: this should be a stack since there could be more than one */
116     OSSL_CMP_PKIFREETEXT *statusString; /* of last IP/CP/KUP/RP/error */
117     int failInfoCode; /* failInfoCode of last received IP/CP/KUP/error, or -1 */
118     /* TODO: this should be a stack since there could be more than one */
119     X509 *newCert; /* newly enrolled cert received from the CA */
120     /* TODO: this should be a stack since there could be more than one */
121     STACK_OF(X509) *caPubs; /* CA certs received from server (in IP message) */
122     STACK_OF(X509) *extraCertsIn; /* extraCerts received from server */
123
124     /* certificate confirmation */
125     OSSL_CMP_certConf_cb_t certConf_cb; /* callback for app checking new cert */
126     void *certConf_cb_arg; /* allows to store an argument individual to cb */
127 } /* OSSL_CMP_CTX */;
128
129 /*
130  * ##########################################################################
131  * ASN.1 DECLARATIONS
132  * ##########################################################################
133  */
134
135 /*-
136  *   RevAnnContent ::= SEQUENCE {
137  *       status              PKIStatus,
138  *       certId              CertId,
139  *       willBeRevokedAt     GeneralizedTime,
140  *       badSinceDate        GeneralizedTime,
141  *       crlDetails          Extensions  OPTIONAL
142  *       -- extra CRL details (e.g., crl number, reason, location, etc.)
143  *   }
144  */
145 typedef struct ossl_cmp_revanncontent_st {
146     ASN1_INTEGER *status;
147     OSSL_CRMF_CERTID *certId;
148     ASN1_GENERALIZEDTIME *willBeRevokedAt;
149     ASN1_GENERALIZEDTIME *badSinceDate;
150     X509_EXTENSIONS *crlDetails;
151 } OSSL_CMP_REVANNCONTENT;
152 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
153
154 /*-
155  *   Challenge ::= SEQUENCE {
156  *       owf                 AlgorithmIdentifier  OPTIONAL,
157  *
158  *       -- MUST be present in the first Challenge; MAY be omitted in
159  *       -- any subsequent Challenge in POPODecKeyChallContent (if
160  *       -- omitted, then the owf used in the immediately preceding
161  *       -- Challenge is to be used).
162  *
163  *       witness             OCTET STRING,
164  *       -- the result of applying the one-way function (owf) to a
165  *       -- randomly-generated INTEGER, A.  [Note that a different
166  *       -- INTEGER MUST be used for each Challenge.]
167  *       challenge           OCTET STRING
168  *       -- the encryption (under the public key for which the cert.
169  *       -- request is being made) of Rand, where Rand is specified as
170  *       --   Rand ::= SEQUENCE {
171  *       --      int      INTEGER,
172  *       --       - the randomly-generated INTEGER A (above)
173  *       --      sender   GeneralName
174  *       --       - the sender's name (as included in PKIHeader)
175  *       --   }
176  *   }
177  */
178 typedef struct ossl_cmp_challenge_st {
179     X509_ALGOR *owf;
180     ASN1_OCTET_STRING *witness;
181     ASN1_OCTET_STRING *challenge;
182 } OSSL_CMP_CHALLENGE;
183 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
184
185 /*-
186  *  CAKeyUpdAnnContent ::= SEQUENCE {
187  *     oldWithNew         Certificate,
188  *     newWithOld         Certificate,
189  *     newWithNew         Certificate
190  *  }
191  */
192 typedef struct ossl_cmp_cakeyupdanncontent_st {
193     X509 *oldWithNew;
194     X509 *newWithOld;
195     X509 *newWithNew;
196 } OSSL_CMP_CAKEYUPDANNCONTENT;
197 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
198
199 /*-
200  * declared already here as it will be used in OSSL_CMP_MSG (nested) and
201  * infoType and infoValue
202  */
203 typedef STACK_OF(OSSL_CMP_MSG) OSSL_CMP_MSGS;
204 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSGS)
205
206 /*-
207  *   InfoTypeAndValue ::= SEQUENCE {
208  *       infoType               OBJECT IDENTIFIER,
209  *       infoValue              ANY DEFINED BY infoType  OPTIONAL
210  *   }
211  */
212 struct ossl_cmp_itav_st {
213     ASN1_OBJECT *infoType;
214     union {
215         char *ptr;
216         /* NID_id_it_caProtEncCert - CA Protocol Encryption Certificate */
217         X509 *caProtEncCert;
218         /* NID_id_it_signKeyPairTypes - Signing Key Pair Types */
219         STACK_OF(X509_ALGOR) *signKeyPairTypes;
220         /* NID_id_it_encKeyPairTypes - Encryption/Key Agreement Key Pair Types */
221         STACK_OF(X509_ALGOR) *encKeyPairTypes;
222         /* NID_id_it_preferredSymmAlg - Preferred Symmetric Algorithm */
223         X509_ALGOR *preferredSymmAlg;
224         /* NID_id_it_caKeyUpdateInfo - Updated CA Key Pair */
225         OSSL_CMP_CAKEYUPDANNCONTENT *caKeyUpdateInfo;
226         /* NID_id_it_currentCRL - CRL */
227         X509_CRL *currentCRL;
228         /* NID_id_it_unsupportedOIDs - Unsupported Object Identifiers */
229         STACK_OF(ASN1_OBJECT) *unsupportedOIDs;
230         /* NID_id_it_keyPairParamReq - Key Pair Parameters Request */
231         ASN1_OBJECT *keyPairParamReq;
232         /* NID_id_it_keyPairParamRep - Key Pair Parameters Response */
233         X509_ALGOR *keyPairParamRep;
234         /* NID_id_it_revPassphrase - Revocation Passphrase */
235         OSSL_CRMF_ENCRYPTEDVALUE *revPassphrase;
236         /* NID_id_it_implicitConfirm - ImplicitConfirm */
237         ASN1_NULL *implicitConfirm;
238         /* NID_id_it_confirmWaitTime - ConfirmWaitTime */
239         ASN1_GENERALIZEDTIME *confirmWaitTime;
240         /* NID_id_it_origPKIMessage - origPKIMessage */
241         OSSL_CMP_MSGS *origPKIMessage;
242         /* NID_id_it_suppLangTags - Supported Language Tags */
243         STACK_OF(ASN1_UTF8STRING) *suppLangTagsValue;
244         /* this is to be used for so far undeclared objects */
245         ASN1_TYPE *other;
246     } infoValue;
247 } /* OSSL_CMP_ITAV */;
248 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
249
250 typedef struct ossl_cmp_certorenccert_st {
251     int type;
252     union {
253         X509 *certificate;
254         OSSL_CRMF_ENCRYPTEDVALUE *encryptedCert;
255     } value;
256 } OSSL_CMP_CERTORENCCERT;
257 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
258
259 /*-
260  *   CertifiedKeyPair ::= SEQUENCE {
261  *       certOrEncCert       CertOrEncCert,
262  *       privateKey      [0] EncryptedValue      OPTIONAL,
263  *       -- see [CRMF] for comment on encoding
264  *       publicationInfo [1] PKIPublicationInfo  OPTIONAL
265  *   }
266  */
267 typedef struct ossl_cmp_certifiedkeypair_st {
268     OSSL_CMP_CERTORENCCERT *certOrEncCert;
269     OSSL_CRMF_ENCRYPTEDVALUE *privateKey;
270     OSSL_CRMF_PKIPUBLICATIONINFO *publicationInfo;
271 } OSSL_CMP_CERTIFIEDKEYPAIR;
272 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
273
274 /*-
275  *   PKIStatusInfo ::= SEQUENCE {
276  *       status        PKIStatus,
277  *       statusString  PKIFreeText     OPTIONAL,
278  *       failInfo      PKIFailureInfo  OPTIONAL
279  *   }
280  */
281 struct ossl_cmp_pkisi_st {
282     OSSL_CMP_PKISTATUS *status;
283     OSSL_CMP_PKIFREETEXT *statusString;
284     OSSL_CMP_PKIFAILUREINFO *failInfo;
285 } /* OSSL_CMP_PKISI */;
286 DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID)
287
288 /*-
289  *  RevReqContent ::= SEQUENCE OF RevDetails
290  *
291  *  RevDetails ::= SEQUENCE {
292  *      certDetails         CertTemplate,
293  *      crlEntryDetails     Extensions       OPTIONAL
294  *  }
295  */
296 struct ossl_cmp_revdetails_st {
297     OSSL_CRMF_CERTTEMPLATE *certDetails;
298     X509_EXTENSIONS *crlEntryDetails;
299 } /* OSSL_CMP_REVDETAILS */;
300 typedef struct ossl_cmp_revdetails_st OSSL_CMP_REVDETAILS;
301 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
302 DEFINE_STACK_OF(OSSL_CMP_REVDETAILS)
303
304 /*-
305  *   RevRepContent ::= SEQUENCE {
306  *       status       SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
307  *       -- in same order as was sent in RevReqContent
308  *       revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId
309  *                                           OPTIONAL,
310  *       -- IDs for which revocation was requested
311  *       -- (same order as status)
312  *       crls     [1] SEQUENCE SIZE (1..MAX) OF CertificateList
313  *                                           OPTIONAL
314  *       -- the resulting CRLs (there may be more than one)
315  *   }
316  */
317 struct ossl_cmp_revrepcontent_st {
318     STACK_OF(OSSL_CMP_PKISI) *status;
319     STACK_OF(OSSL_CRMF_CERTID) *revCerts;
320     STACK_OF(X509_CRL) *crls;
321 } /* OSSL_CMP_REVREPCONTENT */;
322 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
323
324 /*-
325  *  KeyRecRepContent ::= SEQUENCE {
326  *      status          PKIStatusInfo,
327  *      newSigCert  [0] Certificate                   OPTIONAL,
328  *      caCerts     [1] SEQUENCE SIZE (1..MAX) OF
329  *                                   Certificate      OPTIONAL,
330  *      keyPairHist [2] SEQUENCE SIZE (1..MAX) OF
331  *                                   CertifiedKeyPair OPTIONAL
332  *   }
333  */
334 typedef struct ossl_cmp_keyrecrepcontent_st {
335     OSSL_CMP_PKISI *status;
336     X509 *newSigCert;
337     STACK_OF(X509) *caCerts;
338     STACK_OF(OSSL_CMP_CERTIFIEDKEYPAIR) *keyPairHist;
339 } OSSL_CMP_KEYRECREPCONTENT;
340 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
341
342 /*-
343  *   ErrorMsgContent ::= SEQUENCE {
344  *       pKIStatusInfo          PKIStatusInfo,
345  *       errorCode              INTEGER           OPTIONAL,
346  *       -- implementation-specific error codes
347  *       errorDetails           PKIFreeText       OPTIONAL
348  *       -- implementation-specific error details
349  *   }
350  */
351 typedef struct ossl_cmp_errormsgcontent_st {
352     OSSL_CMP_PKISI *pKIStatusInfo;
353     ASN1_INTEGER *errorCode;
354     OSSL_CMP_PKIFREETEXT *errorDetails;
355 } OSSL_CMP_ERRORMSGCONTENT;
356 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
357
358 /*-
359  *   CertConfirmContent ::= SEQUENCE OF CertStatus
360  *
361  *   CertStatus ::= SEQUENCE {
362  *      certHash    OCTET STRING,
363  *      -- the hash of the certificate, using the same hash algorithm
364  *      -- as is used to create and verify the certificate signature
365  *      certReqId   INTEGER,
366  *      -- to match this confirmation with the corresponding req/rep
367  *      statusInfo  PKIStatusInfo OPTIONAL
368  *   }
369  */
370 struct ossl_cmp_certstatus_st {
371     ASN1_OCTET_STRING *certHash;
372     ASN1_INTEGER *certReqId;
373     OSSL_CMP_PKISI *statusInfo;
374 } /* OSSL_CMP_CERTSTATUS */;
375 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
376 typedef STACK_OF(OSSL_CMP_CERTSTATUS) OSSL_CMP_CERTCONFIRMCONTENT;
377 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTCONFIRMCONTENT)
378
379 /*-
380  *   CertResponse ::= SEQUENCE {
381  *       certReqId           INTEGER,
382  *       -- to match this response with corresponding request (a value
383  *       -- of -1 is to be used if certReqId is not specified in the
384  *       -- corresponding request)
385  *       status              PKIStatusInfo,
386  *       certifiedKeyPair    CertifiedKeyPair    OPTIONAL,
387  *       rspInfo             OCTET STRING        OPTIONAL
388  *       -- analogous to the id-regInfo-utf8Pairs string defined
389  *       -- for regInfo in CertReqMsg [CRMF]
390  *   }
391  */
392 struct ossl_cmp_certresponse_st {
393     ASN1_INTEGER *certReqId;
394     OSSL_CMP_PKISI *status;
395     OSSL_CMP_CERTIFIEDKEYPAIR *certifiedKeyPair;
396     ASN1_OCTET_STRING *rspInfo;
397 } /* OSSL_CMP_CERTRESPONSE */;
398 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
399
400 /*-
401  *   CertRepMessage ::= SEQUENCE {
402  *       caPubs       [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
403  *                        OPTIONAL,
404  *       response         SEQUENCE OF CertResponse
405  *   }
406  */
407 struct ossl_cmp_certrepmessage_st {
408     STACK_OF(X509) *caPubs;
409     STACK_OF(OSSL_CMP_CERTRESPONSE) *response;
410 } /* OSSL_CMP_CERTREPMESSAGE */;
411 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
412
413 /*-
414  *   PollReqContent ::= SEQUENCE OF SEQUENCE {
415  *         certReqId                              INTEGER
416  *   }
417  */
418 typedef struct ossl_cmp_pollreq_st {
419     ASN1_INTEGER *certReqId;
420 } OSSL_CMP_POLLREQ;
421 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
422 DEFINE_STACK_OF(OSSL_CMP_POLLREQ)
423 typedef STACK_OF(OSSL_CMP_POLLREQ) OSSL_CMP_POLLREQCONTENT;
424 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQCONTENT)
425
426 /*-
427  * PollRepContent ::= SEQUENCE OF SEQUENCE {
428  *         certReqId                              INTEGER,
429  *         checkAfter                             INTEGER,  -- time in seconds
430  *         reason                                 PKIFreeText OPTIONAL
431  * }
432  */
433 struct ossl_cmp_pollrep_st {
434     ASN1_INTEGER *certReqId;
435     ASN1_INTEGER *checkAfter;
436     OSSL_CMP_PKIFREETEXT *reason;
437 } /* OSSL_CMP_POLLREP */;
438 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
439 DEFINE_STACK_OF(OSSL_CMP_POLLREP)
440 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREPCONTENT)
441
442 /*-
443  * PKIHeader ::= SEQUENCE {
444  *     pvno                INTEGER     { cmp1999(1), cmp2000(2) },
445  *     sender              GeneralName,
446  *     -- identifies the sender
447  *     recipient           GeneralName,
448  *     -- identifies the intended recipient
449  *     messageTime     [0] GeneralizedTime         OPTIONAL,
450  *     -- time of production of this message (used when sender
451  *     -- believes that the transport will be "suitable"; i.e.,
452  *     -- that the time will still be meaningful upon receipt)
453  *     protectionAlg   [1] AlgorithmIdentifier     OPTIONAL,
454  *     -- algorithm used for calculation of protection bits
455  *     senderKID       [2] KeyIdentifier           OPTIONAL,
456  *     recipKID        [3] KeyIdentifier           OPTIONAL,
457  *     -- to identify specific keys used for protection
458  *     transactionID   [4] OCTET STRING            OPTIONAL,
459  *     -- identifies the transaction; i.e., this will be the same in
460  *     -- corresponding request, response, certConf, and PKIConf
461  *     -- messages
462  *     senderNonce     [5] OCTET STRING            OPTIONAL,
463  *     recipNonce      [6] OCTET STRING            OPTIONAL,
464  *     -- nonces used to provide replay protection, senderNonce
465  *     -- is inserted by the creator of this message; recipNonce
466  *     -- is a nonce previously inserted in a related message by
467  *     -- the intended recipient of this message
468  *     freeText        [7] PKIFreeText             OPTIONAL,
469  *     -- this may be used to indicate context-specific instructions
470  *     -- (this field is intended for human consumption)
471  *     generalInfo     [8] SEQUENCE SIZE (1..MAX) OF
472  *                            InfoTypeAndValue     OPTIONAL
473  *     -- this may be used to convey context-specific information
474  *     -- (this field not primarily intended for human consumption)
475  *   }
476  */
477 struct ossl_cmp_pkiheader_st {
478     ASN1_INTEGER *pvno;
479     GENERAL_NAME *sender;
480     GENERAL_NAME *recipient;
481     ASN1_GENERALIZEDTIME *messageTime; /* 0 */
482     X509_ALGOR *protectionAlg; /* 1 */
483     ASN1_OCTET_STRING *senderKID; /* 2 */
484     ASN1_OCTET_STRING *recipKID; /* 3 */
485     ASN1_OCTET_STRING *transactionID; /* 4 */
486     ASN1_OCTET_STRING *senderNonce; /* 5 */
487     ASN1_OCTET_STRING *recipNonce; /* 6 */
488     OSSL_CMP_PKIFREETEXT *freeText; /* 7 */
489     STACK_OF(OSSL_CMP_ITAV) *generalInfo; /* 8 */
490 } /* OSSL_CMP_PKIHEADER */;
491
492 typedef STACK_OF(OSSL_CMP_CHALLENGE) OSSL_CMP_POPODECKEYCHALLCONTENT;
493 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYCHALLCONTENT)
494 typedef STACK_OF(ASN1_INTEGER) OSSL_CMP_POPODECKEYRESPCONTENT;
495 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYRESPCONTENT)
496 typedef STACK_OF(OSSL_CMP_REVDETAILS) OSSL_CMP_REVREQCONTENT;
497 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREQCONTENT)
498 typedef STACK_OF(X509_CRL) OSSL_CMP_CRLANNCONTENT;
499 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CRLANNCONTENT)
500 typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENMSGCONTENT;
501 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENMSGCONTENT)
502 typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENREPCONTENT;
503 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENREPCONTENT)
504
505 /*-
506  *   PKIBody ::= CHOICE {           -- message-specific body elements
507  *           ir       [0]  CertReqMessages,            --Initialization Request
508  *           ip       [1]  CertRepMessage,             --Initialization Response
509  *           cr       [2]  CertReqMessages,            --Certification Request
510  *           cp       [3]  CertRepMessage,             --Certification Response
511  *           p10cr    [4]  CertificationRequest,       --imported from [PKCS10]
512  *           popdecc  [5]  POPODecKeyChallContent,     --pop Challenge
513  *           popdecr  [6]  POPODecKeyRespContent,      --pop Response
514  *           kur      [7]  CertReqMessages,            --Key Update Request
515  *           kup      [8]  CertRepMessage,             --Key Update Response
516  *           krr      [9]  CertReqMessages,            --Key Recovery Request
517  *           krp      [10] KeyRecRepContent,           --Key Recovery Response
518  *           rr       [11] RevReqContent,              --Revocation Request
519  *           rp       [12] RevRepContent,              --Revocation Response
520  *           ccr      [13] CertReqMessages,            --Cross-Cert. Request
521  *           ccp      [14] CertRepMessage,             --Cross-Cert. Response
522  *           ckuann   [15] CAKeyUpdAnnContent,         --CA Key Update Ann.
523  *           cann     [16] CertAnnContent,             --Certificate Ann.
524  *           rann     [17] RevAnnContent,              --Revocation Ann.
525  *           crlann   [18] CRLAnnContent,              --CRL Announcement
526  *           pkiconf  [19] PKIConfirmContent,          --Confirmation
527  *           nested   [20] NestedMessageContent,       --Nested Message
528  *           genm     [21] GenMsgContent,              --General Message
529  *           genp     [22] GenRepContent,              --General Response
530  *           error    [23] ErrorMsgContent,            --Error Message
531  *           certConf [24] CertConfirmContent,         --Certificate confirm
532  *           pollReq  [25] PollReqContent,             --Polling request
533  *           pollRep  [26] PollRepContent              --Polling response
534  *   }
535  */
536 typedef struct ossl_cmp_pkibody_st {
537     int type;
538     union {
539         OSSL_CRMF_MSGS *ir; /* 0 */
540         OSSL_CMP_CERTREPMESSAGE *ip; /* 1 */
541         OSSL_CRMF_MSGS *cr; /* 2 */
542         OSSL_CMP_CERTREPMESSAGE *cp; /* 3 */
543         /*-
544          * p10cr      [4]  CertificationRequest,     --imported from [PKCS10]
545          *
546          * PKCS10_CERTIFICATIONREQUEST is effectively X509_REQ
547          * so it is used directly
548          */
549         X509_REQ *p10cr; /* 4 */
550         /*-
551          * popdecc    [5]  POPODecKeyChallContent, --pop Challenge
552          *
553          * POPODecKeyChallContent ::= SEQUENCE OF Challenge
554          */
555         OSSL_CMP_POPODECKEYCHALLCONTENT *popdecc; /* 5 */
556         /*-
557          * popdecr    [6]  POPODecKeyRespContent,  --pop Response
558          *
559          * POPODecKeyRespContent ::= SEQUENCE OF INTEGER
560          */
561         OSSL_CMP_POPODECKEYRESPCONTENT *popdecr; /* 6 */
562         OSSL_CRMF_MSGS *kur; /* 7 */
563         OSSL_CMP_CERTREPMESSAGE *kup; /* 8 */
564         OSSL_CRMF_MSGS *krr; /* 9 */
565
566         /*-
567          * krp        [10] KeyRecRepContent,         --Key Recovery Response
568          */
569         OSSL_CMP_KEYRECREPCONTENT *krp; /* 10 */
570         /*-
571          * rr         [11] RevReqContent,            --Revocation Request
572          */
573         OSSL_CMP_REVREQCONTENT *rr; /* 11 */
574         /*-
575          * rp         [12] RevRepContent,            --Revocation Response
576          */
577         OSSL_CMP_REVREPCONTENT *rp; /* 12 */
578         /*-
579          * ccr        [13] CertReqMessages,          --Cross-Cert. Request
580          */
581         OSSL_CRMF_MSGS *ccr; /* 13 */
582         /*-
583          * ccp        [14] CertRepMessage,           --Cross-Cert. Response
584          */
585         OSSL_CMP_CERTREPMESSAGE *ccp; /* 14 */
586         /*-
587          * ckuann     [15] CAKeyUpdAnnContent,       --CA Key Update Ann.
588          */
589         OSSL_CMP_CAKEYUPDANNCONTENT *ckuann; /* 15 */
590         /*-
591          * cann       [16] CertAnnContent,           --Certificate Ann.
592          * OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly
593          */
594         X509 *cann; /* 16 */
595         /*-
596          * rann       [17] RevAnnContent,            --Revocation Ann.
597          */
598         OSSL_CMP_REVANNCONTENT *rann; /* 17 */
599         /*-
600          * crlann     [18] CRLAnnContent,            --CRL Announcement
601          * CRLAnnContent ::= SEQUENCE OF CertificateList
602          */
603         OSSL_CMP_CRLANNCONTENT *crlann; /* 18 */
604         /*-
605          * PKIConfirmContent ::= NULL
606          * pkiconf    [19] PKIConfirmContent,        --Confirmation
607          * OSSL_CMP_PKICONFIRMCONTENT would be only a typedef of ASN1_NULL
608          * OSSL_CMP_CONFIRMCONTENT *pkiconf;
609          *
610          * NOTE: this should ASN1_NULL according to the RFC
611          * but there might be a struct in it when sent from faulty servers...
612          */
613         ASN1_TYPE *pkiconf; /* 19 */
614         /*-
615          * nested     [20] NestedMessageContent,     --Nested Message
616          * NestedMessageContent ::= PKIMessages
617          */
618         OSSL_CMP_MSGS *nested; /* 20 */
619         /*-
620          * genm       [21] GenMsgContent,            --General Message
621          * GenMsgContent ::= SEQUENCE OF InfoTypeAndValue
622          */
623         OSSL_CMP_GENMSGCONTENT *genm; /* 21 */
624         /*-
625          * genp       [22] GenRepContent,            --General Response
626          * GenRepContent ::= SEQUENCE OF InfoTypeAndValue
627          */
628         OSSL_CMP_GENREPCONTENT *genp; /* 22 */
629         /*-
630          * error      [23] ErrorMsgContent,          --Error Message
631          */
632         OSSL_CMP_ERRORMSGCONTENT *error; /* 23 */
633         /*-
634          * certConf [24] CertConfirmContent,     --Certificate confirm
635          */
636         OSSL_CMP_CERTCONFIRMCONTENT *certConf; /* 24 */
637         /*-
638          * pollReq    [25] PollReqContent,           --Polling request
639          */
640         OSSL_CMP_POLLREQCONTENT *pollReq; /* 25 */
641         /*-
642          * pollRep    [26] PollRepContent            --Polling response
643          */
644         OSSL_CMP_POLLREPCONTENT *pollRep; /* 26 */
645     } value;
646 } OSSL_CMP_PKIBODY;
647 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
648
649 /*-
650  *   PKIProtection ::= BIT STRING
651  *
652  *   PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage
653  *
654  *    PKIMessage ::= SEQUENCE {
655  *           header           PKIHeader,
656  *           body             PKIBody,
657  *           protection   [0] PKIProtection OPTIONAL,
658  *           extraCerts   [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
659  *                                            OPTIONAL
660  *   }
661  */
662 struct ossl_cmp_msg_st {
663     OSSL_CMP_PKIHEADER *header;
664     OSSL_CMP_PKIBODY *body;
665     ASN1_BIT_STRING *protection; /* 0 */
666     /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
667     STACK_OF(X509) *extraCerts; /* 1 */
668 } /* OSSL_CMP_MSG */;
669 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSG)
670
671 /*-
672  * ProtectedPart ::= SEQUENCE {
673  * header    PKIHeader,
674  * body      PKIBody
675  * }
676  */
677 typedef struct ossl_cmp_protectedpart_st {
678     OSSL_CMP_PKIHEADER *header;
679     OSSL_CMP_PKIBODY *body;
680 } OSSL_CMP_PROTECTEDPART;
681 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PROTECTEDPART)
682
683 /*-
684  *  this is not defined here as it is already in CRMF:
685  *   id-PasswordBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 13}
686  *   PBMParameter ::= SEQUENCE {
687  *           salt                OCTET STRING,
688  *           -- note:  implementations MAY wish to limit acceptable sizes
689  *           -- of this string to values appropriate for their environment
690  *           -- in order to reduce the risk of denial-of-service attacks
691  *           owf                 AlgorithmIdentifier,
692  *           -- AlgId for a One-Way Function (SHA-1 recommended)
693  *           iterationCount      INTEGER,
694  *           -- number of times the OWF is applied
695  *           -- note:  implementations MAY wish to limit acceptable sizes
696  *           -- of this integer to values appropriate for their environment
697  *           -- in order to reduce the risk of denial-of-service attacks
698  *           mac                 AlgorithmIdentifier
699  *           -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
700  *   }       -- or HMAC [RFC2104, RFC2202])
701  */
702 /*-
703  *  TODO: this is not yet defined here - but DH is anyway not used yet
704  *
705  *   id-DHBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 30}
706  *   DHBMParameter ::= SEQUENCE {
707  *           owf                 AlgorithmIdentifier,
708  *           -- AlgId for a One-Way Function (SHA-1 recommended)
709  *           mac                 AlgorithmIdentifier
710  *           -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
711  *   }       -- or HMAC [RFC2104, RFC2202])
712  */
713 /*-
714  * The following is not cared for, because it is described in section 5.2.5
715  * that this is beyond the scope of CMP
716  *   OOBCert ::= CMPCertificate
717  *
718  *   OOBCertHash ::= SEQUENCE {
719  *           hashAlg         [0] AlgorithmIdentifier         OPTIONAL,
720  *           certId          [1] CertId                      OPTIONAL,
721  *           hashVal             BIT STRING
722  *           -- hashVal is calculated over the DER encoding of the
723  *           -- self-signed certificate with the identifier certID.
724  *   }
725  */
726
727 /* from cmp_asn.c */
728 int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a);
729
730 /* from cmp_util.c */
731 const char *ossl_cmp_log_parse_metadata(const char *buf,
732                                         OSSL_CMP_severity *level, char **func,
733                                         char **file, int *line);
734 # define ossl_cmp_add_error_data(txt) ERR_add_error_txt(" : ", txt)
735 # define ossl_cmp_add_error_line(txt) ERR_add_error_txt("\n", txt)
736 /* functions manipulating lists of certificates etc could be generally useful */
737 int ossl_cmp_sk_X509_add1_cert(STACK_OF(X509) *sk, X509 *cert,
738                                int no_dup, int prepend);
739 int ossl_cmp_sk_X509_add1_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs,
740                                 int no_self_issued, int no_dups, int prepend);
741 int ossl_cmp_X509_STORE_add1_certs(X509_STORE *store, STACK_OF(X509) *certs,
742                                    int only_self_issued);
743 STACK_OF(X509) *ossl_cmp_X509_STORE_get1_certs(X509_STORE *store);
744 int ossl_cmp_sk_ASN1_UTF8STRING_push_str(STACK_OF(ASN1_UTF8STRING) *sk,
745                                          const char *text);
746 int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING **tgt,
747                                     const ASN1_OCTET_STRING *src);
748 int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,
749                                           const unsigned char *bytes, int len);
750 STACK_OF(X509) *ossl_cmp_build_cert_chain(STACK_OF(X509) *certs, X509 *cert);
751
752 /* from cmp_ctx.c */
753 int ossl_cmp_print_log(OSSL_CMP_severity level, const OSSL_CMP_CTX *ctx,
754                        const char *func, const char *file, int line,
755                        const char *level_str, const char *format, ...);
756 # define ossl_cmp_log(level, ctx, msg) \
757     ossl_cmp_print_log(OSSL_CMP_LOG_##level, ctx, OPENSSL_FUNC, OPENSSL_FILE, \
758                        OPENSSL_LINE, #level, "%s", msg)
759 # define ossl_cmp_log1(level, ctx, fmt, arg1) \
760     ossl_cmp_print_log(OSSL_CMP_LOG_##level, ctx, OPENSSL_FUNC, OPENSSL_FILE, \
761                        OPENSSL_LINE, #level, fmt, arg1)
762 # define ossl_cmp_log2(level, ctx, fmt, arg1, arg2) \
763     ossl_cmp_print_log(OSSL_CMP_LOG_##level, ctx, OPENSSL_FUNC, OPENSSL_FILE, \
764                        OPENSSL_LINE, #level, fmt, arg1, arg2)
765 # define ossl_cmp_log3(level, ctx, fmt, arg1, arg2, arg3) \
766     ossl_cmp_print_log(OSSL_CMP_LOG_##level, ctx, OPENSSL_FUNC, OPENSSL_FILE, \
767                        OPENSSL_LINE, #level, fmt, arg1, arg2, arg3)
768 # define ossl_cmp_log4(level, ctx, fmt, arg1, arg2, arg3, arg4)         \
769     ossl_cmp_print_log(OSSL_CMP_LOG_##level, ctx, OPENSSL_FUNC, OPENSSL_FILE, \
770                        OPENSSL_LINE, #level, fmt, arg1, arg2, arg3, arg4)
771 # define OSSL_CMP_LOG_ERROR OSSL_CMP_LOG_ERR
772 # define OSSL_CMP_LOG_WARN OSSL_CMP_LOG_WARNING
773 # define ossl_cmp_alert(ctx, msg) ossl_cmp_log(ALERT, ctx, msg)
774 # define ossl_cmp_err(ctx, msg)   ossl_cmp_log(ERROR, ctx, msg)
775 # define ossl_cmp_warn(ctx, msg)  ossl_cmp_log(WARN,  ctx, msg)
776 # define ossl_cmp_info(ctx, msg)  ossl_cmp_log(INFO,  ctx, msg)
777 # define ossl_cmp_debug(ctx, msg) ossl_cmp_log(DEBUG, ctx, msg)
778 int ossl_cmp_ctx_set0_validatedSrvCert(OSSL_CMP_CTX *ctx, X509 *cert);
779 int ossl_cmp_ctx_set_status(OSSL_CMP_CTX *ctx, int status);
780 int ossl_cmp_ctx_set0_statusString(OSSL_CMP_CTX *ctx,
781                                    OSSL_CMP_PKIFREETEXT *text);
782 int ossl_cmp_ctx_set_failInfoCode(OSSL_CMP_CTX *ctx, int fail_info);
783 int ossl_cmp_ctx_set0_newCert(OSSL_CMP_CTX *ctx, X509 *cert);
784 int ossl_cmp_ctx_set1_caPubs(OSSL_CMP_CTX *ctx, STACK_OF(X509) *caPubs);
785 int ossl_cmp_ctx_set1_extraCertsIn(OSSL_CMP_CTX *ctx,
786                                    STACK_OF(X509) *extraCertsIn);
787 int ossl_cmp_ctx_set1_recipNonce(OSSL_CMP_CTX *ctx,
788                                  const ASN1_OCTET_STRING *nonce);
789
790 /* from cmp_status.c */
791 int ossl_cmp_pkisi_get_status(const OSSL_CMP_PKISI *si);
792 const char *ossl_cmp_PKIStatus_to_string(int status);
793 OSSL_CMP_PKIFREETEXT *ossl_cmp_pkisi_get0_statusString(const OSSL_CMP_PKISI *si);
794 int ossl_cmp_pkisi_get_pkifailureinfo(const OSSL_CMP_PKISI *si);
795 int ossl_cmp_pkisi_check_pkifailureinfo(const OSSL_CMP_PKISI *si, int index);
796
797 /* from cmp_hdr.c */
798 int ossl_cmp_hdr_set_pvno(OSSL_CMP_PKIHEADER *hdr, int pvno);
799 int ossl_cmp_hdr_get_pvno(const OSSL_CMP_PKIHEADER *hdr);
800 ASN1_OCTET_STRING *ossl_cmp_hdr_get0_senderNonce(const OSSL_CMP_PKIHEADER *hdr);
801 int ossl_cmp_general_name_is_NULL_DN(GENERAL_NAME *name);
802 int ossl_cmp_hdr_set1_sender(OSSL_CMP_PKIHEADER *hdr, const X509_NAME *nm);
803 int ossl_cmp_hdr_set1_recipient(OSSL_CMP_PKIHEADER *hdr, const X509_NAME *nm);
804 int ossl_cmp_hdr_update_messageTime(OSSL_CMP_PKIHEADER *hdr);
805 int ossl_cmp_hdr_set1_senderKID(OSSL_CMP_PKIHEADER *hdr,
806                                 const ASN1_OCTET_STRING *senderKID);
807 int ossl_cmp_hdr_push0_freeText(OSSL_CMP_PKIHEADER *hdr, ASN1_UTF8STRING *text);
808 int ossl_cmp_hdr_push1_freeText(OSSL_CMP_PKIHEADER *hdr, ASN1_UTF8STRING *text);
809 int ossl_cmp_hdr_generalInfo_push0_item(OSSL_CMP_PKIHEADER *hdr,
810                                         OSSL_CMP_ITAV *itav);
811 int ossl_cmp_hdr_generalInfo_push1_items(OSSL_CMP_PKIHEADER *hdr,
812                                          const STACK_OF(OSSL_CMP_ITAV) *itavs);
813 int ossl_cmp_hdr_set_implicitConfirm(OSSL_CMP_PKIHEADER *hdr);
814 int ossl_cmp_hdr_has_implicitConfirm(const OSSL_CMP_PKIHEADER *hdr);
815 # define OSSL_CMP_TRANSACTIONID_LENGTH 16
816 # define OSSL_CMP_SENDERNONCE_LENGTH 16
817 int ossl_cmp_hdr_init(OSSL_CMP_CTX *ctx, OSSL_CMP_PKIHEADER *hdr);
818
819 /* from cmp_msg.c */
820 /* OSSL_CMP_MSG bodytype ASN.1 choice IDs */
821 # define OSSL_CMP_PKIBODY_IR        0
822 # define OSSL_CMP_PKIBODY_IP        1
823 # define OSSL_CMP_PKIBODY_CR        2
824 # define OSSL_CMP_PKIBODY_CP        3
825 # define OSSL_CMP_PKIBODY_P10CR     4
826 # define OSSL_CMP_PKIBODY_POPDECC   5
827 # define OSSL_CMP_PKIBODY_POPDECR   6
828 # define OSSL_CMP_PKIBODY_KUR       7
829 # define OSSL_CMP_PKIBODY_KUP       8
830 # define OSSL_CMP_PKIBODY_KRR       9
831 # define OSSL_CMP_PKIBODY_KRP      10
832 # define OSSL_CMP_PKIBODY_RR       11
833 # define OSSL_CMP_PKIBODY_RP       12
834 # define OSSL_CMP_PKIBODY_CCR      13
835 # define OSSL_CMP_PKIBODY_CCP      14
836 # define OSSL_CMP_PKIBODY_CKUANN   15
837 # define OSSL_CMP_PKIBODY_CANN     16
838 # define OSSL_CMP_PKIBODY_RANN     17
839 # define OSSL_CMP_PKIBODY_CRLANN   18
840 # define OSSL_CMP_PKIBODY_PKICONF  19
841 # define OSSL_CMP_PKIBODY_NESTED   20
842 # define OSSL_CMP_PKIBODY_GENM     21
843 # define OSSL_CMP_PKIBODY_GENP     22
844 # define OSSL_CMP_PKIBODY_ERROR    23
845 # define OSSL_CMP_PKIBODY_CERTCONF 24
846 # define OSSL_CMP_PKIBODY_POLLREQ  25
847 # define OSSL_CMP_PKIBODY_POLLREP  26
848 # define OSSL_CMP_PKIBODY_TYPE_MAX OSSL_CMP_PKIBODY_POLLREP
849 /* certReqId for the first - and so far only - certificate request */
850 # define OSSL_CMP_CERTREQID 0
851 /* sequence id for the first - and so far only - revocation request */
852 # define OSSL_CMP_REVREQSID 0
853 const char *ossl_cmp_bodytype_to_string(int type);
854 int ossl_cmp_msg_set_bodytype(OSSL_CMP_MSG *msg, int type);
855 int ossl_cmp_msg_get_bodytype(const OSSL_CMP_MSG *msg);
856 OSSL_CMP_MSG *ossl_cmp_msg_create(OSSL_CMP_CTX *ctx, int bodytype);
857 OSSL_CMP_MSG *ossl_cmp_certReq_new(OSSL_CMP_CTX *ctx, int bodytype,
858                                    int err_code);
859 OSSL_CMP_MSG *ossl_cmp_certRep_new(OSSL_CMP_CTX *ctx, int bodytype,
860                                    int certReqId, OSSL_CMP_PKISI *si,
861                                    X509 *cert, STACK_OF(X509) *chain,
862                                    STACK_OF(X509) *caPubs, int encrypted,
863                                    int unprotectedErrors);
864 OSSL_CMP_MSG *ossl_cmp_rr_new(OSSL_CMP_CTX *ctx);
865 OSSL_CMP_MSG *ossl_cmp_rp_new(OSSL_CMP_CTX *ctx, OSSL_CMP_PKISI *si,
866                               OSSL_CRMF_CERTID *certId, int unprot_err);
867 OSSL_CMP_MSG *ossl_cmp_pkiconf_new(OSSL_CMP_CTX *ctx);
868 OSSL_CMP_MSG *ossl_cmp_pollRep_new(OSSL_CMP_CTX *ctx, int crid,
869                                    int64_t poll_after);
870 int ossl_cmp_msg_gen_push0_ITAV(OSSL_CMP_MSG *msg, OSSL_CMP_ITAV *itav);
871 int ossl_cmp_msg_gen_push1_ITAVs(OSSL_CMP_MSG *msg,
872                                  const STACK_OF(OSSL_CMP_ITAV) *itavs);
873 OSSL_CMP_MSG *ossl_cmp_genm_new(OSSL_CMP_CTX *ctx);
874 OSSL_CMP_MSG *ossl_cmp_genp_new(OSSL_CMP_CTX *ctx,
875                                 const STACK_OF(OSSL_CMP_ITAV) *itavs);
876 OSSL_CMP_MSG *ossl_cmp_error_new(OSSL_CMP_CTX *ctx, OSSL_CMP_PKISI *si,
877                                  int errorCode,
878                                  const char *details, int unprotected);
879 int ossl_cmp_certstatus_set0_certHash(OSSL_CMP_CERTSTATUS *certStatus,
880                                       ASN1_OCTET_STRING *hash);
881 OSSL_CMP_MSG *ossl_cmp_certConf_new(OSSL_CMP_CTX *ctx, int fail_info,
882                                     const char *text);
883 OSSL_CMP_MSG *ossl_cmp_pollReq_new(OSSL_CMP_CTX *ctx, int crid);
884 OSSL_CMP_MSG *ossl_cmp_pollRep_new(OSSL_CMP_CTX *ctx, int crid,
885                                    int64_t poll_after);
886 OSSL_CMP_PKISI *
887 ossl_cmp_revrepcontent_get_pkisi(OSSL_CMP_REVREPCONTENT *rrep, int rsid);
888 OSSL_CRMF_CERTID *ossl_cmp_revrepcontent_get_CertId(OSSL_CMP_REVREPCONTENT *rrep,
889                                                     int rsid);
890 OSSL_CMP_POLLREP *
891 ossl_cmp_pollrepcontent_get0_pollrep(const OSSL_CMP_POLLREPCONTENT *prc,
892                                      int rid);
893 OSSL_CMP_CERTRESPONSE *
894 ossl_cmp_certrepmessage_get0_certresponse(const OSSL_CMP_CERTREPMESSAGE *crepmsg,
895                                           int rid);
896 X509 *ossl_cmp_certresponse_get1_certificate(EVP_PKEY *privkey,
897                                              const OSSL_CMP_CERTRESPONSE *crep);
898 OSSL_CMP_MSG *ossl_cmp_msg_load(const char *file);
899
900 /* from cmp_protect.c */
901 ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_MSG *msg,
902                                           const ASN1_OCTET_STRING *secret,
903                                           EVP_PKEY *pkey);
904 int ossl_cmp_msg_add_extraCerts(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
905 int ossl_cmp_msg_protect(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
906
907 /* from cmp_vfy.c */
908 typedef int (*ossl_cmp_allow_unprotected_cb_t)(const OSSL_CMP_CTX *ctx,
909                                                const OSSL_CMP_MSG *msg,
910                                                int invalid_protection, int arg);
911 int ossl_cmp_msg_check_received(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg,
912                                 ossl_cmp_allow_unprotected_cb_t cb, int cb_arg);
913 int ossl_cmp_verify_popo(const OSSL_CMP_MSG *msg, int accept_RAVerified);
914
915 /* from cmp_client.c */
916 int ossl_cmp_exchange_certConf(OSSL_CMP_CTX *ctx, int fail_info,
917                                const char *txt);
918 int ossl_cmp_exchange_error(OSSL_CMP_CTX *ctx, int status, int fail_info,
919                             const char *txt, int errorCode, const char *details);
920
921 #endif /* !defined(OSSL_CRYPTO_CMP_LOCAL_H) */