blob: fe64bccf901d0d95ecb75752421fc76bda7a33e9 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
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 <constr_TYPE.h>
9
10struct asn1_TYPE_descriptor_s; /* Forward declaration */
11
12/*
Lev Walkinf15320b2004-06-03 03:38:44 +000013 * The DER encoder of any type. May be invoked by the application.
14 */
Lev Walkina9cc46e2004-09-22 16:06:28 +000015asn_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor,
Lev Walkinf15320b2004-06-03 03:38:44 +000016 void *struct_ptr, /* Structure to be encoded */
17 asn_app_consume_bytes_f *consume_bytes_cb,
18 void *app_key /* Arbitrary callback argument */
19 );
20
21/*
22 * Type of the generic DER encoder.
23 */
Lev Walkina9cc46e2004-09-22 16:06:28 +000024typedef asn_enc_rval_t (der_type_encoder_f)(
Lev Walkinf15320b2004-06-03 03:38:44 +000025 struct asn1_TYPE_descriptor_s *type_descriptor,
26 void *struct_ptr, /* Structure to be encoded */
27 int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
28 ber_tlv_tag_t tag,
29 asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
30 void *app_key /* Arbitrary callback argument */
31 );
32
33
34/*******************************
35 * INTERNALLY USEFUL FUNCTIONS *
36 *******************************/
37
38/*
39 * Write out leading TL[v] sequence according to the type definition.
40 */
41ssize_t der_write_tags(
42 struct asn1_TYPE_descriptor_s *type_descriptor,
43 size_t struct_length,
44 int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
45 ber_tlv_tag_t tag,
46 asn_app_consume_bytes_f *consume_bytes_cb,
47 void *app_key
48 );
49
50#endif /* _DER_ENCODER_H_ */