blob: 5a296130f1bbc69b0bbe88ddefb3e22c580d1a6f [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
Lev Walkin11c3e172004-09-24 21:00:50 +00008#include <asn_application.h>
Lev Walkinf15320b2004-06-03 03:38:44 +00009
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 */
Lev Walkin8e8078a2004-09-26 13:10:40 +000045 int last_tag_form, /* {0,!0}: prim, constructed */
Lev Walkinf15320b2004-06-03 03:38:44 +000046 ber_tlv_tag_t tag,
47 asn_app_consume_bytes_f *consume_bytes_cb,
48 void *app_key
49 );
50
51#endif /* _DER_ENCODER_H_ */