checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / epan / dissectors / packet-dcerpc-krb5rpc.c
1 /* packet-dcerpc-krb5rpc.c
2  *
3  * Routines for dcerpc DCE/KRB5 interface
4  * Copyright 2002, Jaime Fournier <Jaime.Fournier@hush.com>
5  * This information is based off the released idl files from opengroup.
6  * ftp://ftp.opengroup.org/pub/dce122/dce/src/security.tar.gz security/idl/krb5rpc.idl
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * SPDX-License-Identifier: GPL-2.0-or-later
13  */
14
15 #include "config.h"
16
17
18 #include <epan/packet.h>
19 #include <epan/asn1.h>
20 #include "packet-dcerpc.h"
21 #include "packet-kerberos.h"
22
23 void proto_register_krb5rpc (void);
24 void proto_reg_handoff_krb5rpc (void);
25
26 static int proto_krb5rpc = -1;
27
28 static gint ett_krb5rpc = -1;
29
30
31 static e_guid_t uuid_krb5rpc =
32   { 0x8f73de50, 0x768c, 0x11ca, {0xbf, 0xfc, 0x08, 0x00, 0x1e, 0x03, 0x94,
33                                  0x31}
34 };
35 static guint16 ver_krb5rpc = 1;
36 static int hf_krb5rpc_opnum = -1;
37 static int hf_krb5rpc_sendto_kdc_rqst_keysize = -1;
38 static int hf_krb5rpc_sendto_kdc_rqst_spare1 = -1;
39 static int hf_krb5rpc_sendto_kdc_resp_len = -1;
40 static int hf_krb5rpc_sendto_kdc_resp_max = -1;
41 static int hf_krb5rpc_sendto_kdc_resp_spare1 = -1;
42 static int hf_krb5rpc_sendto_kdc_resp_keysize = -1;
43 /* static int hf_krb5rpc_sendto_kdc_resp_st = -1; */
44 static int hf_krb5rpc_krb5 = -1;
45 static gint ett_krb5rpc_krb5 = -1;
46
47 static int
48 krb5rpc_dissect_sendto_kdc_rqst (tvbuff_t * tvb, int offset,
49                                  packet_info * pinfo, proto_tree * tree,
50                                  dcerpc_info *di, guint8 *drep)
51 {
52   guint32 keysize, spare1, remain;
53   proto_item *item;
54   tvbuff_t *krb5_tvb;
55   proto_tree *subtree;
56
57
58   /*
59    *        [in]        handle_t        h,
60    *        [in]        unsigned32      len,
61    *        [in, size_is(len)]
62    *        byte            message[],
63    *        [in]        unsigned32      out_buf_len,
64    */
65
66   offset =
67     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
68                        hf_krb5rpc_sendto_kdc_rqst_keysize, &keysize);
69   offset =
70     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
71                        hf_krb5rpc_sendto_kdc_rqst_spare1, &spare1);
72   item = proto_tree_add_item (tree, hf_krb5rpc_krb5, tvb, offset, -1, ENC_NA);
73   subtree = proto_item_add_subtree (item, ett_krb5rpc_krb5);
74
75   remain = tvb_captured_length_remaining(tvb, offset);
76   krb5_tvb = tvb_new_subset_length_caplen (tvb, offset, remain, remain);
77   offset = dissect_kerberos_main (krb5_tvb, pinfo, subtree, TRUE, NULL);
78
79
80   return offset;
81 }
82
83
84 static int
85 krb5rpc_dissect_sendto_kdc_resp (tvbuff_t * tvb, int offset,
86                                  packet_info * pinfo, proto_tree * tree,
87                                  dcerpc_info *di, guint8 *drep)
88 {
89   guint32 resp_len, maxsize, spare1, keysize, remain;
90   proto_item *item;
91   tvbuff_t *krb5_tvb;
92   proto_tree *subtree;
93
94
95   /*
96    *
97    *        [out]       unsigned32      *resp_len,
98    *        [out, length_is(*resp_len), size_is(out_buf_len)]
99    *        byte            out_buf[],
100    *        [out]       error_status_t  *st unsigned long
101    *
102    */
103
104   offset =
105     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
106                        hf_krb5rpc_sendto_kdc_resp_len, &resp_len);
107   offset =
108     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
109                        hf_krb5rpc_sendto_kdc_resp_max, &maxsize);
110   offset =
111     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
112                        hf_krb5rpc_sendto_kdc_resp_spare1, &spare1);
113   offset =
114     dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
115                        hf_krb5rpc_sendto_kdc_resp_keysize, &keysize);
116
117
118   item = proto_tree_add_item (tree, hf_krb5rpc_krb5, tvb, offset, -1, ENC_NA);
119   subtree = proto_item_add_subtree (item, ett_krb5rpc_krb5);
120   remain = tvb_captured_length_remaining(tvb, offset);
121   krb5_tvb = tvb_new_subset_length_caplen (tvb, offset, remain, remain);
122
123   offset = dissect_kerberos_main (krb5_tvb, pinfo, subtree, TRUE, NULL);
124   offset += 16; /* no idea what this is, probably just extended encrypted text. */
125
126   return offset;
127 }
128
129
130 static dcerpc_sub_dissector krb5rpc_dissectors[] = {
131   {0, "rsec_krb5rpc_sendto_kdc", krb5rpc_dissect_sendto_kdc_rqst,
132    krb5rpc_dissect_sendto_kdc_resp},
133   {0, NULL, NULL, NULL},
134 };
135
136
137 void
138 proto_register_krb5rpc (void)
139 {
140   static hf_register_info hf[] = {
141     {&hf_krb5rpc_opnum,
142      {"Opnum", "krb5rpc.opnum", FT_UINT16, BASE_DEC, NULL, 0x0,
143       NULL, HFILL }},
144     {&hf_krb5rpc_sendto_kdc_rqst_keysize,
145      {"Request keysize",
146       "krb5rpc.sendto_kdc_rqst_keysize", FT_UINT32, BASE_DEC, NULL, 0x0,
147       NULL, HFILL}},
148     {&hf_krb5rpc_sendto_kdc_rqst_spare1,
149      {"Request spare1",
150       "krb5rpc.sendto_kdc_rqst_spare1", FT_UINT32, BASE_DEC, NULL, 0x0, NULL,
151       HFILL}},
152     {&hf_krb5rpc_sendto_kdc_resp_len,
153      {"Response length", "krb5rpc.sendto_kdc_resp_len",
154       FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
155     {&hf_krb5rpc_sendto_kdc_resp_max,
156      {"Response max", "krb5rpc.sendto_kdc_resp_max",
157       FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
158     {&hf_krb5rpc_sendto_kdc_resp_spare1,
159      {"Response spare1",
160       "krb5rpc.sendto_kdc_resp_spare1", FT_UINT32, BASE_DEC, NULL, 0x0, NULL,
161       HFILL}},
162     {&hf_krb5rpc_sendto_kdc_resp_keysize,
163      {"Response key size",
164       "krb5rpc.sendto_kdc_resp_keysize", FT_UINT32, BASE_DEC, NULL, 0x0,
165       NULL, HFILL}},
166 #if 0
167     {&hf_krb5rpc_sendto_kdc_resp_st,
168      {"Response st", "krb5rpc.sendto_kdc_resp_st",
169       FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
170 #endif
171     {&hf_krb5rpc_krb5,
172      {"krb5", "krb5rpc.krb5", FT_BYTES, BASE_NONE, NULL, 0x0,
173       "krb5 blob", HFILL}},
174
175   };
176
177   static gint *ett[] = {
178     &ett_krb5rpc,
179     &ett_krb5rpc_krb5,
180   };
181   proto_krb5rpc =
182     proto_register_protocol ("DCE/RPC Kerberos V", "KRB5RPC", "krb5rpc");
183   proto_register_field_array (proto_krb5rpc, hf, array_length (hf));
184   proto_register_subtree_array (ett, array_length (ett));
185 }
186
187 void
188 proto_reg_handoff_krb5rpc (void)
189 {
190   /* Register the protocol as dcerpc */
191   dcerpc_init_uuid (proto_krb5rpc, ett_krb5rpc, &uuid_krb5rpc, ver_krb5rpc,
192                     krb5rpc_dissectors, hf_krb5rpc_opnum);
193 }
194
195 /*
196  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
197  *
198  * Local Variables:
199  * c-basic-offset: 2
200  * tab-width: 8
201  * indent-tabs-mode: nil
202  * End:
203  *
204  * ex: set shiftwidth=2 tabstop=8 expandtab:
205  * :indentSize=2:tabSize=8:noTabs=true:
206  */