]>
git.ipfire.org Git - thirdparty/squid.git/blob - include/asn1.h
2 * Definitions for Abstract Syntax Notation One, ASN.1
3 * As defined in ISO/IS 8824 and ISO/IS 8825
7 /***********************************************************
8 Copyright 1988, 1989 by Carnegie Mellon University
12 Permission to use, copy, modify, and distribute this software and its
13 documentation for any purpose and without fee is hereby granted,
14 provided that the above copyright notice appear in all copies and that
15 both that copyright notice and this permission notice appear in
16 supporting documentation, and that the name of CMU not be
17 used in advertising or publicity pertaining to distribution of the
18 software without specific, written prior permission.
20 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
22 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27 ******************************************************************/
32 /* assume someone else includes "config.h" for us */
34 #include <sys/types.h>
37 #ifndef EIGHTBIT_SUBIDS
39 #define MAX_SUBID 0xFFFFFFFF
42 #define MAX_SUBID 0xFF
45 #define MAX_OID_LEN 64 /* max subid's in an oid */
47 #define ASN_BOOLEAN (0x01)
48 #define ASN_INTEGER (0x02)
49 #define ASN_BIT_STR (0x03)
50 #define ASN_OCTET_STR (0x04)
51 #define ASN_NULL (0x05)
52 #define ASN_OBJECT_ID (0x06)
53 #define ASN_SEQUENCE (0x10)
54 #define ASN_SET (0x11)
56 #define ASN_UNIVERSAL (0x00)
57 #define ASN_APPLICATION (0x40)
58 #define ASN_CONTEXT (0x80)
59 #define ASN_PRIVATE (0xC0)
61 #define ASN_PRIMITIVE (0x00)
62 #define ASN_CONSTRUCTOR (0x20)
64 #define ASN_LONG_LEN (0x80)
65 #define ASN_EXTENSION_ID (0x1F)
66 #define ASN_BIT8 (0x80)
68 #define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
69 #define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
71 /* 32 bit integer compatability hack */
74 typedef unsigned int u_num32
;
75 #elif SIZEOF_LONG == 4
77 typedef unsigned long u_num32
;
79 typedef long num32
; /* assume that long's are 32bit */
80 typedef unsigned long u_num32
;
82 #define NUM32LEN sizeof(num32) /* this should always be 4 */
85 * internal 64 bit representation:
92 extern u_char
*asn_parse_int (u_char
* data
,
98 extern u_char
*asn_build_int (u_char
* data
,
104 extern u_char
*asn_parse_unsigned_int (u_char
* data
,
110 extern u_char
*asn_build_unsigned_int (u_char
* data
,
116 extern u_char
*asn_parse_string (u_char
* data
,
122 extern u_char
*asn_build_string (u_char
* data
,
128 extern u_char
*asn_parse_header (u_char
* data
,
132 extern u_char
*asn_build_header (u_char
* data
,
137 extern u_char
*asn_build_sequence (u_char
* data
,
142 extern u_char
*asn_parse_length (u_char
* data
,
145 extern u_char
*asn_build_length (u_char
* data
,
149 extern u_char
*asn_parse_objid (
156 extern u_char
*asn_build_objid (u_char
* data
,
162 extern u_char
*asn_parse_null (u_char
* data
,
166 extern u_char
*asn_build_null (u_char
* data
,
169 extern u_char
*asn_parse_bitstring (u_char
* data
,
175 extern u_char
*asn_build_bitstring (u_char
* data
,
181 extern u_char
*asn_parse_unsigned_int64 (u_char
* data
,
184 struct counter64
* cp
,
187 extern u_char
*asn_build_unsigned_int64 (u_char
* data
,
190 struct counter64
* cp
,