Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ncp-sss.c
Line
Count
Source
1
/* packet-ncp-sss.c
2
 * Routines for Novell SecretStore Services
3
 * Greg Morris <gmorris@novell.com>
4
 * Copyright (c) Novell, Inc. 2002-2003
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1998 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 */
12
13
#include "config.h"
14
15
#include <epan/packet.h>
16
#include "packet-ncp-int.h"
17
#include "packet-ncp-sss.h"
18
19
void proto_register_sss(void);
20
21
static int ett_sss;
22
23
static int proto_sss;
24
static int hf_sss_buffer_size;
25
static int hf_sss_ping_version;
26
static int hf_sss_flags;
27
static int hf_sss_context;
28
static int hf_sss_frag_handle;
29
static int hf_sss_length;
30
static int hf_sss_verb;
31
static int hf_sss_user;
32
static int hf_sss_secret;
33
static int hf_sss_sss_version;
34
static int hf_sss_return_code;
35
static int hf_sss_enc_cred;
36
static int hf_sss_enc_data;
37
static int hf_sss_bit1;
38
static int hf_sss_bit2;
39
static int hf_sss_bit3;
40
static int hf_sss_bit4;
41
static int hf_sss_bit5;
42
static int hf_sss_bit6;
43
static int hf_sss_bit7;
44
static int hf_sss_bit8;
45
static int hf_sss_bit9;
46
static int hf_sss_bit10;
47
static int hf_sss_bit11;
48
static int hf_sss_bit12;
49
static int hf_sss_bit13;
50
static int hf_sss_bit14;
51
static int hf_sss_bit15;
52
static int hf_sss_bit16;
53
static int hf_sss_bit17;
54
static int hf_sss_bit18;
55
static int hf_sss_bit19;
56
static int hf_sss_bit20;
57
static int hf_sss_bit21;
58
static int hf_sss_bit22;
59
static int hf_sss_bit23;
60
static int hf_sss_bit24;
61
static int hf_sss_bit25;
62
static int hf_sss_bit26;
63
static int hf_sss_bit27;
64
static int hf_sss_bit28;
65
static int hf_sss_bit29;
66
static int hf_sss_bit30;
67
static int hf_sss_bit31;
68
static int hf_sss_bit32;
69
70
static expert_field ei_return_code;
71
72
static const value_string sss_func_enum[] = {
73
    { 0x00000001, "Ping Server" },
74
    { 0x00000002, "Fragment" },
75
    { 0x00000003, "Write App Secrets" },
76
    { 0x00000004, "Add Secret ID" },
77
    { 0x00000005, "Remove Secret ID" },
78
    { 0x00000006, "Remove SecretStore" },
79
    { 0x00000007, "Enumerate Secret IDs" },
80
    { 0x00000008, "Unlock Store" },
81
    { 0x00000009, "Set Master Password" },
82
    { 0x0000000a, "Get Service Information" },
83
    { 0,          NULL }
84
};
85
86
static const value_string sss_errors_enum[] = {
87
    { 0xFFFFFCE0, "(-800) Target object could not be found" },
88
    { 0xFFFFFCDF, "(-801) NICI operations have failed" },
89
    { 0xFFFFFCDE, "(-802) The Secret ID is not in the user secret store" },
90
    { 0xFFFFFCDD, "(-803) Some internal operating system services have not been available" },
91
    { 0xFFFFFCDC, "(-804) Access to the target Secret Store has been denied" },
92
    { 0xFFFFFCDB, "(-805) NDS internal NDS services have not been available" },
93
    { 0xFFFFFCDA, "(-806) Secret has not been initialized with a write" },
94
    { 0xFFFFFCD9, "(-807) Size of the buffer is not in a nominal range between minimum and maximum" },
95
    { 0xFFFFFCD8, "(-808) Client and server components are not of the compatible versions" },
96
    { 0xFFFFFCD7, "(-809) Secret Store data on the server has been corrupted" },
97
    { 0xFFFFFCD6, "(-810) Secret ID already exists in the SecretStore" },
98
    { 0xFFFFFCD5, "(-811) User NDS password has been changed by the administrator" },
99
    { 0xFFFFFCD4, "(-812) Target NDS user object not found" },
100
    { 0xFFFFFCD3, "(-813) Target NDS user object does not have a Secret Store" },
101
    { 0xFFFFFCD2, "(-814) Secret Store is not on the network" },
102
    { 0xFFFFFCD1, "(-815) Length of the Secret ID buffer exceeds the limit" },
103
    { 0xFFFFFCD0, "(-816) Length of the enumeration buffer is too short" },
104
    { 0xFFFFFCCF, "(-817) User not authenticated" },
105
    { 0xFFFFFCCE, "(-818) Not supported operations" },
106
    { 0xFFFFFCCD, "(-819) Typed in NDS password not valid" },
107
    { 0xFFFFFCCC, "(-820) Session keys of the client and server NICI are out of sync" },
108
    { 0xFFFFFCCB, "(-821) Requested service not yet supported" },
109
    { 0xFFFFFCCA, "(-822) NDS authentication type not supported" },
110
    { 0xFFFFFCC9, "(-823) Unicode text conversion operation failed" },
111
    { 0xFFFFFCC8, "(-824) Connection to server is lost" },
112
    { 0xFFFFFCC7, "(-825) Cryptographic operation failed" },
113
    { 0xFFFFFCC6, "(-826) Opening a connection to the server failed" },
114
    { 0xFFFFFCC5, "(-827) Access to server connection failed" },
115
    { 0xFFFFFCC4, "(-828) Size of the enumeration buffer exceeds the limit" },
116
    { 0xFFFFFCC3, "(-829) Size of the Secret buffer exceeds the limit" },
117
    { 0xFFFFFCC2, "(-830) Length of the Secret ID should be greater than zero" },
118
    { 0xFFFFFCC1, "(-831) Protocol data corrupted on the wire" },
119
    { 0xFFFFFCC0, "(-832) Enhanced protection's password validation failed. Access to the secret denied" },
120
    { 0xFFFFFCBF, "(-833) Schema is not extended to support SecretStore on the target tree" },
121
    { 0xFFFFFCBE, "(-834) One of the optional service attributes is not instantiated" },
122
    { 0xFFFFFCBD, "(-835) Server has been upgraded and the users SecretStore should be updated" },
123
    { 0xFFFFFCBC, "(-836) Master password could not be verified to read or unlock the secrets" },
124
    { 0xFFFFFCBB, "(-837) Master password has not been set on the SecretStore" },
125
    { 0xFFFFFCBA, "(-838) Ability to use master password has been disabled" },
126
    { 0xFFFFFCB9, "(-839) Not a writeable replica of NDS" },
127
    { 0xFFFFFCB8, "(-840) The API was unable to find a value for an attribute in the Directory" },
128
    { 0xFFFFFCB7, "(-841) A parameter passed to the API has not been properly initialized" },
129
    { 0xFFFFFCB6, "(-842) The connection to SecretStore requires SSL to be secure" },
130
    { 0xFFFFFCB5, "(-843) The client could not locate a server that supports the policy override required by the caller" },
131
    { 0xFFFFFCB4, "(-844) Attempt to unlock SecretStore failed because the store is not locked" },
132
    { 0xFFFFFCB3, "(-845) NDS Replica on the server that holds SecretStore is out of sync with the replica ring" },
133
    { 0xFFFFFC88, "(-888) Feature not yet implemented" },
134
    { 0xFFFFFC7D, "(-899) Products BETA life has expired" },
135
    { 0,          NULL }
136
};
137
138
139
static void
140
process_flags(proto_tree *sss_tree, tvbuff_t *tvb, uint32_t foffset)
141
0
{
142
0
    char                    flags_str[1024];
143
0
    const char             *sep;
144
0
    proto_item             *tinew;
145
0
    proto_tree             *flags_tree;
146
0
    uint32_t                i;
147
0
    uint32_t                bvalue = 0;
148
0
    uint32_t                flags = 0;
149
150
0
    bvalue = 0x00000001;
151
0
    flags_str[0]='\0';
152
0
    sep="";
153
0
    flags = tvb_get_ntohl(tvb, foffset);
154
0
    for (i = 0 ; i < 256; i++) {
155
0
        if (flags & bvalue) {
156
0
            (void) g_strlcat(flags_str, sep, 1024);
157
0
            switch(bvalue) {
158
0
                case 0x00000001:
159
0
                        (void) g_strlcat(flags_str, "Enhanced Protection", 1024);
160
0
                        break;
161
0
                case 0x00000002:
162
0
                        (void) g_strlcat(flags_str, "Create ID", 1024);
163
0
                        break;
164
0
                case 0x00000004:
165
0
                        (void) g_strlcat(flags_str, "Remove Lock", 1024);
166
0
                        break;
167
0
                case 0x00000008:
168
0
                        (void) g_strlcat(flags_str, "Repair", 1024);
169
0
                        break;
170
0
                case 0x00000010:
171
0
                        (void) g_strlcat(flags_str, "Unicode", 1024);
172
0
                        break;
173
0
                case 0x00000020:
174
0
                        (void) g_strlcat(flags_str, "EP Master Password Used", 1024);
175
0
                        break;
176
0
                case 0x00000040:
177
0
                        (void) g_strlcat(flags_str, "EP Password Used", 1024);
178
0
                        break;
179
0
                case 0x00000080:
180
0
                        (void) g_strlcat(flags_str, "Set Tree Name", 1024);
181
0
                        break;
182
0
                case 0x00000100:
183
0
                        (void) g_strlcat(flags_str, "Get Context", 1024);
184
0
                        break;
185
0
                case 0x00000200:
186
0
                        (void) g_strlcat(flags_str, "Destroy Context", 1024);
187
0
                        break;
188
0
                case 0x00000400:
189
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
190
0
                        break;
191
0
                case 0x00000800:
192
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
193
0
                        break;
194
0
                case 0x00001000:
195
0
                        (void) g_strlcat(flags_str, "EP Lock", 1024);
196
0
                        break;
197
0
                case 0x00002000:
198
0
                        (void) g_strlcat(flags_str, "Not Initialized", 1024);
199
0
                        break;
200
0
                case 0x00004000:
201
0
                        (void) g_strlcat(flags_str, "Enhanced Protection", 1024);
202
0
                        break;
203
0
                case 0x00008000:
204
0
                        (void) g_strlcat(flags_str, "Store Not Synced", 1024);
205
0
                        break;
206
0
                case 0x00010000:
207
0
                        (void) g_strlcat(flags_str, "Admin Last Modified", 1024);
208
0
                        break;
209
0
                case 0x00020000:
210
0
                        (void) g_strlcat(flags_str, "EP Password Present", 1024);
211
0
                        break;
212
0
                case 0x00040000:
213
0
                        (void) g_strlcat(flags_str, "EP Master Password Present", 1024);
214
0
                        break;
215
0
                case 0x00080000:
216
0
                        (void) g_strlcat(flags_str, "MP Disabled", 1024);
217
0
                        break;
218
0
                case 0x00100000:
219
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
220
0
                        break;
221
0
                case 0x00200000:
222
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
223
0
                        break;
224
0
                case 0x00400000:
225
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
226
0
                        break;
227
0
                case 0x00800000:
228
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
229
0
                        break;
230
0
                case 0x01000000:
231
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
232
0
                        break;
233
0
                case 0x02000000:
234
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
235
0
                        break;
236
0
                case 0x04000000:
237
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
238
0
                        break;
239
0
                case 0x08000000:
240
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
241
0
                        break;
242
0
                case 0x10000000:
243
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
244
0
                        break;
245
0
                case 0x20000000:
246
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
247
0
                        break;
248
0
                case 0x40000000:
249
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
250
0
                        break;
251
0
                case 0x80000000:
252
0
                        (void) g_strlcat(flags_str, "Not Defined", 1024);
253
0
                        break;
254
0
                default:
255
0
                        break;
256
0
            }
257
0
            sep = ", ";
258
0
        }
259
0
            bvalue = bvalue*2;
260
0
    }
261
262
0
    tinew = proto_tree_add_uint(sss_tree, hf_sss_flags, tvb, foffset, 4, flags);
263
0
    flags_tree = proto_item_add_subtree(tinew, ett_nds);
264
265
0
    bvalue = 0x00000001;
266
267
0
    for (i = 0 ; i < 256; i++ ) {
268
0
        if (flags & bvalue) {
269
0
            switch(bvalue) {
270
0
                case 0x00000001:
271
0
                        proto_tree_add_item(flags_tree, hf_sss_bit1, tvb, foffset, 4, ENC_BIG_ENDIAN);
272
0
                        break;
273
0
                case 0x00000002:
274
0
                    proto_tree_add_item(flags_tree, hf_sss_bit2, tvb, foffset, 4, ENC_BIG_ENDIAN);
275
0
                        break;
276
0
                case 0x00000004:
277
0
                    proto_tree_add_item(flags_tree, hf_sss_bit3, tvb, foffset, 4, ENC_BIG_ENDIAN);
278
0
                        break;
279
0
                case 0x00000008:
280
0
                        proto_tree_add_item(flags_tree, hf_sss_bit4, tvb, foffset, 4, ENC_BIG_ENDIAN);
281
0
                        break;
282
0
                case 0x00000010:
283
0
                        proto_tree_add_item(flags_tree, hf_sss_bit5, tvb, foffset, 4, ENC_BIG_ENDIAN);
284
0
                        break;
285
0
                case 0x00000020:
286
0
                        proto_tree_add_item(flags_tree, hf_sss_bit6, tvb, foffset, 4, ENC_BIG_ENDIAN);
287
0
                        break;
288
0
                case 0x00000040:
289
0
                        proto_tree_add_item(flags_tree, hf_sss_bit7, tvb, foffset, 4, ENC_BIG_ENDIAN);
290
0
                        break;
291
0
                case 0x00000080:
292
0
                        proto_tree_add_item(flags_tree, hf_sss_bit8, tvb, foffset, 4, ENC_BIG_ENDIAN);
293
0
                        break;
294
0
                case 0x00000100:
295
0
                        proto_tree_add_item(flags_tree, hf_sss_bit9, tvb, foffset, 4, ENC_BIG_ENDIAN);
296
0
                        break;
297
0
                case 0x00000200:
298
0
                        proto_tree_add_item(flags_tree, hf_sss_bit10, tvb, foffset, 4, ENC_BIG_ENDIAN);
299
0
                        break;
300
0
                case 0x00000400:
301
0
                        proto_tree_add_item(flags_tree, hf_sss_bit11, tvb, foffset, 4, ENC_BIG_ENDIAN);
302
0
                        break;
303
0
                case 0x00000800:
304
0
                        proto_tree_add_item(flags_tree, hf_sss_bit12, tvb, foffset, 4, ENC_BIG_ENDIAN);
305
0
                        break;
306
0
                case 0x00001000:
307
0
                        proto_tree_add_item(flags_tree, hf_sss_bit13, tvb, foffset, 4, ENC_BIG_ENDIAN);
308
0
                        break;
309
0
                case 0x00002000:
310
0
                        proto_tree_add_item(flags_tree, hf_sss_bit14, tvb, foffset, 4, ENC_BIG_ENDIAN);
311
0
                        break;
312
0
                case 0x00004000:
313
0
                        proto_tree_add_item(flags_tree, hf_sss_bit15, tvb, foffset, 4, ENC_BIG_ENDIAN);
314
0
                        break;
315
0
                case 0x00008000:
316
0
                        proto_tree_add_item(flags_tree, hf_sss_bit16, tvb, foffset, 4, ENC_BIG_ENDIAN);
317
0
                        break;
318
0
                case 0x00010000:
319
0
                        proto_tree_add_item(flags_tree, hf_sss_bit17, tvb, foffset, 4, ENC_BIG_ENDIAN);
320
0
                        break;
321
0
                case 0x00020000:
322
0
                        proto_tree_add_item(flags_tree, hf_sss_bit18, tvb, foffset, 4, ENC_BIG_ENDIAN);
323
0
                        break;
324
0
                case 0x00040000:
325
0
                        proto_tree_add_item(flags_tree, hf_sss_bit19, tvb, foffset, 4, ENC_BIG_ENDIAN);
326
0
                        break;
327
0
                case 0x00080000:
328
0
                        proto_tree_add_item(flags_tree, hf_sss_bit20, tvb, foffset, 4, ENC_BIG_ENDIAN);
329
0
                        break;
330
0
                case 0x00100000:
331
0
                        proto_tree_add_item(flags_tree, hf_sss_bit21, tvb, foffset, 4, ENC_BIG_ENDIAN);
332
0
                        break;
333
0
                case 0x00200000:
334
0
                        proto_tree_add_item(flags_tree, hf_sss_bit22, tvb, foffset, 4, ENC_BIG_ENDIAN);
335
0
                        break;
336
0
                case 0x00400000:
337
0
                        proto_tree_add_item(flags_tree, hf_sss_bit23, tvb, foffset, 4, ENC_BIG_ENDIAN);
338
0
                        break;
339
0
                case 0x00800000:
340
0
                        proto_tree_add_item(flags_tree, hf_sss_bit24, tvb, foffset, 4, ENC_BIG_ENDIAN);
341
0
                        break;
342
0
                case 0x01000000:
343
0
                        proto_tree_add_item(flags_tree, hf_sss_bit25, tvb, foffset, 4, ENC_BIG_ENDIAN);
344
0
                        break;
345
0
                case 0x02000000:
346
0
                        proto_tree_add_item(flags_tree, hf_sss_bit26, tvb, foffset, 4, ENC_BIG_ENDIAN);
347
0
                        break;
348
0
                case 0x04000000:
349
0
                        proto_tree_add_item(flags_tree, hf_sss_bit27, tvb, foffset, 4, ENC_BIG_ENDIAN);
350
0
                        break;
351
0
                case 0x08000000:
352
0
                        proto_tree_add_item(flags_tree, hf_sss_bit28, tvb, foffset, 4, ENC_BIG_ENDIAN);
353
0
                        break;
354
0
                case 0x10000000:
355
0
                        proto_tree_add_item(flags_tree, hf_sss_bit29, tvb, foffset, 4, ENC_BIG_ENDIAN);
356
0
                        break;
357
0
                case 0x20000000:
358
0
                        proto_tree_add_item(flags_tree, hf_sss_bit30, tvb, foffset, 4, ENC_BIG_ENDIAN);
359
0
                        break;
360
0
                case 0x40000000:
361
0
                        proto_tree_add_item(flags_tree, hf_sss_bit31, tvb, foffset, 4, ENC_BIG_ENDIAN);
362
0
                        break;
363
0
                case 0x80000000:
364
0
                        proto_tree_add_item(flags_tree, hf_sss_bit32, tvb, foffset, 4, ENC_BIG_ENDIAN);
365
0
                        break;
366
0
                default:
367
0
                        break;
368
0
            }
369
0
        }
370
0
        bvalue = bvalue*2;
371
0
    }
372
0
    return;
373
0
}
374
375
/* Find the delimiter, '*'.
376
 * Returns the number of bytes from foffset to the delimiter or 0 if not
377
 * found within 256 bytes from foffset */
