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.
19 asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
20 void *struct_ptr, /* Structure to be encoded */
21 asn_app_consume_bytes_f *consume_bytes_cb,
22 void *app_key /* Arbitrary callback argument */
25 /* A variant of der_encode() which encodes data into the pre-allocated buffer */
26 asn_enc_rval_t der_encode_to_buffer(
27 struct asn_TYPE_descriptor_s *type_descriptor,
28 void *struct_ptr, /* Structure to be encoded */
29 void *buffer, /* Pre-allocated buffer */
30 size_t buffer_size /* Initial buffer size (maximum) */
34 * Type of the generic DER encoder.
36 typedef asn_enc_rval_t (der_type_encoder_f)(
37 struct asn_TYPE_descriptor_s *type_descriptor,
38 void *struct_ptr, /* Structure to be encoded */
39 int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
41 asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
42 void *app_key /* Arbitrary callback argument */
46 /*******************************
47 * INTERNALLY USEFUL FUNCTIONS *
48 *******************************/
51 * Write out leading TL[v] sequence according to the type definition.
53 ssize_t der_write_tags(
54 struct asn_TYPE_descriptor_s *type_descriptor,
56 int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
57 int last_tag_form, /* {0,!0}: prim, constructed */
59 asn_app_consume_bytes_f *consume_bytes_cb,
67 #endif /* _DER_ENCODER_H_ */