]> git.stg.codes - stg.git/blob - stglibs/smux.lib/der_encoder.h
Pass config file via const reference in sgauth/sgathstress settings
[stg.git] / stglibs / smux.lib / der_encoder.h
1 /*-
2  * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef _DER_ENCODER_H_
6 #define _DER_ENCODER_H_
7
8 #include <asn_application.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 struct asn_TYPE_descriptor_s;   /* Forward declaration */
15
16 /*
17  * The DER encoder of any type. May be invoked by the application.
18  */
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 */
23         );
24
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) */
31         );
32
33 /*
34  * Type of the generic DER encoder.
35  */
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 */
40                 ber_tlv_tag_t tag,
41                 asn_app_consume_bytes_f *consume_bytes_cb,      /* Callback */
42                 void *app_key           /* Arbitrary callback argument */
43         );
44
45
46 /*******************************
47  * INTERNALLY USEFUL FUNCTIONS *
48  *******************************/
49
50 /*
51  * Write out leading TL[v] sequence according to the type definition.
52  */
53 ssize_t der_write_tags(
54                 struct asn_TYPE_descriptor_s *type_descriptor,
55                 size_t struct_length,
56                 int tag_mode,           /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
57                 int last_tag_form,      /* {0,!0}: prim, constructed */
58                 ber_tlv_tag_t tag,
59                 asn_app_consume_bytes_f *consume_bytes_cb,
60                 void *app_key
61         );
62
63 #ifdef __cplusplus
64 }
65 #endif
66
67 #endif  /* _DER_ENCODER_H_ */