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/* 24 * Copyright (c) 1997 - 2006 Kungliga Tekniska Högskolan 25 * (Royal Institute of Technology, Stockholm, Sweden). 26 * All rights reserved. 27 * 28 * Redistribution and use in source and binary forms, with or without 29 * modification, are permitted provided that the following conditions 30 * are met: 31 * 32 * 1. Redistributions of source code must retain the above copyright 33 * notice, this list of conditions and the following disclaimer. 34 * 35 * 2. Redistributions in binary form must reproduce the above copyright 36 * notice, this list of conditions and the following disclaimer in the 37 * documentation and/or other materials provided with the distribution. 38 * 39 * 3. Neither the name of the Institute nor the names of its contributors 40 * may be used to endorse or promote products derived from this software 41 * without specific prior written permission. 42 * 43 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 * SUCH DAMAGE. 54 */ 55 56/* $Id$ */ 57 58#ifndef __ASN1_DER_H__ 59#define __ASN1_DER_H__ 60 61typedef enum { 62 ASN1_C_UNIV = 0, 63 ASN1_C_APPL = 1, 64 ASN1_C_CONTEXT = 2, 65 ASN1_C_PRIVATE = 3 66} Der_class; 67 68typedef enum {PRIM = 0, CONS = 1} Der_type; 69 70#define MAKE_TAG(CLASS, TYPE, TAG) (((CLASS) << 6) | ((TYPE) << 5) | (TAG)) 71 72/* Universal tags */ 73 74enum { 75 UT_EndOfContent = 0, 76 UT_Boolean = 1, 77 UT_Integer = 2, 78 UT_BitString = 3, 79 UT_OctetString = 4, 80 UT_Null = 5, 81 UT_OID = 6, 82 UT_Enumerated = 10, 83 UT_UTF8String = 12, 84 UT_Sequence = 16, 85 UT_Set = 17, 86 UT_PrintableString = 19, 87 UT_IA5String = 22, 88 UT_UTCTime = 23, 89 UT_GeneralizedTime = 24, 90 UT_UniversalString = 25, 91 UT_VisibleString = 26, 92 UT_GeneralString = 27, 93 UT_BMPString = 30, 94 /* unsupported types */ 95 UT_ObjectDescriptor = 7, 96 UT_External = 8, 97 UT_Real = 9, 98 UT_EmbeddedPDV = 11, 99 UT_RelativeOID = 13, 100 UT_NumericString = 18, 101 UT_TeletexString = 20, 102 UT_VideotexString = 21, 103 UT_GraphicString = 25 104}; 105 106#define ASN1_INDEFINITE 0xdce0deed 107 108typedef struct heim_der_time_t { 109 time_t dt_sec; 110 unsigned long dt_nsec; 111} heim_der_time_t; 112 113typedef struct heim_ber_time_t { 114 time_t bt_sec; 115 unsigned bt_nsec; 116 int bt_zone; 117} heim_ber_time_t; 118 119struct asn1_template; 120 121#include "asn1-der-protos.h" 122 123int _heim_fix_dce(size_t reallen, size_t *len); 124int _heim_der_set_sort(const void *, const void *); 125int _heim_time2generalizedtime (time_t, heim_octet_string *, int); 126 127#endif /* __ASN1_DER_H__ */ 128