cmp_local.h 41 KB

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