2 Unix SMB/CIFS implementation.
3 Test conversion form struct lsa_TrustDomainInfoAuthInfo to
4 struct trustAuthInOutBlob and back
5 Copyright (C) Sumit Bose 2011
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/proto.h"
23 #include "librpc/gen_ndr/lsa.h"
24 #include "rpc_client/util_lsarpc.h"
26 static bool cmp_TrustDomainInfoBuffer(struct lsa_TrustDomainInfoBuffer a
,
27 struct lsa_TrustDomainInfoBuffer b
)
29 if (a
.last_update_time
!= b
. last_update_time
||
30 a
.AuthType
!= b
.AuthType
||
31 a
.data
.size
!= b
.data
.size
||
32 memcmp(a
.data
.data
, b
.data
.data
, a
.data
.size
) !=0) {
39 static bool cmp_auth_info(struct lsa_TrustDomainInfoAuthInfo
*a
,
40 struct lsa_TrustDomainInfoAuthInfo
*b
)
44 if (a
->incoming_count
!= b
->incoming_count
||
45 a
->outgoing_count
!= b
->outgoing_count
) {
49 for (c
= 0; c
< a
->incoming_count
; c
++) {
50 if (!cmp_TrustDomainInfoBuffer(a
->incoming_current_auth_info
[c
],
51 b
->incoming_current_auth_info
[c
])) {
55 if (a
->incoming_previous_auth_info
!= NULL
&&
56 b
->incoming_previous_auth_info
!= NULL
) {
57 if (!cmp_TrustDomainInfoBuffer(a
->incoming_previous_auth_info
[c
],
58 b
->incoming_previous_auth_info
[c
])) {
61 } else if (a
->incoming_previous_auth_info
== NULL
&&
62 b
->incoming_previous_auth_info
== NULL
) {
69 for (c
= 0; c
< a
->outgoing_count
; c
++) {
70 if (!cmp_TrustDomainInfoBuffer(a
->outgoing_current_auth_info
[c
],
71 b
->outgoing_current_auth_info
[c
])) {
75 if (a
->outgoing_previous_auth_info
!= NULL
&&
76 b
->outgoing_previous_auth_info
!= NULL
) {
77 if (!cmp_TrustDomainInfoBuffer(a
->outgoing_previous_auth_info
[c
],
78 b
->outgoing_previous_auth_info
[c
])) {
81 } else if (a
->outgoing_previous_auth_info
== NULL
&&
82 b
->outgoing_previous_auth_info
== NULL
) {
92 static bool covert_and_compare(struct lsa_TrustDomainInfoAuthInfo
*auth_info
)
98 struct lsa_TrustDomainInfoAuthInfo auth_info_out
;
101 tmp_ctx
= talloc_new(NULL
);
102 if (tmp_ctx
== NULL
) {
106 status
= auth_info_2_auth_blob(tmp_ctx
, auth_info
, &incoming
, &outgoing
);
107 if (!NT_STATUS_IS_OK(status
)) {
108 talloc_free(tmp_ctx
);
112 status
= auth_blob_2_auth_info(tmp_ctx
, incoming
, outgoing
,
114 if (!NT_STATUS_IS_OK(status
)) {
115 talloc_free(tmp_ctx
);
119 result
= cmp_auth_info(auth_info
, &auth_info_out
);
120 talloc_free(tmp_ctx
);
125 bool run_local_conv_auth_info(int dummy
)
127 struct lsa_TrustDomainInfoAuthInfo auth_info
;
128 struct lsa_TrustDomainInfoBuffer ic
[1];
129 struct lsa_TrustDomainInfoBuffer ip
[1];
130 struct lsa_TrustDomainInfoBuffer oc
[2];
131 struct lsa_TrustDomainInfoBuffer op
[2];
132 uint32_t version
= 3;
134 ic
[0].last_update_time
= 12345;
135 ic
[0].AuthType
= TRUST_AUTH_TYPE_CLEAR
;
136 ic
[0].data
.size
= strlen("iPaSsWoRd");
137 ic
[0].data
.data
= discard_const_p(uint8_t, "iPaSsWoRd");
139 ip
[0].last_update_time
= 67890;
140 ip
[0].AuthType
= TRUST_AUTH_TYPE_CLEAR
;
141 ip
[0].data
.size
= strlen("OlDiPaSsWoRd");
142 ip
[0].data
.data
= discard_const_p(uint8_t, "OlDiPaSsWoRd");
144 oc
[0].last_update_time
= 24580;
145 oc
[0].AuthType
= TRUST_AUTH_TYPE_CLEAR
;
146 oc
[0].data
.size
= strlen("oPaSsWoRd");
147 oc
[0].data
.data
= discard_const_p(uint8_t, "oPaSsWoRd");
148 oc
[1].last_update_time
= 24580;
149 oc
[1].AuthType
= TRUST_AUTH_TYPE_VERSION
;
151 oc
[1].data
.data
= (uint8_t *) &version
;
153 op
[0].last_update_time
= 13579;
154 op
[0].AuthType
= TRUST_AUTH_TYPE_CLEAR
;
155 op
[0].data
.size
= strlen("OlDoPaSsWoRd");
156 op
[0].data
.data
= discard_const_p(uint8_t, "OlDoPaSsWoRd");
157 op
[1].last_update_time
= 24580;
158 op
[1].AuthType
= TRUST_AUTH_TYPE_VERSION
;
160 op
[1].data
.data
= (uint8_t *) &version
;
162 auth_info
.incoming_count
= 0;
163 auth_info
.incoming_current_auth_info
= NULL
;
164 auth_info
.incoming_previous_auth_info
= NULL
;
165 auth_info
.outgoing_count
= 0;
166 auth_info
.outgoing_current_auth_info
= NULL
;
167 auth_info
.outgoing_previous_auth_info
= NULL
;
169 if (!covert_and_compare(&auth_info
)) {
173 auth_info
.incoming_count
= 1;
174 auth_info
.incoming_current_auth_info
= ic
;
175 auth_info
.incoming_previous_auth_info
= NULL
;
176 auth_info
.outgoing_count
= 0;
177 auth_info
.outgoing_current_auth_info
= NULL
;
178 auth_info
.outgoing_previous_auth_info
= NULL
;
180 if (!covert_and_compare(&auth_info
)) {
184 auth_info
.incoming_count
= 0;
185 auth_info
.incoming_current_auth_info
= NULL
;
186 auth_info
.incoming_previous_auth_info
= NULL
;
187 auth_info
.outgoing_count
= 2;
188 auth_info
.outgoing_current_auth_info
= oc
;
189 auth_info
.outgoing_previous_auth_info
= NULL
;
191 if (!covert_and_compare(&auth_info
)) {
195 auth_info
.incoming_count
= 1;
196 auth_info
.incoming_current_auth_info
= ic
;
197 auth_info
.incoming_previous_auth_info
= NULL
;
198 auth_info
.outgoing_count
= 2;
199 auth_info
.outgoing_current_auth_info
= oc
;
200 auth_info
.outgoing_previous_auth_info
= NULL
;
202 if (!covert_and_compare(&auth_info
)) {
206 auth_info
.incoming_count
= 1;
207 auth_info
.incoming_current_auth_info
= ic
;
208 auth_info
.incoming_previous_auth_info
= ip
;
209 auth_info
.outgoing_count
= 2;
210 auth_info
.outgoing_current_auth_info
= oc
;
211 auth_info
.outgoing_previous_auth_info
= op
;
213 if (!covert_and_compare(&auth_info
)) {