2 Unix SMB/CIFS implementation.
4 test suite for DCE/RPC verification trailer parsing
6 Copyright (C) David Disseldorp 2014
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <sys/types.h>
27 #include "librpc/gen_ndr/security.h"
28 #include "lib/param/param.h"
29 #include "lib/util/dlinklist.h"
30 #include "libcli/resolve/resolve.h"
31 #include "librpc/gen_ndr/ndr_dcerpc.h"
32 #include "librpc/gen_ndr/ndr_dcerpc_c.h"
33 #include "torture/torture.h"
34 #include "torture/local/proto.h"
36 /* VT blob obtained from an FSRVP request */
37 uint8_t test_vt
[] = {0x8a, 0xe3, 0x13, 0x71, 0x02, 0xf4, 0x36, 0x71,
38 0x02, 0x40, 0x28, 0x00, 0x3c, 0x65, 0xe0, 0xa8,
39 0x44, 0x27, 0x89, 0x43, 0xa6, 0x1d, 0x73, 0x73,
40 0xdf, 0x8b, 0x22, 0x92, 0x01, 0x00, 0x00, 0x00,
41 0x33, 0x05, 0x71, 0x71, 0xba, 0xbe, 0x37, 0x49,
42 0x83, 0x19, 0xb5, 0xdb, 0xef, 0x9c, 0xcc, 0x36,
43 0x01, 0x00, 0x00, 0x00};
45 const char *vt_abstr_syntax
= "a8e0653c-2744-4389-a61d-7373df8b2292/0x00000001";
46 const char *vt_trans_syntax
= "71710533-beba-4937-8319-b5dbef9ccc36/0x00000001";
48 static bool test_verif_trailer_pctx(struct torture_context
*tctx
)
52 struct dcerpc_sec_vt_pcontext pctx
;
53 struct dcerpc_sec_verification_trailer
*vt
= NULL
;
55 enum ndr_err_code ndr_err
;
56 struct ndr_print
*ndr_print
;
57 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
58 torture_assert(tctx
, mem_ctx
!= NULL
, "mem");
61 blob
.length
= ARRAY_SIZE(test_vt
);
63 ndr
= ndr_pull_init_blob(&blob
, mem_ctx
);
64 torture_assert(tctx
, ndr
!= NULL
, "ndr");
66 ndr_err
= ndr_pop_dcerpc_sec_verification_trailer(ndr
, mem_ctx
, &vt
);
67 torture_assert(tctx
, NDR_ERR_CODE_IS_SUCCESS(ndr_err
), "ndr");
69 ndr_print
= talloc_zero(mem_ctx
, struct ndr_print
);
70 torture_assert(tctx
, ndr_print
!= NULL
, "mem");
71 ndr_print
->print
= ndr_print_printf_helper
;
74 ndr_print_dcerpc_sec_verification_trailer(ndr_print
,
75 "Verification Trailer", vt
);
78 ok
= ndr_syntax_id_from_string(vt_abstr_syntax
, &pctx
.abstract_syntax
);
79 torture_assert(tctx
, ok
, "vt_abstr_syntax");
80 ok
= ndr_syntax_id_from_string(vt_trans_syntax
, &pctx
.transfer_syntax
);
81 torture_assert(tctx
, ok
, "vt_trans_syntax");
83 ok
= dcerpc_sec_verification_trailer_check(vt
, NULL
, &pctx
, NULL
);
84 torture_assert(tctx
, ok
, "VT check");
91 struct torture_suite
*torture_local_verif_trailer(TALLOC_CTX
*mem_ctx
)
93 struct torture_suite
*suite
= torture_suite_create(mem_ctx
,
96 torture_suite_add_simple_test(suite
,
98 test_verif_trailer_pctx
);