mbed TLS v2.7.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: 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 #include "asn1.h"
28 
29 #define MBEDTLS_ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else \
30  g += ret; } while( 0 )
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
46 int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len );
47 
58 int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start,
59  unsigned char tag );
60 
72 int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
73  const unsigned char *buf, size_t size );
74 
75 #if defined(MBEDTLS_BIGNUM_C)
76 
86 int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X );
87 #endif /* MBEDTLS_BIGNUM_C */
88 
98 int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start );
99 
111 int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start,
112  const char *oid, size_t oid_len );
113 
127 int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start,
128  const char *oid, size_t oid_len,
129  size_t par_len );
130 
141 int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean );
142 
153 int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val );
154 
167 int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start,
168  const char *text, size_t text_len );
169 
182 int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
183  const char *text, size_t text_len );
184 
197 int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
198  const unsigned char *buf, size_t bits );
199 
212 int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start,
213  const unsigned char *buf, size_t size );
214 
232  const char *oid, size_t oid_len,
233  const unsigned char *val,
234  size_t val_len );
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #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 Note: function works backwa...
mbedtls_asn1_buf oid
Definition: asn1.h:168
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...
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:169
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 Note: function works ...
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:180
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...