1 /* $NetBSD: asn1-common.h,v 1.2 2017/01/28 21:31:45 christos Exp $ */ 2 3 /* Id */ 4 5 #include <stddef.h> 6 #include <time.h> 7 #include <krb5/krb5-types.h> 8 9 #ifndef __asn1_common_definitions__ 10 #define __asn1_common_definitions__ 11 12 #ifndef __HEIM_BASE_DATA__ 13 #define __HEIM_BASE_DATA__ 1 14 struct heim_base_data { 15 size_t length; 16 void *data; 17 }; 18 #endif 19 20 typedef struct heim_integer { 21 size_t length; 22 void *data; 23 int negative; 24 } heim_integer; 25 26 typedef struct heim_base_data heim_octet_string; 27 28 typedef char *heim_general_string; 29 typedef char *heim_utf8_string; 30 typedef struct heim_base_data heim_printable_string; 31 typedef struct heim_base_data heim_ia5_string; 32 33 typedef struct heim_bmp_string { 34 size_t length; 35 uint16_t *data; 36 } heim_bmp_string; 37 38 typedef struct heim_universal_string { 39 size_t length; 40 uint32_t *data; 41 } heim_universal_string; 42 43 typedef char *heim_visible_string; 44 45 typedef struct heim_oid { 46 size_t length; 47 unsigned *components; 48 } heim_oid; 49 50 typedef struct heim_bit_string { 51 size_t length; 52 void *data; 53 } heim_bit_string; 54 55 typedef struct heim_base_data heim_any; 56 typedef struct heim_base_data heim_any_set; 57 58 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \ 59 do { \ 60 (BL) = length_##T((S)); \ 61 (B) = malloc((BL)); \ 62 if((B) == NULL) { \ 63 (R) = ENOMEM; \ 64 } else { \ 65 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \ 66 (S), (L)); \ 67 if((R) != 0) { \ 68 free((B)); \ 69 (B) = NULL; \ 70 } \ 71 } \ 72 } while (0) 73 74 #ifdef _WIN32 75 #ifndef ASN1_LIB 76 #define ASN1EXP __declspec(dllimport) 77 #else 78 #define ASN1EXP 79 #endif 80 #define ASN1CALL __stdcall 81 #else 82 #define ASN1EXP 83 #define ASN1CALL 84 #endif 85 86 #endif 87