378
static unsigned
379
find_delimiter(tvbuff_t *tvb, unsigned foffset)
380
0
{
381
0
    unsigned offset;
382
383
0
    if (tvb_find_uint8_length(tvb, foffset, 256, '*', &offset)) {
384
0
        return offset - foffset;
385
0
    }
386
0
    return 0;
387
0
}
388
389
static int
390
sss_string(tvbuff_t* tvb, int hfinfo, proto_tree *sss_tree, int offset, bool little, uint32_t length)
391
0
{
392
0
    int     foffset = offset;
393
0
    uint32_t str_length;
394
0
    char    buffer[1024];
395
0
    size_t  i = 0;
396
0
    uint8_t c_char;
397
0
    int length_remaining;
398
399
0
    if (length==0) {
400
0
        if (little) {
401
0
            str_length = tvb_get_letohl(tvb, foffset);
402
0
        } else {
403
0
            str_length = tvb_get_ntohl(tvb, foffset);
404
0
        }
405
0
        foffset += 4;
406
0
    } else {
407
0
        str_length = length;
408
0
    }
409
0
    length_remaining = tvb_captured_length_remaining(tvb, foffset);
410
0
    if (length_remaining <= 0) {
411
0
        return foffset;
412
0
    }
413
0
    if (str_length > (unsigned)length_remaining || str_length > (sizeof(buffer)-1)) {
414
0
        proto_tree_add_string(sss_tree, hfinfo, tvb, foffset,
415
0
            length_remaining + 4, "<String too long to process>");
416
0
        foffset += length_remaining;
417
0
        return foffset;
418
0
    }
419
0
    if (str_length == 0) {
420
0
        proto_tree_add_string(sss_tree, hfinfo, tvb, offset, 4, "<Not Specified>");
421
0
        return foffset;
422
0
    }
423
0
    while (i < str_length) {
424
0
        c_char = tvb_get_uint8(tvb, foffset);
425
0
        if (g_ascii_isprint(c_char)) {
426
0
            buffer[i++] = c_char;
427
0
        } else {
428
0
            if (c_char) {
429
0
                buffer[i++] = '.';
430
0
            } else {
431
                /* Skip NULL-terminators */
432
0
                str_length--;
433
0
            }
434
0
        }
435
0
        foffset++;
436
0
    }
437
0
    buffer[i] = '\0';
438
439
0
    if (length==0) {
440
0
        if (little) {
441
0
            str_length = tvb_get_letohl(tvb, offset);
442
0
        } else {
443
0
            str_length = tvb_get_ntohl(tvb, offset);
444
0
        }
445
0
        offset += 4;
446
0
    } else {
447
0
        str_length = length;
448
0
    }
449
0
    proto_tree_add_string(sss_tree, hfinfo, tvb, offset, str_length, buffer);
450
0
    return foffset;
451
0
}
452
453
void
454
dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp_req_hash_value *request_value)
455
0
{
456
0
    uint8_t             /*func,*/ subfunc = 0;
457
0
    uint32_t            subverb=0;
458
0
    uint32_t            msg_length=0;
459
0
    uint32_t            foffset= 0;
460
0
    proto_tree          *atree;
461
0
    proto_item          *aitem;
462
463
464
0
    if (tvb_reported_length_remaining(tvb, foffset)<4) {
465
0
        return;
466
0
    }
467
0
    foffset = 6;
468
    /*func = tvb_get_uint8(tvb, foffset);*/
469
0
    foffset += 1;
470
0
    subfunc = tvb_get_uint8(tvb, foffset);
471
0
    foffset += 1;
472
473
    /* Fill in the PROTOCOL & INFO  columns. */
474
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSSS");
475
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "C SecretStore - %s", val_to_str(pinfo->pool, subfunc, sss_func_enum, "Unknown (%d)"));
476
477
0
    switch (subfunc) {
478
0
    case 1:
479
0
        atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_sss, NULL, "Packet Type: %s", val_to_str(pinfo->pool, subfunc, sss_func_enum, "Unknown (%d)"));
