1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-pkcs10.c */
4 /* asn2wrs.py -b -p pkcs10 -c ./pkcs10.cnf -s ./packet-pkcs10-template -D . -O ../.. PKCS10.asn */
5
6 /* Input file: packet-pkcs10-template.c */
7
8 #line 1 "./asn1/pkcs10/packet-pkcs10-template.c"
9 /* packet-p10.c
10 *
11 * Routines for PKCS10 packet dissection
12 * Martin Peylo <wireshark@izac.de> 2018
13 *
14 * Wireshark - Network traffic analyzer
15 * By Gerald Combs <gerald@wireshark.org>
16 * Copyright 1998 Gerald Combs
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 */
32
33 #include "config.h"
34
35 #include <epan/packet.h>
36
37 #include <epan/oids.h>
38 #include <epan/asn1.h>
39 #include "packet-ber.h"
40 #include "packet-pkcs10.h"
41 #include "packet-pkix1explicit.h"
42 #include "packet-pkix1implicit.h"
43 #include <epan/prefs.h>
44
45 #define PNAME "PKCS10 Certification Request"
46 #define PSNAME "PKCS10"
47 #define PFNAME "pkcs10"
48
49 void proto_register_pkcs10(void);
50
51 /* Initialize the protocol and registered fields */
52 static int proto_pkcs10 = -1;
53
54 /*--- Included file: packet-pkcs10-hf.c ---*/
55 #line 1 "./asn1/pkcs10/packet-pkcs10-hf.c"
56 static int hf_pkcs10_Attributes_PDU = -1; /* Attributes */
57 static int hf_pkcs10_CertificationRequest_PDU = -1; /* CertificationRequest */
58 static int hf_pkcs10_version = -1; /* T_version */
59 static int hf_pkcs10_subject = -1; /* Name */
60 static int hf_pkcs10_subjectPKInfo = -1; /* SubjectPublicKeyInfo */
61 static int hf_pkcs10_attributes = -1; /* Attributes */
62 static int hf_pkcs10_Attributes_item = -1; /* Attribute */
63 static int hf_pkcs10_type = -1; /* T_type */
64 static int hf_pkcs10_values = -1; /* T_values */
65 static int hf_pkcs10_values_item = -1; /* T_values_item */
66 static int hf_pkcs10_certificationRequestInfo = -1; /* CertificationRequestInfo */
67 static int hf_pkcs10_signatureAlgorithm = -1; /* AlgorithmIdentifier */
68 static int hf_pkcs10_signature = -1; /* BIT_STRING */
69
70 /*--- End of included file: packet-pkcs10-hf.c ---*/
71 #line 46 "./asn1/pkcs10/packet-pkcs10-template.c"
72
73 /* Initialize the subtree pointers */
74
75 /*--- Included file: packet-pkcs10-ett.c ---*/
76 #line 1 "./asn1/pkcs10/packet-pkcs10-ett.c"
77 static gint ett_pkcs10_CertificationRequestInfo = -1;
78 static gint ett_pkcs10_Attributes = -1;
79 static gint ett_pkcs10_Attribute = -1;
80 static gint ett_pkcs10_T_values = -1;
81 static gint ett_pkcs10_CertificationRequest = -1;
82
83 /*--- End of included file: packet-pkcs10-ett.c ---*/
84 #line 49 "./asn1/pkcs10/packet-pkcs10-template.c"
85
86 /*--- Included file: packet-pkcs10-fn.c ---*/
87 #line 1 "./asn1/pkcs10/packet-pkcs10-fn.c"
88
89 static const value_string pkcs10_T_version_vals[] = {
90 { 0, "v1" },
91 { 0, NULL }
92 };
93
94
95 static int
dissect_pkcs10_T_version(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)96 dissect_pkcs10_T_version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
97 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
98 NULL);
99
100 return offset;
101 }
102
103
104
105 static int
dissect_pkcs10_T_type(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)106 dissect_pkcs10_T_type(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
107 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_pkcs10_type, &actx->external.direct_reference);
108
109 return offset;
110 }
111
112
113
114 static int
dissect_pkcs10_T_values_item(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)115 dissect_pkcs10_T_values_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
116 #line 29 "./asn1/pkcs10/pkcs10.cnf"
117 offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL);
118
119
120
121 return offset;
122 }
123
124
125 static const ber_sequence_t T_values_set_of[1] = {
126 { &hf_pkcs10_values_item , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_pkcs10_T_values_item },
127 };
128
129 static int
dissect_pkcs10_T_values(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)130 dissect_pkcs10_T_values(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
131 offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
132 T_values_set_of, hf_index, ett_pkcs10_T_values);
133
134 return offset;
135 }
136
137
138 static const ber_sequence_t Attribute_sequence[] = {
139 { &hf_pkcs10_type , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs10_T_type },
140 { &hf_pkcs10_values , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_pkcs10_T_values },
141 { NULL, 0, 0, 0, NULL }
142 };
143
144 static int
dissect_pkcs10_Attribute(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)145 dissect_pkcs10_Attribute(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
146 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
147 Attribute_sequence, hf_index, ett_pkcs10_Attribute);
148
149 return offset;
150 }
151
152
153 static const ber_sequence_t Attributes_set_of[1] = {
154 { &hf_pkcs10_Attributes_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkcs10_Attribute },
155 };
156
157 static int
dissect_pkcs10_Attributes(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)158 dissect_pkcs10_Attributes(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
159 offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
160 Attributes_set_of, hf_index, ett_pkcs10_Attributes);
161
162 return offset;
163 }
164
165
166 static const ber_sequence_t CertificationRequestInfo_sequence[] = {
167 { &hf_pkcs10_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkcs10_T_version },
168 { &hf_pkcs10_subject , BER_CLASS_ANY, -1, BER_FLAGS_NOOWNTAG, dissect_pkix1explicit_Name },
169 { &hf_pkcs10_subjectPKInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkix1explicit_SubjectPublicKeyInfo },
170 { &hf_pkcs10_attributes , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_pkcs10_Attributes },
171 { NULL, 0, 0, 0, NULL }
172 };
173
174 static int
dissect_pkcs10_CertificationRequestInfo(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)175 dissect_pkcs10_CertificationRequestInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
176 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
177 CertificationRequestInfo_sequence, hf_index, ett_pkcs10_CertificationRequestInfo);
178
179 return offset;
180 }
181
182
183
184 static int
dissect_pkcs10_BIT_STRING(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)185 dissect_pkcs10_BIT_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
186 offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
187 NULL, 0, hf_index, -1,
188 NULL);
189
190 return offset;
191 }
192
193
194 static const ber_sequence_t CertificationRequest_sequence[] = {
195 { &hf_pkcs10_certificationRequestInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkcs10_CertificationRequestInfo },
196 { &hf_pkcs10_signatureAlgorithm, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkix1explicit_AlgorithmIdentifier },
197 { &hf_pkcs10_signature , BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs10_BIT_STRING },
198 { NULL, 0, 0, 0, NULL }
199 };
200
201 int
dissect_pkcs10_CertificationRequest(gboolean implicit_tag _U_,tvbuff_t * tvb _U_,int offset _U_,asn1_ctx_t * actx _U_,proto_tree * tree _U_,int hf_index _U_)202 dissect_pkcs10_CertificationRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
203 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
204 CertificationRequest_sequence, hf_index, ett_pkcs10_CertificationRequest);
205
206 return offset;
207 }
208
209 /*--- PDUs ---*/
210
dissect_Attributes_PDU(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,void * data _U_)211 static int dissect_Attributes_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
212 int offset = 0;
213 asn1_ctx_t asn1_ctx;
214 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
215 offset = dissect_pkcs10_Attributes(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs10_Attributes_PDU);
216 return offset;
217 }
dissect_CertificationRequest_PDU(tvbuff_t * tvb _U_,packet_info * pinfo _U_,proto_tree * tree _U_,void * data _U_)218 static int dissect_CertificationRequest_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
219 int offset = 0;
220 asn1_ctx_t asn1_ctx;
221 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
222 offset = dissect_pkcs10_CertificationRequest(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs10_CertificationRequest_PDU);
223 return offset;
224 }
225
226
227 /*--- End of included file: packet-pkcs10-fn.c ---*/
228 #line 50 "./asn1/pkcs10/packet-pkcs10-template.c"
229
230 /*--- proto_register_pkcs10 ----------------------------------------------*/
proto_register_pkcs10(void)231 void proto_register_pkcs10(void) {
232
233 /* List of fields */
234 static hf_register_info hf[] = {
235
236 /*--- Included file: packet-pkcs10-hfarr.c ---*/
237 #line 1 "./asn1/pkcs10/packet-pkcs10-hfarr.c"
238 { &hf_pkcs10_Attributes_PDU,
239 { "Attributes", "pkcs10.Attributes",
240 FT_UINT32, BASE_DEC, NULL, 0,
241 NULL, HFILL }},
242 { &hf_pkcs10_CertificationRequest_PDU,
243 { "CertificationRequest", "pkcs10.CertificationRequest_element",
244 FT_NONE, BASE_NONE, NULL, 0,
245 NULL, HFILL }},
246 { &hf_pkcs10_version,
247 { "version", "pkcs10.version",
248 FT_UINT32, BASE_DEC, VALS(pkcs10_T_version_vals), 0,
249 NULL, HFILL }},
250 { &hf_pkcs10_subject,
251 { "subject", "pkcs10.subject",
252 FT_UINT32, BASE_DEC, NULL, 0,
253 "Name", HFILL }},
254 { &hf_pkcs10_subjectPKInfo,
255 { "subjectPKInfo", "pkcs10.subjectPKInfo_element",
256 FT_NONE, BASE_NONE, NULL, 0,
257 "SubjectPublicKeyInfo", HFILL }},
258 { &hf_pkcs10_attributes,
259 { "attributes", "pkcs10.attributes",
260 FT_UINT32, BASE_DEC, NULL, 0,
261 NULL, HFILL }},
262 { &hf_pkcs10_Attributes_item,
263 { "Attribute", "pkcs10.Attribute_element",
264 FT_NONE, BASE_NONE, NULL, 0,
265 NULL, HFILL }},
266 { &hf_pkcs10_type,
267 { "type", "pkcs10.type",
268 FT_OID, BASE_NONE, NULL, 0,
269 NULL, HFILL }},
270 { &hf_pkcs10_values,
271 { "values", "pkcs10.values",
272 FT_UINT32, BASE_DEC, NULL, 0,
273 NULL, HFILL }},
274 { &hf_pkcs10_values_item,
275 { "values item", "pkcs10.values_item_element",
276 FT_NONE, BASE_NONE, NULL, 0,
277 NULL, HFILL }},
278 { &hf_pkcs10_certificationRequestInfo,
279 { "certificationRequestInfo", "pkcs10.certificationRequestInfo_element",
280 FT_NONE, BASE_NONE, NULL, 0,
281 NULL, HFILL }},
282 { &hf_pkcs10_signatureAlgorithm,
283 { "signatureAlgorithm", "pkcs10.signatureAlgorithm_element",
284 FT_NONE, BASE_NONE, NULL, 0,
285 "AlgorithmIdentifier", HFILL }},
286 { &hf_pkcs10_signature,
287 { "signature", "pkcs10.signature",
288 FT_BYTES, BASE_NONE, NULL, 0,
289 "BIT_STRING", HFILL }},
290
291 /*--- End of included file: packet-pkcs10-hfarr.c ---*/
292 #line 57 "./asn1/pkcs10/packet-pkcs10-template.c"
293 };
294
295 /* List of subtrees */
296 static gint *ett[] = {
297
298 /*--- Included file: packet-pkcs10-ettarr.c ---*/
299 #line 1 "./asn1/pkcs10/packet-pkcs10-ettarr.c"
300 &ett_pkcs10_CertificationRequestInfo,
301 &ett_pkcs10_Attributes,
302 &ett_pkcs10_Attribute,
303 &ett_pkcs10_T_values,
304 &ett_pkcs10_CertificationRequest,
305
306 /*--- End of included file: packet-pkcs10-ettarr.c ---*/
307 #line 62 "./asn1/pkcs10/packet-pkcs10-template.c"
308 };
309 /* Register protocol */
310 proto_pkcs10 = proto_register_protocol(PNAME, PSNAME, PFNAME);
311
312 /* Register fields and subtrees */
313 proto_register_field_array(proto_pkcs10, hf, array_length(hf));
314 proto_register_subtree_array(ett, array_length(ett));
315
316 register_ber_syntax_dissector("CertificationRequest", proto_pkcs10, dissect_CertificationRequest_PDU);
317 register_ber_oid_syntax(".p10", NULL, "CertificationRequest");
318 register_ber_oid_syntax(".csr", NULL, "CertificationRequest");
319 }
320
321
322 /*--- proto_reg_handoff_pkcs10 -------------------------------------------*/
proto_reg_handoff_pkcs10(void)323 void proto_reg_handoff_pkcs10(void) {
324 dissector_handle_t csr_handle;
325
326
327 /*--- Included file: packet-pkcs10-dis-tab.c ---*/
328 #line 1 "./asn1/pkcs10/packet-pkcs10-dis-tab.c"
329 register_ber_oid_dissector("1.2.840.113549.1.9.9", dissect_Attributes_PDU, proto_pkcs10, "pkcs-9-at-extendedCertificateAttributes");
330
331
332 /*--- End of included file: packet-pkcs10-dis-tab.c ---*/
333 #line 81 "./asn1/pkcs10/packet-pkcs10-template.c"
334
335 csr_handle = create_dissector_handle(dissect_CertificationRequest_PDU, proto_pkcs10);
336 dissector_add_string("media_type", "application/pkcs10", csr_handle); /* RFC 5967 */
337 dissector_add_string("rfc7468.preeb_label", "CERTIFICATE REQUEST", csr_handle); /* RFC 7468 */
338 dissector_add_string("rfc7468.preeb_label", "NEW CERTIFICATE REQUEST", csr_handle); /* RFC 7468 Appendix A. Non-conforming expample*/
339 }
340