cmp.h.in 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /*
  2. * {- join("\n * ", @autowarntext) -}
  3. *
  4. * Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
  5. * Copyright Nokia 2007-2019
  6. * Copyright Siemens AG 2015-2019
  7. *
  8. * Licensed under the Apache License 2.0 (the "License"). You may not use
  9. * this file except in compliance with the License. You can obtain a copy
  10. * in the file LICENSE in the source distribution or at
  11. * https://www.openssl.org/source/license.html
  12. */
  13. {-
  14. use OpenSSL::stackhash qw(generate_stack_macros);
  15. -}
  16. #ifndef OPENSSL_CMP_H
  17. # define OPENSSL_CMP_H
  18. # include <openssl/opensslconf.h>
  19. # ifndef OPENSSL_NO_CMP
  20. # include <openssl/crmf.h>
  21. # include <openssl/cmperr.h>
  22. # include <openssl/cmp_util.h>
  23. # include <openssl/http.h>
  24. /* explicit #includes not strictly needed since implied by the above: */
  25. # include <openssl/types.h>
  26. # include <openssl/safestack.h>
  27. # include <openssl/x509.h>
  28. # include <openssl/x509v3.h>
  29. # ifdef __cplusplus
  30. extern "C" {
  31. # endif
  32. # define OSSL_CMP_PVNO_2 2
  33. # define OSSL_CMP_PVNO_3 3
  34. # define OSSL_CMP_PVNO OSSL_CMP_PVNO_2 /* v2 is the default */
  35. /*-
  36. * PKIFailureInfo ::= BIT STRING {
  37. * -- since we can fail in more than one way!
  38. * -- More codes may be added in the future if/when required.
  39. * badAlg (0),
  40. * -- unrecognized or unsupported Algorithm Identifier
  41. * badMessageCheck (1),
  42. * -- integrity check failed (e.g., signature did not verify)
  43. * badRequest (2),
  44. * -- transaction not permitted or supported
  45. * badTime (3),
  46. * -- messageTime was not sufficiently close to the system time,
  47. * -- as defined by local policy
  48. * badCertId (4),
  49. * -- no certificate could be found matching the provided criteria
  50. * badDataFormat (5),
  51. * -- the data submitted has the wrong format
  52. * wrongAuthority (6),
  53. * -- the authority indicated in the request is different from the
  54. * -- one creating the response token
  55. * incorrectData (7),
  56. * -- the requester's data is incorrect (for notary services)
  57. * missingTimeStamp (8),
  58. * -- when the timestamp is missing but should be there
  59. * -- (by policy)
  60. * badPOP (9),
  61. * -- the proof-of-possession failed
  62. * certRevoked (10),
  63. * -- the certificate has already been revoked
  64. * certConfirmed (11),
  65. * -- the certificate has already been confirmed
  66. * wrongIntegrity (12),
  67. * -- invalid integrity, password based instead of signature or
  68. * -- vice versa
  69. * badRecipientNonce (13),
  70. * -- invalid recipient nonce, either missing or wrong value
  71. * timeNotAvailable (14),
  72. * -- the TSA's time source is not available
  73. * unacceptedPolicy (15),
  74. * -- the requested TSA policy is not supported by the TSA.
  75. * unacceptedExtension (16),
  76. * -- the requested extension is not supported by the TSA.
  77. * addInfoNotAvailable (17),
  78. * -- the additional information requested could not be
  79. * -- understood or is not available
  80. * badSenderNonce (18),
  81. * -- invalid sender nonce, either missing or wrong size
  82. * badCertTemplate (19),
  83. * -- invalid cert. template or missing mandatory information
  84. * signerNotTrusted (20),
  85. * -- signer of the message unknown or not trusted
  86. * transactionIdInUse (21),
  87. * -- the transaction identifier is already in use
  88. * unsupportedVersion (22),
  89. * -- the version of the message is not supported
  90. * notAuthorized (23),
  91. * -- the sender was not authorized to make the preceding
  92. * -- request or perform the preceding action
  93. * systemUnavail (24),
  94. * -- the request cannot be handled due to system unavailability
  95. * systemFailure (25),
  96. * -- the request cannot be handled due to system failure
  97. * duplicateCertReq (26)
  98. * -- certificate cannot be issued because a duplicate
  99. * -- certificate already exists
  100. * }
  101. */
  102. # define OSSL_CMP_PKIFAILUREINFO_badAlg 0
  103. # define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1
  104. # define OSSL_CMP_PKIFAILUREINFO_badRequest 2
  105. # define OSSL_CMP_PKIFAILUREINFO_badTime 3
  106. # define OSSL_CMP_PKIFAILUREINFO_badCertId 4
  107. # define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5
  108. # define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6
  109. # define OSSL_CMP_PKIFAILUREINFO_incorrectData 7
  110. # define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8
  111. # define OSSL_CMP_PKIFAILUREINFO_badPOP 9
  112. # define OSSL_CMP_PKIFAILUREINFO_certRevoked 10
  113. # define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11
  114. # define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12
  115. # define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13
  116. # define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14
  117. # define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15
  118. # define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16
  119. # define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17
  120. # define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18
  121. # define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19
  122. # define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20
  123. # define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21
  124. # define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22
  125. # define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23
  126. # define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24
  127. # define OSSL_CMP_PKIFAILUREINFO_systemFailure 25
  128. # define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26
  129. # define OSSL_CMP_PKIFAILUREINFO_MAX 26
  130. # define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN \
  131. ((1 << (OSSL_CMP_PKIFAILUREINFO_MAX + 1)) - 1)
  132. # if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX
  133. # error CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int
  134. # endif
  135. typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO;
  136. # define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0)
  137. # define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1)
  138. # define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2)
  139. # define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3)
  140. # define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4)
  141. # define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5)
  142. # define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6)
  143. # define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7)
  144. # define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8)
  145. # define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9)
  146. # define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10)
  147. # define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11)
  148. # define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12)
  149. # define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13)
  150. # define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14)
  151. # define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15)
  152. # define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16)
  153. # define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17)
  154. # define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18)
  155. # define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19)
  156. # define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20)
  157. # define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21)
  158. # define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22)
  159. # define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23)
  160. # define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24)
  161. # define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25)
  162. # define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26)
  163. /*-
  164. * PKIStatus ::= INTEGER {
  165. * accepted (0),
  166. * -- you got exactly what you asked for
  167. * grantedWithMods (1),
  168. * -- you got something like what you asked for; the
  169. * -- requester is responsible for ascertaining the differences
  170. * rejection (2),
  171. * -- you don't get it, more information elsewhere in the message
  172. * waiting (3),
  173. * -- the request body part has not yet been processed; expect to
  174. * -- hear more later (note: proper handling of this status
  175. * -- response MAY use the polling req/rep PKIMessages specified
  176. * -- in Section 5.3.22; alternatively, polling in the underlying
  177. * -- transport layer MAY have some utility in this regard)
  178. * revocationWarning (4),
  179. * -- this message contains a warning that a revocation is
  180. * -- imminent
  181. * revocationNotification (5),
  182. * -- notification that a revocation has occurred
  183. * keyUpdateWarning (6)
  184. * -- update already done for the oldCertId specified in
  185. * -- CertReqMsg
  186. * }
  187. */
  188. # define OSSL_CMP_PKISTATUS_request -3
  189. # define OSSL_CMP_PKISTATUS_trans -2
  190. # define OSSL_CMP_PKISTATUS_unspecified -1
  191. # define OSSL_CMP_PKISTATUS_accepted 0
  192. # define OSSL_CMP_PKISTATUS_grantedWithMods 1
  193. # define OSSL_CMP_PKISTATUS_rejection 2
  194. # define OSSL_CMP_PKISTATUS_waiting 3
  195. # define OSSL_CMP_PKISTATUS_revocationWarning 4
  196. # define OSSL_CMP_PKISTATUS_revocationNotification 5
  197. # define OSSL_CMP_PKISTATUS_keyUpdateWarning 6
  198. typedef ASN1_INTEGER OSSL_CMP_PKISTATUS;
  199. DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS)
  200. # define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0
  201. # define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1
  202. /* data type declarations */
  203. typedef struct ossl_cmp_ctx_st OSSL_CMP_CTX;
  204. typedef struct ossl_cmp_pkiheader_st OSSL_CMP_PKIHEADER;
  205. DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
  206. typedef struct ossl_cmp_msg_st OSSL_CMP_MSG;
  207. DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
  208. DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG)
  209. typedef struct ossl_cmp_certstatus_st OSSL_CMP_CERTSTATUS;
  210. {-
  211. generate_stack_macros("OSSL_CMP_CERTSTATUS");
  212. -}
  213. typedef struct ossl_cmp_itav_st OSSL_CMP_ITAV;
  214. DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
  215. {-
  216. generate_stack_macros("OSSL_CMP_ITAV");
  217. -}
  218. typedef struct ossl_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT;
  219. typedef struct ossl_cmp_pkisi_st OSSL_CMP_PKISI;
  220. DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
  221. DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
  222. {-
  223. generate_stack_macros("OSSL_CMP_PKISI");
  224. -}
  225. typedef struct ossl_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE;
  226. {-
  227. generate_stack_macros("OSSL_CMP_CERTREPMESSAGE");
  228. -}
  229. typedef struct ossl_cmp_pollrep_st OSSL_CMP_POLLREP;
  230. typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT;
  231. typedef struct ossl_cmp_certresponse_st OSSL_CMP_CERTRESPONSE;
  232. {-
  233. generate_stack_macros("OSSL_CMP_CERTRESPONSE");
  234. -}
  235. typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT;
  236. /*
  237. * function DECLARATIONS
  238. */
  239. /* from cmp_asn.c */
  240. OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
  241. void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
  242. ASN1_TYPE *value);
  243. ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
  244. ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
  245. int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
  246. OSSL_CMP_ITAV *itav);
  247. void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav);
  248. void OSSL_CMP_MSG_free(OSSL_CMP_MSG *msg);
  249. /* from cmp_ctx.c */
  250. OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq);
  251. void OSSL_CMP_CTX_free(OSSL_CMP_CTX *ctx);
  252. int OSSL_CMP_CTX_reinit(OSSL_CMP_CTX *ctx);
  253. OSSL_LIB_CTX *OSSL_CMP_CTX_get0_libctx(const OSSL_CMP_CTX *ctx);
  254. const char *OSSL_CMP_CTX_get0_propq(const OSSL_CMP_CTX *ctx);
  255. /* CMP general options: */
  256. # define OSSL_CMP_OPT_LOG_VERBOSITY 0
  257. /* CMP transfer options: */
  258. # define OSSL_CMP_OPT_KEEP_ALIVE 10
  259. # define OSSL_CMP_OPT_MSG_TIMEOUT 11
  260. # define OSSL_CMP_OPT_TOTAL_TIMEOUT 12
  261. /* CMP request options: */
  262. # define OSSL_CMP_OPT_VALIDITY_DAYS 20
  263. # define OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT 21
  264. # define OSSL_CMP_OPT_SUBJECTALTNAME_CRITICAL 22
  265. # define OSSL_CMP_OPT_POLICIES_CRITICAL 23
  266. # define OSSL_CMP_OPT_POPO_METHOD 24
  267. # define OSSL_CMP_OPT_IMPLICIT_CONFIRM 25
  268. # define OSSL_CMP_OPT_DISABLE_CONFIRM 26
  269. # define OSSL_CMP_OPT_REVOCATION_REASON 27
  270. /* CMP protection options: */
  271. # define OSSL_CMP_OPT_UNPROTECTED_SEND 30
  272. # define OSSL_CMP_OPT_UNPROTECTED_ERRORS 31
  273. # define OSSL_CMP_OPT_OWF_ALGNID 32
  274. # define OSSL_CMP_OPT_MAC_ALGNID 33
  275. # define OSSL_CMP_OPT_DIGEST_ALGNID 34
  276. # define OSSL_CMP_OPT_IGNORE_KEYUSAGE 35
  277. # define OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR 36
  278. int OSSL_CMP_CTX_set_option(OSSL_CMP_CTX *ctx, int opt, int val);
  279. int OSSL_CMP_CTX_get_option(const OSSL_CMP_CTX *ctx, int opt);
  280. /* CMP-specific callback for logging and outputting the error queue: */
  281. int OSSL_CMP_CTX_set_log_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_log_cb_t cb);
  282. # define OSSL_CMP_CTX_set_log_verbosity(ctx, level) \
  283. OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_LOG_VERBOSITY, level)
  284. void OSSL_CMP_CTX_print_errors(const OSSL_CMP_CTX *ctx);
  285. /* message transfer: */
  286. int OSSL_CMP_CTX_set1_serverPath(OSSL_CMP_CTX *ctx, const char *path);
  287. int OSSL_CMP_CTX_set1_server(OSSL_CMP_CTX *ctx, const char *address);
  288. int OSSL_CMP_CTX_set_serverPort(OSSL_CMP_CTX *ctx, int port);
  289. int OSSL_CMP_CTX_set1_proxy(OSSL_CMP_CTX *ctx, const char *name);
  290. int OSSL_CMP_CTX_set1_no_proxy(OSSL_CMP_CTX *ctx, const char *names);
  291. int OSSL_CMP_CTX_set_http_cb(OSSL_CMP_CTX *ctx, OSSL_HTTP_bio_cb_t cb);
  292. int OSSL_CMP_CTX_set_http_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
  293. void *OSSL_CMP_CTX_get_http_cb_arg(const OSSL_CMP_CTX *ctx);
  294. typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t) (OSSL_CMP_CTX *ctx,
  295. const OSSL_CMP_MSG *req);
  296. int OSSL_CMP_CTX_set_transfer_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_transfer_cb_t cb);
  297. int OSSL_CMP_CTX_set_transfer_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
  298. void *OSSL_CMP_CTX_get_transfer_cb_arg(const OSSL_CMP_CTX *ctx);
  299. /* server authentication: */
  300. int OSSL_CMP_CTX_set1_srvCert(OSSL_CMP_CTX *ctx, X509 *cert);
  301. int OSSL_CMP_CTX_set1_expected_sender(OSSL_CMP_CTX *ctx, const X509_NAME *name);
  302. int OSSL_CMP_CTX_set0_trustedStore(OSSL_CMP_CTX *ctx, X509_STORE *store);
  303. #define OSSL_CMP_CTX_set0_trusted OSSL_CMP_CTX_set0_trustedStore
  304. X509_STORE *OSSL_CMP_CTX_get0_trustedStore(const OSSL_CMP_CTX *ctx);
  305. #define OSSL_CMP_CTX_get0_trusted OSSL_CMP_CTX_get0_trustedStore
  306. int OSSL_CMP_CTX_set1_untrusted(OSSL_CMP_CTX *ctx, STACK_OF(X509) *certs);
  307. STACK_OF(X509) *OSSL_CMP_CTX_get0_untrusted(const OSSL_CMP_CTX *ctx);
  308. /* client authentication: */
  309. int OSSL_CMP_CTX_set1_cert(OSSL_CMP_CTX *ctx, X509 *cert);
  310. int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted,
  311. STACK_OF(X509) *candidates);
  312. int OSSL_CMP_CTX_set1_pkey(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey);
  313. int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx,
  314. const unsigned char *ref, int len);
  315. int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx, const unsigned char *sec,
  316. const int len);
  317. /* CMP message header and extra certificates: */
  318. int OSSL_CMP_CTX_set1_recipient(OSSL_CMP_CTX *ctx, const X509_NAME *name);
  319. int OSSL_CMP_CTX_push0_geninfo_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav);
  320. int OSSL_CMP_CTX_reset_geninfo_ITAVs(OSSL_CMP_CTX *ctx);
  321. int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx,
  322. STACK_OF(X509) *extraCertsOut);
  323. /* certificate template: */
  324. int OSSL_CMP_CTX_set0_newPkey(OSSL_CMP_CTX *ctx, int priv, EVP_PKEY *pkey);
  325. EVP_PKEY *OSSL_CMP_CTX_get0_newPkey(const OSSL_CMP_CTX *ctx, int priv);
  326. int OSSL_CMP_CTX_set1_issuer(OSSL_CMP_CTX *ctx, const X509_NAME *name);
  327. int OSSL_CMP_CTX_set1_subjectName(OSSL_CMP_CTX *ctx, const X509_NAME *name);
  328. int OSSL_CMP_CTX_push1_subjectAltName(OSSL_CMP_CTX *ctx,
  329. const GENERAL_NAME *name);
  330. int OSSL_CMP_CTX_set0_reqExtensions(OSSL_CMP_CTX *ctx, X509_EXTENSIONS *exts);
  331. int OSSL_CMP_CTX_reqExtensions_have_SAN(OSSL_CMP_CTX *ctx);
  332. int OSSL_CMP_CTX_push0_policy(OSSL_CMP_CTX *ctx, POLICYINFO *pinfo);
  333. int OSSL_CMP_CTX_set1_oldCert(OSSL_CMP_CTX *ctx, X509 *cert);
  334. int OSSL_CMP_CTX_set1_p10CSR(OSSL_CMP_CTX *ctx, const X509_REQ *csr);
  335. /* misc body contents: */
  336. int OSSL_CMP_CTX_push0_genm_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav);
  337. /* certificate confirmation: */
  338. typedef int (*OSSL_CMP_certConf_cb_t) (OSSL_CMP_CTX *ctx, X509 *cert,
  339. int fail_info, const char **txt);
  340. int OSSL_CMP_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info,
  341. const char **text);
  342. int OSSL_CMP_CTX_set_certConf_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_certConf_cb_t cb);
  343. int OSSL_CMP_CTX_set_certConf_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
  344. void *OSSL_CMP_CTX_get_certConf_cb_arg(const OSSL_CMP_CTX *ctx);
  345. /* result fetching: */
  346. int OSSL_CMP_CTX_get_status(const OSSL_CMP_CTX *ctx);
  347. OSSL_CMP_PKIFREETEXT *OSSL_CMP_CTX_get0_statusString(const OSSL_CMP_CTX *ctx);
  348. int OSSL_CMP_CTX_get_failInfoCode(const OSSL_CMP_CTX *ctx);
  349. # define OSSL_CMP_PKISI_BUFLEN 1024
  350. X509 *OSSL_CMP_CTX_get0_validatedSrvCert(const OSSL_CMP_CTX *ctx);
  351. X509 *OSSL_CMP_CTX_get0_newCert(const OSSL_CMP_CTX *ctx);
  352. STACK_OF(X509) *OSSL_CMP_CTX_get1_newChain(const OSSL_CMP_CTX *ctx);
  353. STACK_OF(X509) *OSSL_CMP_CTX_get1_caPubs(const OSSL_CMP_CTX *ctx);
  354. STACK_OF(X509) *OSSL_CMP_CTX_get1_extraCertsIn(const OSSL_CMP_CTX *ctx);
  355. int OSSL_CMP_CTX_set1_transactionID(OSSL_CMP_CTX *ctx,
  356. const ASN1_OCTET_STRING *id);
  357. int OSSL_CMP_CTX_set1_senderNonce(OSSL_CMP_CTX *ctx,
  358. const ASN1_OCTET_STRING *nonce);
  359. /* from cmp_status.c */
  360. char *OSSL_CMP_CTX_snprint_PKIStatus(const OSSL_CMP_CTX *ctx, char *buf,
  361. size_t bufsize);
  362. char *OSSL_CMP_snprint_PKIStatusInfo(const OSSL_CMP_PKISI *statusInfo,
  363. char *buf, size_t bufsize);
  364. OSSL_CMP_PKISI *
  365. OSSL_CMP_STATUSINFO_new(int status, int fail_info, const char *text);
  366. /* from cmp_hdr.c */
  367. ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_transactionID(const
  368. OSSL_CMP_PKIHEADER *hdr);
  369. ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_recipNonce(const OSSL_CMP_PKIHEADER *hdr);
  370. /* from cmp_msg.c */
  371. OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg);
  372. int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg);
  373. int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
  374. OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid);
  375. OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx,
  376. const char *propq);
  377. int OSSL_CMP_MSG_write(const char *file, const OSSL_CMP_MSG *msg);
  378. OSSL_CMP_MSG *d2i_OSSL_CMP_MSG_bio(BIO *bio, OSSL_CMP_MSG **msg);
  379. int i2d_OSSL_CMP_MSG_bio(BIO *bio, const OSSL_CMP_MSG *msg);
  380. /* from cmp_vfy.c */
  381. int OSSL_CMP_validate_msg(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg);
  382. int OSSL_CMP_validate_cert_path(const OSSL_CMP_CTX *ctx,
  383. X509_STORE *trusted_store, X509 *cert);
  384. /* from cmp_http.c */
  385. OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx,
  386. const OSSL_CMP_MSG *req);
  387. /* from cmp_server.c */
  388. typedef struct ossl_cmp_srv_ctx_st OSSL_CMP_SRV_CTX;
  389. OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
  390. const OSSL_CMP_MSG *req);
  391. OSSL_CMP_MSG * OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx,
  392. const OSSL_CMP_MSG *req);
  393. OSSL_CMP_SRV_CTX *OSSL_CMP_SRV_CTX_new(OSSL_LIB_CTX *libctx, const char *propq);
  394. void OSSL_CMP_SRV_CTX_free(OSSL_CMP_SRV_CTX *srv_ctx);
  395. typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_cert_request_cb_t)
  396. (OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, int certReqId,
  397. const OSSL_CRMF_MSG *crm, const X509_REQ *p10cr,
  398. X509 **certOut, STACK_OF(X509) **chainOut, STACK_OF(X509) **caPubs);
  399. typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  400. const OSSL_CMP_MSG *req,
  401. const X509_NAME *issuer,
  402. const ASN1_INTEGER *serial);
  403. typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  404. const OSSL_CMP_MSG *req,
  405. const STACK_OF(OSSL_CMP_ITAV) *in,
  406. STACK_OF(OSSL_CMP_ITAV) **out);
  407. typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  408. const OSSL_CMP_MSG *req,
  409. const OSSL_CMP_PKISI *statusInfo,
  410. const ASN1_INTEGER *errorCode,
  411. const OSSL_CMP_PKIFREETEXT *errDetails);
  412. typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  413. const OSSL_CMP_MSG *req,
  414. int certReqId,
  415. const ASN1_OCTET_STRING *certHash,
  416. const OSSL_CMP_PKISI *si);
  417. typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  418. const OSSL_CMP_MSG *req, int certReqId,
  419. OSSL_CMP_MSG **certReq,
  420. int64_t *check_after);
  421. int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx,
  422. OSSL_CMP_SRV_cert_request_cb_t process_cert_request,
  423. OSSL_CMP_SRV_rr_cb_t process_rr,
  424. OSSL_CMP_SRV_genm_cb_t process_genm,
  425. OSSL_CMP_SRV_error_cb_t process_error,
  426. OSSL_CMP_SRV_certConf_cb_t process_certConf,
  427. OSSL_CMP_SRV_pollReq_cb_t process_pollReq);
  428. OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
  429. void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
  430. int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx,
  431. int val);
  432. int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val);
  433. int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val);
  434. int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx,
  435. int val);
  436. /* from cmp_client.c */
  437. X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type,
  438. const OSSL_CRMF_MSG *crm);
  439. # define OSSL_CMP_IR 0
  440. # define OSSL_CMP_CR 2
  441. # define OSSL_CMP_P10CR 4
  442. # define OSSL_CMP_KUR 7
  443. # define OSSL_CMP_exec_IR_ses(ctx) \
  444. OSSL_CMP_exec_certreq(ctx, OSSL_CMP_IR, NULL)
  445. # define OSSL_CMP_exec_CR_ses(ctx) \
  446. OSSL_CMP_exec_certreq(ctx, OSSL_CMP_CR, NULL)
  447. # define OSSL_CMP_exec_P10CR_ses(ctx) \
  448. OSSL_CMP_exec_certreq(ctx, OSSL_CMP_P10CR, NULL)
  449. # define OSSL_CMP_exec_KUR_ses(ctx) \
  450. OSSL_CMP_exec_certreq(ctx, OSSL_CMP_KUR, NULL)
  451. int OSSL_CMP_try_certreq(OSSL_CMP_CTX *ctx, int req_type,
  452. const OSSL_CRMF_MSG *crm, int *checkAfter);
  453. int OSSL_CMP_exec_RR_ses(OSSL_CMP_CTX *ctx);
  454. STACK_OF(OSSL_CMP_ITAV) *OSSL_CMP_exec_GENM_ses(OSSL_CMP_CTX *ctx);
  455. # ifdef __cplusplus
  456. }
  457. # endif
  458. # endif /* !defined(OPENSSL_NO_CMP) */
  459. #endif /* !defined(OPENSSL_CMP_H) */