1 /* $Id: asn1-common.h 22429 2008-01-13 10:25:50Z lha $ */ 2 3 #include <stddef.h> 4 #include <time.h> 5 6 #ifndef __asn1_common_definitions__ 7 #define __asn1_common_definitions__ 8 9 typedef struct heim_integer { 10 size_t length; 11 void *data; 12 int negative; 13 } heim_integer; 14 15 typedef struct heim_octet_string { 16 size_t length; 17 void *data; 18 } heim_octet_string; 19 20 typedef char *heim_general_string; 21 typedef char *heim_utf8_string; 22 typedef char *heim_printable_string; 23 typedef char *heim_ia5_string; 24 25 typedef struct heim_bmp_string { 26 size_t length; 27 uint16_t *data; 28 } heim_bmp_string; 29 30 typedef struct heim_universal_string { 31 size_t length; 32 uint32_t *data; 33 } heim_universal_string; 34 35 typedef char *heim_visible_string; 36 37 typedef struct heim_oid { 38 size_t length; 39 unsigned *components; 40 } heim_oid; 41 42 typedef struct heim_bit_string { 43 size_t length; 44 void *data; 45 } heim_bit_string; 46 47 typedef struct heim_octet_string heim_any; 48 typedef struct heim_octet_string heim_any_set; 49 50 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \ 51 do { \ 52 (BL) = length_##T((S)); \ 53 (B) = malloc((BL)); \ 54 if((B) == NULL) { \ 55 (R) = ENOMEM; \ 56 } else { \ 57 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \ 58 (S), (L)); \ 59 if((R) != 0) { \ 60 free((B)); \ 61 (B) = NULL; \ 62 } \ 63 } \ 64 } while (0) 65 66 #endif 67