X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/b4e566689f469cc1cffe99e50e16a346d0f9832d..ccc6adcdf6cf0744132bffa36f4b0175396c97f9:/ethereal/packet-tripe.c diff --git a/ethereal/packet-tripe.c b/ethereal/packet-tripe.c index 4b4e0ace..afeb1bcc 100644 --- a/ethereal/packet-tripe.c +++ b/ethereal/packet-tripe.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: packet-tripe.c,v 1.3 2004/04/08 01:36:17 mdw Exp $ + * $Id: packet-tripe.c,v 1.4 2004/04/18 18:08:11 mdw Exp $ * * TrIPE protocol dissector for Ethereal * @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef ETHEREAL_BUGGERED # define plugin_address_table_t void @@ -53,6 +54,8 @@ static int proto_tripe = -1; +static guint hashsz = 20, tagsz = 10, ivsz = 8; + typedef struct hfmp { int hf, hf_len, hf_val, tt; } hfmp; @@ -65,8 +68,8 @@ static int hf_tripe_packet_type = -1; static int hf_tripe_ct = -1; static int hf_tripe_ct_seq = -1; static int hf_tripe_ct_iv = -1; -static int hf_tripe_ct_cbc = -1; -static int hf_tripe_ct_mac = -1; +static int hf_tripe_ct_ct = -1; +static int hf_tripe_ct_tag = -1; static int hf_tripe_kx_type = -1; static hfge hf_tripe_kx_mychal = { -1, -1, -1, -1, -1, -1, -1, -1 }; static int hf_tripe_kx_mycookie = -1; @@ -81,10 +84,12 @@ G_MODULE_EXPORT const gchar version[] = VERSION; /*----- Main code ---------------------------------------------------------*/ +static void prefcb(void) { } + static gint gethash(proto_tree *tt, int hf, tvbuff_t *b, gint off) { - proto_tree_add_item(tt, hf, b, off, 20, FALSE); - return (off + 20); + proto_tree_add_item(tt, hf, b, off, hashsz, FALSE); + return (off + hashsz); } static gint getmp(proto_tree *tt, const hfmp *hf, tvbuff_t *b, gint off) @@ -246,17 +251,21 @@ static void dissect_tripe(tvbuff_t *b, packet_info *p, proto_tree *t) goto done; ct: ti = proto_tree_add_item(tt, hf_tripe_ct, b, off, -1, FALSE); - seq = tvb_get_ntohl(b, off + 10); + seq = tvb_get_ntohl(b, off + tagsz); proto_item_set_text(ti, "Encrypted ciphertext (sequence number %lu)", (unsigned long)seq); tt = proto_item_add_subtree(ti, tt_tripe_ct); - proto_tree_add_item(tt, hf_tripe_ct_mac, b, off, 10, FALSE); - off += 10; + if (tagsz) { + proto_tree_add_item(tt, hf_tripe_ct_tag, b, off, tagsz, FALSE); + off += tagsz; + } proto_tree_add_item(tt, hf_tripe_ct_seq, b, off, 4, FALSE); off += 4; - proto_tree_add_item(tt, hf_tripe_ct_iv, b, off, 8, FALSE); - off += 8; - proto_tree_add_item(ti, hf_tripe_ct_cbc, b, off, -1, FALSE); + if (ivsz) { + proto_tree_add_item(tt, hf_tripe_ct_iv, b, off, ivsz, FALSE); + off += ivsz; + } + proto_tree_add_item(ti, hf_tripe_ct_ct, b, off, -1, FALSE); goto done; done:; } @@ -264,6 +273,8 @@ static void dissect_tripe(tvbuff_t *b, packet_info *p, proto_tree *t) void proto_register_tripe(void) { + module_t *mod; + static value_string vs_kxtype[] = { { KX_PRECHAL, "KX_PRECHAL (prechallenge)" }, { KX_COOKIE, "KX_COOKIE (cookie)" }, @@ -299,15 +310,15 @@ void proto_register_tripe(void) FT_BYTES, BASE_NONE, 0, 0, "This is the initialization vector used for the actual encryption." }, - &hf_tripe_ct_cbc, { - "CBC-encrypted data", "tripe.ct.cbc", + &hf_tripe_ct_ct, { + "Actual encrypted data", "tripe.ct.ct", FT_BYTES, BASE_NONE, 0, 0, - "This is the CBC-encrypted message. Reading it ought to be hard." + "This is the encrypted message. Reading it ought to be hard." }, - &hf_tripe_ct_mac, { - "Message authentication code", "tripe.ct.mac", + &hf_tripe_ct_tag, { + "Message authentication code", "tripe.ct.tag", FT_BYTES, BASE_NONE, 0, 0, - "This is the message authentication code for the ciphertext." + "This is the message authentication code tag for the ciphertext." }, &hf_tripe_kx_type, { "Key-exchange message type", "tripe.kx.type", @@ -392,6 +403,17 @@ void proto_register_tripe(void) proto_tripe = proto_register_protocol("TrIPE", "TrIPE", "tripe"); proto_register_field_array(proto_tripe, hfs, array_length(hfs)); proto_register_subtree_array(tts, array_length(tts)); + + mod = prefs_register_protocol(proto_tripe, prefcb); + prefs_register_uint_preference(mod, "hashsz", "Hash length", + "hash function output length (in octets)", + 10, &hashsz); + prefs_register_uint_preference(mod, "tagsz", "MAC tag length", + "MAC tag length (in octets)", 10, &tagsz); + prefs_register_uint_preference(mod, "ivsz", "IV length", + "block cipher initialization vector length" + " (in octets)", + 10, &ivsz); } void proto_reg_handoff_tripe(void)