480
0
        proto_tree_add_item(atree, hf_sss_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
481
0
        foffset += 4;
482
0
        proto_tree_add_item(atree, hf_sss_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
483
        /*foffset += 4;*/
484
0
        break;
485
0
    case 2:
486
0
        proto_tree_add_item(ncp_tree, hf_sss_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
487
0
        if (tvb_get_letohl(tvb, foffset)==0xffffffff) { /* Fragment handle of -1 means no fragment. So process packet */
488
0
            foffset += 4;
489
0
            proto_tree_add_item(ncp_tree, hf_sss_buffer_size, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
490
0
            foffset += 4;
491
0
            proto_tree_add_item(ncp_tree, hf_sss_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
492
0
            foffset += 4;
493
0
            foffset += 12; /* Blank Context */
494
0
            subverb = tvb_get_letohl(tvb, foffset);
495
0
            col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(pinfo->pool, subverb, sss_verb_enum, "Unknown (%d)"));
496
497
0
            aitem = proto_tree_add_item(ncp_tree, hf_sss_verb, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
498
0
            atree = proto_item_add_subtree(aitem, ett_sss);
499
0
            if (request_value) {
500
0
                request_value->req_nds_flags=subverb;
501
0
            }
502
0
            foffset += 4;
503
0
            process_flags(atree, tvb, foffset);
504
0
            foffset += 4;
505
0
            proto_tree_add_item(atree, hf_sss_context, tvb, foffset, 4, ENC_BIG_ENDIAN);
506
0
            foffset += 4;
507
0
            switch (subverb) {
508
0
            case 0:
509
0
                foffset += 4;
510
0
                /*foffset =*/ sss_string(tvb, hf_sss_user, atree, foffset, true, 0);
511
0
                break;
512
0
            case 1:
513
0
                foffset = sss_string(tvb, hf_sss_secret, atree, foffset, true, 0);
514
0
                msg_length = tvb_get_letohl(tvb, foffset);
515
0
                foffset += (msg_length+4);   /* Unsure of what this length and parameter are */
516
                /* A bad secret of length greater than 256 characters will cause frag
517
                   packets and then we will see these as malformed packets.
518
                   So check to make sure we still have data in the packet anytime
519
                   we read a secret. */
520
0
                if (tvb_reported_length_remaining(tvb, foffset) > 4) {
521
0
                    /*foffset =*/ sss_string(tvb, hf_sss_user, atree, foffset, true, 0);
522
0
                }
523
0
                break;
524
0
            case 2:
525
0
                foffset += 4;
526
0
                foffset = sss_string(tvb, hf_sss_secret, atree, foffset, true, 0);
527
0
                if (tvb_reported_length_remaining(tvb, foffset) > 4) {
528
0
                    msg_length = tvb_get_letohl(tvb, foffset);
529
0
                    foffset += 4;
530
0
                    if (tvb_captured_length_remaining(tvb, foffset) < msg_length) {
531
0
                        proto_tree_add_item(atree, hf_sss_enc_data, tvb, foffset, -1, ENC_NA);
532
0
                    } else {
533
0
                        proto_tree_add_item(atree, hf_sss_enc_data, tvb, foffset, msg_length, ENC_NA);
534
0
                    }
535
0
                }
536
0
                break;
537
0
            case 3:
538
0
            case 4:
539
0
                foffset = sss_string(tvb, hf_sss_secret, atree, foffset, true, 0);
540
0
                if (tvb_reported_length_remaining(tvb, foffset) > 4) {
541
0
                    /*foffset =*/ sss_string(tvb, hf_sss_user, atree, foffset, true, 0);
542
0
                }
543
0
                break;
544
0
            case 5:
545
0
                break;
546
0
            case 6:
547
0
                foffset = sss_string(tvb, hf_sss_secret, atree, foffset, true, 0);
548
0
                if (tvb_reported_length_remaining(tvb, foffset) > 4) {
549
0
                    /*foffset =*/ sss_string(tvb, hf_sss_user, atree, foffset, true, 0);
550
0
                }
551
0
                break;
552
0
            case 7:
553
0
                msg_length = tvb_get_letohl(tvb, foffset);
554
0
                foffset += 4;
555
0
                proto_tree_add_item(atree, hf_sss_enc_cred, tvb, foffset, msg_length, ENC_NA);
556
0
                break;
557
0
            case 8:
558
0
            case 9:
559
0
            default:
560
0
                break;
561
0
            }
562
0
        } else {
563
0
            col_set_str(pinfo->cinfo, COL_INFO, "C SecretStore - fragment");
564
565
            /* Fragments don't really carry a subverb so store 0xff as the subverb number */
566
0
            if (request_value) {
567
0
                request_value->req_nds_flags=255;
568
0
            }
569
0
            if (tvb_reported_length_remaining(tvb, foffset) > 8) {
570
0
                foffset += 4;
571
0
                proto_tree_add_item(ncp_tree, hf_sss_enc_data, tvb, foffset, -1, ENC_NA);
572
0
            }
573
0
        }
574
0
        break;
575
0
    case 3:
576
        /* No Op */
577
0
        break;
578
0
    default:
579
0
        break;
580
0
    }
581
0
}
582
583
void
584
dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, uint8_t subfunc, ncp_req_hash_value *request_value)
585
0
{
586
0
    uint32_t            foffset=0;
587
0
    uint32_t            subverb=0;
588
0
    uint32_t            msg_length=0;
589
0
    uint32_t            return_code=0;
590
0
    uint32_t            number_of_items=0;
591
0
    uint32_t            length_of_string=0;
592
0
    uint32_t            i = 0;
593
0
    const char          *str;
594
595
0
    proto_tree          *atree;
596
0
    proto_item          *expert_item;
597
0
    proto_item          *ti;
598
599
0
    foffset = 8;
600
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSSS");
601
0
    if (tvb_captured_length_remaining(tvb, foffset)<4) {
602
0
        return;
603
0
    }
604
0
    atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_sss, NULL, "Function: %s", val_to_str_const(subfunc, sss_func_enum, "Unknown"));
605
0
    switch (subfunc) {
606
0
    case 1:
607
0
        proto_tree_add_item(atree, hf_sss_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
608
0
        foffset += 4;
609
0
        proto_tree_add_item(atree, hf_sss_sss_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
610
        /*foffset += 4;*/
611
0
        break;
612
0
    case 2:
613
0
        if (request_value) {
614
0
            subverb = request_value->req_nds_flags;
615
0
            str = try_val_to_str(subverb, sss_verb_enum);
616
0
            if (str) {
617
0
                ti = proto_tree_add_uint(atree, hf_sss_verb, tvb, 0, 0, subverb);
618
0
                proto_item_set_generated(ti);
619
0
            }
620
0
        }
621
0
        proto_tree_add_item(atree, hf_sss_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
622
0
        msg_length = tvb_get_letohl(tvb, foffset);
623
0
        foffset += 4;
624
0
        proto_tree_add_item(atree, hf_sss_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
625
0
        foffset += 4;
626
0
        msg_length -= 4;
627
0
        if ((tvb_get_letohl(tvb, foffset-4)==0xffffffff) && (msg_length > 4)) {
628
0
            foffset += 4;
629
0
            return_code = tvb_get_letohl(tvb, foffset);
630
0
            str = try_val_to_str(return_code, sss_errors_enum);
631
0
            if (str) {
632
0
                expert_item = proto_tree_add_item(atree, hf_sss_return_code, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
633
0
                expert_add_info_format(pinfo, expert_item, &ei_return_code, "SSS Error: %s", str);
634
0
                col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", val_to_str(pinfo->pool, return_code, sss_errors_enum, "Unknown (%d)"));
635
                /*foffset+=4;*/
636
0
            } else {
637
0
                proto_tree_add_uint_format_value(atree, hf_sss_return_code, tvb, foffset, 4, 0, "Success (0x00000000)");
638
0
                if (tvb_reported_length_remaining(tvb, foffset) > 8) {
639
0
                    foffset += 4;
640
0
                    if (request_value && subverb == 6) {
641
0
                        foffset += 4;
642
0
                        number_of_items = tvb_get_letohl(tvb, foffset);
643
0
                        foffset += 8;
644
0
                        for (i=0; i<number_of_items; i++) {
645
0
                            length_of_string = find_delimiter(tvb, foffset);
646
0
                            if (length_of_string > tvb_reported_length_remaining(tvb, foffset)) {
647
0
                                return;
648
0
                            }
649
0
                            foffset = sss_string(tvb, hf_sss_secret, atree, foffset, true, length_of_string);
650
0
                            if (tvb_reported_length_remaining(tvb, foffset) < 8) {
651
0
                                return;
652
0
                            }
653
0
                            foffset++;
654
0
                        }
655
0
                    } else {
656
0
                        proto_tree_add_item(atree, hf_sss_enc_data, tvb, foffset, tvb_captured_length_remaining(tvb, foffset), ENC_NA);
657
0
                    }
658
0
                }
659
0
            }
660
0
        } else {
661
0
            proto_tree_add_uint_format_value(atree, hf_sss_return_code, tvb, foffset, 4, 0, "Success (0x00000000)");
662
0
            if (tvb_reported_length_remaining(tvb, foffset) > 8) {
663
0
                foffset += 4;
664
0
                proto_tree_add_item(atree, hf_sss_enc_data, tvb, foffset, tvb_captured_length_remaining(tvb, foffset), ENC_NA);
665
0
            }
666
0
        }
667
0
        break;
668
0
    case 3:
669
0
        break;
670
0
    default:
671
0
        break;
672
0
    }
673
0
}
674
675
void
676
proto_register_sss(void)
677
16
{
678
16
    static hf_register_info hf_sss[] = {
679
16
        { &hf_sss_buffer_size,
680
16
        { "Buffer Size", "sss.buffer", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
681
682
16
        { &hf_sss_ping_version,
683
16
        { "Ping Version", "sss.ping_version", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
684
685
16
        { &hf_sss_flags,
686
16
        { "Flags", "sss.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
687
688
16
        { &hf_sss_context,
689
16
        { "Context", "sss.context", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
690
691
16
        { &hf_sss_frag_handle,
692
16
        { "Fragment Handle", "sss.frag_handle", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
693
694
16
        { &hf_sss_length,
695
16
        { "Length", "sss.length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
696
697
16
        { &hf_sss_verb,
698
16
        { "Verb", "sss.verb", FT_UINT32, BASE_HEX,   VALS(sss_verb_enum), 0x0, NULL, HFILL }},
699
700
16
        { &hf_sss_user,
701
16
        { "User",  "sss.user", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
702
703
16
        { &hf_sss_secret,
704
16
        { "Secret ID", "sss.secret", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
705
706
16
        { &hf_sss_sss_version,
707
16
        { "SecretStore Protocol Version", "sss.version", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
708
709
16
        { &hf_sss_return_code,
710
16
        { "Return Code", "sss.return_code", FT_UINT32, BASE_HEX, VALS(sss_errors_enum), 0x0, NULL, HFILL }},
711
712
16
        { &hf_sss_enc_cred,
713
16
        { "Encrypted Credential", "sss.enc_cred", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
714
715
16
        { &hf_sss_enc_data,
716
16
        { "Encrypted Data", "sss.enc_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
717
718
16
        { &hf_sss_bit1,
719
16
        { "Enhanced Protection", "sss.bit1", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
720
721
16
        { &hf_sss_bit2,
722
16
        { "Create ID", "sss.bit2", FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL }},
723
724
16
        { &hf_sss_bit3,
725
16
        { "Remove Lock", "sss.bit3", FT_BOOLEAN, 32, NULL, 0x00000004, NULL, HFILL }},
726
727
16
        { &hf_sss_bit4,
728
16
        { "Repair", "sss.bit4", FT_BOOLEAN, 32, NULL, 0x00000008, NULL, HFILL }},
729
730
16
        { &hf_sss_bit5,
731
16
        { "Unicode", "sss.bit5", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL }},
732
733
16
        { &hf_sss_bit6,
734
16
        { "EP Master Password Used", "sss.bit6", FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL }},
735
736
16
        { &hf_sss_bit7,
737
16
        { "EP Password Used", "sss.bit7", FT_BOOLEAN, 32, NULL, 0x00000040, NULL, HFILL }},
738
739
16
        { &hf_sss_bit8,
740
16
        { "Set Tree Name", "sss.bit8", FT_BOOLEAN, 32, NULL, 0x00000080, NULL, HFILL }},
741
742
16
        { &hf_sss_bit9,
743
16
        { "Get Context", "sss.bit9", FT_BOOLEAN, 32, NULL, 0x00000100, NULL, HFILL }},
744
745
16
        { &hf_sss_bit10,
746
16
        { "Destroy Context", "sss.bit10", FT_BOOLEAN, 32, NULL, 0x00000200, NULL, HFILL }},
747
748
16
        { &hf_sss_bit11,
749
16
        { "Not Defined", "sss.bit11", FT_BOOLEAN, 32, NULL, 0x00000400, NULL, HFILL }},
750
751
16
        { &hf_sss_bit12,
752
16
        { "Not Defined", "sss.bit12", FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL }},
753
754
16
        { &hf_sss_bit13,
755
16
        { "Not Defined", "sss.bit13", FT_BOOLEAN, 32, NULL, 0x00001000, NULL, HFILL }},
756
757
16
        { &hf_sss_bit14,
758
16
        { "Not Defined", "sss.bit14", FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL }},
759
760
16
        { &hf_sss_bit15,
761
16
        { "Not Defined", "sss.bit15", FT_BOOLEAN, 32, NULL, 0x00004000, NULL, HFILL }},
762
763
16
        { &hf_sss_bit16,
764
16
        { "Not Defined", "sss.bit16", FT_BOOLEAN, 32, NULL, 0x00008000, NULL, HFILL }},
765
766
16
        { &hf_sss_bit17,
767
16
        { "EP Lock", "sss.bit17", FT_BOOLEAN, 32, NULL, 0x00010000, NULL, HFILL }},
768
769
16
        { &hf_sss_bit18,
770
16
        { "Not Initialized", "sss.bit18", FT_BOOLEAN, 32, NULL, 0x00020000, NULL, HFILL }},
771
772
16
        { &hf_sss_bit19,
773
16
        { "Enhanced Protection", "sss.bit19", FT_BOOLEAN, 32, NULL, 0x00040000, NULL, HFILL }},
774
775
16
        { &hf_sss_bit20,
776
16
        { "Store Not Synced", "sss.bit20", FT_BOOLEAN, 32, NULL, 0x00080000, NULL, HFILL }},
777
778
16
        { &hf_sss_bit21,
779
16
        { "Admin Last Modified", "sss.bit21", FT_BOOLEAN, 32, NULL, 0x00100000, NULL, HFILL }},
780
781
16
        { &hf_sss_bit22,
782
16
        { "EP Password Present", "sss.bit22", FT_BOOLEAN, 32, NULL, 0x00200000, NULL, HFILL }},
783
784
16
        { &hf_sss_bit23,
785
16
        { "EP Master Password Present", "sss.bit23", FT_BOOLEAN, 32, NULL, 0x00400000, NULL, HFILL }},
786
787
16
        { &hf_sss_bit24,
788
16
        { "MP Disabled", "sss.bit24", FT_BOOLEAN, 32, NULL, 0x00800000, NULL, HFILL }},
789
790
16
        { &hf_sss_bit25,
791
16
        { "Not Defined", "sss.bit25", FT_BOOLEAN, 32, NULL, 0x01000000, NULL, HFILL }},
792
793
16
        { &hf_sss_bit26,
794
16
        { "Not Defined", "sss.bit26", FT_BOOLEAN, 32, NULL, 0x02000000, NULL, HFILL }},
795
796
16
        { &hf_sss_bit27,
797
16
        { "Not Defined", "sss.bit27", FT_BOOLEAN, 32, NULL, 0x04000000, NULL, HFILL }},
798
799
16
        { &hf_sss_bit28,
800
16
        { "Not Defined", "sss.bit28", FT_BOOLEAN, 32, NULL, 0x08000000, NULL, HFILL }},
801
802
16
        { &hf_sss_bit29,
803
16
        { "Not Defined", "sss.bit29", FT_BOOLEAN, 32, NULL, 0x10000000, NULL, HFILL }},
804
805
16
        { &hf_sss_bit30,
806
16
        { "Not Defined", "sss.bit30", FT_BOOLEAN, 32, NULL, 0x20000000, NULL, HFILL }},
807
808
16
        { &hf_sss_bit31,
809
16
        { "Not Defined", "sss.bit31", FT_BOOLEAN, 32, NULL, 0x40000000, NULL, HFILL }},
810
811
16
        { &hf_sss_bit32,
812
16
        { "Not Defined", "sss.bit32", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL }}
813
16
    };
814
815
16
    static int *ett[] = {
816
16
        &ett_sss
817
16
    };
818
819
16
    static ei_register_info ei[] = {
820
16
        { &ei_return_code, { "sss.return_code.expert", PI_RESPONSE_CODE, PI_NOTE, "SSS Error", EXPFILL }}
821
16
    };
822
823
16
    expert_module_t* expert_sss;
824
    /*module_t *sss_module;*/
825
826
16
    proto_sss = proto_register_protocol("Novell SecretStore Services", "SSS", "sss");
827
16
    proto_register_field_array(proto_sss, hf_sss, array_length(hf_sss));
828
16
    proto_register_subtree_array(ett, array_length(ett));
829
16
    expert_sss = expert_register_protocol(proto_sss);
830
16
    expert_register_field_array(expert_sss, ei, array_length(ei));
831
16
}
832
833
/*
834
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
835
 *
836
 * Local variables:
837
 * c-basic-offset: 4
838
 * tab-width: 8
839
 * indent-tabs-mode: nil
840
 * End:
841
 *
842
 * vi: set shiftwidth=4 tabstop=8 expandtab:
843
 * :indentSize=4:tabSize=8:noTabs=true:
844
 */
845