1/* 2 * Copyright (c) 2011-12 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23/* $Id$ */ 24 25#include <stddef.h> 26#include <time.h> 27 28#include "krb5-types.h" 29 30#ifndef __asn1_common_definitions__ 31#define __asn1_common_definitions__ 32 33#ifndef __HEIM_BASE_DATA__ 34#define __HEIM_BASE_DATA__ 1 35struct heim_base_data { 36 size_t length; 37 void *data; 38}; 39#endif 40 41typedef struct heim_integer { 42 size_t length; 43 void *data; 44 int negative; 45} heim_integer; 46 47typedef struct heim_base_data heim_octet_string; 48 49typedef char *heim_general_string; 50typedef char *heim_utf8_string; 51typedef struct heim_base_data heim_printable_string; 52typedef struct heim_base_data heim_ia5_string; 53 54typedef struct heim_bmp_string { 55 size_t length; 56 uint16_t *data; 57} heim_bmp_string; 58 59typedef struct heim_universal_string { 60 size_t length; 61 uint32_t *data; 62} heim_universal_string; 63 64typedef char *heim_visible_string; 65 66typedef struct heim_oid { 67 size_t length; 68 unsigned *components; 69} heim_oid; 70 71typedef struct heim_bit_string { 72 size_t length; 73 void *data; 74} heim_bit_string; 75 76typedef struct heim_base_data heim_any; 77typedef struct heim_base_data heim_any_set; 78 79#define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \ 80 do { \ 81 (BL) = length_##T((S)); \ 82 (B) = malloc((BL)); \ 83 if((B) == NULL) { \ 84 (R) = ENOMEM; \ 85 } else { \ 86 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \ 87 (S), (L)); \ 88 if((R) != 0) { \ 89 free((B)); \ 90 (B) = NULL; \ 91 } \ 92 } \ 93 } while (0) 94 95#ifdef _WIN32 96#ifndef ASN1_LIB 97#define ASN1EXP __declspec(dllimport) 98#else 99#define ASN1EXP 100#endif 101#define ASN1CALL __stdcall 102#else 103#define ASN1EXP 104#define ASN1CALL 105#endif 106 107#endif 108