Blame src/asn1c/der_encoder.h

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