cmp_local.h 41 KB

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