2 * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
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
12 #ifndef OSSL_CRYPTO_CMP_LOCAL_H
13 # define OSSL_CRYPTO_CMP_LOCAL_H
15 # include "internal/cryptlib.h"
17 # include <openssl/cmp.h>
18 # include <openssl/err.h>
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>
28 * this structure is used to store the context for CMP sessions
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 */
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 */
43 int msgtimeout
; /* max seconds to wait for each CMP message round trip */
44 int totaltimeout
; /* maximum number 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_cmp_http_cb_t http_cb
;
48 void *http_cb_arg
; /* allows to store optional argument to cb */
50 /* server authentication */
51 int unprotectedErrors
; /* accept neg. response with no/invalid protection */
52 /* to cope with broken server */
53 X509
*srvCert
; /* certificate used to identify the server */
54 X509
*validatedSrvCert
; /* caches any already validated server cert */
55 X509_NAME
*expected_sender
; /* expected sender in pkiheader of response */
56 X509_STORE
*trusted
; /* trust store maybe w CRLs and cert verify callback */
57 STACK_OF(X509
) *untrusted_certs
; /* untrusted (intermediate) certs */
58 int ignore_keyusage
; /* ignore key usage entry when validating certs */
59 int permitTAInExtraCertsForIR
; /* allow use of root certs in extracerts */
60 /* when validating message protection; used for 3GPP-style E.7 */
62 /* client authentication */
63 int unprotectedSend
; /* send unprotected PKI messages */
64 X509
*clCert
; /* client cert used to identify and sign for MSG_SIG_ALG */
65 EVP_PKEY
*pkey
; /* the key pair corresponding to clCert */
66 ASN1_OCTET_STRING
*referenceValue
; /* optional user name for MSG_MAC_ALG */
67 ASN1_OCTET_STRING
*secretValue
; /* password/shared secret for MSG_MAC_ALG */
68 /* PBMParameters for MSG_MAC_ALG */
69 size_t pbm_slen
; /* currently fixed to 16 */
70 int pbm_owf
; /* NID of one-way function (OWF), default: SHA256 */
71 int pbm_itercnt
; /* currently fixed to 500 */
72 int pbm_mac
; /* NID of MAC algorithm, default: HMAC-SHA1 as per RFC 4210 */
74 /* CMP message header and extra certificates */
75 X509_NAME
*recipient
; /* to set in recipient in pkiheader */
76 int digest
; /* NID of digest used in MSG_SIG_ALG and POPO, default SHA256 */
77 ASN1_OCTET_STRING
*transactionID
; /* the current transaction ID */
78 ASN1_OCTET_STRING
*senderNonce
; /* last nonce sent */
79 ASN1_OCTET_STRING
*recipNonce
; /* last nonce received */
80 ASN1_UTF8STRING
*freeText
; /* optional string to include each msg */
81 STACK_OF(OSSL_CMP_ITAV
) *geninfo_ITAVs
;
82 int implicitConfirm
; /* set implicitConfirm in IR/KUR/CR messages */
83 int disableConfirm
; /* disable certConf in IR/KUR/CR for broken servers */
84 STACK_OF(X509
) *extraCertsOut
; /* to be included in request messages */
86 /* certificate template */
87 EVP_PKEY
*newPkey
; /* explicit new private/public key for cert enrollment */
88 int newPkey_priv
; /* flag indicating if newPkey contains private key */
89 X509_NAME
*issuer
; /* issuer name to used in cert template */
90 int days
; /* Number of days new certificates are asked to be valid for */
91 X509_NAME
*subjectName
; /* subject name to be used in the cert template */
92 STACK_OF(GENERAL_NAME
) *subjectAltNames
; /* to add to the cert template */
93 int SubjectAltName_nodefault
;
94 int setSubjectAltNameCritical
;
95 X509_EXTENSIONS
*reqExtensions
; /* exts to be added to cert template */
96 CERTIFICATEPOLICIES
*policies
; /* policies to be included in extensions */
97 int setPoliciesCritical
;
98 int popoMethod
; /* Proof-of-possession mechanism; default: signature */
99 X509
*oldCert
; /* cert to be updated (via KUR) or to be revoked (via RR) */
100 X509_REQ
*p10CSR
; /* for P10CR: PKCS#10 CSR to be sent */
102 /* misc body contents */
103 int revocationReason
; /* revocation reason code to be included in RR */
104 STACK_OF(OSSL_CMP_ITAV
) *genm_ITAVs
; /* content of general message */
106 /* result returned in responses */
107 int status
; /* PKIStatus of last received IP/CP/KUP/RP/error or -1 */
108 /* TODO: this should be a stack since there could be more than one */
109 OSSL_CMP_PKIFREETEXT
*statusString
; /* of last IP/CP/KUP/RP/error */
110 int failInfoCode
; /* failInfoCode of last received IP/CP/KUP/error, or -1 */
111 /* TODO: this should be a stack since there could be more than one */
112 X509
*newCert
; /* newly enrolled cert received from the CA */
113 /* TODO: this should be a stack since there could be more than one */
114 STACK_OF(X509
) *caPubs
; /* CA certs received from server (in IP message) */
115 STACK_OF(X509
) *extraCertsIn
; /* extraCerts received from server */
117 /* certificate confirmation */
118 OSSL_cmp_certConf_cb_t certConf_cb
; /* callback for app checking new cert */
119 void *certConf_cb_arg
; /* allows to store an argument individual to cb */
120 } /* OSSL_CMP_CTX */;
123 * ##########################################################################
125 * ##########################################################################
129 * RevAnnContent ::= SEQUENCE {
132 * willBeRevokedAt GeneralizedTime,
133 * badSinceDate GeneralizedTime,
134 * crlDetails Extensions OPTIONAL
135 * -- extra CRL details (e.g., crl number, reason, location, etc.)
138 typedef struct ossl_cmp_revanncontent_st
{
139 ASN1_INTEGER
*status
;
140 OSSL_CRMF_CERTID
*certId
;
141 ASN1_GENERALIZEDTIME
*willBeRevokedAt
;
142 ASN1_GENERALIZEDTIME
*badSinceDate
;
143 X509_EXTENSIONS
*crlDetails
;
144 } OSSL_CMP_REVANNCONTENT
;
145 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT
)
148 * Challenge ::= SEQUENCE {
149 * owf AlgorithmIdentifier OPTIONAL,
151 * -- MUST be present in the first Challenge; MAY be omitted in
152 * -- any subsequent Challenge in POPODecKeyChallContent (if
153 * -- omitted, then the owf used in the immediately preceding
154 * -- Challenge is to be used).
156 * witness OCTET STRING,
157 * -- the result of applying the one-way function (owf) to a
158 * -- randomly-generated INTEGER, A. [Note that a different
159 * -- INTEGER MUST be used for each Challenge.]
160 * challenge OCTET STRING
161 * -- the encryption (under the public key for which the cert.
162 * -- request is being made) of Rand, where Rand is specified as
163 * -- Rand ::= SEQUENCE {
165 * -- - the randomly-generated INTEGER A (above)
166 * -- sender GeneralName
167 * -- - the sender's name (as included in PKIHeader)
171 typedef struct ossl_cmp_challenge_st
{
173 ASN1_OCTET_STRING
*witness
;
174 ASN1_OCTET_STRING
*challenge
;
175 } OSSL_CMP_CHALLENGE
;
176 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE
)
179 * CAKeyUpdAnnContent ::= SEQUENCE {
180 * oldWithNew Certificate,
181 * newWithOld Certificate,
182 * newWithNew Certificate
185 typedef struct ossl_cmp_cakeyupdanncontent_st
{
189 } OSSL_CMP_CAKEYUPDANNCONTENT
;
190 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT
)
193 * declared already here as it will be used in OSSL_CMP_MSG (nested) and
194 * infoType and infoValue
196 typedef STACK_OF(OSSL_CMP_MSG
) OSSL_CMP_MSGS
;
197 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSGS
)
200 * InfoTypeAndValue ::= SEQUENCE {
201 * infoType OBJECT IDENTIFIER,
202 * infoValue ANY DEFINED BY infoType OPTIONAL
205 struct ossl_cmp_itav_st
{
206 ASN1_OBJECT
*infoType
;
209 /* NID_id_it_caProtEncCert - CA Protocol Encryption Certificate */
211 /* NID_id_it_signKeyPairTypes - Signing Key Pair Types */
212 STACK_OF(X509_ALGOR
) *signKeyPairTypes
;
213 /* NID_id_it_encKeyPairTypes - Encryption/Key Agreement Key Pair Types */
214 STACK_OF(X509_ALGOR
) *encKeyPairTypes
;
215 /* NID_id_it_preferredSymmAlg - Preferred Symmetric Algorithm */
216 X509_ALGOR
*preferredSymmAlg
;
217 /* NID_id_it_caKeyUpdateInfo - Updated CA Key Pair */
218 OSSL_CMP_CAKEYUPDANNCONTENT
*caKeyUpdateInfo
;
219 /* NID_id_it_currentCRL - CRL */
220 X509_CRL
*currentCRL
;
221 /* NID_id_it_unsupportedOIDs - Unsupported Object Identifiers */
222 STACK_OF(ASN1_OBJECT
) *unsupportedOIDs
;
223 /* NID_id_it_keyPairParamReq - Key Pair Parameters Request */
224 ASN1_OBJECT
*keyPairParamReq
;
225 /* NID_id_it_keyPairParamRep - Key Pair Parameters Response */
226 X509_ALGOR
*keyPairParamRep
;
227 /* NID_id_it_revPassphrase - Revocation Passphrase */
228 OSSL_CRMF_ENCRYPTEDVALUE
*revPassphrase
;
229 /* NID_id_it_implicitConfirm - ImplicitConfirm */
230 ASN1_NULL
*implicitConfirm
;
231 /* NID_id_it_confirmWaitTime - ConfirmWaitTime */
232 ASN1_GENERALIZEDTIME
*confirmWaitTime
;
233 /* NID_id_it_origPKIMessage - origPKIMessage */
234 OSSL_CMP_MSGS
*origPKIMessage
;
235 /* NID_id_it_suppLangTags - Supported Language Tags */
236 STACK_OF(ASN1_UTF8STRING
) *suppLangTagsValue
;
237 /* this is to be used for so far undeclared objects */
240 } /* OSSL_CMP_ITAV */;
241 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ITAV
)
242 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV
)
244 typedef struct ossl_cmp_certorenccert_st
{
248 OSSL_CRMF_ENCRYPTEDVALUE
*encryptedCert
;
250 } OSSL_CMP_CERTORENCCERT
;
251 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT
)
254 * CertifiedKeyPair ::= SEQUENCE {
255 * certOrEncCert CertOrEncCert,
256 * privateKey [0] EncryptedValue OPTIONAL,
257 * -- see [CRMF] for comment on encoding
258 * publicationInfo [1] PKIPublicationInfo OPTIONAL
261 typedef struct ossl_cmp_certifiedkeypair_st
{
262 OSSL_CMP_CERTORENCCERT
*certOrEncCert
;
263 OSSL_CRMF_ENCRYPTEDVALUE
*privateKey
;
264 OSSL_CRMF_PKIPUBLICATIONINFO
*publicationInfo
;
265 } OSSL_CMP_CERTIFIEDKEYPAIR
;
266 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR
)
269 * PKIStatusInfo ::= SEQUENCE {
271 * statusString PKIFreeText OPTIONAL,
272 * failInfo PKIFailureInfo OPTIONAL
275 struct ossl_cmp_pkisi_st
{
276 OSSL_CMP_PKISTATUS
*status
;
277 OSSL_CMP_PKIFREETEXT
*statusString
;
278 OSSL_CMP_PKIFAILUREINFO
*failInfo
;
279 } /* OSSL_CMP_PKISI */;
280 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI
)
281 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI
)
284 * RevReqContent ::= SEQUENCE OF RevDetails
286 * RevDetails ::= SEQUENCE {
287 * certDetails CertTemplate,
288 * crlEntryDetails Extensions OPTIONAL
291 typedef struct ossl_cmp_revdetails_st
{
292 OSSL_CRMF_CERTTEMPLATE
*certDetails
;
293 X509_EXTENSIONS
*crlEntryDetails
;
294 } OSSL_CMP_REVDETAILS
;
295 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS
)
296 DEFINE_STACK_OF(OSSL_CMP_REVDETAILS
)
299 * RevRepContent ::= SEQUENCE {
300 * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo,
301 * -- in same order as was sent in RevReqContent
302 * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId
304 * -- IDs for which revocation was requested
305 * -- (same order as status)
306 * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList
308 * -- the resulting CRLs (there may be more than one)
311 struct ossl_cmp_revrepcontent_st
{
312 STACK_OF(OSSL_CMP_PKISI
) *status
;
313 STACK_OF(OSSL_CRMF_CERTID
) *revCerts
;
314 STACK_OF(X509_CRL
) *crls
;
315 } /* OSSL_CMP_REVREPCONTENT */;
316 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT
)
319 * KeyRecRepContent ::= SEQUENCE {
320 * status PKIStatusInfo,
321 * newSigCert [0] Certificate OPTIONAL,
322 * caCerts [1] SEQUENCE SIZE (1..MAX) OF
323 * Certificate OPTIONAL,
324 * keyPairHist [2] SEQUENCE SIZE (1..MAX) OF
325 * CertifiedKeyPair OPTIONAL
328 typedef struct ossl_cmp_keyrecrepcontent_st
{
329 OSSL_CMP_PKISI
*status
;
331 STACK_OF(X509
) *caCerts
;
332 STACK_OF(OSSL_CMP_CERTIFIEDKEYPAIR
) *keyPairHist
;
333 } OSSL_CMP_KEYRECREPCONTENT
;
334 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT
)
337 * ErrorMsgContent ::= SEQUENCE {
338 * pKIStatusInfo PKIStatusInfo,
339 * errorCode INTEGER OPTIONAL,
340 * -- implementation-specific error codes
341 * errorDetails PKIFreeText OPTIONAL
342 * -- implementation-specific error details
345 typedef struct ossl_cmp_errormsgcontent_st
{
346 OSSL_CMP_PKISI
*pKIStatusInfo
;
347 ASN1_INTEGER
*errorCode
;
348 OSSL_CMP_PKIFREETEXT
*errorDetails
;
349 } OSSL_CMP_ERRORMSGCONTENT
;
350 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT
)
353 * CertConfirmContent ::= SEQUENCE OF CertStatus
355 * CertStatus ::= SEQUENCE {
356 * certHash OCTET STRING,
357 * -- the hash of the certificate, using the same hash algorithm
358 * -- as is used to create and verify the certificate signature
360 * -- to match this confirmation with the corresponding req/rep
361 * statusInfo PKIStatusInfo OPTIONAL
364 struct ossl_cmp_certstatus_st
{
365 ASN1_OCTET_STRING
*certHash
;
366 ASN1_INTEGER
*certReqId
;
367 OSSL_CMP_PKISI
*statusInfo
;
368 } /* OSSL_CMP_CERTSTATUS */;
369 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS
)
371 typedef STACK_OF(OSSL_CMP_CERTSTATUS
) OSSL_CMP_CERTCONFIRMCONTENT
;
372 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTCONFIRMCONTENT
)
375 * CertResponse ::= SEQUENCE {
377 * -- to match this response with corresponding request (a value
378 * -- of -1 is to be used if certReqId is not specified in the
379 * -- corresponding request)
380 * status PKIStatusInfo,
381 * certifiedKeyPair CertifiedKeyPair OPTIONAL,
382 * rspInfo OCTET STRING OPTIONAL
383 * -- analogous to the id-regInfo-utf8Pairs string defined
384 * -- for regInfo in CertReqMsg [CRMF]
387 struct ossl_cmp_certresponse_st
{
388 ASN1_INTEGER
*certReqId
;
389 OSSL_CMP_PKISI
*status
;
390 OSSL_CMP_CERTIFIEDKEYPAIR
*certifiedKeyPair
;
391 ASN1_OCTET_STRING
*rspInfo
;
392 } /* OSSL_CMP_CERTRESPONSE */;
393 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE
)
396 * CertRepMessage ::= SEQUENCE {
397 * caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
399 * response SEQUENCE OF CertResponse
402 struct ossl_cmp_certrepmessage_st
{
403 STACK_OF(X509
) *caPubs
;
404 STACK_OF(OSSL_CMP_CERTRESPONSE
) *response
;
405 } /* OSSL_CMP_CERTREPMESSAGE */;
406 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE
)
409 * PollReqContent ::= SEQUENCE OF SEQUENCE {
413 typedef struct ossl_cmp_pollreq_st
{
414 ASN1_INTEGER
*certReqId
;
416 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ
)
417 DEFINE_STACK_OF(OSSL_CMP_POLLREQ
)
418 typedef STACK_OF(OSSL_CMP_POLLREQ
) OSSL_CMP_POLLREQCONTENT
;
419 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQCONTENT
)
422 * PollRepContent ::= SEQUENCE OF SEQUENCE {
424 * checkAfter INTEGER, -- time in seconds
425 * reason PKIFreeText OPTIONAL
428 struct ossl_cmp_pollrep_st
{
429 ASN1_INTEGER
*certReqId
;
430 ASN1_INTEGER
*checkAfter
;
431 OSSL_CMP_PKIFREETEXT
*reason
;
432 } /* OSSL_CMP_POLLREP */;
433 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREP
)
434 DEFINE_STACK_OF(OSSL_CMP_POLLREP
)
435 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREPCONTENT
)
438 * PKIHeader ::= SEQUENCE {
439 * pvno INTEGER { cmp1999(1), cmp2000(2) },
440 * sender GeneralName,
441 * -- identifies the sender
442 * recipient GeneralName,
443 * -- identifies the intended recipient
444 * messageTime [0] GeneralizedTime OPTIONAL,
445 * -- time of production of this message (used when sender
446 * -- believes that the transport will be "suitable"; i.e.,
447 * -- that the time will still be meaningful upon receipt)
448 * protectionAlg [1] AlgorithmIdentifier OPTIONAL,
449 * -- algorithm used for calculation of protection bits
450 * senderKID [2] KeyIdentifier OPTIONAL,
451 * recipKID [3] KeyIdentifier OPTIONAL,
452 * -- to identify specific keys used for protection
453 * transactionID [4] OCTET STRING OPTIONAL,
454 * -- identifies the transaction; i.e., this will be the same in
455 * -- corresponding request, response, certConf, and PKIConf
457 * senderNonce [5] OCTET STRING OPTIONAL,
458 * recipNonce [6] OCTET STRING OPTIONAL,
459 * -- nonces used to provide replay protection, senderNonce
460 * -- is inserted by the creator of this message; recipNonce
461 * -- is a nonce previously inserted in a related message by
462 * -- the intended recipient of this message
463 * freeText [7] PKIFreeText OPTIONAL,
464 * -- this may be used to indicate context-specific instructions
465 * -- (this field is intended for human consumption)
466 * generalInfo [8] SEQUENCE SIZE (1..MAX) OF
467 * InfoTypeAndValue OPTIONAL
468 * -- this may be used to convey context-specific information
469 * -- (this field not primarily intended for human consumption)
472 struct ossl_cmp_pkiheader_st
{
474 GENERAL_NAME
*sender
;
475 GENERAL_NAME
*recipient
;
476 ASN1_GENERALIZEDTIME
*messageTime
; /* 0 */
477 X509_ALGOR
*protectionAlg
; /* 1 */
478 ASN1_OCTET_STRING
*senderKID
; /* 2 */
479 ASN1_OCTET_STRING
*recipKID
; /* 3 */
480 ASN1_OCTET_STRING
*transactionID
; /* 4 */
481 ASN1_OCTET_STRING
*senderNonce
; /* 5 */
482 ASN1_OCTET_STRING
*recipNonce
; /* 6 */
483 OSSL_CMP_PKIFREETEXT
*freeText
; /* 7 */
484 STACK_OF(OSSL_CMP_ITAV
) *generalInfo
; /* 8 */
485 } /* OSSL_CMP_PKIHEADER */;
487 typedef STACK_OF(OSSL_CMP_CHALLENGE
) OSSL_CMP_POPODECKEYCHALLCONTENT
;
488 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYCHALLCONTENT
)
489 typedef STACK_OF(ASN1_INTEGER
) OSSL_CMP_POPODECKEYRESPCONTENT
;
490 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYRESPCONTENT
)
491 typedef STACK_OF(OSSL_CMP_REVDETAILS
) OSSL_CMP_REVREQCONTENT
;
492 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREQCONTENT
)
493 typedef STACK_OF(X509_CRL
) OSSL_CMP_CRLANNCONTENT
;
494 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CRLANNCONTENT
)
495 typedef STACK_OF(OSSL_CMP_ITAV
) OSSL_CMP_GENMSGCONTENT
;
496 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENMSGCONTENT
)
497 typedef STACK_OF(OSSL_CMP_ITAV
) OSSL_CMP_GENREPCONTENT
;
498 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENREPCONTENT
)
501 * PKIBody ::= CHOICE { -- message-specific body elements
502 * ir [0] CertReqMessages, --Initialization Request
503 * ip [1] CertRepMessage, --Initialization Response
504 * cr [2] CertReqMessages, --Certification Request
505 * cp [3] CertRepMessage, --Certification Response
506 * p10cr [4] CertificationRequest, --imported from [PKCS10]
507 * popdecc [5] POPODecKeyChallContent, --pop Challenge
508 * popdecr [6] POPODecKeyRespContent, --pop Response
509 * kur [7] CertReqMessages, --Key Update Request
510 * kup [8] CertRepMessage, --Key Update Response
511 * krr [9] CertReqMessages, --Key Recovery Request
512 * krp [10] KeyRecRepContent, --Key Recovery Response
513 * rr [11] RevReqContent, --Revocation Request
514 * rp [12] RevRepContent, --Revocation Response
515 * ccr [13] CertReqMessages, --Cross-Cert. Request
516 * ccp [14] CertRepMessage, --Cross-Cert. Response
517 * ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann.
518 * cann [16] CertAnnContent, --Certificate Ann.
519 * rann [17] RevAnnContent, --Revocation Ann.
520 * crlann [18] CRLAnnContent, --CRL Announcement
521 * pkiconf [19] PKIConfirmContent, --Confirmation
522 * nested [20] NestedMessageContent, --Nested Message
523 * genm [21] GenMsgContent, --General Message
524 * genp [22] GenRepContent, --General Response
525 * error [23] ErrorMsgContent, --Error Message
526 * certConf [24] CertConfirmContent, --Certificate confirm
527 * pollReq [25] PollReqContent, --Polling request
528 * pollRep [26] PollRepContent --Polling response
530 typedef struct ossl_cmp_pkibody_st
{
533 OSSL_CRMF_MSGS
*ir
; /* 0 */
534 OSSL_CMP_CERTREPMESSAGE
*ip
; /* 1 */
535 OSSL_CRMF_MSGS
*cr
; /* 2 */
536 OSSL_CMP_CERTREPMESSAGE
*cp
; /* 3 */
537 /* p10cr [4] CertificationRequest, --imported from [PKCS10] */
539 * PKCS10_CERTIFICATIONREQUEST is effectively X509_REQ
540 * so it is used directly
542 X509_REQ
*p10cr
; /* 4 */
543 /* popdecc [5] POPODecKeyChallContent, --pop Challenge */
544 /* POPODecKeyChallContent ::= SEQUENCE OF Challenge */
545 OSSL_CMP_POPODECKEYCHALLCONTENT
*popdecc
; /* 5 */
546 /* popdecr [6] POPODecKeyRespContent, --pop Response */
547 /* POPODecKeyRespContent ::= SEQUENCE OF INTEGER */
548 OSSL_CMP_POPODECKEYRESPCONTENT
*popdecr
; /* 6 */
549 OSSL_CRMF_MSGS
*kur
; /* 7 */
550 OSSL_CMP_CERTREPMESSAGE
*kup
; /* 8 */
551 OSSL_CRMF_MSGS
*krr
; /* 9 */
553 /* krp [10] KeyRecRepContent, --Key Recovery Response */
554 OSSL_CMP_KEYRECREPCONTENT
*krp
; /* 10 */
555 /* rr [11] RevReqContent, --Revocation Request */
556 OSSL_CMP_REVREQCONTENT
*rr
; /* 11 */
557 /* rp [12] RevRepContent, --Revocation Response */
558 OSSL_CMP_REVREPCONTENT
*rp
; /* 12 */
559 /* ccr [13] CertReqMessages, --Cross-Cert. Request */
560 OSSL_CRMF_MSGS
*ccr
; /* 13 */
561 /* ccp [14] CertRepMessage, --Cross-Cert. Response */
562 OSSL_CMP_CERTREPMESSAGE
*ccp
; /* 14 */
563 /* ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. */
564 OSSL_CMP_CAKEYUPDANNCONTENT
*ckuann
; /* 15 */
565 /* cann [16] CertAnnContent, --Certificate Ann. */
566 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
568 /* rann [17] RevAnnContent, --Revocation Ann. */
569 OSSL_CMP_REVANNCONTENT
*rann
; /* 17 */
570 /* crlann [18] CRLAnnContent, --CRL Announcement */
571 /* CRLAnnContent ::= SEQUENCE OF CertificateList */
572 OSSL_CMP_CRLANNCONTENT
*crlann
;
573 /* PKIConfirmContent ::= NULL */
574 /* pkiconf [19] PKIConfirmContent, --Confirmation */
575 /* OSSL_CMP_PKICONFIRMCONTENT would be only a typedef of ASN1_NULL */
576 /* OSSL_CMP_CONFIRMCONTENT *pkiconf; */
578 * NOTE: this should ASN1_NULL according to the RFC
579 * but there might be a struct in it when sent from faulty servers...
581 ASN1_TYPE
*pkiconf
; /* 19 */
582 /* nested [20] NestedMessageContent, --Nested Message */
583 /* NestedMessageContent ::= PKIMessages */
584 OSSL_CMP_MSGS
*nested
; /* 20 */
585 /* genm [21] GenMsgContent, --General Message */
586 /* GenMsgContent ::= SEQUENCE OF InfoTypeAndValue */
587 OSSL_CMP_GENMSGCONTENT
*genm
; /* 21 */
588 /* genp [22] GenRepContent, --General Response */
589 /* GenRepContent ::= SEQUENCE OF InfoTypeAndValue */
590 OSSL_CMP_GENREPCONTENT
*genp
; /* 22 */
591 /* error [23] ErrorMsgContent, --Error Message */
592 OSSL_CMP_ERRORMSGCONTENT
*error
; /* 23 */
593 /* certConf [24] CertConfirmContent, --Certificate confirm */
594 OSSL_CMP_CERTCONFIRMCONTENT
*certConf
; /* 24 */
595 /* pollReq [25] PollReqContent, --Polling request */
596 OSSL_CMP_POLLREQCONTENT
*pollReq
;
597 /* pollRep [26] PollRepContent --Polling response */
598 OSSL_CMP_POLLREPCONTENT
*pollRep
;
601 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY
)
604 * PKIProtection ::= BIT STRING
606 * PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage
608 * PKIMessage ::= SEQUENCE {
611 * protection [0] PKIProtection OPTIONAL,
612 * extraCerts [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
616 struct ossl_cmp_msg_st
{
617 OSSL_CMP_PKIHEADER
*header
;
618 OSSL_CMP_PKIBODY
*body
;
619 ASN1_BIT_STRING
*protection
; /* 0 */
620 /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
621 STACK_OF(X509
) *extraCerts
; /* 1 */
622 } /* OSSL_CMP_MSG */;
623 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSG
)
624 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG
)
627 * ProtectedPart ::= SEQUENCE {
632 typedef struct cmp_protectedpart_st
{
633 OSSL_CMP_PKIHEADER
*header
;
634 OSSL_CMP_PKIBODY
*body
;
636 DECLARE_ASN1_FUNCTIONS(CMP_PROTECTEDPART
)
639 * this is not defined here as it is already in CRMF:
640 * id-PasswordBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 13}
641 * PBMParameter ::= SEQUENCE {
643 * -- note: implementations MAY wish to limit acceptable sizes
644 * -- of this string to values appropriate for their environment
645 * -- in order to reduce the risk of denial-of-service attacks
646 * owf AlgorithmIdentifier,
647 * -- AlgId for a One-Way Function (SHA-1 recommended)
648 * iterationCount INTEGER,
649 * -- number of times the OWF is applied
650 * -- note: implementations MAY wish to limit acceptable sizes
651 * -- of this integer to values appropriate for their environment
652 * -- in order to reduce the risk of denial-of-service attacks
653 * mac AlgorithmIdentifier
654 * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
655 * } -- or HMAC [RFC2104, RFC2202])
658 * TODO: this is not yet defined here - but DH is anyway not used yet
660 * id-DHBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 30}
661 * DHBMParameter ::= SEQUENCE {
662 * owf AlgorithmIdentifier,
663 * -- AlgId for a One-Way Function (SHA-1 recommended)
664 * mac AlgorithmIdentifier
665 * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
666 * } -- or HMAC [RFC2104, RFC2202])
669 * The following is not cared for, because it is described in section 5.2.5
670 * that this is beyond the scope of CMP
671 * OOBCert ::= CMPCertificate
673 * OOBCertHash ::= SEQUENCE {
674 * hashAlg [0] AlgorithmIdentifier OPTIONAL,
675 * certId [1] CertId OPTIONAL,
677 * -- hashVal is calculated over the DER encoding of the
678 * -- self-signed certificate with the identifier certID.
687 int ossl_cmp_asn1_get_int(const ASN1_INTEGER
*a
);
689 /* from cmp_util.c */
690 const char *ossl_cmp_log_parse_metadata(const char *buf
,
691 OSSL_CMP_severity
*level
, char **func
,
692 char **file
, int *line
);
693 /* workaround for 4096 bytes limitation of ERR_print_errors_cb() */
694 void ossl_cmp_add_error_txt(const char *separator
, const char *txt
);
695 # define ossl_cmp_add_error_data(txt) ossl_cmp_add_error_txt(" : ", txt)
696 # define ossl_cmp_add_error_line(txt) ossl_cmp_add_error_txt("\n", txt)
697 /* functions manipulating lists of certificates etc could be generally useful */
698 int ossl_cmp_sk_X509_add1_cert (STACK_OF(X509
) *sk
, X509
*cert
,
699 int no_dup
, int prepend
);
700 int ossl_cmp_sk_X509_add1_certs(STACK_OF(X509
) *sk
, STACK_OF(X509
) *certs
,
701 int no_self_signed
, int no_dups
, int prepend
);
702 int ossl_cmp_X509_STORE_add1_certs(X509_STORE
*store
, STACK_OF(X509
) *certs
,
703 int only_self_signed
);
704 STACK_OF(X509
) *ossl_cmp_X509_STORE_get1_certs(X509_STORE
*store
);
705 int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING
**tgt
,
706 const ASN1_OCTET_STRING
*src
);
707 int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING
**tgt
,
708 const unsigned char *bytes
, int len
);
709 STACK_OF(X509
) *ossl_cmp_build_cert_chain(STACK_OF(X509
) *certs
, X509
*cert
);
712 int ossl_cmp_ctx_set0_validatedSrvCert(OSSL_CMP_CTX
*ctx
, X509
*cert
);
713 int ossl_cmp_ctx_set_status(OSSL_CMP_CTX
*ctx
, int status
);
714 int ossl_cmp_ctx_set0_statusString(OSSL_CMP_CTX
*ctx
,
715 OSSL_CMP_PKIFREETEXT
*text
);
716 int ossl_cmp_ctx_set_failInfoCode(OSSL_CMP_CTX
*ctx
, int fail_info
);
717 int ossl_cmp_ctx_set0_newCert(OSSL_CMP_CTX
*ctx
, X509
*cert
);
718 int ossl_cmp_ctx_set1_caPubs(OSSL_CMP_CTX
*ctx
, STACK_OF(X509
) *caPubs
);
719 int ossl_cmp_ctx_set1_extraCertsIn(OSSL_CMP_CTX
*ctx
,
720 STACK_OF(X509
) *extraCertsIn
);
721 int ossl_cmp_ctx_set1_recipNonce(OSSL_CMP_CTX
*ctx
,
722 const ASN1_OCTET_STRING
*nonce
);
724 /* from cmp_status.c */
726 ossl_cmp_statusinfo_new(int status
, int fail_info
, const char *text
);
727 int ossl_cmp_pkisi_get_pkistatus(const OSSL_CMP_PKISI
*statusInfo
);
728 const char *ossl_cmp_PKIStatus_to_string(int status
);
729 OSSL_CMP_PKIFREETEXT
*ossl_cmp_pkisi_get0_statusstring(const OSSL_CMP_PKISI
*si
);
730 int ossl_cmp_pkisi_get_pkifailureinfo(const OSSL_CMP_PKISI
*si
);
731 int ossl_cmp_pkisi_pkifailureinfo_check(const OSSL_CMP_PKISI
*si
, int bit_index
);
734 int ossl_cmp_hdr_set_pvno(OSSL_CMP_PKIHEADER
*hdr
, int pvno
);
735 int ossl_cmp_hdr_get_pvno(const OSSL_CMP_PKIHEADER
*hdr
);
736 ASN1_OCTET_STRING
*ossl_cmp_hdr_get0_senderNonce(const OSSL_CMP_PKIHEADER
*hdr
);
737 int ossl_cmp_hdr_set1_sender(OSSL_CMP_PKIHEADER
*hdr
, const X509_NAME
*nm
);
738 int ossl_cmp_hdr_set1_recipient(OSSL_CMP_PKIHEADER
*hdr
, const X509_NAME
*nm
);
739 int ossl_cmp_hdr_update_messageTime(OSSL_CMP_PKIHEADER
*hdr
);
740 int ossl_cmp_hdr_set1_senderKID(OSSL_CMP_PKIHEADER
*hdr
,
741 const ASN1_OCTET_STRING
*senderKID
);
742 int ossl_cmp_pkifreetext_push_str(OSSL_CMP_PKIFREETEXT
*ft
, const char *text
);
743 int ossl_cmp_hdr_push0_freeText(OSSL_CMP_PKIHEADER
*hdr
, ASN1_UTF8STRING
*text
);
744 int ossl_cmp_hdr_push1_freeText(OSSL_CMP_PKIHEADER
*hdr
, ASN1_UTF8STRING
*text
);
745 int ossl_cmp_hdr_generalInfo_push0_item(OSSL_CMP_PKIHEADER
*hdr
,
746 OSSL_CMP_ITAV
*itav
);
747 int ossl_cmp_hdr_generalInfo_push1_items(OSSL_CMP_PKIHEADER
*hdr
,
748 STACK_OF(OSSL_CMP_ITAV
) *itavs
);
749 int ossl_cmp_hdr_set_implicitConfirm(OSSL_CMP_PKIHEADER
*hdr
);
750 int ossl_cmp_hdr_check_implicitConfirm(const OSSL_CMP_PKIHEADER
*hdr
);
751 # define OSSL_CMP_TRANSACTIONID_LENGTH 16
752 # define OSSL_CMP_SENDERNONCE_LENGTH 16
753 int ossl_cmp_hdr_init(OSSL_CMP_CTX
*ctx
, OSSL_CMP_PKIHEADER
*hdr
);
755 #endif /* !defined OSSL_CRYPTO_CMP_LOCAL_H */