2 * Definitions for ASN.1 BER dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
9 * Based on "g_asn1.h" from:
11 * GXSNMP -- An snmp mangament application
12 * Copyright (C) 1998 Gregory McLean & Jochen Friedrich
13 * Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #define ASN1_UNI 0 /* Universal */
34 #define ASN1_APL 1 /* Application */
35 #define ASN1_CTX 2 /* Context */
36 #define ASN1_PRV 3 /* Private */
38 #define BER_CLASS_UNI 0
39 #define BER_CLASS_APP 1
40 #define BER_CLASS_CON 2
41 #define BER_CLASS_PRI 3
42 #define BER_CLASS_ANY 99 /* dont check class nor tag */
44 #define BER_UNI_TAG_EOC 0 /* 'end-of-content' */
45 #define BER_UNI_TAG_BOOLEAN 1
46 #define BER_UNI_TAG_INTEGER 2
47 #define BER_UNI_TAG_BITSTRING 3
48 #define BER_UNI_TAG_OCTETSTRING 4
49 #define BER_UNI_TAG_NULL 5
50 #define BER_UNI_TAG_OID 6 /* OBJECT IDENTIFIER */
51 #define BER_UNI_TAG_ObjectDescriptor 7
52 #define BER_UNI_TAG_EXTERNAL 8
53 #define BER_UNI_TAG_REAL 9
54 #define BER_UNI_TAG_ENUMERATED 10
55 #define BER_UNI_TAG_EMBEDDED_PDV 11
56 #define BER_UNI_TAG_UTF8String 12
57 #define BER_UNI_TAG_RELATIVE_OID 13
59 * Reserved for future editions of this
60 * Recommendation | International Standard
62 #define BER_UNI_TAG_SEQUENCE 16 /* SEQUENCE, SEQUENCE OF */
63 #define BER_UNI_TAG_SET 17 /* SET, SET OF */
64 /* UNIVERSAL 18-22 Character string types */
65 #define BER_UNI_TAG_NumericString 18
66 #define BER_UNI_TAG_PrintableString 19
67 #define BER_UNI_TAG_TeletexString 20 /* TeletextString, T61String */
68 #define BER_UNI_TAG_VideotexString 21
69 #define BER_UNI_TAG_IA5String 22
70 /* UNIVERSAL 23-24 Time types */
71 #define BER_UNI_TAG_UTCTime 23
72 #define BER_UNI_TAG_GeneralizedTime 24
73 /* UNIVERSAL 25-30 Character string types */
74 #define BER_UNI_TAG_GraphicString 25
75 #define BER_UNI_TAG_VisibleString 26 /* VisibleString, ISO64String */
76 #define BER_UNI_TAG_GeneralString 27
77 #define BER_UNI_TAG_UniversalString 28
78 #define BER_UNI_TAG_CHARACTERSTRING 29
79 #define BER_UNI_TAG_BMPString 30
81 * Reserved for addenda to this Recommendation | International Standard
84 #define ASN1_EOC 0 /* End Of Contents */
85 #define ASN1_BOL 1 /* Boolean */
86 #define ASN1_INT 2 /* Integer */
87 #define ASN1_BTS 3 /* Bit String */
88 #define ASN1_OTS 4 /* Octet String */
89 #define ASN1_NUL 5 /* Null */
90 #define ASN1_OJI 6 /* Object Identifier */
91 #define ASN1_OJD 7 /* Object Description */
92 #define ASN1_EXT 8 /* External */
93 #define ASN1_REAL 9 /* Real */
94 #define ASN1_ENUM 10 /* Enumerated */
95 #define ASN1_SEQ 16 /* Sequence */
96 #define ASN1_SET 17 /* Set */
97 #define ASN1_NUMSTR 18 /* Numerical String */
98 #define ASN1_PRNSTR 19 /* Printable String */
99 #define ASN1_TEXSTR 20 /* Teletext String */
100 #define ASN1_VIDSTR 21 /* Video String */
101 #define ASN1_IA5STR 22 /* IA5 String */
102 #define ASN1_UNITIM 23 /* Universal Time */
103 #define ASN1_GENTIM 24 /* General Time */
104 #define ASN1_GRASTR 25 /* Graphical String */
105 #define ASN1_VISSTR 26 /* Visible String */
106 #define ASN1_GENSTR 27 /* General String */
108 /* Primitive / Constructed */
109 #define ASN1_PRI 0 /* Primitive */
110 #define ASN1_CON 1 /* Constructed */
113 #define ASN1_ERR_NOERROR 0 /* no error */
114 #define ASN1_ERR_EOC_MISMATCH 1
115 #define ASN1_ERR_WRONG_TYPE 2 /* type not right */
116 #define ASN1_ERR_LENGTH_NOT_DEFINITE 3 /* length should be definite */
117 #define ASN1_ERR_LENGTH_MISMATCH 4
118 #define ASN1_ERR_WRONG_LENGTH_FOR_TYPE 5 /* length wrong for type */
120 typedef struct _ASN1_SCK ASN1_SCK
;
124 tvbuff_t
*tvb
; /* Tvbuff whence the data comes */
125 int offset
; /* Current offset in tvbuff */
128 extern void asn1_open (ASN1_SCK
*asn1
, tvbuff_t
*tvb
, int offset
);
129 extern void asn1_close (ASN1_SCK
*asn1
, int *offset
);
130 extern int asn1_octet_decode (ASN1_SCK
*asn1
, guchar
*ch
);
131 extern int asn1_tag_decode (ASN1_SCK
*asn1
, guint
*tag
);
132 extern int asn1_id_decode (ASN1_SCK
*asn1
, guint
*cls
, guint
*con
, guint
*tag
);
133 extern int asn1_id_decode1 (ASN1_SCK
*asn1
, guint
*tag
);
134 extern int asn1_length_decode (ASN1_SCK
*asn1
, gboolean
*def
, guint
*len
);
135 extern int asn1_header_decode(ASN1_SCK
*asn1
, guint
*cls
, guint
*con
,
136 guint
*tag
, gboolean
*defp
, guint
*lenp
);
137 extern int asn1_eoc (ASN1_SCK
*asn1
, int eoc
);
138 extern int asn1_eoc_decode (ASN1_SCK
*asn1
, int eoc
);
139 extern int asn1_null_decode (ASN1_SCK
*asn1
, int enc_len
);
140 extern int asn1_bool_decode (ASN1_SCK
*asn1
, int enc_len
, gboolean
*boolean
);
141 extern int asn1_int32_value_decode (ASN1_SCK
*asn1
, int enc_len
,
143 extern int asn1_int32_decode (ASN1_SCK
*asn1
, gint32
*integer
, guint
*nbytes
);
144 extern int asn1_uint32_value_decode (ASN1_SCK
*asn1
, int enc_len
,
146 extern int asn1_uint32_decode (ASN1_SCK
*asn1
, guint32
*integer
, guint
*nbytes
);
147 extern int asn1_bits_decode (ASN1_SCK
*asn1
, int enc_len
, guchar
**bits
,
148 guint
*len
, guchar
*unused
);
149 extern int asn1_string_value_decode (ASN1_SCK
*asn1
, int enc_len
,
151 extern int asn1_string_decode (ASN1_SCK
*asn1
, guchar
**octets
, guint
*str_len
,
152 guint
*nbytes
, guint expected_tag
);
153 extern int asn1_octet_string_decode (ASN1_SCK
*asn1
, guchar
**octets
,
154 guint
*str_len
, guint
*nbytes
);
155 extern int asn1_subid_decode (ASN1_SCK
*asn1
, subid_t
*subid
);
156 extern int asn1_oid_value_decode (ASN1_SCK
*asn1
, int enc_len
, subid_t
**oid
,
158 extern int asn1_oid_decode (ASN1_SCK
*asn1
, subid_t
**oid
, guint
*len
,
160 extern int asn1_sequence_decode (ASN1_SCK
*asn1
, guint
*seq_len
, guint
*nbytes
);
162 extern const char *asn1_err_to_str (int err
);