aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2006-01-13 04:35:10 +0000
committerJörg Mayer <jmayer@loplof.de>2006-01-13 04:35:10 +0000
commit96576bbb3e2a4b9752d4c29d53802dc0dc6da0ce (patch)
treebc518298fca8797d3cbd3c034378d84642a9c29a
parent545110c9391c6e7f8a81bab9c8eb70101f12399e (diff)
downloadwireshark-96576bbb3e2a4b9752d4c29d53802dc0dc6da0ce.tar.gz
wireshark-96576bbb3e2a4b9752d4c29d53802dc0dc6da0ce.tar.bz2
wireshark-96576bbb3e2a4b9752d4c29d53802dc0dc6da0ce.zip
Add code to verify the shared secret for documentation purposes.
#if 0 that code. svn path=/trunk/; revision=17026
-rw-r--r--epan/dissectors/packet-3com-njack.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/epan/dissectors/packet-3com-njack.c b/epan/dissectors/packet-3com-njack.c
index e9f2b6b03b..e7912d99cf 100644
--- a/epan/dissectors/packet-3com-njack.c
+++ b/epan/dissectors/packet-3com-njack.c
@@ -27,7 +27,6 @@
/*
TODO:
- Find out lots more values :-)
- - Find out set authentication mechanism, offer verification option
- Support for other 3com devices that use the same protocol
- Do any devices use TCP or different ports?
- Sanity checks for tlv_length depending on tlv_type
@@ -506,6 +505,58 @@ dissect_tlvs(tvbuff_t *tvb, proto_tree *njack_tree, guint32 offset)
return offset;
}
+#if 0
+#include <epan/crypt-md5.h>
+
+static gboolean
+verify_password(tvbuff_t *tvb, const char *password)
+{
+ /* 1. pad non-terminated password-string to a length of 32 bytes
+ * (padding: 0x01, 0x02, 0x03...)
+ * 2. Calculate MD5 of padded password and write it to offset 12 of packet
+ * 3. Calculate MD5 of resulting packet and write it to offset 12 of packet
+ */
+
+ gboolean is_valid = TRUE;
+ const guint8 *packetdata;
+ guint32 length;
+ guint8 workbuffer[32];
+ guint i;
+ guint8 byte;
+ md5_state_t md_ctx;
+ md5_byte_t digest[16];
+
+
+ length = tvb_get_ntohs(tvb, 6);
+ packetdata = tvb_get_ptr(tvb, 0, length);
+ for (i = 0; i<32 && *password; i++, password++) {
+ workbuffer[i] = *password;
+ }
+ for (byte = 1; i<32; i++, byte++) {
+ workbuffer[i] = byte;
+ }
+ md5_init(&md_ctx);
+ md5_append(&md_ctx, workbuffer, 32);
+ md5_finish(&md_ctx, digest);
+ md5_init(&md_ctx);
+ md5_append(&md_ctx, packetdata, 12);
+ md5_append(&md_ctx, digest, 16);
+ md5_append(&md_ctx, packetdata + 28, length - 28);
+ md5_finish(&md_ctx, digest);
+ fprintf(stderr, "Calclulated digest: "); //debugging
+ for (i = 0; i < 16; i++) {
+ fprintf(stderr, "%02X", digest[i]); //debugging
+ if (digest[i] != *(packetdata + 12 + i)) {
+ is_valid = FALSE;
+ break;
+ }
+ }
+ fprintf(stderr, " (%d)\n", is_valid); //debugging
+
+ return is_valid;
+}
+#endif
+
static int
dissect_njack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{