asn1c/skeletons/der_encoder.h

69 lines
1.9 KiB
C
Raw Normal View History

2004-06-03 03:38:44 +00:00
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _DER_ENCODER_H_
#define _DER_ENCODER_H_
2004-09-24 21:00:50 +00:00
#include <asn_application.h>
2004-06-03 03:38:44 +00:00
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2004-09-29 13:26:15 +00:00
struct asn_TYPE_descriptor_s; /* Forward declaration */
2004-06-03 03:38:44 +00:00
/*
* The DER encoder of any type. May be invoked by the application.
2007-05-30 17:42:00 +00:00
* The ber_decode() function (ber_decoder.h) is an opposite of der_encode().
2004-06-03 03:38:44 +00:00
*/
2004-09-29 13:26:15 +00:00
asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
2004-06-03 03:38:44 +00:00
void *struct_ptr, /* Structure to be encoded */
asn_app_consume_bytes_f *consume_bytes_cb,
void *app_key /* Arbitrary callback argument */
);
2004-11-16 09:46:00 +00:00
/* A variant of der_encode() which encodes data into the pre-allocated buffer */
asn_enc_rval_t der_encode_to_buffer(
struct asn_TYPE_descriptor_s *type_descriptor,
void *struct_ptr, /* Structure to be encoded */
void *buffer, /* Pre-allocated buffer */
2006-08-18 01:34:18 +00:00
size_t buffer_size /* Initial buffer size (maximum) */
2004-11-16 09:46:00 +00:00
);
2004-06-03 03:38:44 +00:00
/*
* Type of the generic DER encoder.
*/
2004-09-22 16:06:28 +00:00
typedef asn_enc_rval_t (der_type_encoder_f)(
2004-09-29 13:26:15 +00:00
struct asn_TYPE_descriptor_s *type_descriptor,
2004-06-03 03:38:44 +00:00
void *struct_ptr, /* Structure to be encoded */
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
ber_tlv_tag_t tag,
asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
void *app_key /* Arbitrary callback argument */
);
/*******************************
* INTERNALLY USEFUL FUNCTIONS *
*******************************/
/*
* Write out leading TL[v] sequence according to the type definition.
*/
ssize_t der_write_tags(
2004-09-29 13:26:15 +00:00
struct asn_TYPE_descriptor_s *type_descriptor,
2004-06-03 03:38:44 +00:00
size_t struct_length,
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
int last_tag_form, /* {0,!0}: prim, constructed */
2004-06-03 03:38:44 +00:00
ber_tlv_tag_t tag,
asn_app_consume_bytes_f *consume_bytes_cb,
void *app_key
);
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
}
#endif
2004-06-03 03:38:44 +00:00
#endif /* _DER_ENCODER_H_ */