HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / epan / dissectors / asn1 / spnego / spnego.cnf
1 # spnego.cnf
2 # spnego conformation file
3
4 #.EXPORTS
5
6 #.PDU
7
8 #.NO_EMIT ONLY_VALS
9 NegotiationToken
10
11 #.FN_BODY NegotiationToken/negTokenInit
12   gboolean is_response = actx->pinfo->ptype == PT_TCP &&
13                          actx->pinfo->srcport < 1024;
14
15   /*
16    * We decode as negTokenInit2 or negTokenInit depending on whether or not
17    * we are in a response or a request. That is essentially what MS-SPNG
18    * says.
19    */
20   if (is_response) {
21     return dissect_spnego_NegTokenInit2(%(IMPLICIT_TAG)s, %(TVB)s, %(OFFSET)s,
22                                         %(ACTX)s, %(TREE)s, %(HF_INDEX)s);
23   } else {
24     return dissect_spnego_NegTokenInit(%(IMPLICIT_TAG)s, %(TVB)s, %(OFFSET)s,
25                                        %(ACTX)s, %(TREE)s, %(HF_INDEX)s);
26   }
27
28 #.FN_PARS MechType
29
30   FN_VARIANT = _str  VAL_PTR = &MechType_oid
31
32 #.FN_BODY MechType
33
34   gssapi_oid_value *value;
35
36 %(DEFAULT_BODY)s
37
38   value = gssapi_lookup_oid_str(MechType_oid);
39
40   /*
41    * Tell our caller the first mechanism we see, so that if
42    * this is a negTokenInit with a mechToken, it can interpret
43    * the mechToken according to the first mechType.  (There
44    * might not have been any indication of the mechType
45    * in prior frames, so we can't necessarily use the
46    * mechanism from the conversation; i.e., a negTokenInit
47    * can contain the initial security token for the desired
48    * mechanism of the initiator - that's the first mechanism
49    * in the list.)
50    */
51   if (!saw_mechanism) {
52     if (value)
53       next_level_value = value;
54     saw_mechanism = TRUE;
55   }
56
57 #.FN_BODY InnerContextToken
58
59   gssapi_oid_value *next_level_value_lcl;
60   proto_item *item;
61   proto_tree *subtree;
62   tvbuff_t *token_tvb;
63   int len;
64
65   /*
66    * XXX - what should we do if this OID doesn't match the value
67    * attached to the frame or conversation?  (That would be
68    * bogus, but that's not impossible - some broken implementation
69    * might negotiate some security mechanism but put the OID
70    * for some other security mechanism in GSS_Wrap tokens.)
71    * Does it matter?
72    */
73   next_level_value_lcl = gssapi_lookup_oid_str(MechType_oid);
74
75   /*
76    * Now dissect the GSS_Wrap token; it's assumed to be in the
77    * rest of the tvbuff.
78    */
79   item = proto_tree_add_item(tree, hf_spnego_wraptoken, tvb, offset, -1, ENC_NA);
80
81   subtree = proto_item_add_subtree(item, ett_spnego_wraptoken);
82
83   /*
84    * Now, we should be able to dispatch after creating a new TVB.
85    * The subdissector must return the length of the part of the
86    * token it dissected, so we can return the length of the part
87    * we (and it) dissected.
88    */
89   token_tvb = tvb_new_subset_remaining(tvb, offset);
90   if (next_level_value_lcl && next_level_value_lcl->wrap_handle) {
91     len = call_dissector(next_level_value_lcl->wrap_handle, token_tvb, actx->pinfo,
92                          subtree);
93     if (len == 0)
94       offset = tvb_reported_length(tvb);
95     else
96       offset = offset + len;
97   } else
98     offset = tvb_reported_length(tvb);
99
100 #.FN_BODY MechTypeList
101
102   conversation_t *conversation;
103
104   saw_mechanism = FALSE;
105
106 %(DEFAULT_BODY)s
107
108   /*
109    * If we saw a mechType we need to store it in case the negTokenTarg
110    * does not provide a supportedMech.
111    */
112   if(saw_mechanism){
113     conversation = find_or_create_conversation(actx->pinfo);
114     conversation_add_proto_data(conversation, proto_spnego, next_level_value);
115   }
116
117 #.FN_PARS NegTokenInit/mechToken
118
119   VAL_PTR = &mechToken_tvb
120
121 #.FN_BODY NegTokenInit/mechToken
122
123   tvbuff_t *mechToken_tvb = NULL;
124
125 %(DEFAULT_BODY)s
126
127   /*
128    * Now, we should be able to dispatch, if we've gotten a tvbuff for
129    * the token and we have information on how to dissect its contents.
130    */
131   if (mechToken_tvb && next_level_value)
132      call_dissector(next_level_value->handle, mechToken_tvb, actx->pinfo, tree);
133
134 #.FN_BODY NegTokenTarg/supportedMech
135
136   conversation_t *conversation;
137
138   saw_mechanism = FALSE;
139
140 %(DEFAULT_BODY)s
141
142   /*
143    * If we saw an explicit mechType we store this in the conversation so that
144    * it will override any mechType we might have picked up from the
145    * negTokenInit.
146    */
147   if(saw_mechanism){
148     conversation = find_or_create_conversation(actx->pinfo);
149     conversation_add_proto_data(conversation, proto_spnego, next_level_value);
150   }
151
152
153 #.FN_PARS NegTokenTarg/responseToken
154
155   VAL_PTR = &responseToken_tvb
156
157 #.FN_BODY NegTokenTarg/responseToken
158
159   tvbuff_t *responseToken_tvb;
160
161
162 %(DEFAULT_BODY)s
163
164
165   /*
166    * Now, we should be able to dispatch, if we've gotten a tvbuff for
167    * the token and we have information on how to dissect its contents.
168    * However, we should make sure that there is something in the
169    * response token ...
170    */
171   if (responseToken_tvb && (tvb_reported_length(responseToken_tvb) > 0) ){
172     gssapi_oid_value *value=next_level_value;
173
174     if(value){
175       call_dissector(value->handle, responseToken_tvb, actx->pinfo, tree);
176     }
177   }
178
179 #.END
180
181 #
182 # Editor modelines  -  https://www.wireshark.org/tools/modelines.html
183 #
184 # Local variables:
185 # c-basic-offset: 2
186 # tab-width: 8
187 # indent-tabs-mode: nil
188 # End:
189 #
190 # vi: set shiftwidth=2 tabstop=8 expandtab:
191 # :indentSize=2:tabSize=8:noTabs=true:
192 #