2 * Routines for RFC 2634 and RFC 5035 Extended Security Services packet
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include <epan/asn1.h>
18 #include <epan/prefs.h>
20 #include <wsutil/array.h>
22 #include "packet-ber.h"
23 #include "packet-ess.h"
24 #include "packet-cms.h"
25 #include "packet-x509ce.h"
26 #include "packet-x509af.h"
28 #define PNAME "Extended Security Services"
32 void proto_register_ess(void);
33 void proto_reg_handoff_ess(void);
35 typedef struct _ess_category_attributes_t
{
39 } ess_category_attributes_t
;
41 static ess_category_attributes_t
*ess_category_attributes
;
42 static unsigned num_ess_category_attributes
;
44 /* Initialize the protocol and registered fields */
46 static int hf_ess_SecurityCategory_type_OID
;
47 static int hf_ess_Category_attribute
;
49 static int ett_Category_attributes
;
51 #include "packet-ess-hf.c"
53 #include "packet-ess-val.h"
55 /* Initialize the subtree pointers */
56 #include "packet-ess-ett.c"
58 static const char *object_identifier_id
;
60 UAT_CSTRING_CB_DEF(ess_category_attributes
, oid
, ess_category_attributes_t
)
61 UAT_DEC_CB_DEF(ess_category_attributes
, lacv
, ess_category_attributes_t
)
62 UAT_CSTRING_CB_DEF(ess_category_attributes
, name
, ess_category_attributes_t
)
65 ess_copy_cb(void *dest
, const void *orig
, size_t len _U_
)
67 ess_category_attributes_t
*u
= (ess_category_attributes_t
*)dest
;
68 const ess_category_attributes_t
*o
= (const ess_category_attributes_t
*)orig
;
70 u
->oid
= g_strdup(o
->oid
);
72 u
->name
= g_strdup(o
->name
);
80 ess_category_attributes_t
*u
= (ess_category_attributes_t
*)r
;
87 ess_dissect_attribute (uint32_t value
, asn1_ctx_t
*actx
)
91 for (i
= 0; i
< num_ess_category_attributes
; i
++) {
92 ess_category_attributes_t
*u
= &(ess_category_attributes
[i
]);
94 if ((strcmp (u
->oid
, object_identifier_id
) == 0) &&
97 proto_item_append_text (actx
->created_item
, " (%s)", u
->name
);
104 ess_dissect_attribute_flags (tvbuff_t
*tvb
, asn1_ctx_t
*actx
)
110 tree
= proto_item_add_subtree (actx
->created_item
, ett_Category_attributes
);
111 value
= (uint8_t *)tvb_memdup (actx
->pinfo
->pool
, tvb
, 0, tvb_captured_length (tvb
));
113 for (i
= 0; i
< num_ess_category_attributes
; i
++) {
114 ess_category_attributes_t
*u
= &(ess_category_attributes
[i
]);
116 if ((strcmp (u
->oid
, object_identifier_id
) == 0) &&
117 ((u
->lacv
/ 8) < tvb_captured_length (tvb
)) &&
118 (value
[u
->lacv
/ 8] & (1U << (7 - (u
->lacv
% 8)))))
120 proto_tree_add_string_format (tree
, hf_ess_Category_attribute
, tvb
,
121 u
->lacv
/ 8, 1, u
->name
,
122 "%s (%d)", u
->name
, u
->lacv
);
127 #include "packet-ess-fn.c"
129 /*--- proto_register_ess ----------------------------------------------*/
130 void proto_register_ess(void) {
133 static hf_register_info hf
[] = {
134 { &hf_ess_SecurityCategory_type_OID
,
135 { "type", "ess.type_OID", FT_STRING
, BASE_NONE
, NULL
, 0,
136 "Type of Security Category", HFILL
}},
137 { &hf_ess_Category_attribute
,
138 { "Attribute", "ess.attribute", FT_STRING
, BASE_NONE
, NULL
, 0,
140 #include "packet-ess-hfarr.c"
143 /* List of subtrees */
144 static int *ett
[] = {
145 &ett_Category_attributes
,
146 #include "packet-ess-ettarr.c"
149 static uat_field_t attributes_flds
[] = {
150 UAT_FLD_CSTRING(ess_category_attributes
,oid
, "Tag Set", "Category Tag Set (Object Identifier)"),
151 UAT_FLD_DEC(ess_category_attributes
,lacv
, "Value", "Label And Cert Value"),
152 UAT_FLD_CSTRING(ess_category_attributes
,name
, "Name", "Category Name"),
156 uat_t
*attributes_uat
= uat_new("ESS Category Attributes",
157 sizeof(ess_category_attributes_t
),
158 "ess_category_attributes",
160 &ess_category_attributes
,
161 &num_ess_category_attributes
,
162 UAT_AFFECTS_DISSECTION
, /* affects dissection of packets, but not set of named fields */
163 "ChEssCategoryAttributes",
171 static module_t
*ess_module
;
173 /* Register protocol */
174 proto_ess
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
176 /* Register fields and subtrees */
177 proto_register_field_array(proto_ess
, hf
, array_length(hf
));
178 proto_register_subtree_array(ett
, array_length(ett
));
180 ess_module
= prefs_register_protocol(proto_ess
, NULL
);
182 prefs_register_uat_preference(ess_module
, "attributes_table",
183 "ESS Category Attributes",
184 "ESS category attributes translation table",
190 /*--- proto_reg_handoff_ess -------------------------------------------*/
191 void proto_reg_handoff_ess(void) {
192 #include "packet-ess-dis-tab.c"