mbed TLS v2.16.1
asn1write.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: GPL-2.0
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * This file is part of mbed TLS (https://tls.mbed.org)
25  */
26 #ifndef MBEDTLS_ASN1_WRITE_H
27 #define MBEDTLS_ASN1_WRITE_H
28 
29 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include "config.h"
31 #else
32 #include MBEDTLS_CONFIG_FILE
33 #endif
34 
35 #include "asn1.h"
36 
37 #define MBEDTLS_ASN1_CHK_ADD(g, f) \
38  do { \
39  if( ( ret = f ) < 0 ) \
40  return( ret ); \
41  else \
42  g += ret; \
43  } while( 0 )
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
61 int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start,
62  size_t len );
75 int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start,
76  unsigned char tag );
77 
91 int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
92  const unsigned char *buf, size_t size );
93 
94 #if defined(MBEDTLS_BIGNUM_C)
95 
108 int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start,
109  const mbedtls_mpi *X );
110 #endif /* MBEDTLS_BIGNUM_C */
111 
124 int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start );
125 
140 int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start,
141  const char *oid, size_t oid_len );
142 
158 int mbedtls_asn1_write_algorithm_identifier( unsigned char **p,
159  unsigned char *start,
160  const char *oid, size_t oid_len,
161  size_t par_len );
162 
176 int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start,
177  int boolean );
178 
192 int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val );
193 
211 int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start,
212  int tag, const char *text,
213  size_t text_len );
214 
230 int mbedtls_asn1_write_printable_string( unsigned char **p,
231  unsigned char *start,
232  const char *text, size_t text_len );
233 
249 int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start,
250  const char *text, size_t text_len );
251 
267 int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
268  const char *text, size_t text_len );
269 
284 int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
285  const unsigned char *buf, size_t bits );
286 
301 int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start,
302  const unsigned char *buf, size_t size );
303 
322  const char *oid, size_t oid_len,
323  const unsigned char *val,
324  size_t val_len );
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #endif /* MBEDTLS_ASN1_WRITE_H */