ITS
der_encoder.h
Go to the documentation of this file.
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  * The ber_decode() function (ber_decoder.h) is an opposite of der_encode().
19  */
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 */
24  );
25 
26 /* A variant of der_encode() which encodes data into the pre-allocated 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) */
32  );
33 
34 /*
35  * Type of the generic DER encoder.
36  */
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 */
41  ber_tlv_tag_t tag,
42  asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
43  void *app_key /* Arbitrary callback argument */
44  );
45 
46 
47 /*******************************
48  * INTERNALLY USEFUL FUNCTIONS *
49  *******************************/
50 
51 /*
52  * Write out leading TL[v] sequence according to the type definition.
53  */
54 ssize_t der_write_tags(
55  struct asn_TYPE_descriptor_s *type_descriptor,
56  size_t struct_length,
57  int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
58  int last_tag_form, /* {0,!0}: prim, constructed */
59  ber_tlv_tag_t tag,
60  asn_app_consume_bytes_f *consume_bytes_cb,
61  void *app_key
62  );
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* _DER_ENCODER_H_ */
ssize_t der_write_tags(struct asn_TYPE_descriptor_s *type_descriptor, size_t struct_length, int tag_mode, int last_tag_form, ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key)
Definition: der_encoder.c:77
asn_enc_rval_t() der_type_encoder_f(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key)
Definition: der_encoder.h:37
int() asn_app_consume_bytes_f(const void *buffer, size_t size, void *application_specific_key)
asn_enc_rval_t der_encode_to_buffer(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, void *buffer, size_t buffer_size)
Definition: der_encoder.c:54
asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key)
Definition: der_encoder.c:15
struct asn_enc_rval_s asn_enc_rval_t
unsigned ber_tlv_tag_t
Definition: ber_tlv_tag.h:18