mbed TLS v3.1.0
asn1write.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
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 #ifndef MBEDTLS_ASN1_WRITE_H
23 #define MBEDTLS_ASN1_WRITE_H
24 
25 #include "mbedtls/build_info.h"
26 
27 #include "mbedtls/asn1.h"
28 
29 #define MBEDTLS_ASN1_CHK_ADD(g, f) \
30  do \
31  { \
32  if( ( ret = (f) ) < 0 ) \
33  return( ret ); \
34  else \
35  (g) += ret; \
36  } while( 0 )
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
54 int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start,
55  size_t len );
68 int mbedtls_asn1_write_tag( unsigned char **p, const unsigned char *start,
69  unsigned char tag );
70 
84 int mbedtls_asn1_write_raw_buffer( unsigned char **p, const unsigned char *start,
85  const unsigned char *buf, size_t size );
86 
87 #if defined(MBEDTLS_BIGNUM_C)
88 
102 int mbedtls_asn1_write_mpi( unsigned char **p, const unsigned char *start,
103  const mbedtls_mpi *X );
104 #endif /* MBEDTLS_BIGNUM_C */
105 
118 int mbedtls_asn1_write_null( unsigned char **p, const unsigned char *start );
119 
134 int mbedtls_asn1_write_oid( unsigned char **p, const unsigned char *start,
135  const char *oid, size_t oid_len );
136 
152 int mbedtls_asn1_write_algorithm_identifier( unsigned char **p,
153  const unsigned char *start,
154  const char *oid, size_t oid_len,
155  size_t par_len );
156 
170 int mbedtls_asn1_write_bool( unsigned char **p, const unsigned char *start,
171  int boolean );
172 
187 int mbedtls_asn1_write_int( unsigned char **p, const unsigned char *start, int val );
188 
202 int mbedtls_asn1_write_enum( unsigned char **p, const unsigned char *start, int val );
203 
221 int mbedtls_asn1_write_tagged_string( unsigned char **p, const unsigned char *start,
222  int tag, const char *text,
223  size_t text_len );
224 
240 int mbedtls_asn1_write_printable_string( unsigned char **p,
241  const unsigned char *start,
242  const char *text, size_t text_len );
243 
259 int mbedtls_asn1_write_utf8_string( unsigned char **p, const unsigned char *start,
260  const char *text, size_t text_len );
261 
277 int mbedtls_asn1_write_ia5_string( unsigned char **p, const unsigned char *start,
278  const char *text, size_t text_len );
279 
294 int mbedtls_asn1_write_bitstring( unsigned char **p, const unsigned char *start,
295  const unsigned char *buf, size_t bits );
296 
314 int mbedtls_asn1_write_named_bitstring( unsigned char **p,
315  const unsigned char *start,
316  const unsigned char *buf,
317  size_t bits );
318 
333 int mbedtls_asn1_write_octet_string( unsigned char **p, const unsigned char *start,
334  const unsigned char *buf, size_t size );
335 
358  const char *oid, size_t oid_len,
359  const unsigned char *val,
360  size_t val_len );
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
366 #endif /* MBEDTLS_ASN1_WRITE_H */
int mbedtls_asn1_write_octet_string(unsigned char **p, const 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_len(unsigned char **p, const unsigned char *start, size_t len)
Write a length field in ASN.1 format.
mbedtls_asn1_buf oid
Definition: asn1.h:195
int mbedtls_asn1_write_bool(unsigned char **p, const unsigned char *start, int boolean)
Write a boolean tag (MBEDTLS_ASN1_BOOLEAN) and value in ASN.1 format.
int mbedtls_asn1_write_printable_string(unsigned char **p, const 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_utf8_string(unsigned char **p, const 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...
int mbedtls_asn1_write_algorithm_identifier(unsigned char **p, const unsigned char *start, const char *oid, size_t oid_len, size_t par_len)
Write an AlgorithmIdentifier sequence in ASN.1 format.
int mbedtls_asn1_write_int(unsigned char **p, const unsigned char *start, int val)
Write an int tag (MBEDTLS_ASN1_INTEGER) and value in ASN.1 format.
Generic ASN.1 parsing.
int mbedtls_asn1_write_bitstring(unsigned char **p, const 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 val
Definition: asn1.h:196
int mbedtls_asn1_write_null(unsigned char **p, const unsigned char *start)
Write a NULL tag (MBEDTLS_ASN1_NULL) with zero data in ASN.1 format.
Build-time configuration info.
int mbedtls_asn1_write_mpi(unsigned char **p, const unsigned char *start, const mbedtls_mpi *X)
Write a arbitrary-precision number (MBEDTLS_ASN1_INTEGER) in ASN.1 format.
int mbedtls_asn1_write_oid(unsigned char **p, const 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_enum(unsigned char **p, const unsigned char *start, int val)
Write an enum tag (MBEDTLS_ASN1_ENUMERATED) and value in ASN.1 format.
int mbedtls_asn1_write_ia5_string(unsigned char **p, const 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).
MPI structure.
Definition: bignum.h:189
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_raw_buffer(unsigned char **p, const unsigned char *start, const unsigned char *buf, size_t size)
Write raw buffer data.
int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start, unsigned char tag)
Write an ASN.1 tag in ASN.1 format.
int mbedtls_asn1_write_tagged_string(unsigned char **p, const 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.
int mbedtls_asn1_write_named_bitstring(unsigned char **p, const 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...