x509_csr.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * X.509 Certificate Signing Request (CSR) parsing
  3. *
  4. * Copyright The Mbed TLS Contributors
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. /*
  20. * The ITU-T X.509 standard defines a certificate format for PKI.
  21. *
  22. * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs)
  23. * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs)
  24. * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10)
  25. *
  26. * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
  27. * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
  28. */
  29. #include "common.h"
  30. #if defined(MBEDTLS_X509_CSR_PARSE_C)
  31. #include "mbedtls/x509_csr.h"
  32. #include "mbedtls/error.h"
  33. #include "mbedtls/oid.h"
  34. #include "mbedtls/platform_util.h"
  35. #include <string.h>
  36. #if defined(MBEDTLS_PEM_PARSE_C)
  37. #include "mbedtls/pem.h"
  38. #endif
  39. #include "mbedtls/platform.h"
  40. #if defined(MBEDTLS_FS_IO) || defined(EFIX64) || defined(EFI32)
  41. #include <stdio.h>
  42. #endif
  43. /*
  44. * Version ::= INTEGER { v1(0) }
  45. */
  46. static int x509_csr_get_version(unsigned char **p,
  47. const unsigned char *end,
  48. int *ver)
  49. {
  50. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  51. if ((ret = mbedtls_asn1_get_int(p, end, ver)) != 0) {
  52. if (ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) {
  53. *ver = 0;
  54. return 0;
  55. }
  56. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_VERSION, ret);
  57. }
  58. return 0;
  59. }
  60. /*
  61. * Parse CSR extension requests in DER format
  62. */
  63. static int x509_csr_parse_extensions(mbedtls_x509_csr *csr,
  64. unsigned char **p, const unsigned char *end)
  65. {
  66. int ret;
  67. size_t len;
  68. unsigned char *end_ext_data;
  69. while (*p < end) {
  70. mbedtls_x509_buf extn_oid = { 0, 0, NULL };
  71. int ext_type = 0;
  72. /* Read sequence tag */
  73. if ((ret = mbedtls_asn1_get_tag(p, end, &len,
  74. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
  75. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  76. }
  77. end_ext_data = *p + len;
  78. /* Get extension ID */
  79. if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &extn_oid.len,
  80. MBEDTLS_ASN1_OID)) != 0) {
  81. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  82. }
  83. extn_oid.tag = MBEDTLS_ASN1_OID;
  84. extn_oid.p = *p;
  85. *p += extn_oid.len;
  86. /* Data should be octet string type */
  87. if ((ret = mbedtls_asn1_get_tag(p, end_ext_data, &len,
  88. MBEDTLS_ASN1_OCTET_STRING)) != 0) {
  89. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  90. }
  91. if (*p + len != end_ext_data) {
  92. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
  93. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  94. }
  95. /*
  96. * Detect supported extensions and skip unsupported extensions
  97. */
  98. ret = mbedtls_oid_get_x509_ext_type(&extn_oid, &ext_type);
  99. if (ret == 0) {
  100. /* Forbid repeated extensions */
  101. if ((csr->ext_types & ext_type) != 0) {
  102. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
  103. MBEDTLS_ERR_ASN1_INVALID_DATA);
  104. }
  105. csr->ext_types |= ext_type;
  106. switch (ext_type) {
  107. case MBEDTLS_X509_EXT_KEY_USAGE:
  108. /* Parse key usage */
  109. if ((ret = mbedtls_x509_get_key_usage(p, end_ext_data,
  110. &csr->key_usage)) != 0) {
  111. return ret;
  112. }
  113. break;
  114. case MBEDTLS_X509_EXT_SUBJECT_ALT_NAME:
  115. /* Parse subject alt name */
  116. if ((ret = mbedtls_x509_get_subject_alt_name(p, end_ext_data,
  117. &csr->subject_alt_names)) != 0) {
  118. return ret;
  119. }
  120. break;
  121. case MBEDTLS_X509_EXT_NS_CERT_TYPE:
  122. /* Parse netscape certificate type */
  123. if ((ret = mbedtls_x509_get_ns_cert_type(p, end_ext_data,
  124. &csr->ns_cert_type)) != 0) {
  125. return ret;
  126. }
  127. break;
  128. default:
  129. break;
  130. }
  131. }
  132. *p = end_ext_data;
  133. }
  134. if (*p != end) {
  135. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
  136. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  137. }
  138. return 0;
  139. }
  140. /*
  141. * Parse CSR attributes in DER format
  142. */
  143. static int x509_csr_parse_attributes(mbedtls_x509_csr *csr,
  144. const unsigned char *start, const unsigned char *end)
  145. {
  146. int ret;
  147. size_t len;
  148. unsigned char *end_attr_data;
  149. unsigned char **p = (unsigned char **) &start;
  150. while (*p < end) {
  151. mbedtls_x509_buf attr_oid = { 0, 0, NULL };
  152. if ((ret = mbedtls_asn1_get_tag(p, end, &len,
  153. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
  154. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  155. }
  156. end_attr_data = *p + len;
  157. /* Get attribute ID */
  158. if ((ret = mbedtls_asn1_get_tag(p, end_attr_data, &attr_oid.len,
  159. MBEDTLS_ASN1_OID)) != 0) {
  160. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  161. }
  162. attr_oid.tag = MBEDTLS_ASN1_OID;
  163. attr_oid.p = *p;
  164. *p += attr_oid.len;
  165. /* Check that this is an extension-request attribute */
  166. if (MBEDTLS_OID_CMP(MBEDTLS_OID_PKCS9_CSR_EXT_REQ, &attr_oid) == 0) {
  167. if ((ret = mbedtls_asn1_get_tag(p, end, &len,
  168. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SET)) != 0) {
  169. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  170. }
  171. if ((ret = mbedtls_asn1_get_tag(p, end, &len,
  172. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) !=
  173. 0) {
  174. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
  175. }
  176. if ((ret = x509_csr_parse_extensions(csr, p, *p + len)) != 0) {
  177. return ret;
  178. }
  179. if (*p != end_attr_data) {
  180. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
  181. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  182. }
  183. }
  184. *p = end_attr_data;
  185. }
  186. if (*p != end) {
  187. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
  188. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  189. }
  190. return 0;
  191. }
  192. /*
  193. * Parse a CSR in DER format
  194. */
  195. int mbedtls_x509_csr_parse_der(mbedtls_x509_csr *csr,
  196. const unsigned char *buf, size_t buflen)
  197. {
  198. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  199. size_t len;
  200. unsigned char *p, *end;
  201. mbedtls_x509_buf sig_params;
  202. memset(&sig_params, 0, sizeof(mbedtls_x509_buf));
  203. /*
  204. * Check for valid input
  205. */
  206. if (csr == NULL || buf == NULL || buflen == 0) {
  207. return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
  208. }
  209. mbedtls_x509_csr_init(csr);
  210. /*
  211. * first copy the raw DER data
  212. */
  213. p = mbedtls_calloc(1, len = buflen);
  214. if (p == NULL) {
  215. return MBEDTLS_ERR_X509_ALLOC_FAILED;
  216. }
  217. memcpy(p, buf, buflen);
  218. csr->raw.p = p;
  219. csr->raw.len = len;
  220. end = p + len;
  221. /*
  222. * CertificationRequest ::= SEQUENCE {
  223. * certificationRequestInfo CertificationRequestInfo,
  224. * signatureAlgorithm AlgorithmIdentifier,
  225. * signature BIT STRING
  226. * }
  227. */
  228. if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
  229. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
  230. mbedtls_x509_csr_free(csr);
  231. return MBEDTLS_ERR_X509_INVALID_FORMAT;
  232. }
  233. if (len != (size_t) (end - p)) {
  234. mbedtls_x509_csr_free(csr);
  235. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT,
  236. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  237. }
  238. /*
  239. * CertificationRequestInfo ::= SEQUENCE {
  240. */
  241. csr->cri.p = p;
  242. if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
  243. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
  244. mbedtls_x509_csr_free(csr);
  245. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);
  246. }
  247. end = p + len;
  248. csr->cri.len = end - csr->cri.p;
  249. /*
  250. * Version ::= INTEGER { v1(0) }
  251. */
  252. if ((ret = x509_csr_get_version(&p, end, &csr->version)) != 0) {
  253. mbedtls_x509_csr_free(csr);
  254. return ret;
  255. }
  256. if (csr->version != 0) {
  257. mbedtls_x509_csr_free(csr);
  258. return MBEDTLS_ERR_X509_UNKNOWN_VERSION;
  259. }
  260. csr->version++;
  261. /*
  262. * subject Name
  263. */
  264. csr->subject_raw.p = p;
  265. if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
  266. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
  267. mbedtls_x509_csr_free(csr);
  268. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);
  269. }
  270. if ((ret = mbedtls_x509_get_name(&p, p + len, &csr->subject)) != 0) {
  271. mbedtls_x509_csr_free(csr);
  272. return ret;
  273. }
  274. csr->subject_raw.len = p - csr->subject_raw.p;
  275. /*
  276. * subjectPKInfo SubjectPublicKeyInfo
  277. */
  278. if ((ret = mbedtls_pk_parse_subpubkey(&p, end, &csr->pk)) != 0) {
  279. mbedtls_x509_csr_free(csr);
  280. return ret;
  281. }
  282. /*
  283. * attributes [0] Attributes
  284. *
  285. * The list of possible attributes is open-ended, though RFC 2985
  286. * (PKCS#9) defines a few in section 5.4. We currently don't support any,
  287. * so we just ignore them. This is a safe thing to do as the worst thing
  288. * that could happen is that we issue a certificate that does not match
  289. * the requester's expectations - this cannot cause a violation of our
  290. * signature policies.
  291. */
  292. if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
  293. MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_CONTEXT_SPECIFIC)) !=
  294. 0) {
  295. mbedtls_x509_csr_free(csr);
  296. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);
  297. }
  298. if ((ret = x509_csr_parse_attributes(csr, p, p + len)) != 0) {
  299. mbedtls_x509_csr_free(csr);
  300. return ret;
  301. }
  302. p += len;
  303. end = csr->raw.p + csr->raw.len;
  304. /*
  305. * signatureAlgorithm AlgorithmIdentifier,
  306. * signature BIT STRING
  307. */
  308. if ((ret = mbedtls_x509_get_alg(&p, end, &csr->sig_oid, &sig_params)) != 0) {
  309. mbedtls_x509_csr_free(csr);
  310. return ret;
  311. }
  312. if ((ret = mbedtls_x509_get_sig_alg(&csr->sig_oid, &sig_params,
  313. &csr->sig_md, &csr->sig_pk,
  314. &csr->sig_opts)) != 0) {
  315. mbedtls_x509_csr_free(csr);
  316. return MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG;
  317. }
  318. if ((ret = mbedtls_x509_get_sig(&p, end, &csr->sig)) != 0) {
  319. mbedtls_x509_csr_free(csr);
  320. return ret;
  321. }
  322. if (p != end) {
  323. mbedtls_x509_csr_free(csr);
  324. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT,
  325. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  326. }
  327. return 0;
  328. }
  329. /*
  330. * Parse a CSR, allowing for PEM or raw DER encoding
  331. */
  332. int mbedtls_x509_csr_parse(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen)
  333. {
  334. #if defined(MBEDTLS_PEM_PARSE_C)
  335. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  336. size_t use_len;
  337. mbedtls_pem_context pem;
  338. #endif
  339. /*
  340. * Check for valid input
  341. */
  342. if (csr == NULL || buf == NULL || buflen == 0) {
  343. return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
  344. }
  345. #if defined(MBEDTLS_PEM_PARSE_C)
  346. /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */
  347. if (buf[buflen - 1] == '\0') {
  348. mbedtls_pem_init(&pem);
  349. ret = mbedtls_pem_read_buffer(&pem,
  350. "-----BEGIN CERTIFICATE REQUEST-----",
  351. "-----END CERTIFICATE REQUEST-----",
  352. buf, NULL, 0, &use_len);
  353. if (ret == MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) {
  354. ret = mbedtls_pem_read_buffer(&pem,
  355. "-----BEGIN NEW CERTIFICATE REQUEST-----",
  356. "-----END NEW CERTIFICATE REQUEST-----",
  357. buf, NULL, 0, &use_len);
  358. }
  359. if (ret == 0) {
  360. /*
  361. * Was PEM encoded, parse the result
  362. */
  363. ret = mbedtls_x509_csr_parse_der(csr, pem.buf, pem.buflen);
  364. }
  365. mbedtls_pem_free(&pem);
  366. if (ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) {
  367. return ret;
  368. }
  369. }
  370. #endif /* MBEDTLS_PEM_PARSE_C */
  371. return mbedtls_x509_csr_parse_der(csr, buf, buflen);
  372. }
  373. #if defined(MBEDTLS_FS_IO)
  374. /*
  375. * Load a CSR into the structure
  376. */
  377. int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path)
  378. {
  379. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  380. size_t n;
  381. unsigned char *buf;
  382. if ((ret = mbedtls_pk_load_file(path, &buf, &n)) != 0) {
  383. return ret;
  384. }
  385. ret = mbedtls_x509_csr_parse(csr, buf, n);
  386. mbedtls_platform_zeroize(buf, n);
  387. mbedtls_free(buf);
  388. return ret;
  389. }
  390. #endif /* MBEDTLS_FS_IO */
  391. #if !defined(MBEDTLS_X509_REMOVE_INFO)
  392. #define BEFORE_COLON 14
  393. #define BC "14"
  394. /*
  395. * Return an informational string about the CSR.
  396. */
  397. int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
  398. const mbedtls_x509_csr *csr)
  399. {
  400. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  401. size_t n;
  402. char *p;
  403. char key_size_str[BEFORE_COLON];
  404. p = buf;
  405. n = size;
  406. ret = mbedtls_snprintf(p, n, "%sCSR version : %d",
  407. prefix, csr->version);
  408. MBEDTLS_X509_SAFE_SNPRINTF;
  409. ret = mbedtls_snprintf(p, n, "\n%ssubject name : ", prefix);
  410. MBEDTLS_X509_SAFE_SNPRINTF;
  411. ret = mbedtls_x509_dn_gets(p, n, &csr->subject);
  412. MBEDTLS_X509_SAFE_SNPRINTF;
  413. ret = mbedtls_snprintf(p, n, "\n%ssigned using : ", prefix);
  414. MBEDTLS_X509_SAFE_SNPRINTF;
  415. ret = mbedtls_x509_sig_alg_gets(p, n, &csr->sig_oid, csr->sig_pk, csr->sig_md,
  416. csr->sig_opts);
  417. MBEDTLS_X509_SAFE_SNPRINTF;
  418. if ((ret = mbedtls_x509_key_size_helper(key_size_str, BEFORE_COLON,
  419. mbedtls_pk_get_name(&csr->pk))) != 0) {
  420. return ret;
  421. }
  422. ret = mbedtls_snprintf(p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str,
  423. (int) mbedtls_pk_get_bitlen(&csr->pk));
  424. MBEDTLS_X509_SAFE_SNPRINTF;
  425. /*
  426. * Optional extensions
  427. */
  428. if (csr->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME) {
  429. ret = mbedtls_snprintf(p, n, "\n%ssubject alt name :", prefix);
  430. MBEDTLS_X509_SAFE_SNPRINTF;
  431. if ((ret = mbedtls_x509_info_subject_alt_name(&p, &n,
  432. &csr->subject_alt_names,
  433. prefix)) != 0) {
  434. return ret;
  435. }
  436. }
  437. if (csr->ext_types & MBEDTLS_X509_EXT_NS_CERT_TYPE) {
  438. ret = mbedtls_snprintf(p, n, "\n%scert. type : ", prefix);
  439. MBEDTLS_X509_SAFE_SNPRINTF;
  440. if ((ret = mbedtls_x509_info_cert_type(&p, &n, csr->ns_cert_type)) != 0) {
  441. return ret;
  442. }
  443. }
  444. if (csr->ext_types & MBEDTLS_X509_EXT_KEY_USAGE) {
  445. ret = mbedtls_snprintf(p, n, "\n%skey usage : ", prefix);
  446. MBEDTLS_X509_SAFE_SNPRINTF;
  447. if ((ret = mbedtls_x509_info_key_usage(&p, &n, csr->key_usage)) != 0) {
  448. return ret;
  449. }
  450. }
  451. if (csr->ext_types != 0) {
  452. ret = mbedtls_snprintf(p, n, "\n");
  453. MBEDTLS_X509_SAFE_SNPRINTF;
  454. }
  455. return (int) (size - n);
  456. }
  457. #endif /* MBEDTLS_X509_REMOVE_INFO */
  458. /*
  459. * Initialize a CSR
  460. */
  461. void mbedtls_x509_csr_init(mbedtls_x509_csr *csr)
  462. {
  463. memset(csr, 0, sizeof(mbedtls_x509_csr));
  464. }
  465. /*
  466. * Unallocate all CSR data
  467. */
  468. void mbedtls_x509_csr_free(mbedtls_x509_csr *csr)
  469. {
  470. if (csr == NULL) {
  471. return;
  472. }
  473. mbedtls_pk_free(&csr->pk);
  474. #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
  475. mbedtls_free(csr->sig_opts);
  476. #endif
  477. mbedtls_asn1_free_named_data_list_shallow(csr->subject.next);
  478. mbedtls_asn1_sequence_free(csr->subject_alt_names.next);
  479. if (csr->raw.p != NULL) {
  480. mbedtls_platform_zeroize(csr->raw.p, csr->raw.len);
  481. mbedtls_free(csr->raw.p);
  482. }
  483. mbedtls_platform_zeroize(csr, sizeof(mbedtls_x509_csr));
  484. }
  485. #endif /* MBEDTLS_X509_CSR_PARSE_C */