/* -*-c-*-
*
- * $Id: packet-tripe.c,v 1.1 2003/10/15 09:30:19 mdw Exp $
+ * $Id: packet-tripe.c,v 1.2 2004/04/03 12:35:13 mdw Exp $
*
* TrIPE protocol dissector for Ethereal
*
/*----- Revision history --------------------------------------------------*
*
* $Log: packet-tripe.c,v $
+ * Revision 1.2 2004/04/03 12:35:13 mdw
+ * Support elliptic curve key exchange.
+ *
* Revision 1.1 2003/10/15 09:30:19 mdw
* Add support for Ethereal protocol analysis.
*
static int proto_tripe = -1;
-typedef struct hfmp { int hf, hf_len, hf_val, tt; } hfmp;
+typedef struct hfmp {
+ int hf, hf_len, hf_val, tt;
+} hfmp;
+typedef struct hfge {
+ int hf, hf_len, hf_val, hfx_len, hfx_val, hfy_len, hfy_val, tt;
+} hfge;
static int hf_tripe_cat = -1;
static int hf_tripe_packet_type = -1;
static int hf_tripe_ct_cbc = -1;
static int hf_tripe_ct_mac = -1;
static int hf_tripe_kx_type = -1;
-static hfmp hf_tripe_kx_mychal = { -1, -1, -1, -1 };
+static hfge hf_tripe_kx_mychal = { -1, -1, -1, -1, -1, -1, -1, -1 };
static int hf_tripe_kx_mycookie = -1;
static int hf_tripe_kx_yourcookie = -1;
static hfmp hf_tripe_kx_check = { -1, -1, -1, -1 };
return (off + 2 + len);
}
+static gint getge(proto_tree *tt, const hfge *hf, tvbuff_t *b, gint off)
+{
+ guint16 len = tvb_get_ntohs(b, off), len2;
+ guint r;
+ proto_item *ti;
+ r = tvb_length_remaining(b, off);
+ if (r < 4 + len ||
+ (len2 = tvb_get_ntohs(b, off + 2 + len), r < 4 + len + len2)) {
+ ti = proto_tree_add_item(tt, hf->hf, b, off, len + 2, FALSE);
+ tt = proto_item_add_subtree(ti, hf->tt);
+ proto_tree_add_item(tt, hf->hf_len, b, off, 2, FALSE);
+ proto_tree_add_item(tt, hf->hf_val, b, off + 2, len, FALSE);
+ r = off + len + 2;
+ } else {
+ ti = proto_tree_add_item(tt, hf->hf, b, off, len + len2 + 4, FALSE);
+ tt = proto_item_add_subtree(ti, hf->tt);
+ proto_tree_add_item(tt, hf->hfx_len, b, off, 2, FALSE);
+ proto_tree_add_item(tt, hf->hfx_val, b, off + 2, len, FALSE);
+ proto_tree_add_item(tt, hf->hfy_len, b, off + 2 + len, 2, FALSE);
+ proto_tree_add_item(tt, hf->hfy_val, b, off + 4 + len, len2, FALSE);
+ r = off + len + len2 + 4;
+ }
+ return (r);
+}
+
static void dissect_tripe(tvbuff_t *b, packet_info *p, proto_tree *t)
{
proto_item *ti;
proto_tree_add_item(tt, hf_tripe_kx_type, b, 0, 1, FALSE);
switch (ty & MSG_TYPEMASK) {
case KX_PRECHAL:
- off = getmp(tt, &hf_tripe_kx_mychal, b, off);
+ off = getge(tt, &hf_tripe_kx_mychal, b, off);
goto tail;
case KX_COOKIE:
- off = getmp(tt, &hf_tripe_kx_mychal, b, off);
+ off = getge(tt, &hf_tripe_kx_mychal, b, off);
off = gethash(tt, hf_tripe_kx_yourcookie, b, off);
goto tail;
case KX_CHAL:
- off = getmp(tt, &hf_tripe_kx_mychal, b, off);
+ off = getge(tt, &hf_tripe_kx_mychal, b, off);
off = gethash(tt, hf_tripe_kx_yourcookie, b, off);
off = getmp(tt, &hf_tripe_kx_check, b, off);
goto tail;
&hf_tripe_kx_mychal.hf, {
"Sender's challenge data", "tripe.kx.mychal",
FT_BYTES, BASE_NONE, 0, 0,
- "This is the sender's challenge value."
+ "This is the sender's challenge."
},
&hf_tripe_kx_mychal.hf_len, {
"Challenge length", "tripe.kx.mychal.len",
FT_UINT16, BASE_DEC, 0, 0,
- "This is the length of the sender's challenge value."
+ "This is the length of the sender's challenge."
},
&hf_tripe_kx_mychal.hf_val, {
- "Challenge value", "tripe.kx.mychal.val",
+ "Challenge", "tripe.kx.mychal.val",
+ FT_BYTES, BASE_NONE, 0, 0,
+ "This is the value of the sender's challenge."
+ },
+ &hf_tripe_kx_mychal.hfx_len, {
+ "Challenge x length", "tripe.kx.mychal.x.len",
+ FT_UINT16, BASE_DEC, 0, 0,
+ "This is the length of the sender's challenge x-coordinate."
+ },
+ &hf_tripe_kx_mychal.hfy_val, {
+ "Challenge x value", "tripe.kx.mychal.x.val",
+ FT_BYTES, BASE_NONE, 0, 0,
+ "This is the value of the sender's challenge x-coordinate."
+ },
+ &hf_tripe_kx_mychal.hfy_len, {
+ "Challenge y length", "tripe.kx.mychal.y.len",
+ FT_UINT16, BASE_DEC, 0, 0,
+ "This is the length of the sender's challenge x-coordinate."
+ },
+ &hf_tripe_kx_mychal.hfx_val, {
+ "Challenge y value", "tripe.kx.mychal.y.val",
FT_BYTES, BASE_NONE, 0, 0,
- "This is the value of the sender's challenge value."
+ "This is the value of the sender's challenge x-coordinate."
},
&hf_tripe_kx_mycookie, {
"Sender's hashed cookie", "tripe.kx.mycookie",