2
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3
* Redistribution and modifications are permitted subject to BSD license.
5
#ifndef _DER_ENCODER_H_
6
#define _DER_ENCODER_H_
8
#include <asn_application.h>
14
struct asn_TYPE_descriptor_s; /* Forward declaration */
17
* The DER encoder of any type. May be invoked by the application.
18
* The ber_decode() function (ber_decoder.h) is an opposite of der_encode().
20
asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
21
void *struct_ptr, /* Structure to be encoded */
22
asn_app_consume_bytes_f *consume_bytes_cb,
23
void *app_key /* Arbitrary callback argument */
26
/* A variant of der_encode() which encodes data into the pre-allocated buffer */
27
asn_enc_rval_t der_encode_to_buffer(
28
struct asn_TYPE_descriptor_s *type_descriptor,
29
void *struct_ptr, /* Structure to be encoded */
30
void *buffer, /* Pre-allocated buffer */
31
size_t buffer_size /* Initial buffer size (maximum) */
35
* Type of the generic DER encoder.
37
typedef asn_enc_rval_t (der_type_encoder_f)(
38
struct asn_TYPE_descriptor_s *type_descriptor,
39
void *struct_ptr, /* Structure to be encoded */
40
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
42
asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
43
void *app_key /* Arbitrary callback argument */
47
/*******************************
48
* INTERNALLY USEFUL FUNCTIONS *
49
*******************************/
52
* Write out leading TL[v] sequence according to the type definition.
54
ssize_t der_write_tags(
55
struct asn_TYPE_descriptor_s *type_descriptor,
57
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
58
int last_tag_form, /* {0,!0}: prim, constructed */
60
asn_app_consume_bytes_f *consume_bytes_cb,
68
#endif /* _DER_ENCODER_H_ */