/src/wireshark/epan/dissectors/packet-app-pkix-cert.c
Line | Count | Source |
1 | | /* packet-app-pkix-cert.c |
2 | | * |
3 | | * Routines for application/pkix-cert media dissection |
4 | | * Copyright 2004, Yaniv Kaul. |
5 | | * |
6 | | * Refer to the AUTHORS file or the AUTHORS section in the man page |
7 | | * for contacting the author(s) of this file. |
8 | | * |
9 | | * Wireshark - Network traffic analyzer |
10 | | * By Gerald Combs <gerald@wireshark.org> |
11 | | * Copyright 1998 Gerald Combs |
12 | | * |
13 | | * SPDX-License-Identifier: GPL-2.0-or-later |
14 | | */ |
15 | | |
16 | | |
17 | | #include "config.h" |
18 | | |
19 | | #include <epan/packet.h> |
20 | | #include <epan/asn1.h> |
21 | | #include "packet-x509af.h" |
22 | | |
23 | | |
24 | | void proto_register_cert(void); |
25 | | void proto_reg_handoff_cert(void); |
26 | | |
27 | | static dissector_handle_t cert_handle; |
28 | | |
29 | | /* Initialize the protocol and registered fields */ |
30 | | static int proto_cert; |
31 | | |
32 | | static int hf_cert; |
33 | | |
34 | | /* Initialize the subtree pointers */ |
35 | | static int ett_cert; |
36 | | |
37 | | |
38 | | static int |
39 | | dissect_cert(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
40 | 0 | { |
41 | 0 | proto_tree *subtree = NULL; |
42 | 0 | proto_item *ti; |
43 | 0 | asn1_ctx_t asn1_ctx; |
44 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
45 | |
|
46 | 0 | col_append_sep_str(pinfo->cinfo, COL_INFO, " ", "(application/pkix-cert)"); |
47 | |
|
48 | 0 | if (tree) { |
49 | 0 | ti = proto_tree_add_item(tree, proto_cert, tvb, 0, -1, ENC_NA); |
50 | 0 | subtree = proto_item_add_subtree(ti, ett_cert); |
51 | 0 | } |
52 | |
|
53 | 0 | dissect_x509af_Certificate(false, tvb, 0, &asn1_ctx, subtree, hf_cert); |
54 | 0 | return tvb_captured_length(tvb); |
55 | 0 | } |
56 | | |
57 | | |
58 | | /****************** Register the protocol with Wireshark ******************/ |
59 | | |
60 | | |
61 | | /* This format is required because a script is used to build the C function |
62 | | * that calls the protocol registration. */ |
63 | | |
64 | | void |
65 | | proto_register_cert(void) |
66 | 14 | { |
67 | | /* |
68 | | * Setup list of header fields. |
69 | | */ |
70 | 14 | static hf_register_info hf[] = { |
71 | 14 | { &hf_cert, |
72 | 14 | { "Certificate", "pkix-cert.cert", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL}}, |
73 | 14 | }; |
74 | | |
75 | | /* Setup protocol subtree array */ |
76 | 14 | static int *ett[] = { |
77 | 14 | &ett_cert, |
78 | 14 | }; |
79 | | |
80 | | /* Register the protocol name and description */ |
81 | 14 | proto_cert = proto_register_protocol("PKIX CERT File Format", "PKIX Certificate", "pkix-cert"); |
82 | | |
83 | | /* Required function calls to register the header fields |
84 | | * and subtrees used */ |
85 | 14 | proto_register_field_array(proto_cert, hf, array_length(hf)); |
86 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
87 | | |
88 | 14 | cert_handle = register_dissector("pkix-cert", dissect_cert, proto_cert); |
89 | 14 | } |
90 | | |
91 | | |
92 | | void |
93 | | proto_reg_handoff_cert(void) |
94 | 14 | { |
95 | | /* Register the PKIX-CERT media type */ |
96 | 14 | dissector_add_string("media_type", "application/pkix-cert", cert_handle); |
97 | 14 | } |
98 | | |
99 | | /* |
100 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
101 | | * |
102 | | * Local variables: |
103 | | * c-basic-offset: 8 |
104 | | * tab-width: 8 |
105 | | * indent-tabs-mode: nil |
106 | | * End: |
107 | | * |
108 | | * vi: set shiftwidth=8 tabstop=8 expandtab: |
109 | | * :indentSize=8:tabSize=8:noTabs=true: |
110 | | */ |