mbed TLS v2.23.0

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: 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.
21 *
22 * This file is part of mbed TLS (https://tls.mbed.org)
23 */
24 #ifndef MBEDTLS_ASN1_WRITE_H
25 #define MBEDTLS_ASN1_WRITE_H
26
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "mbedtls/config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32
33 #include "mbedtls/asn1.h"
34
35 #define MBEDTLS_ASN1_CHK_ADD(g, f) \
36 do \
37 { \
38 if( ( ret = (f) ) < 0 ) \
39 return( ret ); \
40 else \
41 (g) += ret; \
42 } while( 0 )
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
60 int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start,
61 size_t len );
74 int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start,
75 unsigned char tag );
76
90 int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
91 const unsigned char *buf, size_t size );
92
93 #if defined(MBEDTLS_BIGNUM_C)
94
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
193 int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val );
194
208 int mbedtls_asn1_write_enum( unsigned char **p, unsigned char *start, int val );
209
227 int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start,
228 int tag, const char *text,
229 size_t text_len );
230
246 int mbedtls_asn1_write_printable_string( unsigned char **p,
247 unsigned char *start,
248 const char *text, size_t text_len );
249
265 int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start,
266 const char *text, size_t text_len );
267
283 int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
284 const char *text, size_t text_len );
285
300 int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
301 const unsigned char *buf, size_t bits );
302
320 int mbedtls_asn1_write_named_bitstring( unsigned char **p,
321 unsigned char *start,
322 const unsigned char *buf,
323 size_t bits );
324
339 int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start,
340 const unsigned char *buf, size_t size );
341
363 mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **list,
364 const char *oid, size_t oid_len,
365 const unsigned char *val,
366 size_t val_len );
367
368 #ifdef __cplusplus
369 }
370 #endif
371
372 #endif /* MBEDTLS_ASN1_WRITE_H */
mbedtls_asn1_write_tagged_string
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.
mbedtls_asn1_write_printable_string
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_...
mbedtls_asn1_write_enum
int mbedtls_asn1_write_enum(unsigned char **p, unsigned char *start, int val)
Write an enum tag (MBEDTLS_ASN1_ENUMERATED) and value in ASN.1 format.
mbedtls_mpi
MPI structure.
Definition: bignum.h:187
mbedtls_asn1_named_data::val
mbedtls_asn1_buf val
Definition: asn1.h:186
mbedtls_asn1_write_utf8_string
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_UTF8_STRIN...
mbedtls_asn1_store_named_data
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....
mbedtls_asn1_named_data
Definition: asn1.h:184
mbedtls_asn1_write_octet_string
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.
mbedtls_asn1_write_mpi
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.
mbedtls_asn1_write_null
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.
mbedtls_asn1_write_bool
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.
mbedtls_asn1_write_int
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.
mbedtls_asn1_write_tag
int mbedtls_asn1_write_tag(unsigned char **p, unsigned char *start, unsigned char tag)
Write an ASN.1 tag in ASN.1 format.
mbedtls_asn1_write_oid
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.
mbedtls_asn1_write_bitstring
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_write_len
int mbedtls_asn1_write_len(unsigned char **p, unsigned char *start, size_t len)
Write a length field in ASN.1 format.
mbedtls_asn1_named_data::oid
mbedtls_asn1_buf oid
Definition: asn1.h:185
config.h
Configuration options (set of defines)
mbedtls_asn1_write_ia5_string
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).
mbedtls_asn1_write_named_bitstring
int mbedtls_asn1_write_named_bitstring(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t bits)
This function writes a named bitstring tag (MBEDTLS_ASN1_BIT_STRING) and value in ASN....
mbedtls_asn1_write_raw_buffer
int mbedtls_asn1_write_raw_buffer(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size)
Write raw buffer data.
asn1.h
Generic ASN.1 parsing.
mbedtls_asn1_write_algorithm_identifier
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.