vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 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 | |
vlm | d157958 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 9 | |
| 10 | struct asn1_TYPE_descriptor_s; /* Forward declaration */ |
| 11 | |
| 12 | /* |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 13 | * The DER encoder of any type. May be invoked by the application. |
| 14 | */ |
vlm | 39ba4c4 | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 15 | asn_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor, |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 16 | 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 | */ |
vlm | 39ba4c4 | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 24 | typedef asn_enc_rval_t (der_type_encoder_f)( |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 25 | 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 | */ |
| 41 | ssize_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 */ |
vlm | 6678cb1 | 2004-09-26 13:10:40 +0000 | [diff] [blame] | 45 | int last_tag_form, /* {0,!0}: prim, constructed */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 46 | 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_ */ |