2004-11-22 03:36:26 +00:00
|
|
|
/* packet-ess.c
|
2010-01-12 14:31:08 +00:00
|
|
|
* Routines for RFC5035 Extended Security Services packet dissection
|
2004-11-22 03:36:26 +00:00
|
|
|
* Ronnie Sahlberg 2004
|
2010-01-12 14:31:08 +00:00
|
|
|
* Stig Bjorlykke 2010
|
2004-11-22 03:36:26 +00:00
|
|
|
*
|
2005-08-02 05:21:19 +00:00
|
|
|
* $Id$
|
2004-11-22 03:36:26 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-11-22 03:36:26 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
2010-04-23 12:43:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-11-22 03:36:26 +00:00
|
|
|
#include <epan/packet.h>
|
2007-05-13 20:58:29 +00:00
|
|
|
#include <epan/asn1.h>
|
2010-04-23 12:43:14 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/uat.h>
|
2004-11-22 03:36:26 +00:00
|
|
|
|
|
|
|
#include "packet-ber.h"
|
|
|
|
#include "packet-ess.h"
|
|
|
|
#include "packet-cms.h"
|
|
|
|
#include "packet-x509ce.h"
|
|
|
|
#include "packet-x509af.h"
|
|
|
|
|
|
|
|
#define PNAME "Extended Security Services"
|
|
|
|
#define PSNAME "ESS"
|
|
|
|
#define PFNAME "ess"
|
|
|
|
|
2010-04-23 12:43:14 +00:00
|
|
|
typedef struct _ess_category_attributes_t {
|
|
|
|
char *oid;
|
|
|
|
guint lacv;
|
|
|
|
char *name;
|
|
|
|
} ess_category_attributes_t;
|
|
|
|
|
|
|
|
static ess_category_attributes_t *ess_category_attributes;
|
|
|
|
static guint num_ess_category_attributes;
|
|
|
|
|
2004-11-22 03:36:26 +00:00
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_ess = -1;
|
|
|
|
static int hf_ess_SecurityCategory_type_OID = -1;
|
2010-04-23 12:43:14 +00:00
|
|
|
static int hf_ess_Category_attribute = -1;
|
|
|
|
|
|
|
|
static gint ett_Category_attributes = -1;
|
|
|
|
|
2004-11-22 03:36:26 +00:00
|
|
|
#include "packet-ess-hf.c"
|
|
|
|
|
2010-01-12 14:31:08 +00:00
|
|
|
#include "packet-ess-val.h"
|
|
|
|
|
2004-11-22 03:36:26 +00:00
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
#include "packet-ess-ett.c"
|
|
|
|
|
2005-11-14 10:02:31 +00:00
|
|
|
static const char *object_identifier_id;
|
2004-11-22 03:36:26 +00:00
|
|
|
|
2010-04-23 12:43:14 +00:00
|
|
|
UAT_CSTRING_CB_DEF(ess_category_attributes, oid, ess_category_attributes_t);
|
|
|
|
UAT_DEC_CB_DEF(ess_category_attributes, lacv, ess_category_attributes_t);
|
|
|
|
UAT_CSTRING_CB_DEF(ess_category_attributes, name, ess_category_attributes_t);
|
2004-11-22 03:36:26 +00:00
|
|
|
|
2010-04-23 12:43:14 +00:00
|
|
|
static void *
|
2010-10-29 21:11:33 +00:00
|
|
|
ess_copy_cb(void *dest, const void *orig, size_t len _U_)
|
2010-04-23 12:43:14 +00:00
|
|
|
{
|
|
|
|
ess_category_attributes_t *u = dest;
|
|
|
|
const ess_category_attributes_t *o = orig;
|
|
|
|
|
|
|
|
u->oid = g_strdup(o->oid);
|
|
|
|
u->lacv = o->lacv;
|
|
|
|
u->name = g_strdup(o->name);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ess_free_cb(void *r)
|
|
|
|
{
|
|
|
|
ess_category_attributes_t *u = r;
|
|
|
|
|
|
|
|
g_free(u->oid);
|
|
|
|
g_free(u->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ess_dissect_attribute (guint32 value, asn1_ctx_t *actx)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_ess_category_attributes; i++) {
|
|
|
|
ess_category_attributes_t *u = &(ess_category_attributes[i]);
|
|
|
|
|
|
|
|
if ((strcmp (u->oid, object_identifier_id) == 0) &&
|
|
|
|
(u->lacv == value))
|
|
|
|
{
|
|
|
|
proto_item_append_text (actx->created_item, " (%s)", u->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx)
|
|
|
|
{
|
|
|
|
proto_tree *tree;
|
|
|
|
guint8 *value;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
tree = proto_item_add_subtree (actx->created_item, ett_Category_attributes);
|
|
|
|
value = tvb_get_ephemeral_string (tvb, 0, tvb_length (tvb));
|
|
|
|
|
|
|
|
for (i = 0; i < num_ess_category_attributes; i++) {
|
|
|
|
ess_category_attributes_t *u = &(ess_category_attributes[i]);
|
|
|
|
|
|
|
|
if ((strcmp (u->oid, object_identifier_id) == 0) &&
|
|
|
|
((u->lacv / 8) < tvb_length (tvb)) &&
|
2010-09-23 07:42:20 +00:00
|
|
|
(value[u->lacv / 8] & (1 << (7 - (u->lacv % 8)))))
|
2010-04-23 12:43:14 +00:00
|
|
|
{
|
|
|
|
proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb,
|
|
|
|
u->lacv / 8, 1, u->name,
|
|
|
|
"%s (%d)", u->name, u->lacv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "packet-ess-fn.c"
|
2004-11-22 03:36:26 +00:00
|
|
|
|
|
|
|
/*--- proto_register_ess ----------------------------------------------*/
|
|
|
|
void proto_register_ess(void) {
|
|
|
|
|
|
|
|
/* List of fields */
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_ess_SecurityCategory_type_OID,
|
|
|
|
{ "type", "ess.type_OID", FT_STRING, BASE_NONE, NULL, 0,
|
|
|
|
"Type of Security Category", HFILL }},
|
2010-04-23 12:43:14 +00:00
|
|
|
{ &hf_ess_Category_attribute,
|
|
|
|
{ "Attribute", "ess.attribute", FT_STRING, BASE_NONE, NULL, 0,
|
|
|
|
NULL, HFILL }},
|
2004-11-22 03:36:26 +00:00
|
|
|
#include "packet-ess-hfarr.c"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* List of subtrees */
|
|
|
|
static gint *ett[] = {
|
2010-04-23 12:43:14 +00:00
|
|
|
&ett_Category_attributes,
|
2004-11-22 03:36:26 +00:00
|
|
|
#include "packet-ess-ettarr.c"
|
|
|
|
};
|
2010-04-23 12:43:14 +00:00
|
|
|
|
|
|
|
static uat_field_t attributes_flds[] = {
|
|
|
|
UAT_FLD_CSTRING(ess_category_attributes,oid, "Tag Set", "Category Tag Set (Object Identifier)"),
|
|
|
|
UAT_FLD_DEC(ess_category_attributes,lacv, "Value", "Label And Cert Value"),
|
|
|
|
UAT_FLD_CSTRING(ess_category_attributes,name, "Name", "Category Name"),
|
|
|
|
UAT_END_FIELDS
|
|
|
|
};
|
|
|
|
|
|
|
|
uat_t *attributes_uat = uat_new("ESS Category Attributes",
|
|
|
|
sizeof(ess_category_attributes_t),
|
|
|
|
"ess_category_attributes",
|
|
|
|
TRUE,
|
2010-05-02 12:32:52 +00:00
|
|
|
(void*) &ess_category_attributes,
|
2010-04-23 12:43:14 +00:00
|
|
|
&num_ess_category_attributes,
|
|
|
|
UAT_CAT_PORTS,
|
|
|
|
"ChEssCategoryAttributes",
|
|
|
|
ess_copy_cb,
|
|
|
|
NULL,
|
|
|
|
ess_free_cb,
|
|
|
|
NULL,
|
|
|
|
attributes_flds);
|
|
|
|
|
|
|
|
static module_t *ess_module;
|
2004-11-22 03:36:26 +00:00
|
|
|
|
|
|
|
/* Register protocol */
|
|
|
|
proto_ess = proto_register_protocol(PNAME, PSNAME, PFNAME);
|
|
|
|
|
|
|
|
/* Register fields and subtrees */
|
|
|
|
proto_register_field_array(proto_ess, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2010-04-23 12:43:14 +00:00
|
|
|
|
|
|
|
ess_module = prefs_register_protocol(proto_ess, NULL);
|
|
|
|
|
|
|
|
prefs_register_uat_preference(ess_module, "attributes_table",
|
|
|
|
"ESS Category Attributes",
|
|
|
|
"ESS category attributes translation table",
|
|
|
|
attributes_uat);
|
2004-11-22 03:36:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--- proto_reg_handoff_ess -------------------------------------------*/
|
|
|
|
void proto_reg_handoff_ess(void) {
|
|
|
|
#include "packet-ess-dis-tab.c"
|
|
|
|
}
|
|
|
|
|