mbed TLS v2.16.6
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  { \
40  if( ( ret = (f) ) < 0 ) \
41  return( ret ); \
42  else \
43  (g) += ret; \
44  } while( 0 )
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
62 int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start,
63  size_t len );
76 int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start,
77  unsigned char tag );
78 
92 int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
93  const unsigned char *buf, size_t size );
94 
95 #if defined(MBEDTLS_BIGNUM_C)
96 
109 int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start,
110  const mbedtls_mpi *X );
111 #endif /* MBEDTLS_BIGNUM_C */
112 
125 int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start );
126 
141 int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start,
142  const char *oid, size_t oid_len );
143 
159 int mbedtls_asn1_write_algorithm_identifier( unsigned char **p,
160  unsigned char *start,
161  const char *oid, size_t oid_len,
162  size_t par_len );
163 
177 int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start,
178  int boolean );
179 
193 int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val );
194 
212 int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start,
213  int tag, const char *text,
214  size_t text_len );
215 
231 int mbedtls_asn1_write_printable_string( unsigned char **p,
232  unsigned char *start,
233  const char *text, size_t text_len );
234 
250 int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start,
251  const char *text, size_t text_len );
252 
268 int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
269  const char *text, size_t text_len );
270 
285 int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
286  const unsigned char *buf, size_t bits );
287 
302 int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start,
303  const unsigned char *buf, size_t size );
304 
323  const char *oid, size_t oid_len,
324  const unsigned char *val,
325  size_t val_len );
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif /* MBEDTLS_ASN1_WRITE_H */
int mbedtls_asn1_write_bitstring(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t bits)
Write a bitstring tag (MBEDTLS_ASN1_BIT_STRING) and value in ASN.1 format.
mbedtls_asn1_buf oid
Definition: asn1.h:170
int mbedtls_asn1_write_null(unsigned char **p, unsigned char *start)
Write a NULL tag (MBEDTLS_ASN1_NULL) with zero data in ASN.1 format.
Configuration options (set of defines)
Generic ASN.1 parsing.
int mbedtls_asn1_write_int(unsigned char **p, unsigned char *start, int val)
Write an int tag (MBEDTLS_ASN1_INTEGER) and value in ASN.1 format.
int mbedtls_asn1_write_bool(unsigned char **p, unsigned char *start, int boolean)
Write a boolean tag (MBEDTLS_ASN1_BOOLEAN) and value in ASN.1 format.
int mbedtls_asn1_write_len(unsigned char **p, unsigned char *start, size_t len)
Write a length field in ASN.1 format.
mbedtls_asn1_buf val
Definition: asn1.h:171
int mbedtls_asn1_write_octet_string(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size)
Write an octet string tag (MBEDTLS_ASN1_OCTET_STRING) and value in ASN.1 format.
int mbedtls_asn1_write_utf8_string(unsigned char **p, unsigned char *start, const char *text, size_t text_len)
Write a UTF8 string in ASN.1 format using the UTF8String string encoding tag (MBEDTLS_ASN1_PRINTABLE_...
int mbedtls_asn1_write_mpi(unsigned char **p, unsigned char *start, const mbedtls_mpi *X)
Write a arbitrary-precision number (MBEDTLS_ASN1_INTEGER) in ASN.1 format.
int mbedtls_asn1_write_printable_string(unsigned char **p, unsigned char *start, const char *text, size_t text_len)
Write a string in ASN.1 format using the PrintableString string encoding tag (MBEDTLS_ASN1_PRINTABLE_...
int mbedtls_asn1_write_algorithm_identifier(unsigned char **p, unsigned char *start, const char *oid, size_t oid_len, size_t par_len)
Write an AlgorithmIdentifier sequence in ASN.1 format.
MPI structure.
Definition: bignum.h:187
mbedtls_asn1_named_data * mbedtls_asn1_store_named_data(mbedtls_asn1_named_data **list, const char *oid, size_t oid_len, const unsigned char *val, size_t val_len)
Create or find a specific named_data entry for writing in a sequence or list based on the OID...
int mbedtls_asn1_write_ia5_string(unsigned char **p, unsigned char *start, const char *text, size_t text_len)
Write a string in ASN.1 format using the IA5String string encoding tag (MBEDTLS_ASN1_IA5_STRING).
int mbedtls_asn1_write_raw_buffer(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size)
Write raw buffer data.
int mbedtls_asn1_write_tag(unsigned char **p, unsigned char *start, unsigned char tag)
Write an ASN.1 tag in ASN.1 format.
int mbedtls_asn1_write_oid(unsigned char **p, unsigned char *start, const char *oid, size_t oid_len)
Write an OID tag (MBEDTLS_ASN1_OID) and data in ASN.1 format.
int mbedtls_asn1_write_tagged_string(unsigned char **p, unsigned char *start, int tag, const char *text, size_t text_len)
Write a string in ASN.1 format using a specific string encoding tag.