/src/samba/librpc/ndr/ndr_drsblobs.c
Line | Count | Source |
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 | | _PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct AuthenticationInformationArray *r) |
28 | 924 | { |
29 | 924 | uint32_t cntr_array_0; |
30 | 924 | if (ndr_flags & NDR_SCALARS) { |
31 | 924 | NDR_CHECK(ndr_push_align(ndr, 4)); |
32 | 52.5k | for (cntr_array_0 = 0; cntr_array_0 < r->count; cntr_array_0++) { |
33 | 51.6k | NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0])); |
34 | 51.6k | } |
35 | 924 | NDR_CHECK(ndr_push_align(ndr, 4)); |
36 | 924 | } |
37 | 924 | if (ndr_flags & NDR_BUFFERS) { |
38 | 572 | } |
39 | 924 | return NDR_ERR_SUCCESS; |
40 | 924 | } |
41 | | |
42 | | _PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct AuthenticationInformationArray *r) |
43 | 499 | { |
44 | 499 | if (ndr_flags & NDR_SCALARS) { |
45 | 499 | r->count = 0; |
46 | 499 | NDR_PULL_ALLOC_N(ndr, r->array, r->count); |
47 | | /* entry is at least 16 bytes large */ |
48 | 51.8k | while (ndr->offset + 16 <= ndr->data_size) { |
49 | 51.4k | r->array = talloc_realloc(ndr, r->array, struct AuthenticationInformation, r->count + 1); |
50 | 51.4k | NDR_ERR_HAVE_NO_MEMORY(r->array); |
51 | 51.4k | NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[r->count])); |
52 | 51.3k | r->count++; |
53 | 51.3k | } |
54 | 454 | NDR_CHECK(ndr_pull_align(ndr, 4)); |
55 | 454 | } |
56 | 451 | if (ndr_flags & NDR_BUFFERS) { |
57 | 143 | } |
58 | 451 | return NDR_ERR_SUCCESS; |
59 | 499 | } |
60 | | |
61 | | _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct trustAuthInOutBlob *r) |
62 | 181 | { |
63 | 181 | if (ndr_flags & NDR_SCALARS) { |
64 | 181 | NDR_CHECK(ndr_push_align(ndr, 4)); |
65 | 181 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); |
66 | 181 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0)); |
67 | 181 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0)); |
68 | 181 | { |
69 | 181 | struct ndr_push *_ndr_current; |
70 | 181 | 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 | 181 | NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current)); |
72 | 181 | 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 | 181 | } |
74 | 171 | { |
75 | 171 | libndr_flags _flags_save_AuthenticationInformationArray = ndr->flags; |
76 | 171 | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); |
77 | 171 | { |
78 | 171 | struct ndr_push *_ndr_previous; |
79 | 171 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_previous, 0, -1)); |
80 | 171 | NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_previous, NDR_SCALARS, &r->previous)); |
81 | 171 | NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_previous, 0, -1)); |
82 | 171 | } |
83 | 171 | ndr->flags = _flags_save_AuthenticationInformationArray; |
84 | 171 | } |
85 | 171 | NDR_CHECK(ndr_push_trailer_align(ndr, 4)); |
86 | 171 | } |
87 | 171 | if (ndr_flags & NDR_BUFFERS) { |
88 | 155 | } |
89 | 171 | return NDR_ERR_SUCCESS; |
90 | 181 | } |
91 | | |
92 | | |
93 | | _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct trustDomainPasswords *r) |
94 | 65 | { |
95 | 65 | if (ndr_flags & NDR_SCALARS) { |
96 | 65 | uint32_t offset; |
97 | 65 | NDR_PULL_ALIGN(ndr, 4); |
98 | 65 | NDR_PULL_NEED_BYTES(ndr, 8); |
99 | | |
100 | 60 | offset = ndr->offset; |
101 | 60 | ndr->offset = ndr->data_size - 8; |
102 | | |
103 | 60 | NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); |
104 | 60 | NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); |
105 | | |
106 | 22 | ndr->offset = offset; |
107 | 22 | NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512)); |
108 | 21 | { |
109 | 21 | struct ndr_pull *_ndr_outgoing; |
110 | 21 | NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size)); |
111 | 20 | NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing)); |
112 | 19 | NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size)); |
113 | 19 | } |
114 | 19 | { |
115 | 19 | struct ndr_pull *_ndr_incoming; |
116 | 19 | NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size)); |
117 | 18 | NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming)); |
118 | 14 | NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size)); |
119 | 14 | } |
120 | 14 | NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); |
121 | 12 | NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); |
122 | 12 | } |
123 | 10 | if (ndr_flags & NDR_BUFFERS) { |
124 | 10 | } |
125 | 10 | return NDR_ERR_SUCCESS; |
126 | 65 | } |
127 | | |
128 | | _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r) |
129 | 3.99k | { |
130 | 3.99k | ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry"); |
131 | 3.99k | { |
132 | 3.99k | libndr_flags _flags_save_STRUCT = ndr->flags; |
133 | 3.99k | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); |
134 | 3.99k | ndr->depth++; |
135 | 3.99k | ndr_print_uint16(ndr, "entryID", r->entryID); |
136 | 3.99k | ndr->print(ndr, "%-25s: length=%"PRIu16, "oid", r->length); |
137 | 3.99k | if (r->binary_oid) { |
138 | 3.99k | char *partial_oid = NULL; |
139 | 3.99k | DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length); |
140 | 3.99k | char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob); |
141 | 3.99k | ber_read_partial_OID_String(ndr, oid_blob, &partial_oid); |
142 | 3.99k | ndr->depth++; |
143 | 3.99k | ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid); |
144 | 3.99k | ndr->depth--; |
145 | 3.99k | TALLOC_FREE(hex_str); |
146 | 3.99k | TALLOC_FREE(partial_oid); |
147 | 3.99k | } |
148 | 3.99k | ndr->depth--; |
149 | 3.99k | ndr->flags = _flags_save_STRUCT; |
150 | 3.99k | } |
151 | 3.99k | } |
152 | | |
153 | | _PUBLIC_ enum ndr_err_code ndr_push_supplementalCredentialsSubBlob(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct supplementalCredentialsSubBlob *r) |
154 | 344 | { |
155 | 344 | uint32_t cntr_packages_0; |
156 | 344 | NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); |
157 | 344 | if (ndr_flags & NDR_SCALARS) { |
158 | 344 | if ((r->signature != SUPPLEMENTAL_CREDENTIALS_SIGNATURE) |
159 | 336 | && (r->num_packages == 0)) { |
160 | 168 | return NDR_ERR_SUCCESS; |
161 | 168 | } |
162 | 176 | NDR_CHECK(ndr_push_align(ndr, 3)); |
163 | 176 | NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_PREFIX, 0x30, sizeof(uint16_t), CH_UTF16)); |
164 | 176 | NDR_CHECK(ndr_push_supplementalCredentialsSignature(ndr, NDR_SCALARS, SUPPLEMENTAL_CREDENTIALS_SIGNATURE)); |
165 | 176 | if (r->num_packages > 0) { |
166 | 168 | NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_packages)); |
167 | 168 | } |
168 | 42.8k | for (cntr_packages_0 = 0; cntr_packages_0 < (r->num_packages); cntr_packages_0++) { |
169 | 42.6k | NDR_CHECK(ndr_push_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0])); |
170 | 42.6k | } |
171 | 176 | NDR_CHECK(ndr_push_trailer_align(ndr, 3)); |
172 | 176 | } |
173 | 176 | if (ndr_flags & NDR_BUFFERS) { |
174 | 132 | } |
175 | 176 | return NDR_ERR_SUCCESS; |
176 | 344 | } |
177 | | |
178 | | _PUBLIC_ enum ndr_err_code ndr_pull_supplementalCredentialsSubBlob(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct supplementalCredentialsSubBlob *r) |
179 | 156 | { |
180 | 156 | uint32_t size_prefix_0 = 0; |
181 | 156 | uint32_t size_packages_0 = 0; |
182 | 156 | uint32_t cntr_packages_0; |
183 | 156 | TALLOC_CTX *_mem_save_packages_0 = NULL; |
184 | 156 | NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); |
185 | 156 | if (ndr_flags & NDR_SCALARS) { |
186 | 156 | uint32_t remaining = 0; |
187 | 156 | NDR_CHECK(ndr_pull_align(ndr, 3)); |
188 | 156 | size_prefix_0 = 0x30; |
189 | 156 | remaining = ndr->data_size - ndr->offset; |
190 | 156 | if (remaining >= size_prefix_0) { |
191 | 59 | NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->prefix, size_prefix_0, sizeof(uint16_t), CH_UTF16)); |
192 | 97 | } else { |
193 | 97 | r->prefix = NULL; |
194 | 97 | } |
195 | 155 | remaining = ndr->data_size - ndr->offset; |
196 | 155 | if (remaining >= 2) { |
197 | 149 | NDR_CHECK(ndr_pull_supplementalCredentialsSignature(ndr, NDR_SCALARS, &r->signature)); |
198 | 149 | } else { |
199 | 6 | r->signature = 0; |
200 | 6 | } |
201 | 155 | remaining = ndr->data_size - ndr->offset; |
202 | 155 | if (remaining > 0) { |
203 | 127 | NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_packages)); |
204 | 127 | } else { |
205 | 28 | r->num_packages = 0; |
206 | 28 | } |
207 | 153 | size_packages_0 = r->num_packages; |
208 | 153 | NDR_PULL_ALLOC_N(ndr, r->packages, size_packages_0); |
209 | 153 | _mem_save_packages_0 = NDR_PULL_GET_MEM_CTX(ndr); |
210 | 153 | NDR_PULL_SET_MEM_CTX(ndr, r->packages, 0); |
211 | 11.3k | for (cntr_packages_0 = 0; cntr_packages_0 < (size_packages_0); cntr_packages_0++) { |
212 | 11.2k | NDR_CHECK(ndr_pull_supplementalCredentialsPackage(ndr, NDR_SCALARS, &r->packages[cntr_packages_0])); |
213 | 11.2k | } |
214 | 100 | NDR_PULL_SET_MEM_CTX(ndr, _mem_save_packages_0, 0); |
215 | 100 | NDR_CHECK(ndr_pull_trailer_align(ndr, 3)); |
216 | 100 | } |
217 | 100 | if (ndr_flags & NDR_BUFFERS) { |
218 | 0 | } |
219 | 100 | return NDR_ERR_SUCCESS; |
220 | 156 | } |