A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

421 lines
17 KiB

  1. /*
  2. * Copyright 2007-2020 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. #include <openssl/asn1t.h>
  12. #include "cmp_local.h"
  13. /* explicit #includes not strictly needed since implied by the above: */
  14. #include <openssl/cmp.h>
  15. #include <openssl/crmf.h>
  16. /* ASN.1 declarations from RFC4210 */
  17. ASN1_SEQUENCE(OSSL_CMP_REVANNCONTENT) = {
  18. /* OSSL_CMP_PKISTATUS is effectively ASN1_INTEGER so it is used directly */
  19. ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, status, ASN1_INTEGER),
  20. ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, certId, OSSL_CRMF_CERTID),
  21. ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, willBeRevokedAt, ASN1_GENERALIZEDTIME),
  22. ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, badSinceDate, ASN1_GENERALIZEDTIME),
  23. ASN1_OPT(OSSL_CMP_REVANNCONTENT, crlDetails, X509_EXTENSIONS)
  24. } ASN1_SEQUENCE_END(OSSL_CMP_REVANNCONTENT)
  25. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT)
  26. ASN1_SEQUENCE(OSSL_CMP_CHALLENGE) = {
  27. ASN1_OPT(OSSL_CMP_CHALLENGE, owf, X509_ALGOR),
  28. ASN1_SIMPLE(OSSL_CMP_CHALLENGE, witness, ASN1_OCTET_STRING),
  29. ASN1_SIMPLE(OSSL_CMP_CHALLENGE, challenge, ASN1_OCTET_STRING)
  30. } ASN1_SEQUENCE_END(OSSL_CMP_CHALLENGE)
  31. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE)
  32. ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYCHALLCONTENT) =
  33. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
  34. OSSL_CMP_POPODECKEYCHALLCONTENT, OSSL_CMP_CHALLENGE)
  35. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYCHALLCONTENT)
  36. ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYRESPCONTENT) =
  37. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
  38. OSSL_CMP_POPODECKEYRESPCONTENT, ASN1_INTEGER)
  39. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYRESPCONTENT)
  40. ASN1_SEQUENCE(OSSL_CMP_CAKEYUPDANNCONTENT) = {
  41. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  42. ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, oldWithNew, X509),
  43. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  44. ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithOld, X509),
  45. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  46. ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithNew, X509)
  47. } ASN1_SEQUENCE_END(OSSL_CMP_CAKEYUPDANNCONTENT)
  48. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT)
  49. ASN1_SEQUENCE(OSSL_CMP_ERRORMSGCONTENT) = {
  50. ASN1_SIMPLE(OSSL_CMP_ERRORMSGCONTENT, pKIStatusInfo, OSSL_CMP_PKISI),
  51. ASN1_OPT(OSSL_CMP_ERRORMSGCONTENT, errorCode, ASN1_INTEGER),
  52. /*
  53. * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
  54. * so it is used directly
  55. *
  56. */
  57. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ERRORMSGCONTENT, errorDetails,
  58. ASN1_UTF8STRING)
  59. } ASN1_SEQUENCE_END(OSSL_CMP_ERRORMSGCONTENT)
  60. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT)
  61. ASN1_ADB_TEMPLATE(infotypeandvalue_default) = ASN1_OPT(OSSL_CMP_ITAV,
  62. infoValue.other,
  63. ASN1_ANY);
  64. /* ITAV means InfoTypeAndValue */
  65. ASN1_ADB(OSSL_CMP_ITAV) = {
  66. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  67. ADB_ENTRY(NID_id_it_caProtEncCert, ASN1_OPT(OSSL_CMP_ITAV,
  68. infoValue.caProtEncCert, X509)),
  69. ADB_ENTRY(NID_id_it_signKeyPairTypes,
  70. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
  71. infoValue.signKeyPairTypes, X509_ALGOR)),
  72. ADB_ENTRY(NID_id_it_encKeyPairTypes,
  73. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
  74. infoValue.encKeyPairTypes, X509_ALGOR)),
  75. ADB_ENTRY(NID_id_it_preferredSymmAlg,
  76. ASN1_OPT(OSSL_CMP_ITAV, infoValue.preferredSymmAlg,
  77. X509_ALGOR)),
  78. ADB_ENTRY(NID_id_it_caKeyUpdateInfo,
  79. ASN1_OPT(OSSL_CMP_ITAV, infoValue.caKeyUpdateInfo,
  80. OSSL_CMP_CAKEYUPDANNCONTENT)),
  81. ADB_ENTRY(NID_id_it_currentCRL,
  82. ASN1_OPT(OSSL_CMP_ITAV, infoValue.currentCRL, X509_CRL)),
  83. ADB_ENTRY(NID_id_it_unsupportedOIDs,
  84. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV,
  85. infoValue.unsupportedOIDs, ASN1_OBJECT)),
  86. ADB_ENTRY(NID_id_it_keyPairParamReq,
  87. ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamReq,
  88. ASN1_OBJECT)),
  89. ADB_ENTRY(NID_id_it_keyPairParamRep,
  90. ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamRep,
  91. X509_ALGOR)),
  92. ADB_ENTRY(NID_id_it_revPassphrase,
  93. ASN1_OPT(OSSL_CMP_ITAV, infoValue.revPassphrase,
  94. OSSL_CRMF_ENCRYPTEDVALUE)),
  95. ADB_ENTRY(NID_id_it_implicitConfirm,
  96. ASN1_OPT(OSSL_CMP_ITAV, infoValue.implicitConfirm,
  97. ASN1_NULL)),
  98. ADB_ENTRY(NID_id_it_confirmWaitTime,
  99. ASN1_OPT(OSSL_CMP_ITAV, infoValue.confirmWaitTime,
  100. ASN1_GENERALIZEDTIME)),
  101. ADB_ENTRY(NID_id_it_origPKIMessage,
  102. ASN1_OPT(OSSL_CMP_ITAV, infoValue.origPKIMessage,
  103. OSSL_CMP_MSGS)),
  104. ADB_ENTRY(NID_id_it_suppLangTags,
  105. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, infoValue.suppLangTagsValue,
  106. ASN1_UTF8STRING)),
  107. } ASN1_ADB_END(OSSL_CMP_ITAV, 0, infoType, 0,
  108. &infotypeandvalue_default_tt, NULL);
  109. ASN1_SEQUENCE(OSSL_CMP_ITAV) = {
  110. ASN1_SIMPLE(OSSL_CMP_ITAV, infoType, ASN1_OBJECT),
  111. ASN1_ADB_OBJECT(OSSL_CMP_ITAV)
  112. } ASN1_SEQUENCE_END(OSSL_CMP_ITAV)
  113. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ITAV)
  114. IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
  115. OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value)
  116. {
  117. OSSL_CMP_ITAV *itav;
  118. if (type == NULL || (itav = OSSL_CMP_ITAV_new()) == NULL)
  119. return NULL;
  120. OSSL_CMP_ITAV_set0(itav, type, value);
  121. return itav;
  122. }
  123. void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
  124. ASN1_TYPE *value)
  125. {
  126. itav->infoType = type;
  127. itav->infoValue.other = value;
  128. }
  129. ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav)
  130. {
  131. if (itav == NULL)
  132. return NULL;
  133. return itav->infoType;
  134. }
  135. ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav)
  136. {
  137. if (itav == NULL)
  138. return NULL;
  139. return itav->infoValue.other;
  140. }
  141. int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
  142. OSSL_CMP_ITAV *itav)
  143. {
  144. int created = 0;
  145. if (itav_sk_p == NULL || itav == NULL) {
  146. ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
  147. goto err;
  148. }
  149. if (*itav_sk_p == NULL) {
  150. if ((*itav_sk_p = sk_OSSL_CMP_ITAV_new_null()) == NULL)
  151. goto err;
  152. created = 1;
  153. }
  154. if (!sk_OSSL_CMP_ITAV_push(*itav_sk_p, itav))
  155. goto err;
  156. return 1;
  157. err:
  158. if (created != 0) {
  159. sk_OSSL_CMP_ITAV_free(*itav_sk_p);
  160. *itav_sk_p = NULL;
  161. }
  162. return 0;
  163. }
  164. /* get ASN.1 encoded integer, return -1 on error */
  165. int ossl_cmp_asn1_get_int(const ASN1_INTEGER *a)
  166. {
  167. int64_t res;
  168. if (!ASN1_INTEGER_get_int64(&res, a)) {
  169. ERR_raise(ERR_LIB_CMP, ASN1_R_INVALID_NUMBER);
  170. return -1;
  171. }
  172. if (res < INT_MIN) {
  173. ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_SMALL);
  174. return -1;
  175. }
  176. if (res > INT_MAX) {
  177. ERR_raise(ERR_LIB_CMP, ASN1_R_TOO_LARGE);
  178. return -1;
  179. }
  180. return (int)res;
  181. }
  182. ASN1_CHOICE(OSSL_CMP_CERTORENCCERT) = {
  183. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  184. ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.certificate, X509, 0),
  185. ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.encryptedCert,
  186. OSSL_CRMF_ENCRYPTEDVALUE, 1),
  187. } ASN1_CHOICE_END(OSSL_CMP_CERTORENCCERT)
  188. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT)
  189. ASN1_SEQUENCE(OSSL_CMP_CERTIFIEDKEYPAIR) = {
  190. ASN1_SIMPLE(OSSL_CMP_CERTIFIEDKEYPAIR, certOrEncCert,
  191. OSSL_CMP_CERTORENCCERT),
  192. ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, privateKey,
  193. OSSL_CRMF_ENCRYPTEDVALUE, 0),
  194. ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, publicationInfo,
  195. OSSL_CRMF_PKIPUBLICATIONINFO, 1)
  196. } ASN1_SEQUENCE_END(OSSL_CMP_CERTIFIEDKEYPAIR)
  197. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR)
  198. ASN1_SEQUENCE(OSSL_CMP_REVDETAILS) = {
  199. ASN1_SIMPLE(OSSL_CMP_REVDETAILS, certDetails, OSSL_CRMF_CERTTEMPLATE),
  200. ASN1_OPT(OSSL_CMP_REVDETAILS, crlEntryDetails, X509_EXTENSIONS)
  201. } ASN1_SEQUENCE_END(OSSL_CMP_REVDETAILS)
  202. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS)
  203. ASN1_ITEM_TEMPLATE(OSSL_CMP_REVREQCONTENT) =
  204. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_REVREQCONTENT,
  205. OSSL_CMP_REVDETAILS)
  206. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_REVREQCONTENT)
  207. ASN1_SEQUENCE(OSSL_CMP_REVREPCONTENT) = {
  208. ASN1_SEQUENCE_OF(OSSL_CMP_REVREPCONTENT, status, OSSL_CMP_PKISI),
  209. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, revCerts, OSSL_CRMF_CERTID,
  210. 0),
  211. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, crls, X509_CRL, 1)
  212. } ASN1_SEQUENCE_END(OSSL_CMP_REVREPCONTENT)
  213. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT)
  214. ASN1_SEQUENCE(OSSL_CMP_KEYRECREPCONTENT) = {
  215. ASN1_SIMPLE(OSSL_CMP_KEYRECREPCONTENT, status, OSSL_CMP_PKISI),
  216. ASN1_EXP_OPT(OSSL_CMP_KEYRECREPCONTENT, newSigCert, X509, 0),
  217. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, caCerts, X509, 1),
  218. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, keyPairHist,
  219. OSSL_CMP_CERTIFIEDKEYPAIR, 2)
  220. } ASN1_SEQUENCE_END(OSSL_CMP_KEYRECREPCONTENT)
  221. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT)
  222. ASN1_ITEM_TEMPLATE(OSSL_CMP_PKISTATUS) =
  223. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_UNIVERSAL, 0, status, ASN1_INTEGER)
  224. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_PKISTATUS)
  225. ASN1_SEQUENCE(OSSL_CMP_PKISI) = {
  226. ASN1_SIMPLE(OSSL_CMP_PKISI, status, OSSL_CMP_PKISTATUS),
  227. /*
  228. * CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
  229. * so it is used directly
  230. */
  231. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_PKISI, statusString, ASN1_UTF8STRING),
  232. /*
  233. * OSSL_CMP_PKIFAILUREINFO is effectively ASN1_BIT_STRING so used directly
  234. */
  235. ASN1_OPT(OSSL_CMP_PKISI, failInfo, ASN1_BIT_STRING)
  236. } ASN1_SEQUENCE_END(OSSL_CMP_PKISI)
  237. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
  238. IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
  239. ASN1_SEQUENCE(OSSL_CMP_CERTSTATUS) = {
  240. ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certHash, ASN1_OCTET_STRING),
  241. ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certReqId, ASN1_INTEGER),
  242. ASN1_OPT(OSSL_CMP_CERTSTATUS, statusInfo, OSSL_CMP_PKISI)
  243. } ASN1_SEQUENCE_END(OSSL_CMP_CERTSTATUS)
  244. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS)
  245. ASN1_ITEM_TEMPLATE(OSSL_CMP_CERTCONFIRMCONTENT) =
  246. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_CERTCONFIRMCONTENT,
  247. OSSL_CMP_CERTSTATUS)
  248. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CERTCONFIRMCONTENT)
  249. ASN1_SEQUENCE(OSSL_CMP_CERTRESPONSE) = {
  250. ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, certReqId, ASN1_INTEGER),
  251. ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, status, OSSL_CMP_PKISI),
  252. ASN1_OPT(OSSL_CMP_CERTRESPONSE, certifiedKeyPair,
  253. OSSL_CMP_CERTIFIEDKEYPAIR),
  254. ASN1_OPT(OSSL_CMP_CERTRESPONSE, rspInfo, ASN1_OCTET_STRING)
  255. } ASN1_SEQUENCE_END(OSSL_CMP_CERTRESPONSE)
  256. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE)
  257. ASN1_SEQUENCE(OSSL_CMP_POLLREQ) = {
  258. ASN1_SIMPLE(OSSL_CMP_POLLREQ, certReqId, ASN1_INTEGER)
  259. } ASN1_SEQUENCE_END(OSSL_CMP_POLLREQ)
  260. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ)
  261. ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREQCONTENT) =
  262. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_POLLREQCONTENT,
  263. OSSL_CMP_POLLREQ)
  264. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREQCONTENT)
  265. ASN1_SEQUENCE(OSSL_CMP_POLLREP) = {
  266. ASN1_SIMPLE(OSSL_CMP_POLLREP, certReqId, ASN1_INTEGER),
  267. ASN1_SIMPLE(OSSL_CMP_POLLREP, checkAfter, ASN1_INTEGER),
  268. ASN1_SEQUENCE_OF_OPT(OSSL_CMP_POLLREP, reason, ASN1_UTF8STRING),
  269. } ASN1_SEQUENCE_END(OSSL_CMP_POLLREP)
  270. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREP)
  271. ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREPCONTENT) =
  272. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
  273. OSSL_CMP_POLLREPCONTENT,
  274. OSSL_CMP_POLLREP)
  275. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREPCONTENT)
  276. ASN1_SEQUENCE(OSSL_CMP_CERTREPMESSAGE) = {
  277. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  278. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_CERTREPMESSAGE, caPubs, X509, 1),
  279. ASN1_SEQUENCE_OF(OSSL_CMP_CERTREPMESSAGE, response, OSSL_CMP_CERTRESPONSE)
  280. } ASN1_SEQUENCE_END(OSSL_CMP_CERTREPMESSAGE)
  281. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE)
  282. ASN1_ITEM_TEMPLATE(OSSL_CMP_GENMSGCONTENT) =
  283. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENMSGCONTENT,
  284. OSSL_CMP_ITAV)
  285. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENMSGCONTENT)
  286. ASN1_ITEM_TEMPLATE(OSSL_CMP_GENREPCONTENT) =
  287. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENREPCONTENT,
  288. OSSL_CMP_ITAV)
  289. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENREPCONTENT)
  290. ASN1_ITEM_TEMPLATE(OSSL_CMP_CRLANNCONTENT) =
  291. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
  292. OSSL_CMP_CRLANNCONTENT, X509_CRL)
  293. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CRLANNCONTENT)
  294. ASN1_CHOICE(OSSL_CMP_PKIBODY) = {
  295. ASN1_EXP(OSSL_CMP_PKIBODY, value.ir, OSSL_CRMF_MSGS, 0),
  296. ASN1_EXP(OSSL_CMP_PKIBODY, value.ip, OSSL_CMP_CERTREPMESSAGE, 1),
  297. ASN1_EXP(OSSL_CMP_PKIBODY, value.cr, OSSL_CRMF_MSGS, 2),
  298. ASN1_EXP(OSSL_CMP_PKIBODY, value.cp, OSSL_CMP_CERTREPMESSAGE, 3),
  299. ASN1_EXP(OSSL_CMP_PKIBODY, value.p10cr, X509_REQ, 4),
  300. ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecc,
  301. OSSL_CMP_POPODECKEYCHALLCONTENT, 5),
  302. ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecr,
  303. OSSL_CMP_POPODECKEYRESPCONTENT, 6),
  304. ASN1_EXP(OSSL_CMP_PKIBODY, value.kur, OSSL_CRMF_MSGS, 7),
  305. ASN1_EXP(OSSL_CMP_PKIBODY, value.kup, OSSL_CMP_CERTREPMESSAGE, 8),
  306. ASN1_EXP(OSSL_CMP_PKIBODY, value.krr, OSSL_CRMF_MSGS, 9),
  307. ASN1_EXP(OSSL_CMP_PKIBODY, value.krp, OSSL_CMP_KEYRECREPCONTENT, 10),
  308. ASN1_EXP(OSSL_CMP_PKIBODY, value.rr, OSSL_CMP_REVREQCONTENT, 11),
  309. ASN1_EXP(OSSL_CMP_PKIBODY, value.rp, OSSL_CMP_REVREPCONTENT, 12),
  310. ASN1_EXP(OSSL_CMP_PKIBODY, value.ccr, OSSL_CRMF_MSGS, 13),
  311. ASN1_EXP(OSSL_CMP_PKIBODY, value.ccp, OSSL_CMP_CERTREPMESSAGE, 14),
  312. ASN1_EXP(OSSL_CMP_PKIBODY, value.ckuann, OSSL_CMP_CAKEYUPDANNCONTENT, 15),
  313. ASN1_EXP(OSSL_CMP_PKIBODY, value.cann, X509, 16),
  314. ASN1_EXP(OSSL_CMP_PKIBODY, value.rann, OSSL_CMP_REVANNCONTENT, 17),
  315. ASN1_EXP(OSSL_CMP_PKIBODY, value.crlann, OSSL_CMP_CRLANNCONTENT, 18),
  316. ASN1_EXP(OSSL_CMP_PKIBODY, value.pkiconf, ASN1_ANY, 19),
  317. ASN1_EXP(OSSL_CMP_PKIBODY, value.nested, OSSL_CMP_MSGS, 20),
  318. ASN1_EXP(OSSL_CMP_PKIBODY, value.genm, OSSL_CMP_GENMSGCONTENT, 21),
  319. ASN1_EXP(OSSL_CMP_PKIBODY, value.genp, OSSL_CMP_GENREPCONTENT, 22),
  320. ASN1_EXP(OSSL_CMP_PKIBODY, value.error, OSSL_CMP_ERRORMSGCONTENT, 23),
  321. ASN1_EXP(OSSL_CMP_PKIBODY, value.certConf, OSSL_CMP_CERTCONFIRMCONTENT, 24),
  322. ASN1_EXP(OSSL_CMP_PKIBODY, value.pollReq, OSSL_CMP_POLLREQCONTENT, 25),
  323. ASN1_EXP(OSSL_CMP_PKIBODY, value.pollRep, OSSL_CMP_POLLREPCONTENT, 26),
  324. } ASN1_CHOICE_END(OSSL_CMP_PKIBODY)
  325. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY)
  326. ASN1_SEQUENCE(OSSL_CMP_PKIHEADER) = {
  327. ASN1_SIMPLE(OSSL_CMP_PKIHEADER, pvno, ASN1_INTEGER),
  328. ASN1_SIMPLE(OSSL_CMP_PKIHEADER, sender, GENERAL_NAME),
  329. ASN1_SIMPLE(OSSL_CMP_PKIHEADER, recipient, GENERAL_NAME),
  330. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, messageTime, ASN1_GENERALIZEDTIME, 0),
  331. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, protectionAlg, X509_ALGOR, 1),
  332. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderKID, ASN1_OCTET_STRING, 2),
  333. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipKID, ASN1_OCTET_STRING, 3),
  334. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, transactionID, ASN1_OCTET_STRING, 4),
  335. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderNonce, ASN1_OCTET_STRING, 5),
  336. ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipNonce, ASN1_OCTET_STRING, 6),
  337. /*
  338. * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING
  339. * so it is used directly
  340. */
  341. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, freeText, ASN1_UTF8STRING, 7),
  342. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, generalInfo,
  343. OSSL_CMP_ITAV, 8)
  344. } ASN1_SEQUENCE_END(OSSL_CMP_PKIHEADER)
  345. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
  346. ASN1_SEQUENCE(OSSL_CMP_PROTECTEDPART) = {
  347. ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
  348. ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY)
  349. } ASN1_SEQUENCE_END(OSSL_CMP_PROTECTEDPART)
  350. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PROTECTEDPART)
  351. ASN1_SEQUENCE(OSSL_CMP_MSG) = {
  352. ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER),
  353. ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY),
  354. ASN1_EXP_OPT(OSSL_CMP_MSG, protection, ASN1_BIT_STRING, 0),
  355. /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */
  356. ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_MSG, extraCerts, X509, 1)
  357. } ASN1_SEQUENCE_END(OSSL_CMP_MSG)
  358. IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_MSG)
  359. IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
  360. ASN1_ITEM_TEMPLATE(OSSL_CMP_MSGS) =
  361. ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_MSGS,
  362. OSSL_CMP_MSG)
  363. ASN1_ITEM_TEMPLATE_END(OSSL_CMP_MSGS)