a4fa32b3d5468dce86fc2a21281da12ffb6d9cdc
[metze/wireshark/wip.git] / epan / dissectors / packet-pkix1explicit.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
3 /* ./packet-pkix1explicit.c                                                   */
4 /* ../../tools/asn2eth.py -e -X -b -p pkix1explicit -c pkix1explicit.cnf -s packet-pkix1explicit-template PKIX1EXPLICIT93.asn */
5
6 /* Input file: packet-pkix1explicit-template.c */
7
8 #define BER_UNI_TAG_TeletexString           20  /* workaround bug in asn2eth */
9
10 /* packet-pkix1explicit.c
11  * Routines for PKIX1Explitic packet dissection
12  *
13  * $Id: packet-pkix1explicit-template.c 12203 2004-10-05 09:18:55Z guy $
14  *
15  * Ethereal - Network traffic analyzer
16  * By Gerald Combs <gerald@ethereal.com>
17  * Copyright 1998 Gerald Combs
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37
38 #include <glib.h>
39 #include <epan/packet.h>
40 #include <epan/conversation.h>
41
42 #include <stdio.h>
43 #include <string.h>
44
45 #include "packet-ber.h"
46 #include "packet-pkix1explicit.h"
47 #include "packet-x509af.h"
48 #include "packet-x509if.h"
49
50 #define PNAME  "PKIX1Explitit"
51 #define PSNAME "PKIX1EXPLICIT"
52 #define PFNAME "pkix1explicit"
53
54 /* Initialize the protocol and registered fields */
55 static int proto_pkix1explicit = -1;
56
57 /*--- Included file: packet-pkix1explicit-hf.c ---*/
58
59 static int hf_pkix1explicit_DomainParameters_PDU = -1;  /* DomainParameters */
60 static int hf_pkix1explicit_p = -1;               /* INTEGER */
61 static int hf_pkix1explicit_g = -1;               /* INTEGER */
62 static int hf_pkix1explicit_q = -1;               /* INTEGER */
63 static int hf_pkix1explicit_j = -1;               /* INTEGER */
64 static int hf_pkix1explicit_validationParms = -1;  /* ValidationParms */
65 static int hf_pkix1explicit_seed = -1;            /* BIT_STRING */
66 static int hf_pkix1explicit_pgenCounter = -1;     /* INTEGER */
67 static int hf_pkix1explicit_type = -1;            /* TeletexString */
68 static int hf_pkix1explicit_value = -1;           /* TeletexString */
69
70 /*--- End of included file: packet-pkix1explicit-hf.c ---*/
71
72
73 /* Initialize the subtree pointers */
74
75 /*--- Included file: packet-pkix1explicit-ett.c ---*/
76
77 static gint ett_pkix1explicit_DomainParameters = -1;
78 static gint ett_pkix1explicit_ValidationParms = -1;
79 static gint ett_pkix1explicit_TeletexDomainDefinedAttribute = -1;
80
81 /*--- End of included file: packet-pkix1explicit-ett.c ---*/
82
83
84
85 int
86 dissect_pkix1explicit_CertificateSerialNumber(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
87   offset = dissect_x509af_CertificateSerialNumber(implicit_tag, tvb, offset, pinfo, tree, hf_index);
88
89   return offset;
90 }
91
92 int
93 dissect_pkix1explicit_Name(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) {
94   offset = dissect_x509if_Name(implicit_tag, tvb, offset, pinfo, tree, hf_index);
95
96   return offset;
97 }
98
99 int
100 dissect_pkix1explicit_AlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
101   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
102
103   return offset;
104 }
105
106 int
107 dissect_pkix1explicit_SubjectPublicKeyInfo(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) {
108   offset = dissect_x509af_SubjectPublicKeyInfo(implicit_tag, tvb, offset, pinfo, tree, hf_index);
109
110   return offset;
111 }
112
113
114
115 /*--- Included file: packet-pkix1explicit-fn.c ---*/
116
117 /*--- Fields for imported types ---*/
118
119
120
121
122
123 static int
124 dissect_pkix1explicit_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
125   offset = dissect_ber_integer(pinfo, tree, tvb, offset, hf_index, NULL);
126
127   return offset;
128 }
129 static int dissect_p(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
130   return dissect_pkix1explicit_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_p);
131 }
132 static int dissect_g(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
133   return dissect_pkix1explicit_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_g);
134 }
135 static int dissect_q(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
136   return dissect_pkix1explicit_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_q);
137 }
138 static int dissect_j(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
139   return dissect_pkix1explicit_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_j);
140 }
141 static int dissect_pgenCounter(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
142   return dissect_pkix1explicit_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_pgenCounter);
143 }
144
145
146 static int
147 dissect_pkix1explicit_BIT_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
148   offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset,
149                                  NULL, hf_index, -1,
150                                  NULL);
151
152   return offset;
153 }
154 static int dissect_seed(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
155   return dissect_pkix1explicit_BIT_STRING(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_seed);
156 }
157
158 static const ber_sequence ValidationParms_sequence[] = {
159   { BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_NOOWNTAG, dissect_seed },
160   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pgenCounter },
161   { 0, 0, 0, NULL }
162 };
163
164 static int
165 dissect_pkix1explicit_ValidationParms(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
166   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
167                                 ValidationParms_sequence, hf_index, ett_pkix1explicit_ValidationParms);
168
169   return offset;
170 }
171 static int dissect_validationParms(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
172   return dissect_pkix1explicit_ValidationParms(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_validationParms);
173 }
174
175 static const ber_sequence DomainParameters_sequence[] = {
176   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_p },
177   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_g },
178   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_q },
179   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_j },
180   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_validationParms },
181   { 0, 0, 0, NULL }
182 };
183
184 static int
185 dissect_pkix1explicit_DomainParameters(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
186   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
187                                 DomainParameters_sequence, hf_index, ett_pkix1explicit_DomainParameters);
188
189   return offset;
190 }
191
192
193 const value_string TerminalType_vals[] = {
194   {   3, "telex" },
195   {   4, "teletex" },
196   {   5, "g3-facsimile" },
197   {   6, "g4-facsimile" },
198   {   7, "ia5-terminal" },
199   {   8, "videotex" },
200   { 0, NULL }
201 };
202
203
204 int
205 dissect_pkix1explicit_TerminalType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
206   offset = dissect_ber_integer(pinfo, tree, tvb, offset, hf_index, NULL);
207
208   return offset;
209 }
210
211
212 static int
213 dissect_pkix1explicit_TeletexString(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
214   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_TeletexString,
215                                          pinfo, tree, tvb, offset, hf_index,
216                                          NULL);
217
218   return offset;
219 }
220 static int dissect_type(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
221   return dissect_pkix1explicit_TeletexString(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_type);
222 }
223 static int dissect_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
224   return dissect_pkix1explicit_TeletexString(FALSE, tvb, offset, pinfo, tree, hf_pkix1explicit_value);
225 }
226
227 static const ber_sequence TeletexDomainDefinedAttribute_sequence[] = {
228   { BER_CLASS_UNI, BER_UNI_TAG_TeletexString, BER_FLAGS_NOOWNTAG, dissect_type },
229   { BER_CLASS_UNI, BER_UNI_TAG_TeletexString, BER_FLAGS_NOOWNTAG, dissect_value },
230   { 0, 0, 0, NULL }
231 };
232
233 int
234 dissect_pkix1explicit_TeletexDomainDefinedAttribute(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
235   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
236                                 TeletexDomainDefinedAttribute_sequence, hf_index, ett_pkix1explicit_TeletexDomainDefinedAttribute);
237
238   return offset;
239 }
240
241 /*--- PDUs ---*/
242
243 static void dissect_DomainParameters_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
244   dissect_pkix1explicit_DomainParameters(FALSE, tvb, 0, pinfo, tree, hf_pkix1explicit_DomainParameters_PDU);
245 }
246
247
248 /*--- End of included file: packet-pkix1explicit-fn.c ---*/
249
250
251
252 /*--- proto_register_pkix1explicit ----------------------------------------------*/
253 void proto_register_pkix1explicit(void) {
254
255   /* List of fields */
256   static hf_register_info hf[] = {
257
258 /*--- Included file: packet-pkix1explicit-hfarr.c ---*/
259
260     { &hf_pkix1explicit_DomainParameters_PDU,
261       { "DomainParameters", "pkix1explicit.DomainParameters",
262         FT_NONE, BASE_NONE, NULL, 0,
263         "DomainParameters", HFILL }},
264     { &hf_pkix1explicit_p,
265       { "p", "pkix1explicit.p",
266         FT_INT32, BASE_DEC, NULL, 0,
267         "DomainParameters/p", HFILL }},
268     { &hf_pkix1explicit_g,
269       { "g", "pkix1explicit.g",
270         FT_INT32, BASE_DEC, NULL, 0,
271         "DomainParameters/g", HFILL }},
272     { &hf_pkix1explicit_q,
273       { "q", "pkix1explicit.q",
274         FT_INT32, BASE_DEC, NULL, 0,
275         "DomainParameters/q", HFILL }},
276     { &hf_pkix1explicit_j,
277       { "j", "pkix1explicit.j",
278         FT_INT32, BASE_DEC, NULL, 0,
279         "DomainParameters/j", HFILL }},
280     { &hf_pkix1explicit_validationParms,
281       { "validationParms", "pkix1explicit.validationParms",
282         FT_NONE, BASE_NONE, NULL, 0,
283         "DomainParameters/validationParms", HFILL }},
284     { &hf_pkix1explicit_seed,
285       { "seed", "pkix1explicit.seed",
286         FT_BYTES, BASE_HEX, NULL, 0,
287         "ValidationParms/seed", HFILL }},
288     { &hf_pkix1explicit_pgenCounter,
289       { "pgenCounter", "pkix1explicit.pgenCounter",
290         FT_INT32, BASE_DEC, NULL, 0,
291         "ValidationParms/pgenCounter", HFILL }},
292     { &hf_pkix1explicit_type,
293       { "type", "pkix1explicit.type",
294         FT_STRING, BASE_NONE, NULL, 0,
295         "TeletexDomainDefinedAttribute/type", HFILL }},
296     { &hf_pkix1explicit_value,
297       { "value", "pkix1explicit.value",
298         FT_STRING, BASE_NONE, NULL, 0,
299         "TeletexDomainDefinedAttribute/value", HFILL }},
300
301 /*--- End of included file: packet-pkix1explicit-hfarr.c ---*/
302
303   };
304
305   /* List of subtrees */
306   static gint *ett[] = {
307
308 /*--- Included file: packet-pkix1explicit-ettarr.c ---*/
309
310     &ett_pkix1explicit_DomainParameters,
311     &ett_pkix1explicit_ValidationParms,
312     &ett_pkix1explicit_TeletexDomainDefinedAttribute,
313
314 /*--- End of included file: packet-pkix1explicit-ettarr.c ---*/
315
316   };
317
318   /* Register protocol */
319   proto_pkix1explicit = proto_register_protocol(PNAME, PSNAME, PFNAME);
320
321   /* Register fields and subtrees */
322   proto_register_field_array(proto_pkix1explicit, hf, array_length(hf));
323   proto_register_subtree_array(ett, array_length(ett));
324
325 }
326
327
328 /*--- proto_reg_handoff_pkix1explicit -------------------------------------------*/
329 void proto_reg_handoff_pkix1explicit(void) {
330
331 /*--- Included file: packet-pkix1explicit-dis-tab.c ---*/
332
333  register_ber_oid_dissector("1.2.840.10046.2.1", dissect_DomainParameters_PDU, proto_pkix1explicit, "dhpublicnumber");
334
335
336 /*--- End of included file: packet-pkix1explicit-dis-tab.c ---*/
337
338 }
339