/src/wireshark/epan/dissectors/packet-ns_cert_exts.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Do not modify this file. Changes will be overwritten. */ |
2 | | /* Generated automatically by the ASN.1 to Wireshark dissector compiler */ |
3 | | /* packet-ns_cert_exts.c */ |
4 | | /* asn2wrs.py -b -q -L -p ns_cert_exts -c ./ns_cert_exts.cnf -s ./packet-ns_cert_exts-template -D . -O ../.. NETSCAPE-CERT-EXTS.asn */ |
5 | | |
6 | | /* packet-ns_cert_exts.c |
7 | | * Routines for NetScape Certificate Extensions packet dissection |
8 | | * Ronnie Sahlberg 2004 |
9 | | * |
10 | | * Wireshark - Network traffic analyzer |
11 | | * By Gerald Combs <gerald@wireshark.org> |
12 | | * Copyright 1998 Gerald Combs |
13 | | * |
14 | | * SPDX-License-Identifier: GPL-2.0-or-later |
15 | | */ |
16 | | |
17 | | #include "config.h" |
18 | | |
19 | | #include <epan/packet.h> |
20 | | #include <wsutil/array.h> |
21 | | |
22 | | #include "packet-ber.h" |
23 | | |
24 | 14 | #define PNAME "NetScape Certificate Extensions" |
25 | 14 | #define PSNAME "NS_CERT_EXTS" |
26 | 14 | #define PFNAME "ns_cert_exts" |
27 | | |
28 | | void proto_register_ns_cert_exts(void); |
29 | | void proto_reg_handoff_ns_cert_exts(void); |
30 | | |
31 | | /* Initialize the protocol and registered fields */ |
32 | | static int proto_ns_cert_exts; |
33 | | static int hf_ns_cert_exts_BaseUrl_PDU; /* BaseUrl */ |
34 | | static int hf_ns_cert_exts_RevocationUrl_PDU; /* RevocationUrl */ |
35 | | static int hf_ns_cert_exts_CaRevocationUrl_PDU; /* CaRevocationUrl */ |
36 | | static int hf_ns_cert_exts_CaPolicyUrl_PDU; /* CaPolicyUrl */ |
37 | | static int hf_ns_cert_exts_Comment_PDU; /* Comment */ |
38 | | static int hf_ns_cert_exts_SslServerName_PDU; /* SslServerName */ |
39 | | static int hf_ns_cert_exts_CertRenewalUrl_PDU; /* CertRenewalUrl */ |
40 | | static int hf_ns_cert_exts_CertType_PDU; /* CertType */ |
41 | | /* named bits */ |
42 | | static int hf_ns_cert_exts_CertType_ssl_client; |
43 | | static int hf_ns_cert_exts_CertType_ssl_server; |
44 | | static int hf_ns_cert_exts_CertType_smime; |
45 | | static int hf_ns_cert_exts_CertType_object_signing; |
46 | | static int hf_ns_cert_exts_CertType_reserved_for_future_use; |
47 | | static int hf_ns_cert_exts_CertType_ssl_ca; |
48 | | static int hf_ns_cert_exts_CertType_smime_ca; |
49 | | static int hf_ns_cert_exts_CertType_object_signing_ca; |
50 | | |
51 | | /* Initialize the subtree pointers */ |
52 | | static int ett_ns_cert_exts_CertType; |
53 | | |
54 | | |
55 | | |
56 | | static int |
57 | 0 | dissect_ns_cert_exts_BaseUrl(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
58 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
59 | 0 | actx, tree, tvb, offset, hf_index, |
60 | 0 | NULL); |
61 | |
|
62 | 0 | return offset; |
63 | 0 | } |
64 | | |
65 | | |
66 | | |
67 | | static int |
68 | 0 | dissect_ns_cert_exts_RevocationUrl(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
69 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
70 | 0 | actx, tree, tvb, offset, hf_index, |
71 | 0 | NULL); |
72 | |
|
73 | 0 | return offset; |
74 | 0 | } |
75 | | |
76 | | |
77 | | |
78 | | static int |
79 | 0 | dissect_ns_cert_exts_CaRevocationUrl(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
80 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
81 | 0 | actx, tree, tvb, offset, hf_index, |
82 | 0 | NULL); |
83 | |
|
84 | 0 | return offset; |
85 | 0 | } |
86 | | |
87 | | |
88 | | |
89 | | static int |
90 | 0 | dissect_ns_cert_exts_CaPolicyUrl(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
91 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
92 | 0 | actx, tree, tvb, offset, hf_index, |
93 | 0 | NULL); |
94 | |
|
95 | 0 | return offset; |
96 | 0 | } |
97 | | |
98 | | |
99 | | |
100 | | static int |
101 | 0 | dissect_ns_cert_exts_Comment(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
102 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
103 | 0 | actx, tree, tvb, offset, hf_index, |
104 | 0 | NULL); |
105 | |
|
106 | 0 | return offset; |
107 | 0 | } |
108 | | |
109 | | |
110 | | |
111 | | static int |
112 | 0 | dissect_ns_cert_exts_SslServerName(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
113 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
114 | 0 | actx, tree, tvb, offset, hf_index, |
115 | 0 | NULL); |
116 | |
|
117 | 0 | return offset; |
118 | 0 | } |
119 | | |
120 | | |
121 | | |
122 | | static int |
123 | 0 | dissect_ns_cert_exts_CertRenewalUrl(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
124 | 0 | offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String, |
125 | 0 | actx, tree, tvb, offset, hf_index, |
126 | 0 | NULL); |
127 | |
|
128 | 0 | return offset; |
129 | 0 | } |
130 | | |
131 | | |
132 | | static int * const CertType_bits[] = { |
133 | | &hf_ns_cert_exts_CertType_ssl_client, |
134 | | &hf_ns_cert_exts_CertType_ssl_server, |
135 | | &hf_ns_cert_exts_CertType_smime, |
136 | | &hf_ns_cert_exts_CertType_object_signing, |
137 | | &hf_ns_cert_exts_CertType_reserved_for_future_use, |
138 | | &hf_ns_cert_exts_CertType_ssl_ca, |
139 | | &hf_ns_cert_exts_CertType_smime_ca, |
140 | | &hf_ns_cert_exts_CertType_object_signing_ca, |
141 | | NULL |
142 | | }; |
143 | | |
144 | | static int |
145 | 0 | dissect_ns_cert_exts_CertType(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
146 | 0 | offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset, |
147 | 0 | CertType_bits, 8, hf_index, ett_ns_cert_exts_CertType, |
148 | 0 | NULL); |
149 | |
|
150 | 0 | return offset; |
151 | 0 | } |
152 | | |
153 | | /*--- PDUs ---*/ |
154 | | |
155 | 0 | static int dissect_BaseUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
156 | 0 | int offset = 0; |
157 | 0 | asn1_ctx_t asn1_ctx; |
158 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
159 | 0 | offset = dissect_ns_cert_exts_BaseUrl(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_BaseUrl_PDU); |
160 | 0 | return offset; |
161 | 0 | } |
162 | 0 | static int dissect_RevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
163 | 0 | int offset = 0; |
164 | 0 | asn1_ctx_t asn1_ctx; |
165 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
166 | 0 | offset = dissect_ns_cert_exts_RevocationUrl(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_RevocationUrl_PDU); |
167 | 0 | return offset; |
168 | 0 | } |
169 | 0 | static int dissect_CaRevocationUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
170 | 0 | int offset = 0; |
171 | 0 | asn1_ctx_t asn1_ctx; |
172 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
173 | 0 | offset = dissect_ns_cert_exts_CaRevocationUrl(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_CaRevocationUrl_PDU); |
174 | 0 | return offset; |
175 | 0 | } |
176 | 0 | static int dissect_CaPolicyUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
177 | 0 | int offset = 0; |
178 | 0 | asn1_ctx_t asn1_ctx; |
179 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
180 | 0 | offset = dissect_ns_cert_exts_CaPolicyUrl(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_CaPolicyUrl_PDU); |
181 | 0 | return offset; |
182 | 0 | } |
183 | 0 | static int dissect_Comment_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
184 | 0 | int offset = 0; |
185 | 0 | asn1_ctx_t asn1_ctx; |
186 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
187 | 0 | offset = dissect_ns_cert_exts_Comment(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_Comment_PDU); |
188 | 0 | return offset; |
189 | 0 | } |
190 | 0 | static int dissect_SslServerName_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
191 | 0 | int offset = 0; |
192 | 0 | asn1_ctx_t asn1_ctx; |
193 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
194 | 0 | offset = dissect_ns_cert_exts_SslServerName(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_SslServerName_PDU); |
195 | 0 | return offset; |
196 | 0 | } |
197 | 0 | static int dissect_CertRenewalUrl_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
198 | 0 | int offset = 0; |
199 | 0 | asn1_ctx_t asn1_ctx; |
200 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
201 | 0 | offset = dissect_ns_cert_exts_CertRenewalUrl(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_CertRenewalUrl_PDU); |
202 | 0 | return offset; |
203 | 0 | } |
204 | 0 | static int dissect_CertType_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
205 | 0 | int offset = 0; |
206 | 0 | asn1_ctx_t asn1_ctx; |
207 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
208 | 0 | offset = dissect_ns_cert_exts_CertType(false, tvb, offset, &asn1_ctx, tree, hf_ns_cert_exts_CertType_PDU); |
209 | 0 | return offset; |
210 | 0 | } |
211 | | |
212 | | |
213 | | |
214 | | /*--- proto_register_ns_cert_exts -------------------------------------------*/ |
215 | 14 | void proto_register_ns_cert_exts(void) { |
216 | | |
217 | | /* List of fields */ |
218 | 14 | static hf_register_info hf[] = { |
219 | 14 | { &hf_ns_cert_exts_BaseUrl_PDU, |
220 | 14 | { "BaseUrl", "ns_cert_exts.BaseUrl", |
221 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
222 | 14 | NULL, HFILL }}, |
223 | 14 | { &hf_ns_cert_exts_RevocationUrl_PDU, |
224 | 14 | { "RevocationUrl", "ns_cert_exts.RevocationUrl", |
225 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
226 | 14 | NULL, HFILL }}, |
227 | 14 | { &hf_ns_cert_exts_CaRevocationUrl_PDU, |
228 | 14 | { "CaRevocationUrl", "ns_cert_exts.CaRevocationUrl", |
229 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
230 | 14 | NULL, HFILL }}, |
231 | 14 | { &hf_ns_cert_exts_CaPolicyUrl_PDU, |
232 | 14 | { "CaPolicyUrl", "ns_cert_exts.CaPolicyUrl", |
233 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
234 | 14 | NULL, HFILL }}, |
235 | 14 | { &hf_ns_cert_exts_Comment_PDU, |
236 | 14 | { "Comment", "ns_cert_exts.Comment", |
237 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
238 | 14 | NULL, HFILL }}, |
239 | 14 | { &hf_ns_cert_exts_SslServerName_PDU, |
240 | 14 | { "SslServerName", "ns_cert_exts.SslServerName", |
241 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
242 | 14 | NULL, HFILL }}, |
243 | 14 | { &hf_ns_cert_exts_CertRenewalUrl_PDU, |
244 | 14 | { "CertRenewalUrl", "ns_cert_exts.CertRenewalUrl", |
245 | 14 | FT_STRING, BASE_NONE, NULL, 0, |
246 | 14 | NULL, HFILL }}, |
247 | 14 | { &hf_ns_cert_exts_CertType_PDU, |
248 | 14 | { "CertType", "ns_cert_exts.CertType", |
249 | 14 | FT_BYTES, BASE_NONE, NULL, 0, |
250 | 14 | NULL, HFILL }}, |
251 | 14 | { &hf_ns_cert_exts_CertType_ssl_client, |
252 | 14 | { "ssl-client", "ns.cert.exts.CertType.ssl.client", |
253 | 14 | FT_BOOLEAN, 8, NULL, 0x80, |
254 | 14 | NULL, HFILL }}, |
255 | 14 | { &hf_ns_cert_exts_CertType_ssl_server, |
256 | 14 | { "ssl-server", "ns.cert.exts.CertType.ssl.server", |
257 | 14 | FT_BOOLEAN, 8, NULL, 0x40, |
258 | 14 | NULL, HFILL }}, |
259 | 14 | { &hf_ns_cert_exts_CertType_smime, |
260 | 14 | { "smime", "ns.cert.exts.CertType.smime", |
261 | 14 | FT_BOOLEAN, 8, NULL, 0x20, |
262 | 14 | NULL, HFILL }}, |
263 | 14 | { &hf_ns_cert_exts_CertType_object_signing, |
264 | 14 | { "object-signing", "ns.cert.exts.CertType.object.signing", |
265 | 14 | FT_BOOLEAN, 8, NULL, 0x10, |
266 | 14 | NULL, HFILL }}, |
267 | 14 | { &hf_ns_cert_exts_CertType_reserved_for_future_use, |
268 | 14 | { "reserved-for-future-use", "ns.cert.exts.CertType.reserved.for.future.use", |
269 | 14 | FT_BOOLEAN, 8, NULL, 0x08, |
270 | 14 | NULL, HFILL }}, |
271 | 14 | { &hf_ns_cert_exts_CertType_ssl_ca, |
272 | 14 | { "ssl-ca", "ns.cert.exts.CertType.ssl.ca", |
273 | 14 | FT_BOOLEAN, 8, NULL, 0x04, |
274 | 14 | NULL, HFILL }}, |
275 | 14 | { &hf_ns_cert_exts_CertType_smime_ca, |
276 | 14 | { "smime-ca", "ns.cert.exts.CertType.smime.ca", |
277 | 14 | FT_BOOLEAN, 8, NULL, 0x02, |
278 | 14 | NULL, HFILL }}, |
279 | 14 | { &hf_ns_cert_exts_CertType_object_signing_ca, |
280 | 14 | { "object-signing-ca", "ns.cert.exts.CertType.object.signing.ca", |
281 | 14 | FT_BOOLEAN, 8, NULL, 0x01, |
282 | 14 | NULL, HFILL }}, |
283 | 14 | }; |
284 | | |
285 | | /* List of subtrees */ |
286 | 14 | static int *ett[] = { |
287 | 14 | &ett_ns_cert_exts_CertType, |
288 | 14 | }; |
289 | | |
290 | | /* Register protocol */ |
291 | 14 | proto_ns_cert_exts = proto_register_protocol(PNAME, PSNAME, PFNAME); |
292 | | |
293 | | /* Register fields and subtrees */ |
294 | 14 | proto_register_field_array(proto_ns_cert_exts, hf, array_length(hf)); |
295 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
296 | | |
297 | 14 | } |
298 | | |
299 | | |
300 | | /*--- proto_reg_handoff_ns_cert_exts ---------------------------------------*/ |
301 | 14 | void proto_reg_handoff_ns_cert_exts(void) { |
302 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.1", dissect_CertType_PDU, proto_ns_cert_exts, "ns_cert_exts.cert_type"); |
303 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.2", dissect_BaseUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.base_url"); |
304 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.3", dissect_RevocationUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.revocation-url"); |
305 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.4", dissect_CaRevocationUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.ca-revocation-url"); |
306 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.7", dissect_CertRenewalUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.cert-renewal-url"); |
307 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.8", dissect_CaPolicyUrl_PDU, proto_ns_cert_exts, "ns_cert_exts.ca-policy-url"); |
308 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.12", dissect_SslServerName_PDU, proto_ns_cert_exts, "ns_cert_exts.ssl-server-name"); |
309 | 14 | register_ber_oid_dissector("2.16.840.1.113730.1.13", dissect_Comment_PDU, proto_ns_cert_exts, "ns_cert_exts.comment"); |
310 | | |
311 | 14 | } |
312 | | |