blob: 1fa7bfaf3c658aa0ba1c43ace70866bbb4406eba [file] [log] [blame]
Paul Bakkerefc30292011-11-10 14:43:23 +00001/**
2 * \file asn1.h
3 *
4 * \brief Generic ASN.1 parsing
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkútia2947ac2020-08-19 16:37:36 +02007 * Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 *
10 * This file is provided under the Apache License 2.0, or the
11 * GNU General Public License v2.0 or later.
12 *
13 * **********
14 * Apache License 2.0:
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020015 *
16 * Licensed under the Apache License, Version 2.0 (the "License"); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
Paul Bakkerefc30292011-11-10 14:43:23 +000027 *
Bence Szépkútif744bd72020-06-05 13:02:18 +020028 * **********
29 *
30 * **********
31 * GNU General Public License v2.0 or later:
32 *
33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or
36 * (at your option) any later version.
37 *
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
42 *
43 * You should have received a copy of the GNU General Public License along
44 * with this program; if not, write to the Free Software Foundation, Inc.,
45 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46 *
47 * **********
Paul Bakkerefc30292011-11-10 14:43:23 +000048 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020049#ifndef MBEDTLS_ASN1_H
50#define MBEDTLS_ASN1_H
Paul Bakkerefc30292011-11-10 14:43:23 +000051
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020052#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakkerccdb0282011-12-15 19:49:51 +000053#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020054#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020055#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020056#endif
Paul Bakkerefc30292011-11-10 14:43:23 +000057
Rich Evans00ab4702015-02-06 13:43:58 +000058#include <stddef.h>
59
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060#if defined(MBEDTLS_BIGNUM_C)
Paul Bakkerccdb0282011-12-15 19:49:51 +000061#include "bignum.h"
Paul Bakkerefc30292011-11-10 14:43:23 +000062#endif
63
Paul Bakker9af723c2014-05-01 13:03:14 +020064/**
Paul Bakkerefc30292011-11-10 14:43:23 +000065 * \addtogroup asn1_module
Paul Bakker9af723c2014-05-01 13:03:14 +020066 * \{
Paul Bakkerefc30292011-11-10 14:43:23 +000067 */
Paul Bakker9af723c2014-05-01 13:03:14 +020068
Paul Bakkerefc30292011-11-10 14:43:23 +000069/**
70 * \name ASN1 Error codes
71 * These error codes are OR'ed to X509 error codes for
Paul Bakker9af723c2014-05-01 13:03:14 +020072 * higher error granularity.
Paul Bakkerefc30292011-11-10 14:43:23 +000073 * ASN1 is a standard to specify data structures.
74 * \{
75 */
Gilles Peskine1990fab2021-07-26 18:48:10 +020076/** Out of data when parsing an ASN1 data structure. */
77#define MBEDTLS_ERR_ASN1_OUT_OF_DATA -0x0060
78/** ASN1 tag was of an unexpected value. */
79#define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG -0x0062
80/** Error when trying to determine the length or invalid length. */
81#define MBEDTLS_ERR_ASN1_INVALID_LENGTH -0x0064
82/** Actual length differs from expected length. */
83#define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH -0x0066
84/** Data is invalid. (not used) */
85#define MBEDTLS_ERR_ASN1_INVALID_DATA -0x0068
86/** Memory allocation failed */
87#define MBEDTLS_ERR_ASN1_ALLOC_FAILED -0x006A
88/** Buffer too small when writing ASN.1 data structure. */
89#define MBEDTLS_ERR_ASN1_BUF_TOO_SMALL -0x006C
Paul Bakker05888152012-02-16 10:26:57 +000090
Paul Bakkerefc30292011-11-10 14:43:23 +000091/* \} name */
92
93/**
94 * \name DER constants
Andres Amaya Garcia9fb02052017-08-25 17:24:44 +010095 * These constants comply with the DER encoded ASN.1 type tags.
Paul Bakkerefc30292011-11-10 14:43:23 +000096 * DER encoding uses hexadecimal representation.
97 * An example DER sequence is:\n
98 * - 0x02 -- tag indicating INTEGER
99 * - 0x01 -- length in octets
100 * - 0x05 -- value
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200101 * Such sequences are typically read into \c ::mbedtls_x509_buf.
Paul Bakkerefc30292011-11-10 14:43:23 +0000102 * \{
103 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200104#define MBEDTLS_ASN1_BOOLEAN 0x01
105#define MBEDTLS_ASN1_INTEGER 0x02
106#define MBEDTLS_ASN1_BIT_STRING 0x03
107#define MBEDTLS_ASN1_OCTET_STRING 0x04
108#define MBEDTLS_ASN1_NULL 0x05
109#define MBEDTLS_ASN1_OID 0x06
110#define MBEDTLS_ASN1_UTF8_STRING 0x0C
111#define MBEDTLS_ASN1_SEQUENCE 0x10
112#define MBEDTLS_ASN1_SET 0x11
113#define MBEDTLS_ASN1_PRINTABLE_STRING 0x13
114#define MBEDTLS_ASN1_T61_STRING 0x14
115#define MBEDTLS_ASN1_IA5_STRING 0x16
116#define MBEDTLS_ASN1_UTC_TIME 0x17
117#define MBEDTLS_ASN1_GENERALIZED_TIME 0x18
118#define MBEDTLS_ASN1_UNIVERSAL_STRING 0x1C
119#define MBEDTLS_ASN1_BMP_STRING 0x1E
120#define MBEDTLS_ASN1_PRIMITIVE 0x00
121#define MBEDTLS_ASN1_CONSTRUCTED 0x20
122#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80
Andres Amaya Garcia7512bf72017-08-25 17:12:11 +0100123
124/*
125 * Bit masks for each of the components of an ASN.1 tag as specified in
Gilles Peskine1ed45ea2018-03-08 18:16:45 +0100126 * ITU X.690 (08/2015), section 8.1 "General rules for encoding",
127 * paragraph 8.1.2.2:
Andres Amaya Garcia7512bf72017-08-25 17:12:11 +0100128 *
129 * Bit 8 7 6 5 1
130 * +-------+-----+------------+
131 * | Class | P/C | Tag number |
132 * +-------+-----+------------+
133 */
Andres Amaya Garcia7786abc2017-11-07 20:21:56 +0000134#define MBEDTLS_ASN1_TAG_CLASS_MASK 0xC0
135#define MBEDTLS_ASN1_TAG_PC_MASK 0x20
136#define MBEDTLS_ASN1_TAG_VALUE_MASK 0x1F
Andres Amaya Garcia7512bf72017-08-25 17:12:11 +0100137
Paul Bakkerefc30292011-11-10 14:43:23 +0000138/* \} name */
139/* \} addtogroup asn1_module */
140
141/** Returns the size of the binary string, without the trailing \\0 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200142#define MBEDTLS_OID_SIZE(x) (sizeof(x) - 1)
Paul Bakkerefc30292011-11-10 14:43:23 +0000143
Manuel Pégourié-Gonnarde76b7502014-01-23 19:15:29 +0100144/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200145 * Compares an mbedtls_asn1_buf structure to a reference OID.
Manuel Pégourié-Gonnarde76b7502014-01-23 19:15:29 +0100146 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200147 * Only works for 'defined' oid_str values (MBEDTLS_OID_HMAC_SHA1), you cannot use a
Manuel Pégourié-Gonnarde76b7502014-01-23 19:15:29 +0100148 * 'unsigned char *oid' here!
Paul Bakkere5eae762013-08-26 12:05:14 +0200149 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200150#define MBEDTLS_OID_CMP(oid_str, oid_buf) \
151 ( ( MBEDTLS_OID_SIZE(oid_str) != (oid_buf)->len ) || \
Manuel Pégourié-Gonnard6e064372015-03-19 16:54:56 +0000152 memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) != 0 )
Paul Bakkerc70b9822013-04-07 22:00:46 +0200153
Paul Bakkerefc30292011-11-10 14:43:23 +0000154#ifdef __cplusplus
155extern "C" {
156#endif
157
158/**
159 * \name Functions to parse ASN.1 data structures
160 * \{
161 */
162
163/**
164 * Type-length-value structure that allows for ASN1 using DER.
165 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166typedef struct mbedtls_asn1_buf
Paul Bakkerefc30292011-11-10 14:43:23 +0000167{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200168 int tag; /**< ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING. */
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200169 size_t len; /**< ASN1 length, in octets. */
Paul Bakkerefc30292011-11-10 14:43:23 +0000170 unsigned char *p; /**< ASN1 data, e.g. in ASCII. */
171}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200172mbedtls_asn1_buf;
Paul Bakkerefc30292011-11-10 14:43:23 +0000173
174/**
175 * Container for ASN1 bit strings.
176 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200177typedef struct mbedtls_asn1_bitstring
Paul Bakkerefc30292011-11-10 14:43:23 +0000178{
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200179 size_t len; /**< ASN1 length, in octets. */
Paul Bakkerefc30292011-11-10 14:43:23 +0000180 unsigned char unused_bits; /**< Number of unused bits at the end of the string */
181 unsigned char *p; /**< Raw ASN1 data for the bit string */
182}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200183mbedtls_asn1_bitstring;
Paul Bakkerefc30292011-11-10 14:43:23 +0000184
185/**
186 * Container for a sequence of ASN.1 items
187 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200188typedef struct mbedtls_asn1_sequence
Paul Bakkerefc30292011-11-10 14:43:23 +0000189{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190 mbedtls_asn1_buf buf; /**< Buffer containing the given ASN.1 item. */
191 struct mbedtls_asn1_sequence *next; /**< The next entry in the sequence. */
Paul Bakkerefc30292011-11-10 14:43:23 +0000192}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200193mbedtls_asn1_sequence;
Paul Bakkerefc30292011-11-10 14:43:23 +0000194
195/**
Paul Bakkere5eae762013-08-26 12:05:14 +0200196 * Container for a sequence or list of 'named' ASN.1 data items
197 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200198typedef struct mbedtls_asn1_named_data
Paul Bakkere5eae762013-08-26 12:05:14 +0200199{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200200 mbedtls_asn1_buf oid; /**< The object identifier. */
201 mbedtls_asn1_buf val; /**< The named value. */
202 struct mbedtls_asn1_named_data *next; /**< The next entry in the sequence. */
Manuel Pégourié-Gonnard555fbf82015-02-04 17:11:55 +0000203 unsigned char next_merged; /**< Merge next item into the current one? */
Paul Bakkere5eae762013-08-26 12:05:14 +0200204}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200205mbedtls_asn1_named_data;
Paul Bakkere5eae762013-08-26 12:05:14 +0200206
207/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200208 * \brief Get the length of an ASN.1 element.
209 * Updates the pointer to immediately behind the length.
Paul Bakkerefc30292011-11-10 14:43:23 +0000210 *
211 * \param p The position in the ASN.1 data
212 * \param end End of data
213 * \param len The variable that will receive the value
214 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200215 * \return 0 if successful, MBEDTLS_ERR_ASN1_OUT_OF_DATA on reaching
216 * end of data, MBEDTLS_ERR_ASN1_INVALID_LENGTH if length is
Paul Bakkerefc30292011-11-10 14:43:23 +0000217 * unparseable.
218 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200219int mbedtls_asn1_get_len( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000220 const unsigned char *end,
221 size_t *len );
222
223/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200224 * \brief Get the tag and length of the tag. Check for the requested tag.
225 * Updates the pointer to immediately behind the tag and length.
Paul Bakkerefc30292011-11-10 14:43:23 +0000226 *
227 * \param p The position in the ASN.1 data
228 * \param end End of data
229 * \param len The variable that will receive the length
230 * \param tag The expected tag
231 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200232 * \return 0 if successful, MBEDTLS_ERR_ASN1_UNEXPECTED_TAG if tag did
Paul Bakkerefc30292011-11-10 14:43:23 +0000233 * not match requested tag, or another specific ASN.1 error code.
234 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200235int mbedtls_asn1_get_tag( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000236 const unsigned char *end,
237 size_t *len, int tag );
238
239/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200240 * \brief Retrieve a boolean ASN.1 tag and its value.
241 * Updates the pointer to immediately behind the full tag.
Paul Bakkerefc30292011-11-10 14:43:23 +0000242 *
243 * \param p The position in the ASN.1 data
244 * \param end End of data
245 * \param val The variable that will receive the value
246 *
247 * \return 0 if successful or a specific ASN.1 error code.
248 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200249int mbedtls_asn1_get_bool( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000250 const unsigned char *end,
251 int *val );
252
253/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200254 * \brief Retrieve an integer ASN.1 tag and its value.
255 * Updates the pointer to immediately behind the full tag.
Paul Bakkerefc30292011-11-10 14:43:23 +0000256 *
257 * \param p The position in the ASN.1 data
258 * \param end End of data
259 * \param val The variable that will receive the value
260 *
261 * \return 0 if successful or a specific ASN.1 error code.
262 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200263int mbedtls_asn1_get_int( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000264 const unsigned char *end,
265 int *val );
266
267/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200268 * \brief Retrieve a bitstring ASN.1 tag and its value.
269 * Updates the pointer to immediately behind the full tag.
Paul Bakkerefc30292011-11-10 14:43:23 +0000270 *
271 * \param p The position in the ASN.1 data
272 * \param end End of data
273 * \param bs The variable that will receive the value
274 *
275 * \return 0 if successful or a specific ASN.1 error code.
276 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200277int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end,
278 mbedtls_asn1_bitstring *bs);
Paul Bakkerefc30292011-11-10 14:43:23 +0000279
280/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200281 * \brief Retrieve a bitstring ASN.1 tag without unused bits and its
282 * value.
283 * Updates the pointer to the beginning of the bit/octet string.
Manuel Pégourié-Gonnarda2d4e642013-07-11 13:59:02 +0200284 *
285 * \param p The position in the ASN.1 data
286 * \param end End of data
287 * \param len Length of the actual bit/octect string in bytes
288 *
289 * \return 0 if successful or a specific ASN.1 error code.
290 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200291int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end,
Manuel Pégourié-Gonnarda2d4e642013-07-11 13:59:02 +0200292 size_t *len );
293
294/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200295 * \brief Parses and splits an ASN.1 "SEQUENCE OF <tag>"
296 * Updated the pointer to immediately behind the full sequence tag.
Paul Bakkerefc30292011-11-10 14:43:23 +0000297 *
298 * \param p The position in the ASN.1 data
299 * \param end End of data
300 * \param cur First variable in the chain to fill
Paul Bakker8b21f7a2012-01-13 13:29:05 +0000301 * \param tag Type of sequence
Paul Bakkerefc30292011-11-10 14:43:23 +0000302 *
303 * \return 0 if successful or a specific ASN.1 error code.
304 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200305int mbedtls_asn1_get_sequence_of( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000306 const unsigned char *end,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200307 mbedtls_asn1_sequence *cur,
Paul Bakkerefc30292011-11-10 14:43:23 +0000308 int tag);
309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310#if defined(MBEDTLS_BIGNUM_C)
Paul Bakkerefc30292011-11-10 14:43:23 +0000311/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200312 * \brief Retrieve a MPI value from an integer ASN.1 tag.
313 * Updates the pointer to immediately behind the full tag.
Paul Bakkerefc30292011-11-10 14:43:23 +0000314 *
315 * \param p The position in the ASN.1 data
316 * \param end End of data
317 * \param X The MPI that will receive the value
318 *
319 * \return 0 if successful or a specific ASN.1 or MPI error code.
320 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200321int mbedtls_asn1_get_mpi( unsigned char **p,
Paul Bakkerefc30292011-11-10 14:43:23 +0000322 const unsigned char *end,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200323 mbedtls_mpi *X );
324#endif /* MBEDTLS_BIGNUM_C */
Paul Bakkerefc30292011-11-10 14:43:23 +0000325
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200326/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200327 * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence.
328 * Updates the pointer to immediately behind the full
329 * AlgorithmIdentifier.
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200330 *
331 * \param p The position in the ASN.1 data
332 * \param end End of data
333 * \param alg The buffer to receive the OID
334 * \param params The buffer to receive the params (if any)
335 *
336 * \return 0 if successful or a specific ASN.1 or MPI error code.
337 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200338int mbedtls_asn1_get_alg( unsigned char **p,
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200339 const unsigned char *end,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200340 mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params );
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200341
342/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200343 * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence with NULL or no
344 * params.
345 * Updates the pointer to immediately behind the full
346 * AlgorithmIdentifier.
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200347 *
348 * \param p The position in the ASN.1 data
349 * \param end End of data
350 * \param alg The buffer to receive the OID
351 *
352 * \return 0 if successful or a specific ASN.1 or MPI error code.
353 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200354int mbedtls_asn1_get_alg_null( unsigned char **p,
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200355 const unsigned char *end,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200356 mbedtls_asn1_buf *alg );
Paul Bakkerf8d018a2013-06-29 12:16:17 +0200357
Paul Bakkere5eae762013-08-26 12:05:14 +0200358/**
Paul Bakkercdda0972013-09-09 12:51:29 +0200359 * \brief Find a specific named_data entry in a sequence or list based on
360 * the OID.
Paul Bakkere5eae762013-08-26 12:05:14 +0200361 *
362 * \param list The list to seek through
363 * \param oid The OID to look for
364 * \param len Size of the OID
365 *
366 * \return NULL if not found, or a pointer to the existing entry.
367 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200368mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list,
Paul Bakkere5eae762013-08-26 12:05:14 +0200369 const char *oid, size_t len );
370
371/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200372 * \brief Free a mbedtls_asn1_named_data entry
Paul Bakkere5eae762013-08-26 12:05:14 +0200373 *
374 * \param entry The named data entry to free
375 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200376void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry );
Paul Bakkere5eae762013-08-26 12:05:14 +0200377
Paul Bakkerc547cc92013-09-09 12:01:23 +0200378/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200379 * \brief Free all entries in a mbedtls_asn1_named_data list
Paul Bakkercdda0972013-09-09 12:51:29 +0200380 * Head will be set to NULL
Paul Bakkerc547cc92013-09-09 12:01:23 +0200381 *
382 * \param head Pointer to the head of the list of named data entries to free
383 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200384void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head );
Paul Bakkerc547cc92013-09-09 12:01:23 +0200385
Paul Bakkerefc30292011-11-10 14:43:23 +0000386#ifdef __cplusplus
387}
388#endif
389
390#endif /* asn1.h */