blob: c57831c7f4a1f09a6b23bbc6d6aaf1bb5f633ea1 [file] [log] [blame]
Paul Bakkerbdb912d2012-02-13 23:11:30 +00001/**
2 * \file asn1write.h
3 *
4 * \brief ASN.1 buffer writing functionality
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 Bakkerbdb912d2012-02-13 23:11:30 +000021 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#ifndef MBEDTLS_ASN1_WRITE_H
23#define MBEDTLS_ASN1_WRITE_H
Paul Bakkerbdb912d2012-02-13 23:11:30 +000024
Bence Szépkútic662b362021-05-27 11:25:03 +020025#include "mbedtls/build_info.h"
Ron Eldor8b0cf2e2018-02-14 16:02:41 +020026
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010027#include "mbedtls/asn1.h"
Paul Bakkerbdb912d2012-02-13 23:11:30 +000028
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020029#define MBEDTLS_ASN1_CHK_ADD(g, f) \
30 do { \
31 if ((ret = (f)) < 0) \
32 return ret; \
33 else \
34 (g) += ret; \
35 } while (0)
Paul Bakkerbdb912d2012-02-13 23:11:30 +000036
Paul Bakker407a0da2013-06-27 14:29:21 +020037#ifdef __cplusplus
38extern "C" {
39#endif
40
Paul Bakker7accbce2013-08-26 17:34:53 +020041/**
Hanno Becker55177552018-10-24 12:29:53 +010042 * \brief Write a length field in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +020043 *
Hanno Becker55177552018-10-24 12:29:53 +010044 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +020045 *
Hanno Becker55177552018-10-24 12:29:53 +010046 * \param p The reference to the current position pointer.
47 * \param start The start of the buffer, for bounds-checking.
48 * \param len The length value to write.
49 *
50 * \return The number of bytes written to \p p on success.
51 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +020052 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020053int mbedtls_asn1_write_len(unsigned char **p,
54 const unsigned char *start,
55 size_t len);
Paul Bakker7accbce2013-08-26 17:34:53 +020056/**
Hanno Becker55177552018-10-24 12:29:53 +010057 * \brief Write an ASN.1 tag in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +020058 *
Hanno Becker55177552018-10-24 12:29:53 +010059 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +020060 *
Hanno Becker55177552018-10-24 12:29:53 +010061 * \param p The reference to the current position pointer.
62 * \param start The start of the buffer, for bounds-checking.
63 * \param tag The tag to write.
64 *
65 * \return The number of bytes written to \p p on success.
66 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +020067 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020068int mbedtls_asn1_write_tag(unsigned char **p,
69 const unsigned char *start,
70 unsigned char tag);
Paul Bakker7accbce2013-08-26 17:34:53 +020071
Paul Bakker9852d002013-08-26 17:56:37 +020072/**
Hanno Becker55177552018-10-24 12:29:53 +010073 * \brief Write raw buffer data.
Paul Bakker9852d002013-08-26 17:56:37 +020074 *
Hanno Becker55177552018-10-24 12:29:53 +010075 * \note This function works backwards in data buffer.
Paul Bakker9852d002013-08-26 17:56:37 +020076 *
Hanno Becker55177552018-10-24 12:29:53 +010077 * \param p The reference to the current position pointer.
78 * \param start The start of the buffer, for bounds-checking.
79 * \param buf The data buffer to write.
80 * \param size The length of the data buffer.
81 *
82 * \return The number of bytes written to \p p on success.
83 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker9852d002013-08-26 17:56:37 +020084 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020085int mbedtls_asn1_write_raw_buffer(unsigned char **p,
86 const unsigned char *start,
87 const unsigned char *buf,
88 size_t size);
Paul Bakker9852d002013-08-26 17:56:37 +020089
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020090#if defined(MBEDTLS_BIGNUM_C)
Paul Bakker7accbce2013-08-26 17:34:53 +020091/**
Hanno Becker55177552018-10-24 12:29:53 +010092 * \brief Write a arbitrary-precision number (#MBEDTLS_ASN1_INTEGER)
93 * in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +020094 *
Hanno Becker55177552018-10-24 12:29:53 +010095 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +020096 *
Hanno Becker55177552018-10-24 12:29:53 +010097 * \param p The reference to the current position pointer.
98 * \param start The start of the buffer, for bounds-checking.
99 * \param X The MPI to write.
Gilles Peskine105031b2019-03-01 19:28:41 +0100100 * It must be non-negative.
Hanno Becker55177552018-10-24 12:29:53 +0100101 *
102 * \return The number of bytes written to \p p on success.
103 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200104 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200105int mbedtls_asn1_write_mpi(unsigned char **p,
106 const unsigned char *start,
107 const mbedtls_mpi *X);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200108#endif /* MBEDTLS_BIGNUM_C */
Paul Bakker7accbce2013-08-26 17:34:53 +0200109
110/**
Hanno Becker55177552018-10-24 12:29:53 +0100111 * \brief Write a NULL tag (#MBEDTLS_ASN1_NULL) with zero data
112 * in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200113 *
Hanno Becker55177552018-10-24 12:29:53 +0100114 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200115 *
Hanno Becker55177552018-10-24 12:29:53 +0100116 * \param p The reference to the current position pointer.
117 * \param start The start of the buffer, for bounds-checking.
118 *
119 * \return The number of bytes written to \p p on success.
120 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200121 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200122int mbedtls_asn1_write_null(unsigned char **p, const unsigned char *start);
Paul Bakker7accbce2013-08-26 17:34:53 +0200123
124/**
Hanno Becker55177552018-10-24 12:29:53 +0100125 * \brief Write an OID tag (#MBEDTLS_ASN1_OID) and data
126 * in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200127 *
Hanno Becker55177552018-10-24 12:29:53 +0100128 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200129 *
Hanno Becker55177552018-10-24 12:29:53 +0100130 * \param p The reference to the current position pointer.
131 * \param start The start of the buffer, for bounds-checking.
132 * \param oid The OID to write.
133 * \param oid_len The length of the OID.
134 *
135 * \return The number of bytes written to \p p on success.
136 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200137 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200138int mbedtls_asn1_write_oid(unsigned char **p,
139 const unsigned char *start,
140 const char *oid,
141 size_t oid_len);
Paul Bakker7accbce2013-08-26 17:34:53 +0200142
143/**
Hanno Becker55177552018-10-24 12:29:53 +0100144 * \brief Write an AlgorithmIdentifier sequence in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200145 *
Hanno Becker55177552018-10-24 12:29:53 +0100146 * \note This function works backwards in data buffer.
147 *
148 * \param p The reference to the current position pointer.
149 * \param start The start of the buffer, for bounds-checking.
150 * \param oid The OID of the algorithm to write.
151 * \param oid_len The length of the algorithm's OID.
152 * \param par_len The length of the parameters, which must be already written.
Manuel Pégourié-Gonnardedda9042013-09-12 02:17:54 +0200153 * If 0, NULL parameters are added
Paul Bakker7accbce2013-08-26 17:34:53 +0200154 *
Hanno Becker55177552018-10-24 12:29:53 +0100155 * \return The number of bytes written to \p p on success.
156 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200157 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200158int mbedtls_asn1_write_algorithm_identifier(unsigned char **p,
159 const unsigned char *start,
160 const char *oid,
161 size_t oid_len,
162 size_t par_len);
Paul Bakker7accbce2013-08-26 17:34:53 +0200163
164/**
Hanno Becker55177552018-10-24 12:29:53 +0100165 * \brief Write a boolean tag (#MBEDTLS_ASN1_BOOLEAN) and value
166 * in ASN.1 format.
Paul Bakker329def32013-09-06 16:34:38 +0200167 *
Hanno Becker55177552018-10-24 12:29:53 +0100168 * \note This function works backwards in data buffer.
Paul Bakker329def32013-09-06 16:34:38 +0200169 *
Hanno Becker55177552018-10-24 12:29:53 +0100170 * \param p The reference to the current position pointer.
171 * \param start The start of the buffer, for bounds-checking.
172 * \param boolean The boolean value to write, either \c 0 or \c 1.
173 *
174 * \return The number of bytes written to \p p on success.
175 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker329def32013-09-06 16:34:38 +0200176 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200177int mbedtls_asn1_write_bool(unsigned char **p,
178 const unsigned char *start,
179 int boolean);
Paul Bakker329def32013-09-06 16:34:38 +0200180
181/**
Hanno Becker55177552018-10-24 12:29:53 +0100182 * \brief Write an int tag (#MBEDTLS_ASN1_INTEGER) and value
183 * in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200184 *
Hanno Becker55177552018-10-24 12:29:53 +0100185 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200186 *
Hanno Becker55177552018-10-24 12:29:53 +0100187 * \param p The reference to the current position pointer.
188 * \param start The start of the buffer, for bounds-checking.
189 * \param val The integer value to write.
Gilles Peskine105031b2019-03-01 19:28:41 +0100190 * It must be non-negative.
Hanno Becker55177552018-10-24 12:29:53 +0100191 *
192 * \return The number of bytes written to \p p on success.
193 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200194 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200195int mbedtls_asn1_write_int(unsigned char **p,
196 const unsigned char *start,
197 int val);
Paul Bakker7accbce2013-08-26 17:34:53 +0200198
199/**
Mykhailo Sopiha20180ca2019-10-29 15:58:10 +0200200 * \brief Write an enum tag (#MBEDTLS_ASN1_ENUMERATED) and value
201 * in ASN.1 format.
202 *
203 * \note This function works backwards in data buffer.
204 *
205 * \param p The reference to the current position pointer.
206 * \param start The start of the buffer, for bounds-checking.
207 * \param val The integer value to write.
208 *
209 * \return The number of bytes written to \p p on success.
210 * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure.
211 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200212int mbedtls_asn1_write_enum(unsigned char **p,
213 const unsigned char *start,
214 int val);
Mykhailo Sopiha20180ca2019-10-29 15:58:10 +0200215
216/**
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100217 * \brief Write a string in ASN.1 format using a specific
218 * string encoding tag.
Hanno Becker55177552018-10-24 12:29:53 +0100219
220 * \note This function works backwards in data buffer.
Jaeden Amero23f954d2018-05-17 11:46:13 +0100221 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100222 * \param p The reference to the current position pointer.
Hanno Becker55177552018-10-24 12:29:53 +0100223 * \param start The start of the buffer, for bounds-checking.
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100224 * \param tag The string encoding tag to write, e.g.
225 * #MBEDTLS_ASN1_UTF8_STRING.
226 * \param text The string to write.
227 * \param text_len The length of \p text in bytes (which might
228 * be strictly larger than the number of characters).
Jaeden Amero23f954d2018-05-17 11:46:13 +0100229 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100230 * \return The number of bytes written to \p p on success.
231 * \return A negative error code on failure.
Jaeden Amero23f954d2018-05-17 11:46:13 +0100232 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200233int mbedtls_asn1_write_tagged_string(unsigned char **p,
234 const unsigned char *start,
235 int tag,
236 const char *text,
237 size_t text_len);
Paul Bakker7accbce2013-08-26 17:34:53 +0200238
239/**
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100240 * \brief Write a string in ASN.1 format using the PrintableString
241 * string encoding tag (#MBEDTLS_ASN1_PRINTABLE_STRING).
Hanno Becker55177552018-10-24 12:29:53 +0100242 *
243 * \note This function works backwards in data buffer.
Jaeden Amero23f954d2018-05-17 11:46:13 +0100244 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100245 * \param p The reference to the current position pointer.
Hanno Becker55177552018-10-24 12:29:53 +0100246 * \param start The start of the buffer, for bounds-checking.
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100247 * \param text The string to write.
248 * \param text_len The length of \p text in bytes (which might
249 * be strictly larger than the number of characters).
Jaeden Amero23f954d2018-05-17 11:46:13 +0100250 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100251 * \return The number of bytes written to \p p on success.
252 * \return A negative error code on failure.
253 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200254int mbedtls_asn1_write_printable_string(unsigned char **p,
255 const unsigned char *start,
256 const char *text,
257 size_t text_len);
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100258
259/**
260 * \brief Write a UTF8 string in ASN.1 format using the UTF8String
Gilles Peskine105031b2019-03-01 19:28:41 +0100261 * string encoding tag (#MBEDTLS_ASN1_UTF8_STRING).
Hanno Becker55177552018-10-24 12:29:53 +0100262 *
263 * \note This function works backwards in data buffer.
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100264 *
265 * \param p The reference to the current position pointer.
Hanno Becker55177552018-10-24 12:29:53 +0100266 * \param start The start of the buffer, for bounds-checking.
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100267 * \param text The string to write.
268 * \param text_len The length of \p text in bytes (which might
269 * be strictly larger than the number of characters).
270 *
271 * \return The number of bytes written to \p p on success.
272 * \return A negative error code on failure.
Jaeden Amero23f954d2018-05-17 11:46:13 +0100273 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200274int mbedtls_asn1_write_utf8_string(unsigned char **p,
275 const unsigned char *start,
276 const char *text,
277 size_t text_len);
Jaeden Amero23f954d2018-05-17 11:46:13 +0100278
279/**
Hanno Becker55177552018-10-24 12:29:53 +0100280 * \brief Write a string in ASN.1 format using the IA5String
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100281 * string encoding tag (#MBEDTLS_ASN1_IA5_STRING).
Hanno Becker55177552018-10-24 12:29:53 +0100282 *
283 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200284 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100285 * \param p The reference to the current position pointer.
Hanno Becker55177552018-10-24 12:29:53 +0100286 * \param start The start of the buffer, for bounds-checking.
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100287 * \param text The string to write.
288 * \param text_len The length of \p text in bytes (which might
289 * be strictly larger than the number of characters).
Paul Bakker7accbce2013-08-26 17:34:53 +0200290 *
Hanno Beckerd0e21fb2018-10-08 14:41:31 +0100291 * \return The number of bytes written to \p p on success.
292 * \return A negative error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200293 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200294int mbedtls_asn1_write_ia5_string(unsigned char **p,
295 const unsigned char *start,
296 const char *text,
297 size_t text_len);
Paul Bakker7accbce2013-08-26 17:34:53 +0200298
299/**
Hanno Becker55177552018-10-24 12:29:53 +0100300 * \brief Write a bitstring tag (#MBEDTLS_ASN1_BIT_STRING) and
301 * value in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200302 *
Hanno Becker55177552018-10-24 12:29:53 +0100303 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200304 *
Hanno Becker55177552018-10-24 12:29:53 +0100305 * \param p The reference to the current position pointer.
306 * \param start The start of the buffer, for bounds-checking.
307 * \param buf The bitstring to write.
308 * \param bits The total number of bits in the bitstring.
309 *
310 * \return The number of bytes written to \p p on success.
311 * \return A negative error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200312 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200313int mbedtls_asn1_write_bitstring(unsigned char **p,
314 const unsigned char *start,
315 const unsigned char *buf,
316 size_t bits);
Paul Bakker7accbce2013-08-26 17:34:53 +0200317
318/**
Andres Amaya Garciad8233f72018-10-08 19:44:55 +0100319 * \brief This function writes a named bitstring tag
320 * (#MBEDTLS_ASN1_BIT_STRING) and value in ASN.1 format.
Andres Amaya Garcia6e959142018-09-26 10:48:24 +0100321 *
Andres Amaya Garciad8233f72018-10-08 19:44:55 +0100322 * As stated in RFC 5280 Appendix B, trailing zeroes are
Andres Amaya Garcia6e959142018-09-26 10:48:24 +0100323 * omitted when encoding named bitstrings in DER.
324 *
Andres Amaya Garciad8233f72018-10-08 19:44:55 +0100325 * \note This function works backwards within the data buffer.
326 *
327 * \param p The reference to the current position pointer.
328 * \param start The start of the buffer which is used for bounds-checking.
329 * \param buf The bitstring to write.
Andres Amaya Garcia6e959142018-09-26 10:48:24 +0100330 * \param bits The total number of bits in the bitstring.
331 *
Andres Amaya Garciad8233f72018-10-08 19:44:55 +0100332 * \return The number of bytes written to \p p on success.
333 * \return A negative error code on failure.
Andres Amaya Garcia6e959142018-09-26 10:48:24 +0100334 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200335int mbedtls_asn1_write_named_bitstring(unsigned char **p,
336 const unsigned char *start,
337 const unsigned char *buf,
338 size_t bits);
Andres Amaya Garcia6e959142018-09-26 10:48:24 +0100339
340/**
Hanno Becker55177552018-10-24 12:29:53 +0100341 * \brief Write an octet string tag (#MBEDTLS_ASN1_OCTET_STRING)
342 * and value in ASN.1 format.
Paul Bakker7accbce2013-08-26 17:34:53 +0200343 *
Hanno Becker55177552018-10-24 12:29:53 +0100344 * \note This function works backwards in data buffer.
Paul Bakker7accbce2013-08-26 17:34:53 +0200345 *
Hanno Becker55177552018-10-24 12:29:53 +0100346 * \param p The reference to the current position pointer.
347 * \param start The start of the buffer, for bounds-checking.
348 * \param buf The buffer holding the data to write.
349 * \param size The length of the data buffer \p buf.
350 *
351 * \return The number of bytes written to \p p on success.
352 * \return A negative error code on failure.
Paul Bakker7accbce2013-08-26 17:34:53 +0200353 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200354int mbedtls_asn1_write_octet_string(unsigned char **p,
355 const unsigned char *start,
356 const unsigned char *buf,
357 size_t size);
Paul Bakker59ba59f2013-09-09 11:26:00 +0200358
359/**
360 * \brief Create or find a specific named_data entry for writing in a
361 * sequence or list based on the OID. If not already in there,
362 * a new entry is added to the head of the list.
363 * Warning: Destructive behaviour for the val data!
364 *
Hanno Becker55177552018-10-24 12:29:53 +0100365 * \param list The pointer to the location of the head of the list to seek
366 * through (will be updated in case of a new entry).
367 * \param oid The OID to look for.
368 * \param oid_len The size of the OID.
Gilles Peskine09c0a232019-03-04 15:00:06 +0100369 * \param val The associated data to store. If this is \c NULL,
370 * no data is copied to the new or existing buffer.
Hanno Becker55177552018-10-24 12:29:53 +0100371 * \param val_len The minimum length of the data buffer needed.
Gilles Peskine09c0a232019-03-04 15:00:06 +0100372 * If this is 0, do not allocate a buffer for the associated
373 * data.
374 * If the OID was already present, enlarge, shrink or free
375 * the existing buffer to fit \p val_len.
Paul Bakker59ba59f2013-09-09 11:26:00 +0200376 *
Hanno Becker55177552018-10-24 12:29:53 +0100377 * \return A pointer to the new / existing entry on success.
378 * \return \c NULL if if there was a memory allocation error.
Paul Bakker59ba59f2013-09-09 11:26:00 +0200379 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +0200380mbedtls_asn1_named_data *
381mbedtls_asn1_store_named_data(mbedtls_asn1_named_data **list,
382 const char *oid,
383 size_t oid_len,
384 const unsigned char *val,
385 size_t val_len);
Paul Bakker59ba59f2013-09-09 11:26:00 +0200386
Paul Bakker407a0da2013-06-27 14:29:21 +0200387#ifdef __cplusplus
388}
389#endif
390
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200391#endif /* MBEDTLS_ASN1_WRITE_H */