blob: dc4f86de460aaa825d643c46ec7381304a3f2e54 [file] [log] [blame]
Paul Bakker7c6b2c32013-09-16 13:49:26 +02001/**
Simon Butcher5b331b92016-01-03 16:14:14 +00002 * \file x509_csr.h
Paul Bakker7c6b2c32013-09-16 13:49:26 +02003 *
4 * \brief X.509 certificate signing request parsing and writing
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02008 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
Paul Bakker7c6b2c32013-09-16 13:49:26 +020021 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#ifndef MBEDTLS_X509_CSR_H
23#define MBEDTLS_X509_CSR_H
Mateusz Starzyk846f0212021-05-19 19:44:07 +020024#include "mbedtls/private_access.h"
Paul Bakker7c6b2c32013-09-16 13:49:26 +020025
Bence Szépkútic662b362021-05-27 11:25:03 +020026#include "mbedtls/build_info.h"
Paul Bakker7c6b2c32013-09-16 13:49:26 +020027
Jaeden Amero6609aef2019-07-04 20:01:14 +010028#include "mbedtls/x509.h"
Paul Bakker7c6b2c32013-09-16 13:49:26 +020029
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * \addtogroup x509_module
36 * \{ */
37
38/**
39 * \name Structures and functions for X.509 Certificate Signing Requests (CSR)
40 * \{
41 */
42
43/**
44 * Certificate Signing Request (CSR) structure.
Gilles Peskine842edf42021-08-04 21:56:10 +020045 *
46 * Some fields of this structure are publicly readable. Do not modify
47 * them except via Mbed TLS library functions: the effect of modifying
Gilles Peskine44ffc792021-08-31 22:59:35 +020048 * those fields or the data that those fields point to is unspecified.
Paul Bakker7c6b2c32013-09-16 13:49:26 +020049 */
Gilles Peskine449bd832023-01-11 14:50:10 +010050typedef struct mbedtls_x509_csr {
Gilles Peskine842edf42021-08-04 21:56:10 +020051 mbedtls_x509_buf raw; /**< The raw CSR data (DER). */
52 mbedtls_x509_buf cri; /**< The raw CertificateRequestInfo body (DER). */
Paul Bakker7c6b2c32013-09-16 13:49:26 +020053
Gilles Peskine842edf42021-08-04 21:56:10 +020054 int version; /**< CSR version (1=v1). */
Paul Bakker7c6b2c32013-09-16 13:49:26 +020055
Gilles Peskine842edf42021-08-04 21:56:10 +020056 mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). */
57 mbedtls_x509_name subject; /**< The parsed subject data (named information object). */
Paul Bakker7c6b2c32013-09-16 13:49:26 +020058
Gilles Peskine842edf42021-08-04 21:56:10 +020059 mbedtls_pk_context pk; /**< Container for the public key context. */
Paul Bakker7c6b2c32013-09-16 13:49:26 +020060
Jens Alfke2d9e3592019-10-29 15:03:37 -070061 unsigned int key_usage; /**< Optional key usage extension value: See the values in x509.h */
62 unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values in x509.h */
Andrzej Kurek17473042023-04-30 14:11:23 -040063 mbedtls_x509_sequence subject_alt_names; /**< Optional list of raw entries of Subject Alternative Names extension. These can be later parsed by mbedtls_x509_parse_subject_alt_name. */
Jens Alfke2d9e3592019-10-29 15:03:37 -070064
Przemek Stekielcbaf3162023-01-12 12:58:02 +010065 int MBEDTLS_PRIVATE(ext_types); /**< Bit string containing detected and parsed extensions */
66
Gilles Peskine842edf42021-08-04 21:56:10 +020067 mbedtls_x509_buf sig_oid;
Mateusz Starzyk846f0212021-05-19 19:44:07 +020068 mbedtls_x509_buf MBEDTLS_PRIVATE(sig);
69 mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md); /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
70 mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
71 void *MBEDTLS_PRIVATE(sig_opts); /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */
Paul Bakker7c6b2c32013-09-16 13:49:26 +020072}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020073mbedtls_x509_csr;
Paul Bakker7c6b2c32013-09-16 13:49:26 +020074
75/**
76 * Container for writing a CSR
77 */
Gilles Peskine449bd832023-01-11 14:50:10 +010078typedef struct mbedtls_x509write_csr {
Mateusz Starzyk846f0212021-05-19 19:44:07 +020079 mbedtls_pk_context *MBEDTLS_PRIVATE(key);
80 mbedtls_asn1_named_data *MBEDTLS_PRIVATE(subject);
81 mbedtls_md_type_t MBEDTLS_PRIVATE(md_alg);
82 mbedtls_asn1_named_data *MBEDTLS_PRIVATE(extensions);
Paul Bakker7c6b2c32013-09-16 13:49:26 +020083}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020084mbedtls_x509write_csr;
Paul Bakker7c6b2c32013-09-16 13:49:26 +020085
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086#if defined(MBEDTLS_X509_CSR_PARSE_C)
Paul Bakker7c6b2c32013-09-16 13:49:26 +020087/**
Manuel Pégourié-Gonnardf3b47242014-06-16 18:06:48 +020088 * \brief Load a Certificate Signing Request (CSR) in DER format
89 *
Matthias Schulzc55b5002023-11-07 16:47:37 +010090 * \note Any unsupported requested extensions are silently
91 * ignored, unless the critical flag is set, in which case
92 * the CSR is rejected.
Manuel Pégourié-Gonnard986bbf22016-02-24 14:36:05 +000093 *
Gilles Peskine5b7e1642022-08-04 23:44:59 +020094 * \note If #MBEDTLS_USE_PSA_CRYPTO is enabled, the PSA crypto
95 * subsystem must have been initialized by calling
96 * psa_crypto_init() before calling this function.
97 *
Manuel Pégourié-Gonnardf3b47242014-06-16 18:06:48 +020098 * \param csr CSR context to fill
99 * \param buf buffer holding the CRL data
100 * \param buflen size of the buffer
101 *
102 * \return 0 if successful, or a specific X509 error code
103 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100104int mbedtls_x509_csr_parse_der(mbedtls_x509_csr *csr,
105 const unsigned char *buf, size_t buflen);
Manuel Pégourié-Gonnardf3b47242014-06-16 18:06:48 +0200106
107/**
Matthias Schulzab408222023-10-18 13:20:59 +0200108 * \brief The type of certificate extension callbacks.
109 *
110 * Callbacks of this type are passed to and used by the
111 * mbedtls_x509_csr_parse_der_with_ext_cb() routine when
112 * it encounters either an unsupported extension.
113 * Future versions of the library may invoke the callback
114 * in other cases, if and when the need arises.
115 *
116 * \param p_ctx An opaque context passed to the callback.
117 * \param csr The CSR being parsed.
118 * \param oid The OID of the extension.
119 * \param critical Whether the extension is critical.
120 * \param p Pointer to the start of the extension value
121 * (the content of the OCTET STRING).
122 * \param end End of extension value.
123 *
124 * \note The callback must fail and return a negative error code
125 * if it can not parse or does not support the extension.
126 * When the callback fails to parse a critical extension
127 * mbedtls_x509_csr_parse_der_with_ext_cb() also fails.
128 * When the callback fails to parse a non critical extension
129 * mbedtls_x509_csr_parse_der_with_ext_cb() simply skips
130 * the extension and continues parsing.
131 *
132 * \return \c 0 on success.
133 * \return A negative error code on failure.
134 */
135typedef int (*mbedtls_x509_csr_ext_cb_t)(void *p_ctx,
136 mbedtls_x509_csr const *csr,
137 mbedtls_x509_buf const *oid,
138 int critical,
139 const unsigned char *p,
140 const unsigned char *end);
141
142/**
143 * \brief Load a Certificate Signing Request (CSR) in DER format
144 *
Matthias Schulzc55b5002023-11-07 16:47:37 +0100145 * \note Any unsupported requested extensions are silently
146 * ignored, unless the critical flag is set, in which case
147 * the result of the callback function decides whether
148 * CSR is rejected.
Matthias Schulzab408222023-10-18 13:20:59 +0200149 *
150 * \note If #MBEDTLS_USE_PSA_CRYPTO is enabled, the PSA crypto
151 * subsystem must have been initialized by calling
152 * psa_crypto_init() before calling this function.
153 *
154 * \param csr CSR context to fill
155 * \param buf buffer holding the CRL data
156 * \param buflen size of the buffer
157 * \param cb A callback invoked for every unsupported certificate
158 * extension.
159 * \param p_ctx An opaque context passed to the callback.
160 *
161 * \return 0 if successful, or a specific X509 error code
162 */
163int mbedtls_x509_csr_parse_der_with_ext_cb(mbedtls_x509_csr *csr,
Matthias Schulzedc32ea2023-10-19 16:09:08 +0200164 const unsigned char *buf, size_t buflen,
165 mbedtls_x509_csr_ext_cb_t cb,
166 void *p_ctx);
Matthias Schulzab408222023-10-18 13:20:59 +0200167
168/**
Manuel Pégourié-Gonnardf3b47242014-06-16 18:06:48 +0200169 * \brief Load a Certificate Signing Request (CSR), DER or PEM format
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200170 *
Manuel Pégourié-Gonnard986bbf22016-02-24 14:36:05 +0000171 * \note See notes for \c mbedtls_x509_csr_parse_der()
172 *
Gilles Peskine5b7e1642022-08-04 23:44:59 +0200173 * \note If #MBEDTLS_USE_PSA_CRYPTO is enabled, the PSA crypto
174 * subsystem must have been initialized by calling
175 * psa_crypto_init() before calling this function.
176 *
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200177 * \param csr CSR context to fill
178 * \param buf buffer holding the CRL data
179 * \param buflen size of the buffer
Manuel Pégourié-Gonnard43b37cb2015-05-12 11:20:10 +0200180 * (including the terminating null byte for PEM data)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200181 *
182 * \return 0 if successful, or a specific X509 or PEM error code
183 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100184int mbedtls_x509_csr_parse(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200185
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200186#if defined(MBEDTLS_FS_IO)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200187/**
188 * \brief Load a Certificate Signing Request (CSR)
189 *
Manuel Pégourié-Gonnard986bbf22016-02-24 14:36:05 +0000190 * \note See notes for \c mbedtls_x509_csr_parse()
191 *
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200192 * \param csr CSR context to fill
193 * \param path filename to read the CSR from
194 *
195 * \return 0 if successful, or a specific X509 or PEM error code
196 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100197int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200198#endif /* MBEDTLS_FS_IO */
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200199
Hanno Becker612a2f12020-10-09 09:19:39 +0100200#if !defined(MBEDTLS_X509_REMOVE_INFO)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200201/**
202 * \brief Returns an informational string about the
203 * CSR.
204 *
205 * \param buf Buffer to write to
206 * \param size Maximum size of buffer
207 * \param prefix A line prefix
208 * \param csr The X509 CSR to represent
209 *
Manuel Pégourié-Gonnarde244f9f2015-06-23 12:10:45 +0200210 * \return The length of the string written (not including the
211 * terminated nul byte), or a negative error code.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200212 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100213int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
214 const mbedtls_x509_csr *csr);
Hanno Becker88c2bf32019-06-14 17:21:24 +0100215#endif /* !MBEDTLS_X509_REMOVE_INFO */
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200216
217/**
Paul Bakker369d2eb2013-09-18 11:58:25 +0200218 * \brief Initialize a CSR
219 *
220 * \param csr CSR to initialize
221 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100222void mbedtls_x509_csr_init(mbedtls_x509_csr *csr);
Paul Bakker369d2eb2013-09-18 11:58:25 +0200223
224/**
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200225 * \brief Unallocate all CSR data
226 *
227 * \param csr CSR to free
228 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100229void mbedtls_x509_csr_free(mbedtls_x509_csr *csr);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200230#endif /* MBEDTLS_X509_CSR_PARSE_C */
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200231
Andrzej Kurek38d4fdd2021-12-28 16:22:52 +0100232/** \} name Structures and functions for X.509 Certificate Signing Requests (CSR) */
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200233
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200234#if defined(MBEDTLS_X509_CSR_WRITE_C)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200235/**
236 * \brief Initialize a CSR context
237 *
238 * \param ctx CSR context to initialize
239 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100240void mbedtls_x509write_csr_init(mbedtls_x509write_csr *ctx);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200241
242/**
243 * \brief Set the subject name for a CSR
244 * Subject names should contain a comma-separated list
245 * of OID types and values:
Gilles Peskinee820c0a2023-08-03 17:45:20 +0200246 * e.g. "C=UK,O=ARM,CN=Mbed TLS Server 1"
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200247 *
248 * \param ctx CSR context to use
249 * \param subject_name subject name to set
250 *
251 * \return 0 if subject name was parsed successfully, or
252 * a specific error code
253 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100254int mbedtls_x509write_csr_set_subject_name(mbedtls_x509write_csr *ctx,
255 const char *subject_name);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200256
257/**
258 * \brief Set the key for a CSR (public key will be included,
259 * private key used to sign the CSR when writing it)
260 *
261 * \param ctx CSR context to use
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800262 * \param key Asymmetric key to include
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200263 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100264void mbedtls_x509write_csr_set_key(mbedtls_x509write_csr *ctx, mbedtls_pk_context *key);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200265
266/**
267 * \brief Set the MD algorithm to use for the signature
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200268 * (e.g. MBEDTLS_MD_SHA1)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200269 *
270 * \param ctx CSR context to use
271 * \param md_alg MD algorithm to use
272 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100273void mbedtls_x509write_csr_set_md_alg(mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200274
275/**
276 * \brief Set the Key Usage Extension flags
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200277 * (e.g. MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_SIGN)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200278 *
279 * \param ctx CSR context to use
280 * \param key_usage key usage flags to set
281 *
Manuel Pégourié-Gonnard6a8ca332015-05-28 09:33:39 +0200282 * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED
Andres Amaya Garciad8233f72018-10-08 19:44:55 +0100283 *
284 * \note The <code>decipherOnly</code> flag from the Key Usage
285 * extension is represented by bit 8 (i.e.
286 * <code>0x8000</code>), which cannot typically be represented
287 * in an unsigned char. Therefore, the flag
288 * <code>decipherOnly</code> (i.e.
289 * #MBEDTLS_X509_KU_DECIPHER_ONLY) cannot be set using this
290 * function.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200291 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100292int mbedtls_x509write_csr_set_key_usage(mbedtls_x509write_csr *ctx, unsigned char key_usage);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200293
294/**
Hannes Tschofenig6b108602022-12-28 18:38:53 +0100295 * \brief Set Subject Alternative Name
296 *
297 * \param ctx CSR context to use
298 * \param san_list List of SAN values
299 *
300 * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED
301 *
302 * \note Only "dnsName", "uniformResourceIdentifier" and "otherName",
303 * as defined in RFC 5280, are supported.
304 */
305int mbedtls_x509write_csr_set_subject_alternative_name(mbedtls_x509write_csr *ctx,
306 const mbedtls_x509_san_list *san_list);
307
308/**
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200309 * \brief Set the Netscape Cert Type flags
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310 * (e.g. MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT | MBEDTLS_X509_NS_CERT_TYPE_EMAIL)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200311 *
312 * \param ctx CSR context to use
313 * \param ns_cert_type Netscape Cert Type flags to set
314 *
Manuel Pégourié-Gonnard6a8ca332015-05-28 09:33:39 +0200315 * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200316 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100317int mbedtls_x509write_csr_set_ns_cert_type(mbedtls_x509write_csr *ctx,
318 unsigned char ns_cert_type);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200319
320/**
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200321 * \brief Generic function to add to or replace an extension in the
322 * CSR
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200323 *
324 * \param ctx CSR context to use
325 * \param oid OID of the extension
326 * \param oid_len length of the OID
Christoph Reiter95273f42021-01-21 13:31:23 +0100327 * \param critical Set to 1 to mark the extension as critical, 0 otherwise.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200328 * \param val value of the extension OCTET STRING
329 * \param val_len length of the value data
330 *
Manuel Pégourié-Gonnard6a8ca332015-05-28 09:33:39 +0200331 * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200332 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100333int mbedtls_x509write_csr_set_extension(mbedtls_x509write_csr *ctx,
334 const char *oid, size_t oid_len,
335 int critical,
336 const unsigned char *val, size_t val_len);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200337
338/**
339 * \brief Free the contents of a CSR context
340 *
341 * \param ctx CSR context to free
342 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100343void mbedtls_x509write_csr_free(mbedtls_x509write_csr *ctx);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200344
345/**
346 * \brief Write a CSR (Certificate Signing Request) to a
347 * DER structure
348 * Note: data is written at the end of the buffer! Use the
349 * return value to determine where you should start
350 * using the buffer
351 *
352 * \param ctx CSR to write away
353 * \param buf buffer to write to
354 * \param size size of the buffer
Manuel Pégourié-Gonnardc305b722021-06-15 11:29:26 +0200355 * \param f_rng RNG function. This must not be \c NULL.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200356 * \param p_rng RNG parameter
357 *
358 * \return length of data written if successful, or a specific
359 * error code
360 *
Manuel Pégourié-Gonnardc305b722021-06-15 11:29:26 +0200361 * \note \p f_rng is used for the signature operation.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200362 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100363int mbedtls_x509write_csr_der(mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size,
364 int (*f_rng)(void *, unsigned char *, size_t),
365 void *p_rng);
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200366
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200367#if defined(MBEDTLS_PEM_WRITE_C)
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200368/**
369 * \brief Write a CSR (Certificate Signing Request) to a
370 * PEM string
371 *
372 * \param ctx CSR to write away
373 * \param buf buffer to write to
374 * \param size size of the buffer
Manuel Pégourié-Gonnardc305b722021-06-15 11:29:26 +0200375 * \param f_rng RNG function. This must not be \c NULL.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200376 * \param p_rng RNG parameter
377 *
Manuel Pégourié-Gonnard81abefd2015-05-29 12:53:47 +0200378 * \return 0 if successful, or a specific error code
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200379 *
Manuel Pégourié-Gonnardc305b722021-06-15 11:29:26 +0200380 * \note \p f_rng is used for the signature operation.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200381 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100382int mbedtls_x509write_csr_pem(mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size,
383 int (*f_rng)(void *, unsigned char *, size_t),
384 void *p_rng);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200385#endif /* MBEDTLS_PEM_WRITE_C */
386#endif /* MBEDTLS_X509_CSR_WRITE_C */
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200387
Andrzej Kureka0defed2021-12-30 12:33:31 +0100388/** \} addtogroup x509_module */
389
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200390#ifdef __cplusplus
391}
392#endif
393
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200394#endif /* mbedtls_x509_csr.h */