Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 :
4 : Manually parsed structures found in the DRS protocol
5 :
6 : Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
7 : Copyright (C) Guenther Deschner <gd@samba.org> 2010
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 3 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, see <http://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "includes.h"
24 : #include "librpc/gen_ndr/ndr_drsblobs.h"
25 : #include "../lib/util/asn1.h"
26 :
27 5713 : _PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct AuthenticationInformationArray *r)
28 : {
29 50 : uint32_t cntr_array_0;
30 5713 : if (ndr_flags & NDR_SCALARS) {
31 5713 : NDR_CHECK(ndr_push_align(ndr, 4));
32 11724 : for (cntr_array_0 = 0; cntr_array_0 < r->count; cntr_array_0++) {
33 6011 : NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
34 : }
35 5713 : NDR_CHECK(ndr_push_align(ndr, 4));
36 : }
37 5713 : if (ndr_flags & NDR_BUFFERS) {
38 50 : }
39 5713 : return NDR_ERR_SUCCESS;
40 : }
41 :
42 6032 : _PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct AuthenticationInformationArray *r)
43 : {
44 6032 : if (ndr_flags & NDR_SCALARS) {
45 6032 : r->count = 0;
46 6032 : NDR_PULL_ALLOC_N(ndr, r->array, r->count);
47 : /* entry is at least 16 bytes large */
48 16327 : while (ndr->offset + 16 <= ndr->data_size) {
49 10295 : r->array = talloc_realloc(ndr, r->array, struct AuthenticationInformation, r->count + 1);
50 10295 : NDR_ERR_HAVE_NO_MEMORY(r->array);
51 10295 : NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[r->count]));
52 10295 : r->count++;
53 : }
54 6032 : NDR_CHECK(ndr_pull_align(ndr, 4));
55 : }
56 6032 : if (ndr_flags & NDR_BUFFERS) {
57 28 : }
58 6032 : return NDR_ERR_SUCCESS;
59 : }
60 :
61 1157 : _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct trustAuthInOutBlob *r)
62 : {
63 1157 : if (ndr_flags & NDR_SCALARS) {
64 1157 : NDR_CHECK(ndr_push_align(ndr, 4));
65 1157 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
66 1157 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0));
67 1157 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0));
68 : {
69 10 : struct ndr_push *_ndr_current;
70 1157 : NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0)));
71 1157 : NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current));
72 1157 : NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0)));
73 : }
74 : {
75 1157 : libndr_flags _flags_save_AuthenticationInformationArray = ndr->flags;
76 1157 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
77 : {
78 10 : struct ndr_push *_ndr_previous;
79 1157 : NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_previous, 0, -1));
80 1157 : NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_previous, NDR_SCALARS, &r->previous));
81 1157 : NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_previous, 0, -1));
82 : }
83 1157 : ndr->flags = _flags_save_AuthenticationInformationArray;
84 : }
85 1157 : NDR_CHECK(ndr_push_trailer_align(ndr, 4));
86 : }
87 1157 : if (ndr_flags & NDR_BUFFERS) {
88 10 : }
89 1157 : return NDR_ERR_SUCCESS;
90 : }
91 :
92 :
93 105 : _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct trustDomainPasswords *r)
94 : {
95 105 : if (ndr_flags & NDR_SCALARS) {
96 2 : uint32_t offset;
97 105 : NDR_PULL_ALIGN(ndr, 4);
98 105 : NDR_PULL_NEED_BYTES(ndr, 8);
99 :
100 105 : offset = ndr->offset;
101 105 : ndr->offset = ndr->data_size - 8;
102 :
103 105 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
104 105 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
105 :
106 105 : ndr->offset = offset;
107 105 : NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512));
108 : {
109 2 : struct ndr_pull *_ndr_outgoing;
110 105 : NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
111 105 : NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
112 105 : NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
113 : }
114 : {
115 2 : struct ndr_pull *_ndr_incoming;
116 105 : NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
117 105 : NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
118 105 : NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
119 : }
120 105 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
121 105 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
122 : }
123 105 : if (ndr_flags & NDR_BUFFERS) {
124 2 : }
125 105 : return NDR_ERR_SUCCESS;
126 : }
127 :
128 0 : _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
129 : {
130 0 : ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
131 : {
132 0 : libndr_flags _flags_save_STRUCT = ndr->flags;
133 0 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
134 0 : ndr->depth++;
135 0 : ndr_print_uint16(ndr, "entryID", r->entryID);
136 0 : ndr->print(ndr, "%-25s: length=%"PRIu16, "oid", r->length);
137 0 : if (r->binary_oid) {
138 0 : char *partial_oid = NULL;
139 0 : DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
140 0 : char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
141 0 : ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
142 0 : ndr->depth++;
143 0 : ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
144 0 : ndr->depth--;
145 0 : talloc_free(hex_str);
146 0 : talloc_free(partial_oid);
147 : }
148 0 : ndr->depth--;
149 0 : ndr->flags = _flags_save_STRUCT;
150 : }
151 0 : }
152 :
153 85928 : _PUBLIC_ enum ndr_err_code ndr_push_supplementalCredentialsSubBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct supplementalCredentialsSubBlob *r)
154 : {
155 844 : uint32_t cntr_packages_0;
156 85928 : NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
157 85928 : if (ndr_flags & NDR_SCALARS) {
158 85928 : if ((r->signature != SUPPLEMENTAL_CREDENTIALS_SIGNATURE)
159 80 : && (r->num_packages == 0)) {
160 72 : return NDR_ERR_SUCCESS;
161 : }
162 85848 : NDR_CHECK(ndr_push_align(ndr, 3));
163 85848 : NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_PREFIX, 0x30, sizeof(uint16_t), CH_UTF16));
164 85848 : NDR_CHECK(ndr_push_supplementalCredentialsSignature(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_SIGNATURE));
165 85848 : if (r->num_packages > 0) {
166 85820 : NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_packages));
167 : }
168 445504 : for (cntr_packages_0 = 0; cntr_packages_0 < (r->num_packages); cntr_packages_0++) {
169 359656 : NDR_CHECK(ndr_push_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
170 : }
171 85848 : NDR_CHECK(ndr_push_trailer_align(ndr, 3));
172 : }
173 85848 : if (ndr_flags & NDR_BUFFERS) {
174 836 : }
175 85848 : return NDR_ERR_SUCCESS;
176 : }
177 :
178 311283 : _PUBLIC_ enum ndr_err_code ndr_pull_supplementalCredentialsSubBlob(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct supplementalCredentialsSubBlob *r)
179 : {
180 311283 : uint32_t size_prefix_0 = 0;
181 311283 : uint32_t size_packages_0 = 0;
182 10203 : uint32_t cntr_packages_0;
183 311283 : TALLOC_CTX *_mem_save_packages_0 = NULL;
184 311283 : NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
185 311283 : if (ndr_flags & NDR_SCALARS) {
186 311283 : uint32_t remaining = 0;
187 311283 : NDR_CHECK(ndr_pull_align(ndr, 3));
188 311283 : size_prefix_0 = 0x30;
189 311283 : remaining = ndr->data_size - ndr->offset;
190 311283 : if (remaining >= size_prefix_0) {
191 311272 : NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->prefix, size_prefix_0, sizeof(uint16_t), CH_UTF16));
192 : } else {
193 11 : r->prefix = NULL;
194 : }
195 311283 : remaining = ndr->data_size - ndr->offset;
196 311283 : if (remaining >= 2) {
197 311272 : NDR_CHECK(ndr_pull_supplementalCredentialsSignature(ndr, NDR_SCALARS, &r->signature));
198 : } else {
199 11 : r->signature = 0;
200 : }
201 311283 : remaining = ndr->data_size - ndr->offset;
202 311283 : if (remaining > 0) {
203 311270 : NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_packages));
204 : } else {
205 13 : r->num_packages = 0;
206 : }
207 311283 : size_packages_0 = r->num_packages;
208 311283 : NDR_PULL_ALLOC_N(ndr, r->packages, size_packages_0);
209 311283 : _mem_save_packages_0 = NDR_PULL_GET_MEM_CTX(ndr);
210 311283 : NDR_PULL_SET_MEM_CTX(ndr, r->packages, 0);
211 1682828 : for (cntr_packages_0 = 0; cntr_packages_0 < (size_packages_0); cntr_packages_0++) {
212 1371545 : NDR_CHECK(ndr_pull_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0]));
213 : }
214 311283 : NDR_PULL_SET_MEM_CTX(ndr, _mem_save_packages_0, 0);
215 311283 : NDR_CHECK(ndr_pull_trailer_align(ndr, 3));
216 : }
217 311283 : if (ndr_flags & NDR_BUFFERS) {
218 10203 : }
219 311283 : return NDR_ERR_SUCCESS;
220 : }
|