mbed TLS v2.7.17
asn1write.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * 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:
15  *
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.
27  *
28  * **********
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  * **********
48  */
49 #ifndef MBEDTLS_ASN1_WRITE_H
50 #define MBEDTLS_ASN1_WRITE_H
51 
52 #if !defined(MBEDTLS_CONFIG_FILE)
53 #include "config.h"
54 #else
55 #include MBEDTLS_CONFIG_FILE
56 #endif
57 
58 #include "asn1.h"
59 
60 #define MBEDTLS_ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else \
61  g += ret; } while( 0 )
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
77 int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len );
78 
89 int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start,
90  unsigned char tag );
91 
103 int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
104  const unsigned char *buf, size_t size );
105 
106 #if defined(MBEDTLS_BIGNUM_C)
107 
117 int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X );
118 #endif /* MBEDTLS_BIGNUM_C */
119 
129 int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start );
130 
142 int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start,
143  const char *oid, size_t oid_len );
144 
158 int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start,
159  const char *oid, size_t oid_len,
160  size_t par_len );
161 
172 int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean );
173 
184 int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val );
185 
198 int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start,
199  const char *text, size_t text_len );
200 
213 int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
214  const char *text, size_t text_len );
215 
230 int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
231  const unsigned char *buf, size_t bits );
232 
246 int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start,
247  const unsigned char *buf, size_t size );
248 
266  const char *oid, size_t oid_len,
267  const unsigned char *val,
268  size_t val_len );
269 
270 #ifdef __cplusplus
271 }
272 #endif
273 
274 #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:193
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 Note: function works backwards in...
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 Note: function works backwards in d...
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 Note: function works backwards i...
int mbedtls_asn1_write_len(unsigned char **p, unsigned char *start, size_t len)
Write a length field in ASN.1 format Note: function works backwards in data buffer.
mbedtls_asn1_buf val
Definition: asn1.h:194
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_mpi(unsigned char **p, unsigned char *start, const mbedtls_mpi *X)
Write a big number (MBEDTLS_ASN1_INTEGER) in ASN.1 format Note: function works backwards in data buff...
int mbedtls_asn1_write_printable_string(unsigned char **p, unsigned char *start, const char *text, size_t text_len)
Write a printable string tag (MBEDTLS_ASN1_PRINTABLE_STRING) and value in ASN.1 format Note: function...
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 Note: function works backwards in data buffer...
MPI structure.
Definition: bignum.h:205
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 an IA5 string tag (MBEDTLS_ASN1_IA5_STRING) and value in ASN.1 format Note: function works back...
int mbedtls_asn1_write_raw_buffer(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size)
Write raw buffer data Note: function works backwards in data buffer.
int mbedtls_asn1_write_tag(unsigned char **p, unsigned char *start, unsigned char tag)
Write a ASN.1 tag in ASN.1 format Note: function works backwards in data buffer.
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 Note: function works backwards in data b...