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