split some security related functions in their own files.
[sfrench/samba-autobuild/.git] / source3 / rpc_parse / parse_rpc.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison                    1999.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include "includes.h"
25
26 #undef DBGC_CLASS
27 #define DBGC_CLASS DBGC_RPC_PARSE
28
29 /*******************************************************************
30 interface/version dce/rpc pipe identification
31 ********************************************************************/
32
33 #define TRANS_SYNT_V2                       \
34 {                                           \
35         {                                   \
36                 0x8a885d04, 0x1ceb, 0x11c9, \
37                 { 0x9f, 0xe8, 0x08, 0x00,   \
38                 0x2b, 0x10, 0x48, 0x60 }    \
39         }, 0x02                             \
40 }
41
42 #define SYNT_NETLOGON_V2                    \
43 {                                           \
44         {                                   \
45                 0x8a885d04, 0x1ceb, 0x11c9, \
46                 { 0x9f, 0xe8, 0x08, 0x00,   \
47                 0x2b, 0x10, 0x48, 0x60 }    \
48         }, 0x02                             \
49 }
50
51 #define SYNT_WKSSVC_V1                      \
52 {                                           \
53         {                                   \
54                 0x6bffd098, 0xa112, 0x3610, \
55                 { 0x98, 0x33, 0x46, 0xc3,   \
56                 0xf8, 0x7e, 0x34, 0x5a }    \
57         }, 0x01                             \
58 }
59
60 #define SYNT_SRVSVC_V3                      \
61 {                                           \
62         {                                   \
63                 0x4b324fc8, 0x1670, 0x01d3, \
64                 { 0x12, 0x78, 0x5a, 0x47,   \
65                 0xbf, 0x6e, 0xe1, 0x88 }    \
66         }, 0x03                             \
67 }
68
69 #define SYNT_LSARPC_V0                      \
70 {                                           \
71         {                                   \
72                 0x12345778, 0x1234, 0xabcd, \
73                 { 0xef, 0x00, 0x01, 0x23,   \
74                 0x45, 0x67, 0x89, 0xab }    \
75         }, 0x00                             \
76 }
77
78 #define SYNT_LSARPC_V0_DS                \
79 {                                           \
80         {                                   \
81                 0x3919286a, 0xb10c, 0x11d0, \
82                 { 0x9b, 0xa8, 0x00, 0xc0,   \
83                 0x4f, 0xd9, 0x2e, 0xf5 }    \
84         }, 0x00                             \
85 }
86
87 #define SYNT_SAMR_V1                        \
88 {                                           \
89         {                                   \
90                 0x12345778, 0x1234, 0xabcd, \
91                 { 0xef, 0x00, 0x01, 0x23,   \
92                 0x45, 0x67, 0x89, 0xac }    \
93         }, 0x01                             \
94 }
95
96 #define SYNT_NETLOGON_V1                    \
97 {                                           \
98         {                                   \
99                 0x12345678, 0x1234, 0xabcd, \
100                 { 0xef, 0x00, 0x01, 0x23,   \
101                 0x45, 0x67, 0xcf, 0xfb }    \
102         }, 0x01                             \
103 }
104
105 #define SYNT_WINREG_V1                      \
106 {                                           \
107         {                                   \
108                 0x338cd001, 0x2244, 0x31f1, \
109                 { 0xaa, 0xaa, 0x90, 0x00,   \
110                 0x38, 0x00, 0x10, 0x03 }    \
111         }, 0x01                             \
112 }
113
114 #define SYNT_SPOOLSS_V1                     \
115 {                                           \
116         {                                   \
117                 0x12345678, 0x1234, 0xabcd, \
118                 { 0xef, 0x00, 0x01, 0x23,   \
119                 0x45, 0x67, 0x89, 0xab }    \
120         }, 0x01                             \
121 }
122
123 #define SYNT_NONE_V0                        \
124 {                                           \
125         {                                   \
126                 0x0, 0x0, 0x0,              \
127                 { 0x00, 0x00, 0x00, 0x00,   \
128                 0x00, 0x00, 0x00, 0x00 }    \
129         }, 0x00                             \
130 }
131
132 #define SYNT_NETDFS_V3                      \
133 {                                           \
134         {                                   \
135                 0x4fc742e0, 0x4a10, 0x11cf, \
136                 { 0x82, 0x73, 0x00, 0xaa,   \
137                   0x00, 0x4a, 0xe6, 0x73 }  \
138         }, 0x03                             \
139 }
140
141 #define SYNT_ECHO_V1                        \
142 {                                           \
143         {                                   \
144                 0x60a15ec5, 0x4de8, 0x11d7, \
145                 { 0xa6, 0x37, 0x00, 0x50,   \
146                   0x56, 0xa2, 0x01, 0x82 }  \
147         }, 0x01                             \
148 }
149
150 /*
151  * IMPORTANT!!  If you update this structure, make sure to
152  * update the index #defines in smb.h.
153  */
154
155 const struct pipe_id_info pipe_names [] =
156 {
157         /* client pipe , abstract syntax       , server pipe   , transfer syntax */
158         { PIPE_LSARPC  , SYNT_LSARPC_V0        , PIPE_LSASS    , TRANS_SYNT_V2 },
159         { PIPE_LSARPC  , SYNT_LSARPC_V0_DS     , PIPE_LSASS    , TRANS_SYNT_V2 },
160         { PIPE_SAMR    , SYNT_SAMR_V1          , PIPE_LSASS    , TRANS_SYNT_V2 },
161         { PIPE_NETLOGON, SYNT_NETLOGON_V1      , PIPE_LSASS    , TRANS_SYNT_V2 },
162         { PIPE_SRVSVC  , SYNT_SRVSVC_V3        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
163         { PIPE_WKSSVC  , SYNT_WKSSVC_V1        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
164         { PIPE_WINREG  , SYNT_WINREG_V1        , PIPE_WINREG   , TRANS_SYNT_V2 },
165         { PIPE_SPOOLSS , SYNT_SPOOLSS_V1       , PIPE_SPOOLSS  , TRANS_SYNT_V2 },
166         { PIPE_NETDFS  , SYNT_NETDFS_V3        , PIPE_NETDFS   , TRANS_SYNT_V2 },
167         { PIPE_ECHO    , SYNT_ECHO_V1          , PIPE_ECHO     , TRANS_SYNT_V2 },
168         { NULL         , SYNT_NONE_V0          , NULL          , SYNT_NONE_V0  }
169 };
170
171 /*******************************************************************
172  Inits an RPC_HDR structure.
173 ********************************************************************/
174
175 void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
176                                 uint32 call_id, int data_len, int auth_len)
177 {
178         hdr->major        = 5;               /* RPC version 5 */
179         hdr->minor        = 0;               /* minor version 0 */
180         hdr->pkt_type     = pkt_type;        /* RPC packet type */
181         hdr->flags        = flags;           /* dce/rpc flags */
182         hdr->pack_type[0] = 0x10;            /* little-endian data representation */
183         hdr->pack_type[1] = 0;               /* packed data representation */
184         hdr->pack_type[2] = 0;               /* packed data representation */
185         hdr->pack_type[3] = 0;               /* packed data representation */
186         hdr->frag_len     = data_len;        /* fragment length, fill in later */
187         hdr->auth_len     = auth_len;        /* authentication length */
188         hdr->call_id      = call_id;         /* call identifier - match incoming RPC */
189 }
190
191 /*******************************************************************
192  Reads or writes an RPC_HDR structure.
193 ********************************************************************/
194
195 BOOL smb_io_rpc_hdr(const char *desc,  RPC_HDR *rpc, prs_struct *ps, int depth)
196 {
197         if (rpc == NULL)
198                 return False;
199
200         prs_debug(ps, depth, desc, "smb_io_rpc_hdr");
201         depth++;
202
203         if(!prs_uint8 ("major     ", ps, depth, &rpc->major))
204                 return False;
205
206         if(!prs_uint8 ("minor     ", ps, depth, &rpc->minor))
207                 return False;
208         if(!prs_uint8 ("pkt_type  ", ps, depth, &rpc->pkt_type))
209                 return False;
210         if(!prs_uint8 ("flags     ", ps, depth, &rpc->flags))
211                 return False;
212
213         /* We always marshall in little endian format. */
214         if (MARSHALLING(ps))
215                 rpc->pack_type[0] = 0x10;
216
217         if(!prs_uint8("pack_type0", ps, depth, &rpc->pack_type[0]))
218                 return False;
219         if(!prs_uint8("pack_type1", ps, depth, &rpc->pack_type[1]))
220                 return False;
221         if(!prs_uint8("pack_type2", ps, depth, &rpc->pack_type[2]))
222                 return False;
223         if(!prs_uint8("pack_type3", ps, depth, &rpc->pack_type[3]))
224                 return False;
225
226         /*
227          * If reading and pack_type[0] == 0 then the data is in big-endian
228          * format. Set the flag in the prs_struct to specify reverse-endainness.
229          */
230
231         if (UNMARSHALLING(ps) && rpc->pack_type[0] == 0) {
232                 DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n"));
233                 prs_set_endian_data(ps, RPC_BIG_ENDIAN);
234         }
235
236         if(!prs_uint16("frag_len  ", ps, depth, &rpc->frag_len))
237                 return False;
238         if(!prs_uint16("auth_len  ", ps, depth, &rpc->auth_len))
239                 return False;
240         if(!prs_uint32("call_id   ", ps, depth, &rpc->call_id))
241                 return False;
242         return True;
243 }
244
245 /*******************************************************************
246  Reads or writes an RPC_UUID structure.
247 ********************************************************************/
248
249 static BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth)
250 {
251         if (uuid == NULL)
252                 return False;
253
254         prs_debug(ps, depth, desc, "smb_io_rpc_uuid");
255         depth++;
256
257         if(!prs_align(ps))
258                 return False;
259
260         if(!prs_uint32 ("data   ", ps, depth, &uuid->time_low))
261                 return False;
262         if(!prs_uint16 ("data   ", ps, depth, &uuid->time_mid))
263                 return False;
264         if(!prs_uint16 ("data   ", ps, depth, &uuid->time_hi_and_version))
265                 return False;
266
267         if(!prs_uint8s (False, "data   ", ps, depth, uuid->remaining, sizeof(uuid->remaining)))
268                 return False;
269
270         return True;
271 }
272
273 /*******************************************************************
274  Reads or writes an RPC_IFACE structure.
275 ********************************************************************/
276
277 static BOOL smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth)
278 {
279         if (ifc == NULL)
280                 return False;
281
282         prs_debug(ps, depth, desc, "smb_io_rpc_iface");
283         depth++;
284
285         if (!smb_io_rpc_uuid(  "uuid", &ifc->uuid, ps, depth))
286                 return False;
287
288         if(!prs_uint32 (       "version", ps, depth, &ifc->version))
289                 return False;
290
291         return True;
292 }
293
294 /*******************************************************************
295  Inits an RPC_ADDR_STR structure.
296 ********************************************************************/
297
298 static void init_rpc_addr_str(RPC_ADDR_STR *str, const char *name)
299 {
300         str->len = strlen(name) + 1;
301         fstrcpy(str->str, name);
302 }
303
304 /*******************************************************************
305  Reads or writes an RPC_ADDR_STR structure.
306 ********************************************************************/
307
308 static BOOL smb_io_rpc_addr_str(const char *desc,  RPC_ADDR_STR *str, prs_struct *ps, int depth)
309 {
310         if (str == NULL)
311                 return False;
312
313         prs_debug(ps, depth, desc, "smb_io_rpc_addr_str");
314         depth++;
315         if(!prs_align(ps))
316                 return False;
317
318         if(!prs_uint16 (      "len", ps, depth, &str->len))
319                 return False;
320         if(!prs_uint8s (True, "str", ps, depth, (uchar*)str->str, MIN(str->len, sizeof(str->str)) ))
321                 return False;
322         return True;
323 }
324
325 /*******************************************************************
326  Inits an RPC_HDR_BBA structure.
327 ********************************************************************/
328
329 static void init_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid)
330 {
331         bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
332         bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */   
333         bba->assoc_gid = assoc_gid; /* associated group id (0x0) */ 
334 }
335
336 /*******************************************************************
337  Reads or writes an RPC_HDR_BBA structure.
338 ********************************************************************/
339
340 static BOOL smb_io_rpc_hdr_bba(const char *desc,  RPC_HDR_BBA *rpc, prs_struct *ps, int depth)
341 {
342         if (rpc == NULL)
343                 return False;
344
345         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_bba");
346         depth++;
347
348         if(!prs_uint16("max_tsize", ps, depth, &rpc->max_tsize))
349                 return False;
350         if(!prs_uint16("max_rsize", ps, depth, &rpc->max_rsize))
351                 return False;
352         if(!prs_uint32("assoc_gid", ps, depth, &rpc->assoc_gid))
353                 return False;
354         return True;
355 }
356
357 /*******************************************************************
358  Inits an RPC_HDR_RB structure.
359 ********************************************************************/
360
361 void init_rpc_hdr_rb(RPC_HDR_RB *rpc, 
362                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
363                                 uint32 num_elements, uint16 context_id, uint8 num_syntaxes,
364                                 RPC_IFACE *abstract, RPC_IFACE *transfer)
365 {
366         init_rpc_hdr_bba(&rpc->bba, max_tsize, max_rsize, assoc_gid);
367
368         rpc->num_elements = num_elements ; /* the number of elements (0x1) */
369         rpc->context_id   = context_id   ; /* presentation context identifier (0x0) */
370         rpc->num_syntaxes = num_syntaxes ; /* the number of syntaxes (has always been 1?)(0x1) */
371
372         /* num and vers. of interface client is using */
373         rpc->abstract = *abstract;
374
375         /* num and vers. of interface to use for replies */
376         rpc->transfer = *transfer;
377 }
378
379 /*******************************************************************
380  Reads or writes an RPC_HDR_RB structure.
381 ********************************************************************/
382
383 BOOL smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth)
384 {
385         if (rpc == NULL)
386                 return False;
387
388         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb");
389         depth++;
390
391         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
392                 return False;
393
394         if(!prs_uint32("num_elements", ps, depth, &rpc->num_elements))
395                 return False;
396         if(!prs_uint16("context_id  ", ps, depth, &rpc->context_id ))
397                 return False;
398         if(!prs_uint8 ("num_syntaxes", ps, depth, &rpc->num_syntaxes))
399                 return False;
400
401         if(!smb_io_rpc_iface("", &rpc->abstract, ps, depth))
402                 return False;
403         if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth))
404                 return False;
405
406         return True;
407 }
408
409 /*******************************************************************
410  Inits an RPC_RESULTS structure.
411
412  lkclXXXX only one reason at the moment!
413 ********************************************************************/
414
415 static void init_rpc_results(RPC_RESULTS *res, 
416                                 uint8 num_results, uint16 result, uint16 reason)
417 {
418         res->num_results = num_results; /* the number of results (0x01) */
419         res->result      = result     ;  /* result (0x00 = accept) */
420         res->reason      = reason     ;  /* reason (0x00 = no reason specified) */
421 }
422
423 /*******************************************************************
424  Reads or writes an RPC_RESULTS structure.
425
426  lkclXXXX only one reason at the moment!
427 ********************************************************************/
428
429 static BOOL smb_io_rpc_results(const char *desc, RPC_RESULTS *res, prs_struct *ps, int depth)
430 {
431         if (res == NULL)
432                 return False;
433
434         prs_debug(ps, depth, desc, "smb_io_rpc_results");
435         depth++;
436
437         if(!prs_align(ps))
438                 return False;
439         
440         if(!prs_uint8 ("num_results", ps, depth, &res->num_results))    
441                 return False;
442
443         if(!prs_align(ps))
444                 return False;
445         
446         if(!prs_uint16("result     ", ps, depth, &res->result))
447                 return False;
448         if(!prs_uint16("reason     ", ps, depth, &res->reason))
449                 return False;
450         return True;
451 }
452
453 /*******************************************************************
454  Init an RPC_HDR_BA structure.
455
456  lkclXXXX only one reason at the moment!
457
458 ********************************************************************/
459
460 void init_rpc_hdr_ba(RPC_HDR_BA *rpc, 
461                                 uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
462                                 const char *pipe_addr,
463                                 uint8 num_results, uint16 result, uint16 reason,
464                                 RPC_IFACE *transfer)
465 {
466         init_rpc_hdr_bba (&rpc->bba, max_tsize, max_rsize, assoc_gid);
467         init_rpc_addr_str(&rpc->addr, pipe_addr);
468         init_rpc_results (&rpc->res, num_results, result, reason);
469
470         /* the transfer syntax from the request */
471         memcpy(&rpc->transfer, transfer, sizeof(rpc->transfer));
472 }
473
474 /*******************************************************************
475  Reads or writes an RPC_HDR_BA structure.
476 ********************************************************************/
477
478 BOOL smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth)
479 {
480         if (rpc == NULL)
481                 return False;
482
483         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_ba");
484         depth++;
485
486         if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth))
487                 return False;
488         if(!smb_io_rpc_addr_str("", &rpc->addr, ps, depth))
489                 return False;
490         if(!smb_io_rpc_results("", &rpc->res, ps, depth))
491                 return False;
492         if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth))
493                 return False;
494         return True;
495 }
496
497 /*******************************************************************
498  Init an RPC_HDR_REQ structure.
499 ********************************************************************/
500
501 void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum)
502 {
503         hdr->alloc_hint   = alloc_hint; /* allocation hint */
504         hdr->context_id   = 0;         /* presentation context identifier */
505         hdr->opnum        = opnum;     /* opnum */
506 }
507
508 /*******************************************************************
509  Reads or writes an RPC_HDR_REQ structure.
510 ********************************************************************/
511
512 BOOL smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth)
513 {
514         if (rpc == NULL)
515                 return False;
516
517         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_req");
518         depth++;
519
520         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
521                 return False;
522         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
523                 return False;
524         if(!prs_uint16("opnum     ", ps, depth, &rpc->opnum))
525                 return False;
526         return True;
527 }
528
529 /*******************************************************************
530  Reads or writes an RPC_HDR_RESP structure.
531 ********************************************************************/
532
533 BOOL smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth)
534 {
535         if (rpc == NULL)
536                 return False;
537
538         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_resp");
539         depth++;
540
541         if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint))
542                 return False;
543         if(!prs_uint16("context_id", ps, depth, &rpc->context_id))
544                 return False;
545         if(!prs_uint8 ("cancel_ct ", ps, depth, &rpc->cancel_count))
546                 return False;
547         if(!prs_uint8 ("reserved  ", ps, depth, &rpc->reserved))
548                 return False;
549         return True;
550 }
551
552 /*******************************************************************
553  Reads or writes an RPC_HDR_FAULT structure.
554 ********************************************************************/
555
556 BOOL smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth)
557 {
558         if (rpc == NULL)
559                 return False;
560
561         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault");
562         depth++;
563
564         if(!prs_ntstatus("status  ", ps, depth, &rpc->status))
565                 return False;
566         if(!prs_uint32("reserved", ps, depth, &rpc->reserved))
567                 return False;
568
569     return True;
570 }
571
572 /*******************************************************************
573  Init an RPC_HDR_AUTHA structure.
574 ********************************************************************/
575
576 void init_rpc_hdr_autha(RPC_HDR_AUTHA *rai,
577                                 uint16 max_tsize, uint16 max_rsize,
578                                 uint8 auth_type, uint8 auth_level,
579                                 uint8 stub_type_len)
580 {
581         rai->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
582         rai->max_rsize = max_rsize; /* max receive fragment size (0x1630) */   
583
584         rai->auth_type     = auth_type; /* nt lm ssp 0x0a */
585         rai->auth_level    = auth_level; /* 0x06 */
586         rai->stub_type_len = stub_type_len; /* 0x00 */
587         rai->padding       = 0; /* padding 0x00 */
588
589         rai->unknown       = 0x0014a0c0; /* non-zero pointer to something */
590 }
591
592 /*******************************************************************
593  Reads or writes an RPC_HDR_AUTHA structure.
594 ********************************************************************/
595
596 BOOL smb_io_rpc_hdr_autha(const char *desc, RPC_HDR_AUTHA *rai, prs_struct *ps, int depth)
597 {
598         if (rai == NULL)
599                 return False;
600
601         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_autha");
602         depth++;
603
604         if(!prs_uint16("max_tsize    ", ps, depth, &rai->max_tsize))
605                 return False;
606         if(!prs_uint16("max_rsize    ", ps, depth, &rai->max_rsize))
607                 return False;
608
609         if(!prs_uint8 ("auth_type    ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */
610                 return False;
611         if(!prs_uint8 ("auth_level   ", ps, depth, &rai->auth_level)) /* 0x06 */
612                 return False;
613         if(!prs_uint8 ("stub_type_len", ps, depth, &rai->stub_type_len))
614                 return False;
615         if(!prs_uint8 ("padding      ", ps, depth, &rai->padding))
616                 return False;
617
618         if(!prs_uint32("unknown      ", ps, depth, &rai->unknown)) /* 0x0014a0c0 */
619                 return False;
620
621         return True;
622 }
623
624 /*******************************************************************
625  Inits an RPC_HDR_AUTH structure.
626 ********************************************************************/
627
628 void init_rpc_hdr_auth(RPC_HDR_AUTH *rai,
629                                 uint8 auth_type, uint8 auth_level,
630                                 uint8 padding,
631                                 uint32 ptr)
632 {
633         rai->auth_type     = auth_type; /* nt lm ssp 0x0a */
634         rai->auth_level    = auth_level; /* 0x06 */
635         rai->padding       = padding;
636         rai->reserved      = 0;
637
638         rai->auth_context  = ptr; /* non-zero pointer to something */
639 }
640
641 /*******************************************************************
642  Reads or writes an RPC_HDR_AUTH structure.
643 ********************************************************************/
644
645 BOOL smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth)
646 {
647         if (rai == NULL)
648                 return False;
649
650         prs_debug(ps, depth, desc, "smb_io_rpc_hdr_auth");
651         depth++;
652
653         if(!prs_align(ps))
654                 return False;
655
656         if(!prs_uint8 ("auth_type    ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */
657                 return False;
658         if(!prs_uint8 ("auth_level   ", ps, depth, &rai->auth_level)) /* 0x06 */
659                 return False;
660         if(!prs_uint8 ("padding      ", ps, depth, &rai->padding))
661                 return False;
662         if(!prs_uint8 ("reserved     ", ps, depth, &rai->reserved))
663                 return False;
664         if(!prs_uint32("auth_context ", ps, depth, &rai->auth_context))
665                 return False;
666
667         return True;
668 }
669
670 /*******************************************************************
671  Checks an RPC_AUTH_VERIFIER structure.
672 ********************************************************************/
673
674 BOOL rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav,
675                                 const char *signature, uint32 msg_type)
676 {
677         return (strequal(rav->signature, signature) && rav->msg_type == msg_type);
678 }
679
680 /*******************************************************************
681  Inits an RPC_AUTH_VERIFIER structure.
682 ********************************************************************/
683
684 void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav,
685                                 const char *signature, uint32 msg_type)
686 {
687         fstrcpy(rav->signature, signature); /* "NTLMSSP" */
688         rav->msg_type = msg_type; /* NTLMSSP_MESSAGE_TYPE */
689 }
690
691 /*******************************************************************
692  Reads or writes an RPC_AUTH_VERIFIER structure.
693 ********************************************************************/
694
695 BOOL smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
696 {
697         if (rav == NULL)
698                 return False;
699
700         prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
701         depth++;
702
703         /* "NTLMSSP" */
704         if(!prs_string("signature", ps, depth, rav->signature,
705                         sizeof(rav->signature)))
706                 return False;
707         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type)) /* NTLMSSP_MESSAGE_TYPE */
708                 return False;
709
710         return True;
711 }
712
713 /*******************************************************************
714  This parses an RPC_AUTH_VERIFIER for NETLOGON schannel. I think
715  assuming "NTLMSSP" in sm_io_rpc_auth_verifier is somewhat wrong.
716  I have to look at that later...
717 ********************************************************************/
718
719 BOOL smb_io_rpc_netsec_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
720 {
721         if (rav == NULL)
722                 return False;
723
724         prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
725         depth++;
726
727         if(!prs_string("signature", ps, depth, rav->signature, sizeof(rav->signature)))
728                 return False;
729         if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type))
730                 return False;
731
732         return True;
733 }
734
735 /*******************************************************************
736  Inits an RPC_AUTH_NTLMSSP_NEG structure.
737 ********************************************************************/
738
739 void init_rpc_auth_ntlmssp_neg(RPC_AUTH_NTLMSSP_NEG *neg,
740                                 uint32 neg_flgs,
741                                 const char *myname, const char *domain)
742 {
743         int len_myname = strlen(myname);
744         int len_domain = strlen(domain);
745
746         neg->neg_flgs = neg_flgs ; /* 0x00b2b3 */
747
748         init_str_hdr(&neg->hdr_domain, len_domain, len_domain, 0x20 + len_myname); 
749         init_str_hdr(&neg->hdr_myname, len_myname, len_myname, 0x20); 
750
751         fstrcpy(neg->myname, myname);
752         fstrcpy(neg->domain, domain);
753 }
754
755 /*******************************************************************
756  Reads or writes an RPC_AUTH_NTLMSSP_NEG structure.
757
758  *** lkclXXXX HACK ALERT! ***
759 ********************************************************************/
760
761 BOOL smb_io_rpc_auth_ntlmssp_neg(const char *desc, RPC_AUTH_NTLMSSP_NEG *neg, prs_struct *ps, int depth)
762 {
763         uint32 start_offset = prs_offset(ps);
764         if (neg == NULL)
765                 return False;
766
767         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_neg");
768         depth++;
769
770         if(!prs_uint32("neg_flgs ", ps, depth, &neg->neg_flgs))
771                 return False;
772
773         if (ps->io) {
774                 uint32 old_offset;
775                 uint32 old_neg_flags = neg->neg_flgs;
776
777                 /* reading */
778
779                 ZERO_STRUCTP(neg);
780
781                 neg->neg_flgs = old_neg_flags;
782
783                 if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth))
784                         return False;
785                 if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth))
786                         return False;
787
788                 old_offset = prs_offset(ps);
789
790                 if(!prs_set_offset(ps, neg->hdr_myname.buffer + start_offset - 12))
791                         return False;
792
793                 if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, 
794                                 MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname))))
795                         return False;
796
797                 old_offset += neg->hdr_myname.str_str_len;
798
799                 if(!prs_set_offset(ps, neg->hdr_domain.buffer + start_offset - 12))
800                         return False;
801
802                 if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, 
803                         MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain  ))))
804                         return False;
805
806                 old_offset += neg->hdr_domain  .str_str_len;
807
808                 if(!prs_set_offset(ps, old_offset))
809                         return False;
810         } else {
811                 /* writing */
812                 if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth))
813                         return False;
814                 if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth))
815                         return False;
816
817                 if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, 
818                                         MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname))))
819                         return False;
820                 if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, 
821                                         MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain  ))))
822                         return False;
823         }
824
825         return True;
826 }
827
828 /*******************************************************************
829 creates an RPC_AUTH_NTLMSSP_CHAL structure.
830 ********************************************************************/
831
832 void init_rpc_auth_ntlmssp_chal(RPC_AUTH_NTLMSSP_CHAL *chl,
833                                 uint32 neg_flags,
834                                 uint8 challenge[8])
835 {
836         chl->unknown_1 = 0x0; 
837         chl->unknown_2 = 0x00000028;
838         chl->neg_flags = neg_flags; /* 0x0082b1 */
839
840         memcpy(chl->challenge, challenge, sizeof(chl->challenge)); 
841         memset((char *)chl->reserved , '\0', sizeof(chl->reserved)); 
842 }
843
844 /*******************************************************************
845  Reads or writes an RPC_AUTH_NTLMSSP_CHAL structure.
846 ********************************************************************/
847
848 BOOL smb_io_rpc_auth_ntlmssp_chal(const char *desc, RPC_AUTH_NTLMSSP_CHAL *chl, prs_struct *ps, int depth)
849 {
850         if (chl == NULL)
851                 return False;
852
853         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chal");
854         depth++;
855
856         if(!prs_uint32("unknown_1", ps, depth, &chl->unknown_1)) /* 0x0000 0000 */
857                 return False;
858         if(!prs_uint32("unknown_2", ps, depth, &chl->unknown_2)) /* 0x0000 b2b3 */
859                 return False;
860         if(!prs_uint32("neg_flags", ps, depth, &chl->neg_flags)) /* 0x0000 82b1 */
861                 return False;
862
863         if(!prs_uint8s (False, "challenge", ps, depth, chl->challenge, sizeof(chl->challenge)))
864                 return False;
865         if(!prs_uint8s (False, "reserved ", ps, depth, chl->reserved , sizeof(chl->reserved )))
866                 return False;
867
868         return True;
869 }
870
871 /*******************************************************************
872  Inits an RPC_AUTH_NTLMSSP_RESP structure.
873
874  *** lkclXXXX FUDGE!  HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) ***
875  *** lkclXXXX the actual offset is at the start of the auth verifier    ***
876 ********************************************************************/
877
878 void init_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
879                                 uchar lm_resp[24], uchar nt_resp[24],
880                                 const char *domain, const char *user, const char *wks,
881                                 uint32 neg_flags)
882 {
883         uint32 offset;
884         int dom_len = strlen(domain);
885         int wks_len = strlen(wks);
886         int usr_len = strlen(user);
887         int lm_len  = (lm_resp != NULL) ? 24 : 0;
888         int nt_len  = (nt_resp != NULL) ? 24 : 0;
889
890         DEBUG(5,("make_rpc_auth_ntlmssp_resp\n"));
891
892 #ifdef DEBUG_PASSWORD
893         DEBUG(100,("lm_resp\n"));
894         dump_data(100, (char *)lm_resp, 24);
895         DEBUG(100,("nt_resp\n"));
896         dump_data(100, (char *)nt_resp, 24);
897 #endif
898
899         DEBUG(6,("dom: %s user: %s wks: %s neg_flgs: 0x%x\n",
900                   domain, user, wks, neg_flags));
901
902         offset = 0x40;
903
904         if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
905                 dom_len *= 2;
906                 wks_len *= 2;
907                 usr_len *= 2;
908         }
909
910         init_str_hdr(&rsp->hdr_domain, dom_len, dom_len, offset);
911         offset += dom_len;
912
913         init_str_hdr(&rsp->hdr_usr, usr_len, usr_len, offset);
914         offset += usr_len;
915
916         init_str_hdr(&rsp->hdr_wks, wks_len, wks_len, offset);
917         offset += wks_len;
918
919         init_str_hdr(&rsp->hdr_lm_resp, lm_len, lm_len, offset);
920         offset += lm_len;
921
922         init_str_hdr(&rsp->hdr_nt_resp, nt_len, nt_len, offset);
923         offset += nt_len;
924
925         init_str_hdr(&rsp->hdr_sess_key, 0, 0, offset);
926
927         rsp->neg_flags = neg_flags;
928
929         memcpy(rsp->lm_resp, lm_resp, 24);
930         memcpy(rsp->nt_resp, nt_resp, 24);
931
932         if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
933                 rpcstr_push(rsp->domain, domain, sizeof(rsp->domain), 0);
934                 rpcstr_push(rsp->user, user, sizeof(rsp->user), 0);
935                 rpcstr_push(rsp->wks, wks, sizeof(rsp->wks), 0);
936         } else {
937                 fstrcpy(rsp->domain, domain);
938                 fstrcpy(rsp->user, user);
939                 fstrcpy(rsp->wks, wks);
940         }
941         
942         rsp->sess_key[0] = 0;
943 }
944
945 /*******************************************************************
946  Reads or writes an RPC_AUTH_NTLMSSP_RESP structure.
947
948  *** lkclXXXX FUDGE!  HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) ***
949  *** lkclXXXX the actual offset is at the start of the auth verifier    ***
950 ********************************************************************/
951
952 BOOL smb_io_rpc_auth_ntlmssp_resp(const char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_struct *ps, int depth)
953 {
954         if (rsp == NULL)
955                 return False;
956
957         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_resp");
958         depth++;
959
960         if (ps->io) {
961                 uint32 old_offset;
962
963                 /* reading */
964
965                 ZERO_STRUCTP(rsp);
966
967                 if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth))
968                         return False;
969                 if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth))
970                         return False;
971                 if(!smb_io_strhdr("hdr_domain  ", &rsp->hdr_domain, ps, depth))
972                         return False;
973                 if(!smb_io_strhdr("hdr_user    ", &rsp->hdr_usr, ps, depth))
974                         return False;
975                 if(!smb_io_strhdr("hdr_wks     ", &rsp->hdr_wks, ps, depth)) 
976                         return False;
977                 if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth))
978                         return False;
979
980                 if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */
981                         return False;
982
983                 old_offset = prs_offset(ps);
984
985                 if(!prs_set_offset(ps, rsp->hdr_domain.buffer + 0xc))
986                         return False;
987
988                 if(!prs_uint8s(True , "domain  ", ps, depth, (uint8*)rsp->domain,
989                                 MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain))))
990                         return False;
991
992                 old_offset += rsp->hdr_domain.str_str_len;
993
994                 if(!prs_set_offset(ps, rsp->hdr_usr.buffer + 0xc))
995                         return False;
996
997                 if(!prs_uint8s(True , "user    ", ps, depth, (uint8*)rsp->user,
998                                 MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user))))
999                         return False;
1000
1001                 old_offset += rsp->hdr_usr.str_str_len;
1002
1003                 if(!prs_set_offset(ps, rsp->hdr_wks.buffer + 0xc))
1004                         return False;
1005
1006                 if(!prs_uint8s(True, "wks     ", ps, depth, (uint8*)rsp->wks,
1007                                 MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks))))
1008                         return False;
1009
1010                 old_offset += rsp->hdr_wks.str_str_len;
1011
1012                 if(!prs_set_offset(ps, rsp->hdr_lm_resp.buffer + 0xc))
1013                         return False;
1014
1015                 if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp,
1016                                 MIN(rsp->hdr_lm_resp.str_str_len, sizeof(rsp->lm_resp ))))
1017                         return False;
1018
1019                 old_offset += rsp->hdr_lm_resp.str_str_len;
1020
1021                 if(!prs_set_offset(ps, rsp->hdr_nt_resp.buffer + 0xc))
1022                         return False;
1023
1024                 if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp,
1025                                 MIN(rsp->hdr_nt_resp.str_str_len, sizeof(rsp->nt_resp ))))
1026                         return False;
1027
1028                 old_offset += rsp->hdr_nt_resp.str_str_len;
1029
1030                 if (rsp->hdr_sess_key.str_str_len != 0) {
1031
1032                         if(!prs_set_offset(ps, rsp->hdr_sess_key.buffer + 0x10))
1033                                 return False;
1034
1035                         old_offset += rsp->hdr_sess_key.str_str_len;
1036
1037                         if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key,
1038                                         MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key))))
1039                                 return False;
1040                 }
1041
1042                 if(!prs_set_offset(ps, old_offset))
1043                         return False;
1044         } else {
1045                 /* writing */
1046                 if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth))
1047                         return False;
1048                 if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth))
1049                         return False;
1050                 if(!smb_io_strhdr("hdr_domain  ", &rsp->hdr_domain, ps, depth))
1051                         return False;
1052                 if(!smb_io_strhdr("hdr_user    ", &rsp->hdr_usr, ps, depth))
1053                         return False;
1054                 if(!smb_io_strhdr("hdr_wks     ", &rsp->hdr_wks, ps, depth))
1055                         return False;
1056                 if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth))
1057                         return False;
1058
1059                 if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */
1060                         return False;
1061
1062                 if(!prs_uint8s(True , "domain  ", ps, depth, (uint8*)rsp->domain,
1063                                 MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain))))
1064                         return False;
1065
1066                 if(!prs_uint8s(True , "user    ", ps, depth, (uint8*)rsp->user,
1067                                 MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user))))
1068                         return False;
1069
1070                 if(!prs_uint8s(True , "wks     ", ps, depth, (uint8*)rsp->wks,
1071                                 MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks))))
1072                         return False;
1073                 if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp,
1074                                 MIN(rsp->hdr_lm_resp .str_str_len, sizeof(rsp->lm_resp))))
1075                         return False;
1076                 if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp,
1077                                 MIN(rsp->hdr_nt_resp .str_str_len, sizeof(rsp->nt_resp ))))
1078                         return False;
1079                 if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key,
1080                                 MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key))))
1081                         return False;
1082         }
1083
1084         return True;
1085 }
1086
1087 /*******************************************************************
1088  Checks an RPC_AUTH_NTLMSSP_CHK structure.
1089 ********************************************************************/
1090
1091 BOOL rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk, uint32 crc32, uint32 seq_num)
1092 {
1093         if (chk == NULL)
1094                 return False;
1095
1096         if (chk->crc32 != crc32 ||
1097             chk->ver   != NTLMSSP_SIGN_VERSION ||
1098             chk->seq_num != seq_num)
1099         {
1100                 DEBUG(5,("verify failed - crc %x ver %x seq %d\n",
1101                          chk->crc32, chk->ver, chk->seq_num));
1102                         
1103                 DEBUG(5,("verify expect - crc %x ver %x seq %d\n",
1104                         crc32, NTLMSSP_SIGN_VERSION, seq_num));
1105                 return False;
1106         }
1107         return True;
1108 }
1109
1110 /*******************************************************************
1111  Inits an RPC_AUTH_NTLMSSP_CHK structure.
1112 ********************************************************************/
1113
1114 void init_rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk,
1115                                 uint32 ver, uint32 crc32, uint32 seq_num)
1116 {
1117         chk->ver      = ver;
1118         chk->reserved = 0x0;
1119         chk->crc32    = crc32;
1120         chk->seq_num  = seq_num;
1121 }
1122
1123 /*******************************************************************
1124  Reads or writes an RPC_AUTH_NTLMSSP_CHK structure.
1125 ********************************************************************/
1126
1127 BOOL smb_io_rpc_auth_ntlmssp_chk(const char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_struct *ps, int depth)
1128 {
1129         if (chk == NULL)
1130                 return False;
1131
1132         prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chk");
1133         depth++;
1134
1135         if(!prs_align(ps))
1136                 return False;
1137
1138         if(!prs_uint32("ver     ", ps, depth, &chk->ver))
1139                 return False;
1140         if(!prs_uint32("reserved", ps, depth, &chk->reserved))
1141                 return False;
1142         if(!prs_uint32("crc32   ", ps, depth, &chk->crc32))
1143                 return False;
1144         if(!prs_uint32("seq_num ", ps, depth, &chk->seq_num))
1145                 return False;
1146
1147         return True;
1148 }
1149
1150 /*******************************************************************
1151 creates an RPC_AUTH_NETSEC_NEG structure.
1152 ********************************************************************/
1153 void init_rpc_auth_netsec_neg(RPC_AUTH_NETSEC_NEG *neg,
1154                               const char *domain, const char *myname)
1155 {
1156         neg->type1 = 0;
1157         neg->type2 = 0x3;
1158         fstrcpy(neg->domain, domain);
1159         fstrcpy(neg->myname, myname);
1160 }
1161
1162 /*******************************************************************
1163  Reads or writes an RPC_AUTH_NETSEC_NEG structure.
1164 ********************************************************************/
1165
1166 BOOL smb_io_rpc_auth_netsec_neg(const char *desc, RPC_AUTH_NETSEC_NEG *neg,
1167                                 prs_struct *ps, int depth)
1168 {
1169         if (neg == NULL)
1170                 return False;
1171
1172         prs_debug(ps, depth, desc, "smb_io_rpc_auth_netsec_neg");
1173         depth++;
1174
1175         if(!prs_align(ps))
1176                 return False;
1177
1178         if(!prs_uint32("type1", ps, depth, &neg->type1))
1179                 return False;
1180         if(!prs_uint32("type2", ps, depth, &neg->type2))
1181                 return False;
1182         if(!prs_string("domain  ", ps, depth, neg->domain, sizeof(neg->domain)))
1183                 return False;
1184         if(!prs_string("myname  ", ps, depth, neg->myname, sizeof(neg->myname)))
1185                 return False;
1186
1187         return True;
1188 }
1189
1190
1191 /*******************************************************************
1192 creates an RPC_AUTH_NETSEC_CHK structure.
1193 ********************************************************************/
1194 BOOL init_rpc_auth_netsec_chk(RPC_AUTH_NETSEC_CHK * chk,
1195                               const uchar sig[8],
1196                               const uchar packet_digest[8],
1197                               const uchar seq_num[8], const uchar confounder[8])
1198 {
1199         if (chk == NULL)
1200                 return False;
1201
1202         memcpy(chk->sig, sig, sizeof(chk->sig));
1203         memcpy(chk->packet_digest, packet_digest, sizeof(chk->packet_digest));
1204         memcpy(chk->seq_num, seq_num, sizeof(chk->seq_num));
1205         memcpy(chk->confounder, confounder, sizeof(chk->confounder));
1206
1207         return True;
1208 }
1209
1210 /*******************************************************************
1211 reads or writes an RPC_AUTH_NETSEC_CHK structure.
1212 ********************************************************************/
1213 BOOL smb_io_rpc_auth_netsec_chk(const char *desc, RPC_AUTH_NETSEC_CHK * chk,
1214                                 prs_struct *ps, int depth)
1215 {
1216         if (chk == NULL)
1217                 return False;
1218
1219         prs_debug(ps, depth, desc, "smb_io_rpc_auth_netsec_chk");
1220         depth++;
1221
1222         prs_uint8s(False, "sig  ", ps, depth, chk->sig, sizeof(chk->sig));
1223         prs_uint8s(False, "seq_num", ps, depth, chk->seq_num, sizeof(chk->seq_num));
1224         prs_uint8s(False, "packet_digest", ps, depth, chk->packet_digest, sizeof(chk->packet_digest));
1225         prs_uint8s(False, "data8", ps, depth, chk->confounder, sizeof(chk->confounder));
1226
1227         return True;
1228 }
1229