1 /* packet-app-pkix-cert.c
3 * Routines for application/pkix-cert media dissection
4 * Copyright 2004, Yaniv Kaul.
6 * Refer to the AUTHORS file or the AUTHORS section in the man page
7 * for contacting the author(s) of this file.
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/asn1.h>
21 #include "packet-x509af.h"
24 void proto_register_cert(void);
25 void proto_reg_handoff_cert(void);
27 static dissector_handle_t cert_handle
;
29 /* Initialize the protocol and registered fields */
30 static int proto_cert
;
34 /* Initialize the subtree pointers */
39 dissect_cert(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
41 proto_tree
*subtree
= NULL
;
44 asn1_ctx_init(&asn1_ctx
, ASN1_ENC_BER
, true, pinfo
);
46 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, " ", "(application/pkix-cert)");
49 ti
= proto_tree_add_item(tree
, proto_cert
, tvb
, 0, -1, ENC_NA
);
50 subtree
= proto_item_add_subtree(ti
, ett_cert
);
53 dissect_x509af_Certificate(false, tvb
, 0, &asn1_ctx
, subtree
, hf_cert
);
54 return tvb_captured_length(tvb
);
58 /****************** Register the protocol with Wireshark ******************/
61 /* This format is required because a script is used to build the C function
62 * that calls the protocol registration. */
65 proto_register_cert(void)
68 * Setup list of header fields.
70 static hf_register_info hf
[] = {
72 { "Certificate", "pkix-cert.cert", FT_NONE
, BASE_NONE
, NULL
, 0x00, NULL
, HFILL
}},
75 /* Setup protocol subtree array */
80 /* Register the protocol name and description */
81 proto_cert
= proto_register_protocol("PKIX CERT File Format", "PKIX Certificate", "pkix-cert");
83 /* Required function calls to register the header fields
84 * and subtrees used */
85 proto_register_field_array(proto_cert
, hf
, array_length(hf
));
86 proto_register_subtree_array(ett
, array_length(ett
));
88 cert_handle
= register_dissector("pkix-cert", dissect_cert
, proto_cert
);
93 proto_reg_handoff_cert(void)
95 /* Register the PKIX-CERT media type */
96 dissector_add_string("media_type", "application/pkix-cert", cert_handle
);
100 * Editor modelines - https://www.wireshark.org/tools/modelines.html
105 * indent-tabs-mode: nil
108 * vi: set shiftwidth=8 tabstop=8 expandtab:
109 * :indentSize=8:tabSize=8:noTabs=true: