2 Unix SMB/CIFS implementation.
3 test suite for drsblobs ndr operations
5 Copyright (C) Guenther Deschner 2010
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "torture/ndr/ndr.h"
23 #include "librpc/gen_ndr/ndr_drsblobs.h"
24 #include "torture/ndr/proto.h"
26 static const uint8_t forest_trust_info_data_out
[] = {
27 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x3e, 0xca, 0xca, 0x01, 0x00, 0xaf, 0xd5, 0x9b,
29 0x00, 0x07, 0x00, 0x00, 0x00, 0x66, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74,
30 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0xca, 0xca, 0x01,
31 0x00, 0xaf, 0xd5, 0x9b, 0x02, 0x18, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0x68, 0x4a, 0x64,
33 0x28, 0xac, 0x88, 0xa2, 0x74, 0x17, 0x3e, 0x2d, 0x8f, 0x07, 0x00, 0x00,
34 0x00, 0x66, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x02, 0x00, 0x00, 0x00,
38 static bool forest_trust_info_check_out(struct torture_context
*tctx
,
39 struct ForestTrustInfo
*r
)
41 torture_assert_int_equal(tctx
, r
->version
, 1, "version");
42 torture_assert_int_equal(tctx
, r
->count
, 2, "count");
43 torture_assert_int_equal(tctx
, r
->records
[0].record_size
, 0x00000018, "record size");
44 torture_assert_int_equal(tctx
, r
->records
[0].record
.flags
, 0, "record flags");
45 torture_assert_u64_equal(tctx
, r
->records
[0].record
.timestamp
, 0x9BD5AF0001CACA3EULL
, "record timestamp");
46 torture_assert_int_equal(tctx
, r
->records
[0].record
.type
, FOREST_TRUST_TOP_LEVEL_NAME
, "record type");
47 torture_assert_int_equal(tctx
, r
->records
[0].record
.data
.name
.size
, 7, "record name size");
48 torture_assert_str_equal(tctx
, r
->records
[0].record
.data
.name
.string
, "f2.test", "record name string");
49 torture_assert_int_equal(tctx
, r
->records
[1].record_size
, 0x0000003a, "record size");
50 torture_assert_int_equal(tctx
, r
->records
[1].record
.flags
, 0, "record flags");
51 torture_assert_u64_equal(tctx
, r
->records
[1].record
.timestamp
, 0x9BD5AF0001CACA3EULL
, "record timestamp");
52 torture_assert_int_equal(tctx
, r
->records
[1].record
.type
, FOREST_TRUST_DOMAIN_INFO
, "record type");
53 torture_assert_int_equal(tctx
, r
->records
[1].record
.data
.info
.sid_size
, 0x00000018, "record info sid_size");
54 torture_assert_sid_equal(tctx
, &r
->records
[1].record
.data
.info
.sid
, dom_sid_parse_talloc(tctx
, "S-1-5-21-677661288-1956808876-2402106903"), "record info sid");
55 torture_assert_int_equal(tctx
, r
->records
[1].record
.data
.info
.dns_name
.size
, 7, "record name size");
56 torture_assert_str_equal(tctx
, r
->records
[1].record
.data
.info
.dns_name
.string
, "f2.test", "record info dns_name string");
57 torture_assert_int_equal(tctx
, r
->records
[1].record
.data
.info
.netbios_name
.size
, 2, "record info netbios_name size");
58 torture_assert_str_equal(tctx
, r
->records
[1].record
.data
.info
.netbios_name
.string
, "F2", "record info netbios_name string");
63 static const uint8_t trust_domain_passwords_in
[] = {
64 0x34, 0x1f, 0x6e, 0xcd, 0x5f, 0x14, 0x99, 0xf9, 0xd8, 0x34, 0x9f, 0x1d,
65 0x1c, 0xcf, 0x1f, 0x02, 0xb8, 0x30, 0xcc, 0x77, 0x21, 0xc1, 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ff, 0x4f, 0xb2, 0x1e, 0xb4, 0x0b, 0xb2,
96 0x4d, 0x7a, 0xdc, 0xf3, 0x7e, 0x81, 0xbb, 0x6b, 0x2e, 0x29, 0x24, 0x61,
97 0x93, 0x1e, 0x20, 0x57, 0x66, 0x20, 0xcf, 0x4d, 0x67, 0x76, 0xb0, 0x7b,
98 0xd9, 0x9d, 0x30, 0x95, 0xba, 0xb0, 0xcc, 0xf6, 0xcc, 0xff, 0xea, 0x32,
99 0x55, 0x15, 0xcd, 0xdf, 0xaf, 0xf6, 0x16, 0xd1, 0x1f, 0x6f, 0xb7, 0xda,
100 0x1a, 0x75, 0xc7, 0x4f, 0xb1, 0xeb, 0x1a, 0xe2, 0x17, 0x8b, 0xe8, 0x5f,
101 0x41, 0x74, 0x5f, 0x41, 0xe0, 0x46, 0x08, 0x9a, 0xc6, 0x81, 0x19, 0x26,
102 0xcd, 0x60, 0xb2, 0x3a, 0x7a, 0x39, 0x2b, 0xee, 0x83, 0x8e, 0xdb, 0x83,
103 0x6b, 0x48, 0x24, 0x73, 0x91, 0x31, 0x64, 0xce, 0x2e, 0x43, 0x32, 0xb2,
104 0xcd, 0x60, 0x98, 0x87, 0xa9, 0x9b, 0xc3, 0x60, 0x7c, 0xa7, 0x52, 0x3e,
105 0xb8, 0x28, 0x4d, 0xcd, 0x5f, 0xaf, 0xe3, 0xe6, 0xa0, 0x06, 0x93, 0xfb,
106 0xd9, 0xd4, 0x2b, 0x52, 0xed, 0xec, 0x97, 0x3a, 0x01, 0x00, 0x00, 0x00,
107 0x0c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x41, 0xb6,
108 0x7c, 0x16, 0xcb, 0x01, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
109 0xb6, 0xe4, 0x4e, 0xa0, 0xf4, 0xed, 0x90, 0x9d, 0x67, 0xff, 0xda, 0xda,
110 0xc7, 0xe5, 0xaf, 0xc7, 0x4d, 0xc1, 0x58, 0xaf, 0x5f, 0x06, 0x5c, 0xe9,
111 0x4c, 0x5a, 0x02, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
112 0x38, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x41, 0xb6, 0x7c, 0x16, 0xcb, 0x01,
113 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0xb6, 0xe4, 0x4e, 0xa0,
114 0xf4, 0xed, 0x90, 0x9d, 0x67, 0xff, 0xda, 0xda, 0xc7, 0xe5, 0xaf, 0xc7,
115 0x4d, 0xc1, 0x58, 0xaf, 0x5f, 0x06, 0x5c, 0xe9, 0x4c, 0x5a, 0x02, 0xfd,
116 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00
119 /* these are taken from the trust objects of a w2k8r2 forest, with a
120 * trust relationship between the forest parent and a child domain
122 static const char *trustAuthIncoming
=
123 "AQAAAAwAAAAcAQAASuQ+RXJdzAECAAAAAAEAAMOWL6UVfVKiJOUsGcT03H"
124 "jHxr2ACsMMOV5ynM617Tp7idNC+c4egdqk4S9YEpvR2YvHmdZdymL6F7QKm8OkXazYZF2r/gZ/bI+"
125 "jkWbsn4O8qyAc3OUKQRZwBbf+lxBW+vM4O3ZpUjz5BSKCcFQgM+MY91yVU8Nji3HNnvGnDquobFAZ"
126 "hxjL+S1l5+QZgkfyfv5mQScGRbU1Lar1xg9G3JznUb7S6pvrBO2nwK8g+KZBfJy5UeULigDH4IWo/"
127 "JmtaEGkKE2uiKIjdsEQd/uwnkouW26XzRc0ulfJnPFftGnT9KIcShPf7DLj/tstmQAAceRMFHJTY3"
128 "PmxoowoK8HUyBK5D5Fcl3MAQIAAAAAAQAAw5YvpRV9UqIk5SwZxPTceMfGvYAKwww5XnKczrXtOnu"
129 "J00L5zh6B2qThL1gSm9HZi8eZ1l3KYvoXtAqbw6RdrNhkXav+Bn9sj6ORZuyfg7yrIBzc5QpBFnAF"
130 "t/6XEFb68zg7dmlSPPkFIoJwVCAz4xj3XJVTw2OLcc2e8acOq6hsUBmHGMv5LWXn5BmCR/J+/mZBJ"
131 "wZFtTUtqvXGD0bcnOdRvtLqm+sE7afAryD4pkF8nLlR5QuKAMfghaj8ma1oQaQoTa6IoiN2wRB3+7"
132 "CeSi5bbpfNFzS6V8mc8V+0adP0ohxKE9/sMuP+2y2ZAABx5EwUclNjc+bGijCgrwdTIA==";
134 static const char *trustAuthOutgoing
=
135 "AQAAAAwAAAAcAQAASuQ+RXJdzAECAAAAAAEAAMOWL6UVfVKiJOUsGcT03H"
136 "jHxr2ACsMMOV5ynM617Tp7idNC+c4egdqk4S9YEpvR2YvHmdZdymL6F7QKm8OkXazYZF2r/gZ/bI+"
137 "jkWbsn4O8qyAc3OUKQRZwBbf+lxBW+vM4O3ZpUjz5BSKCcFQgM+MY91yVU8Nji3HNnvGnDquobFAZ"
138 "hxjL+S1l5+QZgkfyfv5mQScGRbU1Lar1xg9G3JznUb7S6pvrBO2nwK8g+KZBfJy5UeULigDH4IWo/"
139 "JmtaEGkKE2uiKIjdsEQd/uwnkouW26XzRc0ulfJnPFftGnT9KIcShPf7DLj/tstmQAAceRMFHJTY3"
140 "PmxoowoK8HUyBK5D5Fcl3MAQIAAAAAAQAAw5YvpRV9UqIk5SwZxPTceMfGvYAKwww5XnKczrXtOnu"
141 "J00L5zh6B2qThL1gSm9HZi8eZ1l3KYvoXtAqbw6RdrNhkXav+Bn9sj6ORZuyfg7yrIBzc5QpBFnAF"
142 "t/6XEFb68zg7dmlSPPkFIoJwVCAz4xj3XJVTw2OLcc2e8acOq6hsUBmHGMv5LWXn5BmCR/J+/mZBJ"
143 "wZFtTUtqvXGD0bcnOdRvtLqm+sE7afAryD4pkF8nLlR5QuKAMfghaj8ma1oQaQoTa6IoiN2wRB3+7"
144 "CeSi5bbpfNFzS6V8mc8V+0adP0ohxKE9/sMuP+2y2ZAABx5EwUclNjc+bGijCgrwdTIA==";
147 static bool trust_domain_passwords_check_in(struct torture_context
*tctx
,
148 struct trustDomainPasswords
*r
)
150 /* torture_assert_mem_equal(tctx, r->confounder, trust_domain_passwords_in, 512, "confounder mismatch"); */
152 torture_assert_int_equal(tctx
, r
->outgoing
.count
, 1, "outgoing count mismatch");
153 torture_assert_int_equal(tctx
, r
->outgoing
.current_offset
, 0x0000000c, "outgoing current offset mismatch");
154 torture_assert_int_equal(tctx
, r
->outgoing
.previous_offset
, 0x00000038, "outgoing previous offset mismatch");
156 torture_assert_int_equal(tctx
, r
->outgoing
.current
.count
, 1, "outgoing current count mismatch");
157 torture_assert_int_equal(tctx
, r
->outgoing
.current
.array
[0].LastUpdateTime
, 0xB6416B4C, "outgoing current last update time mismatch");
158 torture_assert_int_equal(tctx
, r
->outgoing
.current
.array
[0].AuthType
, TRUST_AUTH_TYPE_CLEAR
, "outgoing current auth type mismatch");
159 torture_assert_int_equal(tctx
, r
->outgoing
.current
.array
[0].AuthInfo
.clear
.size
, 0x0000001c, "outgoing current auth info size mismatch");
160 torture_assert_mem_equal(tctx
, r
->outgoing
.current
.array
[0].AuthInfo
.clear
.password
, trust_domain_passwords_in
+512+12+8+4+4, 0x0000001c, "outgoing current auth info password mismatch");
162 torture_assert_int_equal(tctx
, r
->outgoing
.previous
.count
, 0, "outgoing previous count mismatch");
164 torture_assert_int_equal(tctx
, r
->incoming
.count
, 1, "incoming count mismatch");
165 torture_assert_int_equal(tctx
, r
->incoming
.current_offset
, 0x0000000c, "incoming current offset mismatch");
166 torture_assert_int_equal(tctx
, r
->incoming
.previous_offset
, 0x00000038, "incoming previous offset mismatch");
168 torture_assert_int_equal(tctx
, r
->incoming
.current
.count
, 1, "incoming current count mismatch");
169 torture_assert_int_equal(tctx
, r
->incoming
.current
.array
[0].LastUpdateTime
, 0xB6416B4C, "incoming current last update time mismatch");
170 torture_assert_int_equal(tctx
, r
->incoming
.current
.array
[0].AuthType
, TRUST_AUTH_TYPE_CLEAR
, "incoming current auth type mismatch");
171 torture_assert_int_equal(tctx
, r
->incoming
.current
.array
[0].AuthInfo
.clear
.size
, 0x0000001c, "incoming current auth info size mismatch");
172 torture_assert_mem_equal(tctx
, r
->incoming
.current
.array
[0].AuthInfo
.clear
.password
, trust_domain_passwords_in
+512+12+8+4+4+0x0000001c+12+8+4+4, 0x0000001c, "incoming current auth info password mismatch");
174 torture_assert_int_equal(tctx
, r
->incoming
.previous
.count
, 0, "incoming previous count mismatch");
176 torture_assert_int_equal(tctx
, r
->outgoing_size
, 0x00000038, "outgoing size mismatch");
177 torture_assert_int_equal(tctx
, r
->incoming_size
, 0x00000038, "incoming size mismatch");
182 struct torture_suite
*ndr_drsblobs_suite(TALLOC_CTX
*ctx
)
184 struct torture_suite
*suite
= torture_suite_create(ctx
, "drsblobs");
186 torture_suite_add_ndr_pull_test(suite
, ForestTrustInfo
, forest_trust_info_data_out
, forest_trust_info_check_out
);
187 torture_suite_add_ndr_pull_test(suite
, trustDomainPasswords
, trust_domain_passwords_in
, trust_domain_passwords_check_in
);
189 torture_suite_add_ndr_pullpush_test(suite
,
191 base64_decode_data_blob_talloc(suite
, trustAuthIncoming
),
194 torture_suite_add_ndr_pullpush_test(suite
,
196 base64_decode_data_blob_talloc(suite
, trustAuthOutgoing
),