sq more...
[metze/wireshark/wip.git] / krb5-1.6-wireshark-hack-01.diff
1 Index: lib/crypto/dk/dk_decrypt.c
2 ===================================================================
3 --- lib/crypto/dk/dk_decrypt.c  (Revision 22448)
4 +++ lib/crypto/dk/dk_decrypt.c  (Arbeitskopie)
5 @@ -155,7 +155,8 @@
6             abort();
7      } else
8         cn = NULL;
9 -
10 +{
11 +int bad = 0;
12      /* verify the hash */
13
14      d1.length = hashsize;
15 @@ -165,8 +166,11 @@
16         goto cleanup;
17
18      if (memcmp(cksum, input->data+enclen, hmacsize) != 0) {
19 +bad = 1;
20 +/*
21         ret = KRB5KRB_AP_ERR_BAD_INTEGRITY;
22         goto cleanup;
23 +*/
24      }
25
26      /* because this encoding isn't self-describing wrt length, the
27 @@ -182,6 +186,29 @@
28
29      memcpy(output->data, d2.data+blocksize, output->length);
30
31 +    if (bad != 0 && output->length > 16) {
32 +       /*
33 +        * HACK:
34 +        * This is a HACK to allow Wireshark to decrypt DCERPC
35 +        * payload when header signing is used.
36 +        *
37 +        * We know the checksum was wrong, this happens
38 +        * when DCERPC uses header signing and we check for
39 +        * a valid gss_cfx_wrap_token header which is 16 byte long
40 +        * and starts with 0x05 0x04 and sits at the end of the
41 +        * encrypted data.
42 +        */
43 +       unsigned char *hdr = output->data + (output->length - 16);
44 +       if (hdr[0] == 0x05 && hdr[1] == 0x04) {
45 +               bad = 0;
46 +       }
47 +    }
48 +
49 +    if (bad != 0) {
50 +       ret = KRB5KRB_AP_ERR_BAD_INTEGRITY;
51 +       goto cleanup;
52 +    }
53 +}
54      if (cn != NULL)
55         memcpy(ivec->data, cn, blocksize);