cmp_asn.c 17 KB

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