1219019Sgabor/*
2219019Sgabor * Copyright (c) 1997 - 2006 Kungliga Tekniska H�gskolan
3219019Sgabor * (Royal Institute of Technology, Stockholm, Sweden).
4219019Sgabor * All rights reserved.
5219019Sgabor *
6219019Sgabor * Redistribution and use in source and binary forms, with or without
7219019Sgabor * modification, are permitted provided that the following conditions
8219019Sgabor * are met:
9219019Sgabor *
10219019Sgabor * 1. Redistributions of source code must retain the above copyright
11219019Sgabor *    notice, this list of conditions and the following disclaimer.
12219019Sgabor *
13219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright
14219019Sgabor *    notice, this list of conditions and the following disclaimer in the
15219019Sgabor *    documentation and/or other materials provided with the distribution.
16219019Sgabor *
17219019Sgabor * 3. Neither the name of the Institute nor the names of its contributors
18219019Sgabor *    may be used to endorse or promote products derived from this software
19219019Sgabor *    without specific prior written permission.
20219019Sgabor *
21219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22219019Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24219019Sgabor * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25219019Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26219019Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27219019Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28219019Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29219019Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30219019Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31219019Sgabor * SUCH DAMAGE.
32219019Sgabor */
33219019Sgabor
34219019Sgabor/* $Id: der.h 18437 2006-10-14 05:16:08Z lha $ */
35219019Sgabor
36219019Sgabor#ifndef __DER_H__
37219019Sgabor#define __DER_H__
38219019Sgabor
39219019Sgabortypedef enum {
40219019Sgabor    ASN1_C_UNIV = 0,
41219019Sgabor    ASN1_C_APPL = 1,
42219019Sgabor    ASN1_C_CONTEXT = 2,
43219019Sgabor    ASN1_C_PRIVATE = 3
44219019Sgabor} Der_class;
45219019Sgabor
46219019Sgabortypedef enum {PRIM = 0, CONS = 1} Der_type;
47219019Sgabor
48219019Sgabor#define MAKE_TAG(CLASS, TYPE, TAG)  (((CLASS) << 6) | ((TYPE) << 5) | (TAG))
49219019Sgabor
50219019Sgabor/* Universal tags */
51219019Sgabor
52219019Sgaborenum {
53219019Sgabor    UT_EndOfContent	= 0,
54219019Sgabor    UT_Boolean		= 1,
55219019Sgabor    UT_Integer		= 2,
56219019Sgabor    UT_BitString	= 3,
57219019Sgabor    UT_OctetString	= 4,
58219019Sgabor    UT_Null		= 5,
59219019Sgabor    UT_OID		= 6,
60219019Sgabor    UT_Enumerated	= 10,
61219019Sgabor    UT_UTF8String	= 12,
62219019Sgabor    UT_Sequence		= 16,
63219019Sgabor    UT_Set		= 17,
64219019Sgabor    UT_PrintableString	= 19,
65219019Sgabor    UT_IA5String	= 22,
66219019Sgabor    UT_UTCTime		= 23,
67219019Sgabor    UT_GeneralizedTime	= 24,
68219019Sgabor    UT_UniversalString	= 25,
69219019Sgabor    UT_VisibleString	= 26,
70219019Sgabor    UT_GeneralString	= 27,
71219019Sgabor    UT_BMPString	= 30,
72219019Sgabor    /* unsupported types */
73219019Sgabor    UT_ObjectDescriptor = 7,
74219019Sgabor    UT_External		= 8,
75219019Sgabor    UT_Real		= 9,
76219019Sgabor    UT_EmbeddedPDV	= 11,
77219019Sgabor    UT_RelativeOID	= 13,
78219019Sgabor    UT_NumericString	= 18,
79219019Sgabor    UT_TeletexString	= 20,
80219019Sgabor    UT_VideotexString	= 21,
81219019Sgabor    UT_GraphicString	= 25
82219019Sgabor};
83219019Sgabor
84219019Sgabor#define ASN1_INDEFINITE 0xdce0deed
85219019Sgabor
86219019Sgabortypedef struct heim_der_time_t {
87219019Sgabor    time_t dt_sec;
88219019Sgabor    unsigned long dt_nsec;
89219019Sgabor} heim_der_time_t;
90219019Sgabor
91219019Sgabortypedef struct heim_ber_time_t {
92219019Sgabor    time_t bt_sec;
93219019Sgabor    unsigned bt_nsec;
94219019Sgabor    int bt_zone;
95219019Sgabor} heim_ber_time_t;
96219019Sgabor
97219019Sgabor#include <der-protos.h>
98219019Sgabor
99219019Sgaborint _heim_fix_dce(size_t reallen, size_t *len);
100219019Sgaborint _heim_der_set_sort(const void *, const void *);
101219019Sgaborint _heim_time2generalizedtime (time_t, heim_octet_string *, int);
102219019Sgabor
103219019Sgabor#endif /* __DER_H__ */
104219019Sgabor