cmp_local.h 42 KB

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