Line data Source code
1 : /* Generated from /builds/samba-team/lts-community/samba/third_party/heimdal/lib/hdb/hdb.asn1 */
2 : /* Do not edit */
3 :
4 : #if defined(_WIN32) && !defined(ASN1_LIB)
5 : # error "ASN1_LIB must be defined"
6 : #endif
7 : #include <stdio.h>
8 : #include <stdlib.h>
9 : #include <time.h>
10 : #include <string.h>
11 : #include <errno.h>
12 : #include <limits.h>
13 : #include <krb5-types.h>
14 : #include "hdb_asn1.h"
15 : #include "hdb_asn1-priv.h"
16 : #include <asn1_err.h>
17 : #include <der.h>
18 : #include <asn1-template.h>
19 :
20 : #include <parse_units.h>
21 :
22 : int ASN1CALL
23 0 : encode_Salt(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Salt *data, size_t *size)
24 : {
25 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
26 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
27 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
28 :
29 : /* opaque */
30 0 : if((data)->opaque) {
31 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
32 0 : ret = 0;
33 0 : e = der_put_octet_string(p, len, (data)->opaque, &l);
34 0 : if (e) return e;
35 0 : p -= l; len -= l; ret += l;
36 :
37 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
38 0 : if (e) return e;
39 0 : p -= l; len -= l; ret += l;
40 :
41 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
42 0 : if (e) return e;
43 0 : p -= l; len -= l; ret += l;
44 :
45 0 : ret += Top_tag_oldret;
46 : }
47 : /* salt */
48 : {
49 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
50 0 : ret = 0;
51 0 : e = der_put_octet_string(p, len, &(data)->salt, &l);
52 0 : if (e) return e;
53 0 : p -= l; len -= l; ret += l;
54 :
55 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
56 0 : if (e) return e;
57 0 : p -= l; len -= l; ret += l;
58 :
59 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
60 0 : if (e) return e;
61 0 : p -= l; len -= l; ret += l;
62 :
63 0 : ret += Top_tag_oldret;
64 : }
65 : /* type */
66 : {
67 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
68 0 : ret = 0;
69 0 : e = der_put_unsigned(p, len, &(data)->type, &l);
70 0 : if (e) return e;
71 0 : p -= l; len -= l; ret += l;
72 :
73 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
74 0 : if (e) return e;
75 0 : p -= l; len -= l; ret += l;
76 :
77 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
78 0 : if (e) return e;
79 0 : p -= l; len -= l; ret += l;
80 :
81 0 : ret += Top_tag_oldret;
82 : }
83 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
84 0 : if (e) return e;
85 0 : p -= l; len -= l; ret += l;
86 :
87 0 : *size = ret;
88 0 : return 0;
89 : }
90 :
91 : int ASN1CALL
92 0 : decode_Salt(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, Salt *data, size_t *size)
93 : {
94 0 : size_t ret = 0;
95 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
96 : int e HEIMDAL_UNUSED_ATTRIBUTE;
97 :
98 0 : memset(data, 0, sizeof(*data));
99 : {
100 : size_t Top_datalen;
101 : Der_type Top_type;
102 : size_t Top_oldlen;
103 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
104 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
105 0 : if (e) goto fail;
106 0 : p += l; len -= l; ret += l;
107 0 : Top_oldlen = len;
108 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
109 0 : len = Top_datalen;
110 : {
111 : size_t type_datalen;
112 : Der_type type_type;
113 : size_t type_oldlen;
114 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &type_type, 0, &type_datalen, &l);
115 0 : if (e == 0 && type_type != CONS) { e = ASN1_BAD_ID; }
116 0 : if (e) goto fail;
117 0 : p += l; len -= l; ret += l;
118 0 : type_oldlen = len;
119 0 : if (type_datalen > len) { e = ASN1_OVERRUN; goto fail; }
120 0 : len = type_datalen;
121 : {
122 : size_t type_Tag_datalen;
123 : Der_type type_Tag_type;
124 : size_t type_Tag_oldlen;
125 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &type_Tag_type, UT_Integer, &type_Tag_datalen, &l);
126 0 : if (e == 0 && type_Tag_type != PRIM) { e = ASN1_BAD_ID; }
127 0 : if (e) goto fail;
128 0 : p += l; len -= l; ret += l;
129 0 : type_Tag_oldlen = len;
130 0 : if (type_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
131 0 : len = type_Tag_datalen;
132 0 : e = der_get_unsigned(p, len, &(data)->type, &l);
133 0 : if(e) goto fail;
134 0 : p += l; len -= l; ret += l;
135 0 : len = type_Tag_oldlen - type_Tag_datalen;
136 : }
137 0 : len = type_oldlen - type_datalen;
138 : }
139 : {
140 : size_t salt_datalen;
141 : Der_type salt_type;
142 : size_t salt_oldlen;
143 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &salt_type, 1, &salt_datalen, &l);
144 0 : if (e == 0 && salt_type != CONS) { e = ASN1_BAD_ID; }
145 0 : if (e) goto fail;
146 0 : p += l; len -= l; ret += l;
147 0 : salt_oldlen = len;
148 0 : if (salt_datalen > len) { e = ASN1_OVERRUN; goto fail; }
149 0 : len = salt_datalen;
150 : {
151 : size_t salt_Tag_datalen;
152 : Der_type salt_Tag_type;
153 : size_t salt_Tag_oldlen;
154 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &salt_Tag_type, UT_OctetString, &salt_Tag_datalen, &l);
155 0 : if (e == 0 && salt_Tag_type != PRIM) { e = ASN1_BAD_ID; }
156 0 : if (e) goto fail;
157 0 : p += l; len -= l; ret += l;
158 0 : salt_Tag_oldlen = len;
159 0 : if (salt_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
160 0 : len = salt_Tag_datalen;
161 0 : e = der_get_octet_string(p, len, &(data)->salt, &l);
162 0 : if(e) goto fail;
163 0 : p += l; len -= l; ret += l;
164 0 : len = salt_Tag_oldlen - salt_Tag_datalen;
165 : }
166 0 : len = salt_oldlen - salt_datalen;
167 : }
168 : {
169 : size_t opaque_datalen;
170 : Der_type opaque_type;
171 : size_t opaque_oldlen;
172 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &opaque_type, 2, &opaque_datalen, &l);
173 0 : if (e == 0 && opaque_type != CONS) { e = ASN1_BAD_ID; }
174 0 : if(e) {
175 0 : (data)->opaque = NULL;
176 : } else {
177 0 : (data)->opaque = calloc(1, sizeof(*(data)->opaque));
178 0 : if ((data)->opaque == NULL) { e = ENOMEM; goto fail; }
179 0 : p += l; len -= l; ret += l;
180 0 : opaque_oldlen = len;
181 0 : if (opaque_datalen > len) { e = ASN1_OVERRUN; goto fail; }
182 0 : len = opaque_datalen;
183 : {
184 : size_t opaque_Tag_datalen;
185 : Der_type opaque_Tag_type;
186 : size_t opaque_Tag_oldlen;
187 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &opaque_Tag_type, UT_OctetString, &opaque_Tag_datalen, &l);
188 0 : if (e == 0 && opaque_Tag_type != PRIM) { e = ASN1_BAD_ID; }
189 0 : if (e) goto fail;
190 0 : p += l; len -= l; ret += l;
191 0 : opaque_Tag_oldlen = len;
192 0 : if (opaque_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
193 0 : len = opaque_Tag_datalen;
194 0 : e = der_get_octet_string(p, len, (data)->opaque, &l);
195 0 : if(e) goto fail;
196 0 : p += l; len -= l; ret += l;
197 0 : len = opaque_Tag_oldlen - opaque_Tag_datalen;
198 : }
199 0 : len = opaque_oldlen - opaque_datalen;
200 : }
201 : }
202 0 : len = Top_oldlen - Top_datalen;
203 : }
204 0 : if(size) *size = ret;
205 0 : return 0;
206 0 : fail:
207 0 : free_Salt(data);
208 0 : return e;
209 : }
210 :
211 : void ASN1CALL
212 256552 : free_Salt(Salt *data)
213 : {
214 256552 : *&(data)->type = 0;
215 256552 : der_free_octet_string(&(data)->salt);
216 256552 : if((data)->opaque) {
217 0 : der_free_octet_string((data)->opaque);
218 0 : free((data)->opaque);
219 0 : (data)->opaque = NULL;
220 : }
221 256552 : }
222 :
223 : size_t ASN1CALL
224 0 : length_Salt(const Salt *data)
225 : {
226 0 : size_t ret = 0;
227 : {
228 0 : size_t Top_tag_oldret = ret;
229 0 : ret = 0;
230 0 : ret += der_length_unsigned(&(data)->type);
231 0 : ret += 1 + der_length_len (ret);
232 0 : ret += 1 + der_length_len (ret);
233 0 : ret += Top_tag_oldret;
234 : }
235 : {
236 0 : size_t Top_tag_oldret = ret;
237 0 : ret = 0;
238 0 : ret += der_length_octet_string(&(data)->salt);
239 0 : ret += 1 + der_length_len (ret);
240 0 : ret += 1 + der_length_len (ret);
241 0 : ret += Top_tag_oldret;
242 : }
243 0 : if((data)->opaque){
244 0 : size_t Top_tag_oldret = ret;
245 0 : ret = 0;
246 0 : ret += der_length_octet_string((data)->opaque);
247 0 : ret += 1 + der_length_len (ret);
248 0 : ret += 1 + der_length_len (ret);
249 0 : ret += Top_tag_oldret;
250 : }
251 0 : ret += 1 + der_length_len (ret);
252 0 : return ret;
253 : }
254 :
255 : int ASN1CALL
256 0 : copy_Salt(const Salt *from, Salt *to)
257 : {
258 0 : memset(to, 0, sizeof(*to));
259 0 : *(&(to)->type) = *(&(from)->type);
260 0 : if(der_copy_octet_string(&(from)->salt, &(to)->salt)) goto fail;
261 0 : if((from)->opaque) {
262 0 : (to)->opaque = calloc(1, sizeof(*(to)->opaque));
263 0 : if((to)->opaque == NULL) goto fail;
264 0 : if(der_copy_octet_string((from)->opaque, (to)->opaque)) goto fail;
265 : }else
266 0 : (to)->opaque = NULL;
267 0 : return 0;
268 0 : fail:
269 0 : free_Salt(to);
270 0 : return ENOMEM;
271 : }
272 :
273 : char * ASN1CALL
274 0 : print_Salt(const Salt *data, int flags)
275 0 : { errno = EINVAL; return 0; }
276 :
277 : int ASN1CALL
278 0 : encode_Key(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Key *data, size_t *size)
279 : {
280 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
281 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
282 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
283 :
284 : /* salt */
285 0 : if((data)->salt) {
286 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
287 0 : ret = 0;
288 0 : e = encode_Salt(p, len, (data)->salt, &l);
289 0 : if (e) return e;
290 0 : p -= l; len -= l; ret += l;
291 :
292 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
293 0 : if (e) return e;
294 0 : p -= l; len -= l; ret += l;
295 :
296 0 : ret += Top_tag_oldret;
297 : }
298 : /* key */
299 : {
300 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
301 0 : ret = 0;
302 0 : e = encode_EncryptionKey(p, len, &(data)->key, &l);
303 0 : if (e) return e;
304 0 : p -= l; len -= l; ret += l;
305 :
306 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
307 0 : if (e) return e;
308 0 : p -= l; len -= l; ret += l;
309 :
310 0 : ret += Top_tag_oldret;
311 : }
312 : /* mkvno */
313 0 : if((data)->mkvno) {
314 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
315 0 : ret = 0;
316 0 : e = der_put_unsigned(p, len, (data)->mkvno, &l);
317 0 : if (e) return e;
318 0 : p -= l; len -= l; ret += l;
319 :
320 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
321 0 : if (e) return e;
322 0 : p -= l; len -= l; ret += l;
323 :
324 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
325 0 : if (e) return e;
326 0 : p -= l; len -= l; ret += l;
327 :
328 0 : ret += Top_tag_oldret;
329 : }
330 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
331 0 : if (e) return e;
332 0 : p -= l; len -= l; ret += l;
333 :
334 0 : *size = ret;
335 0 : return 0;
336 : }
337 :
338 : int ASN1CALL
339 0 : decode_Key(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, Key *data, size_t *size)
340 : {
341 0 : size_t ret = 0;
342 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
343 : int e HEIMDAL_UNUSED_ATTRIBUTE;
344 :
345 0 : memset(data, 0, sizeof(*data));
346 : {
347 : size_t Top_datalen;
348 : Der_type Top_type;
349 : size_t Top_oldlen;
350 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
351 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
352 0 : if (e) goto fail;
353 0 : p += l; len -= l; ret += l;
354 0 : Top_oldlen = len;
355 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
356 0 : len = Top_datalen;
357 : {
358 : size_t mkvno_datalen;
359 : Der_type mkvno_type;
360 : size_t mkvno_oldlen;
361 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mkvno_type, 0, &mkvno_datalen, &l);
362 0 : if (e == 0 && mkvno_type != CONS) { e = ASN1_BAD_ID; }
363 0 : if(e) {
364 0 : (data)->mkvno = NULL;
365 : } else {
366 0 : (data)->mkvno = calloc(1, sizeof(*(data)->mkvno));
367 0 : if ((data)->mkvno == NULL) { e = ENOMEM; goto fail; }
368 0 : p += l; len -= l; ret += l;
369 0 : mkvno_oldlen = len;
370 0 : if (mkvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
371 0 : len = mkvno_datalen;
372 : {
373 : size_t mkvno_Tag_datalen;
374 : Der_type mkvno_Tag_type;
375 : size_t mkvno_Tag_oldlen;
376 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mkvno_Tag_type, UT_Integer, &mkvno_Tag_datalen, &l);
377 0 : if (e == 0 && mkvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
378 0 : if (e) goto fail;
379 0 : p += l; len -= l; ret += l;
380 0 : mkvno_Tag_oldlen = len;
381 0 : if (mkvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
382 0 : len = mkvno_Tag_datalen;
383 0 : e = der_get_unsigned(p, len, (data)->mkvno, &l);
384 0 : if(e) goto fail;
385 0 : p += l; len -= l; ret += l;
386 0 : len = mkvno_Tag_oldlen - mkvno_Tag_datalen;
387 : }
388 0 : len = mkvno_oldlen - mkvno_datalen;
389 : }
390 : }
391 : {
392 : size_t key_datalen;
393 : Der_type key_type;
394 : size_t key_oldlen;
395 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &key_type, 1, &key_datalen, &l);
396 0 : if (e == 0 && key_type != CONS) { e = ASN1_BAD_ID; }
397 0 : if (e) goto fail;
398 0 : p += l; len -= l; ret += l;
399 0 : key_oldlen = len;
400 0 : if (key_datalen > len) { e = ASN1_OVERRUN; goto fail; }
401 0 : len = key_datalen;
402 0 : e = decode_EncryptionKey(p, len, &(data)->key, &l);
403 0 : if(e) goto fail;
404 0 : p += l; len -= l; ret += l;
405 0 : len = key_oldlen - key_datalen;
406 : }
407 : {
408 : size_t salt_datalen;
409 : Der_type salt_type;
410 : size_t salt_oldlen;
411 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &salt_type, 2, &salt_datalen, &l);
412 0 : if (e == 0 && salt_type != CONS) { e = ASN1_BAD_ID; }
413 0 : if(e) {
414 0 : (data)->salt = NULL;
415 : } else {
416 0 : (data)->salt = calloc(1, sizeof(*(data)->salt));
417 0 : if ((data)->salt == NULL) { e = ENOMEM; goto fail; }
418 0 : p += l; len -= l; ret += l;
419 0 : salt_oldlen = len;
420 0 : if (salt_datalen > len) { e = ASN1_OVERRUN; goto fail; }
421 0 : len = salt_datalen;
422 0 : e = decode_Salt(p, len, (data)->salt, &l);
423 0 : if(e) goto fail;
424 0 : p += l; len -= l; ret += l;
425 0 : len = salt_oldlen - salt_datalen;
426 : }
427 : }
428 0 : len = Top_oldlen - Top_datalen;
429 : }
430 0 : if(size) *size = ret;
431 0 : return 0;
432 0 : fail:
433 0 : free_Key(data);
434 0 : return e;
435 : }
436 :
437 : void ASN1CALL
438 356455 : free_Key(Key *data)
439 : {
440 356455 : if((data)->mkvno) {
441 0 : *(data)->mkvno = 0;
442 0 : free((data)->mkvno);
443 0 : (data)->mkvno = NULL;
444 : }
445 356455 : free_EncryptionKey(&(data)->key);
446 356455 : if((data)->salt) {
447 256552 : free_Salt((data)->salt);
448 256552 : free((data)->salt);
449 256552 : (data)->salt = NULL;
450 : }
451 356455 : }
452 :
453 : size_t ASN1CALL
454 0 : length_Key(const Key *data)
455 : {
456 0 : size_t ret = 0;
457 0 : if((data)->mkvno){
458 0 : size_t Top_tag_oldret = ret;
459 0 : ret = 0;
460 0 : ret += der_length_unsigned((data)->mkvno);
461 0 : ret += 1 + der_length_len (ret);
462 0 : ret += 1 + der_length_len (ret);
463 0 : ret += Top_tag_oldret;
464 : }
465 : {
466 0 : size_t Top_tag_oldret = ret;
467 0 : ret = 0;
468 0 : ret += length_EncryptionKey(&(data)->key);
469 0 : ret += 1 + der_length_len (ret);
470 0 : ret += Top_tag_oldret;
471 : }
472 0 : if((data)->salt){
473 0 : size_t Top_tag_oldret = ret;
474 0 : ret = 0;
475 0 : ret += length_Salt((data)->salt);
476 0 : ret += 1 + der_length_len (ret);
477 0 : ret += Top_tag_oldret;
478 : }
479 0 : ret += 1 + der_length_len (ret);
480 0 : return ret;
481 : }
482 :
483 : int ASN1CALL
484 0 : copy_Key(const Key *from, Key *to)
485 : {
486 0 : memset(to, 0, sizeof(*to));
487 0 : if((from)->mkvno) {
488 0 : (to)->mkvno = calloc(1, sizeof(*(to)->mkvno));
489 0 : if((to)->mkvno == NULL) goto fail;
490 0 : *((to)->mkvno) = *((from)->mkvno);
491 : }else
492 0 : (to)->mkvno = NULL;
493 0 : if(copy_EncryptionKey(&(from)->key, &(to)->key)) goto fail;
494 0 : if((from)->salt) {
495 0 : (to)->salt = calloc(1, sizeof(*(to)->salt));
496 0 : if((to)->salt == NULL) goto fail;
497 0 : if(copy_Salt((from)->salt, (to)->salt)) goto fail;
498 : }else
499 0 : (to)->salt = NULL;
500 0 : return 0;
501 0 : fail:
502 0 : free_Key(to);
503 0 : return ENOMEM;
504 : }
505 :
506 : char * ASN1CALL
507 0 : print_Key(const Key *data, int flags)
508 0 : { errno = EINVAL; return 0; }
509 :
510 : int ASN1CALL
511 0 : encode_Event(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Event *data, size_t *size)
512 : {
513 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
514 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
515 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
516 :
517 : /* principal */
518 0 : if((data)->principal) {
519 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
520 0 : ret = 0;
521 0 : e = encode_Principal(p, len, (data)->principal, &l);
522 0 : if (e) return e;
523 0 : p -= l; len -= l; ret += l;
524 :
525 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
526 0 : if (e) return e;
527 0 : p -= l; len -= l; ret += l;
528 :
529 0 : ret += Top_tag_oldret;
530 : }
531 : /* time */
532 : {
533 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
534 0 : ret = 0;
535 0 : e = encode_KerberosTime(p, len, &(data)->time, &l);
536 0 : if (e) return e;
537 0 : p -= l; len -= l; ret += l;
538 :
539 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
540 0 : if (e) return e;
541 0 : p -= l; len -= l; ret += l;
542 :
543 0 : ret += Top_tag_oldret;
544 : }
545 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
546 0 : if (e) return e;
547 0 : p -= l; len -= l; ret += l;
548 :
549 0 : *size = ret;
550 0 : return 0;
551 : }
552 :
553 : int ASN1CALL
554 0 : decode_Event(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, Event *data, size_t *size)
555 : {
556 0 : size_t ret = 0;
557 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
558 : int e HEIMDAL_UNUSED_ATTRIBUTE;
559 :
560 0 : memset(data, 0, sizeof(*data));
561 : {
562 : size_t Top_datalen;
563 : Der_type Top_type;
564 : size_t Top_oldlen;
565 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
566 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
567 0 : if (e) goto fail;
568 0 : p += l; len -= l; ret += l;
569 0 : Top_oldlen = len;
570 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
571 0 : len = Top_datalen;
572 : {
573 : size_t time_datalen;
574 : Der_type time_type;
575 : size_t time_oldlen;
576 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &time_type, 0, &time_datalen, &l);
577 0 : if (e == 0 && time_type != CONS) { e = ASN1_BAD_ID; }
578 0 : if (e) goto fail;
579 0 : p += l; len -= l; ret += l;
580 0 : time_oldlen = len;
581 0 : if (time_datalen > len) { e = ASN1_OVERRUN; goto fail; }
582 0 : len = time_datalen;
583 0 : e = decode_KerberosTime(p, len, &(data)->time, &l);
584 0 : if(e) goto fail;
585 0 : p += l; len -= l; ret += l;
586 0 : len = time_oldlen - time_datalen;
587 : }
588 : {
589 : size_t principal_datalen;
590 : Der_type principal_type;
591 : size_t principal_oldlen;
592 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &principal_type, 1, &principal_datalen, &l);
593 0 : if (e == 0 && principal_type != CONS) { e = ASN1_BAD_ID; }
594 0 : if(e) {
595 0 : (data)->principal = NULL;
596 : } else {
597 0 : (data)->principal = calloc(1, sizeof(*(data)->principal));
598 0 : if ((data)->principal == NULL) { e = ENOMEM; goto fail; }
599 0 : p += l; len -= l; ret += l;
600 0 : principal_oldlen = len;
601 0 : if (principal_datalen > len) { e = ASN1_OVERRUN; goto fail; }
602 0 : len = principal_datalen;
603 0 : e = decode_Principal(p, len, (data)->principal, &l);
604 0 : if(e) goto fail;
605 0 : p += l; len -= l; ret += l;
606 0 : len = principal_oldlen - principal_datalen;
607 : }
608 : }
609 0 : len = Top_oldlen - Top_datalen;
610 : }
611 0 : if(size) *size = ret;
612 0 : return 0;
613 0 : fail:
614 0 : free_Event(data);
615 0 : return e;
616 : }
617 :
618 : void ASN1CALL
619 214228 : free_Event(Event *data)
620 : {
621 214228 : free_KerberosTime(&(data)->time);
622 214228 : if((data)->principal) {
623 1147 : free_Principal((data)->principal);
624 1147 : free((data)->principal);
625 1147 : (data)->principal = NULL;
626 : }
627 214228 : }
628 :
629 : size_t ASN1CALL
630 0 : length_Event(const Event *data)
631 : {
632 0 : size_t ret = 0;
633 : {
634 0 : size_t Top_tag_oldret = ret;
635 0 : ret = 0;
636 0 : ret += length_KerberosTime(&(data)->time);
637 0 : ret += 1 + der_length_len (ret);
638 0 : ret += Top_tag_oldret;
639 : }
640 0 : if((data)->principal){
641 0 : size_t Top_tag_oldret = ret;
642 0 : ret = 0;
643 0 : ret += length_Principal((data)->principal);
644 0 : ret += 1 + der_length_len (ret);
645 0 : ret += Top_tag_oldret;
646 : }
647 0 : ret += 1 + der_length_len (ret);
648 0 : return ret;
649 : }
650 :
651 : int ASN1CALL
652 0 : copy_Event(const Event *from, Event *to)
653 : {
654 0 : memset(to, 0, sizeof(*to));
655 0 : if(copy_KerberosTime(&(from)->time, &(to)->time)) goto fail;
656 0 : if((from)->principal) {
657 0 : (to)->principal = calloc(1, sizeof(*(to)->principal));
658 0 : if((to)->principal == NULL) goto fail;
659 0 : if(copy_Principal((from)->principal, (to)->principal)) goto fail;
660 : }else
661 0 : (to)->principal = NULL;
662 0 : return 0;
663 0 : fail:
664 0 : free_Event(to);
665 0 : return ENOMEM;
666 : }
667 :
668 : char * ASN1CALL
669 0 : print_Event(const Event *data, int flags)
670 0 : { errno = EINVAL; return 0; }
671 :
672 : int ASN1CALL
673 0 : encode_HDBFlags(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDBFlags *data, size_t *size)
674 : {
675 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
676 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
677 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
678 :
679 : {
680 0 : unsigned char c = 0;
681 0 : int rest = 0;
682 0 : int bit_set = 0;
683 0 : if((data)->do_not_store) {
684 0 : c |= 1<<0;
685 : }
686 0 : if((data)->force_canonicalize) {
687 0 : c |= 1<<1;
688 : }
689 0 : if (c != 0 || bit_set) {
690 0 : if (len < 1) return ASN1_OVERFLOW;
691 0 : *p-- = c; len--; ret++;
692 0 : if (!bit_set) {
693 0 : rest = 0;
694 0 : while(c) {
695 0 : if (c & 1) break;
696 0 : c = c >> 1;
697 0 : rest++;
698 : }
699 0 : bit_set = 1;
700 : }
701 : }
702 0 : c = 0;
703 0 : if((data)->no_auth_data_reqd) {
704 0 : c |= 1<<0;
705 : }
706 0 : if((data)->synthetic) {
707 0 : c |= 1<<1;
708 : }
709 0 : if((data)->virtual) {
710 0 : c |= 1<<2;
711 : }
712 0 : if((data)->virtual_keys) {
713 0 : c |= 1<<3;
714 : }
715 0 : if((data)->materialize) {
716 0 : c |= 1<<4;
717 : }
718 0 : if((data)->require_pwchange) {
719 0 : c |= 1<<5;
720 : }
721 0 : if((data)->locked_out) {
722 0 : c |= 1<<6;
723 : }
724 0 : if((data)->allow_digest) {
725 0 : c |= 1<<7;
726 : }
727 0 : if (c != 0 || bit_set) {
728 0 : if (len < 1) return ASN1_OVERFLOW;
729 0 : *p-- = c; len--; ret++;
730 0 : if (!bit_set) {
731 0 : rest = 0;
732 0 : while(c) {
733 0 : if (c & 1) break;
734 0 : c = c >> 1;
735 0 : rest++;
736 : }
737 0 : bit_set = 1;
738 : }
739 : }
740 0 : c = 0;
741 0 : if((data)->allow_kerberos4) {
742 0 : c |= 1<<0;
743 : }
744 0 : if((data)->trusted_for_delegation) {
745 0 : c |= 1<<1;
746 : }
747 0 : if((data)->immutable) {
748 0 : c |= 1<<2;
749 : }
750 0 : if((data)->user_to_user) {
751 0 : c |= 1<<3;
752 : }
753 0 : if((data)->ok_as_delegate) {
754 0 : c |= 1<<4;
755 : }
756 0 : if((data)->require_hwauth) {
757 0 : c |= 1<<5;
758 : }
759 0 : if((data)->change_pw) {
760 0 : c |= 1<<6;
761 : }
762 0 : if((data)->require_preauth) {
763 0 : c |= 1<<7;
764 : }
765 0 : if (c != 0 || bit_set) {
766 0 : if (len < 1) return ASN1_OVERFLOW;
767 0 : *p-- = c; len--; ret++;
768 0 : if (!bit_set) {
769 0 : rest = 0;
770 0 : while(c) {
771 0 : if (c & 1) break;
772 0 : c = c >> 1;
773 0 : rest++;
774 : }
775 0 : bit_set = 1;
776 : }
777 : }
778 0 : c = 0;
779 0 : if((data)->invalid) {
780 0 : c |= 1<<0;
781 : }
782 0 : if((data)->client) {
783 0 : c |= 1<<1;
784 : }
785 0 : if((data)->server) {
786 0 : c |= 1<<2;
787 : }
788 0 : if((data)->postdate) {
789 0 : c |= 1<<3;
790 : }
791 0 : if((data)->renewable) {
792 0 : c |= 1<<4;
793 : }
794 0 : if((data)->proxiable) {
795 0 : c |= 1<<5;
796 : }
797 0 : if((data)->forwardable) {
798 0 : c |= 1<<6;
799 : }
800 0 : if((data)->initial) {
801 0 : c |= 1<<7;
802 : }
803 0 : if (c != 0 || bit_set) {
804 0 : if (len < 1) return ASN1_OVERFLOW;
805 0 : *p-- = c; len--; ret++;
806 0 : if (!bit_set) {
807 0 : rest = 0;
808 0 : if(c) {
809 0 : while(c) {
810 0 : if (c & 1) break;
811 0 : c = c >> 1;
812 0 : rest++;
813 : }
814 : }
815 : }
816 : }
817 0 : if (len < 1) return ASN1_OVERFLOW;
818 0 : *p-- = rest;
819 0 : len -= 1;
820 0 : ret += 1;
821 : }
822 :
823 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
824 0 : if (e) return e;
825 0 : p -= l; len -= l; ret += l;
826 :
827 0 : *size = ret;
828 0 : return 0;
829 : }
830 :
831 : int ASN1CALL
832 0 : decode_HDBFlags(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDBFlags *data, size_t *size)
833 : {
834 0 : size_t ret = 0;
835 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
836 : int e HEIMDAL_UNUSED_ATTRIBUTE;
837 :
838 0 : memset(data, 0, sizeof(*data));
839 : {
840 : size_t Top_datalen;
841 : Der_type Top_type;
842 : size_t Top_oldlen;
843 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_BitString, &Top_datalen, &l);
844 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
845 0 : if (e) goto fail;
846 0 : p += l; len -= l; ret += l;
847 0 : Top_oldlen = len;
848 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
849 0 : len = Top_datalen;
850 0 : if (len < 1) return ASN1_OVERRUN;
851 0 : p++; len--; ret++;
852 : do {
853 0 : if (len < 1) break;
854 0 : (data)->initial = (*p >> 7) & 1;
855 0 : (data)->forwardable = (*p >> 6) & 1;
856 0 : (data)->proxiable = (*p >> 5) & 1;
857 0 : (data)->renewable = (*p >> 4) & 1;
858 0 : (data)->postdate = (*p >> 3) & 1;
859 0 : (data)->server = (*p >> 2) & 1;
860 0 : (data)->client = (*p >> 1) & 1;
861 0 : (data)->invalid = (*p >> 0) & 1;
862 0 : p++; len--; ret++;
863 0 : if (len < 1) break;
864 0 : (data)->require_preauth = (*p >> 7) & 1;
865 0 : (data)->change_pw = (*p >> 6) & 1;
866 0 : (data)->require_hwauth = (*p >> 5) & 1;
867 0 : (data)->ok_as_delegate = (*p >> 4) & 1;
868 0 : (data)->user_to_user = (*p >> 3) & 1;
869 0 : (data)->immutable = (*p >> 2) & 1;
870 0 : (data)->trusted_for_delegation = (*p >> 1) & 1;
871 0 : (data)->allow_kerberos4 = (*p >> 0) & 1;
872 0 : p++; len--; ret++;
873 0 : if (len < 1) break;
874 0 : (data)->allow_digest = (*p >> 7) & 1;
875 0 : (data)->locked_out = (*p >> 6) & 1;
876 0 : (data)->require_pwchange = (*p >> 5) & 1;
877 0 : (data)->materialize = (*p >> 4) & 1;
878 0 : (data)->virtual_keys = (*p >> 3) & 1;
879 0 : (data)->virtual = (*p >> 2) & 1;
880 0 : (data)->synthetic = (*p >> 1) & 1;
881 0 : (data)->no_auth_data_reqd = (*p >> 0) & 1;
882 0 : p++; len--; ret++;
883 0 : if (len < 1) break;
884 0 : (data)->force_canonicalize = (*p >> 1) & 1;
885 0 : (data)->do_not_store = (*p >> 0) & 1;
886 : } while(0);
887 0 : p += len; ret += len;
888 0 : len = Top_oldlen - Top_datalen;
889 : }
890 0 : if(size) *size = ret;
891 0 : return 0;
892 0 : fail:
893 0 : free_HDBFlags(data);
894 0 : return e;
895 : }
896 :
897 : void ASN1CALL
898 214228 : free_HDBFlags(HDBFlags *data)
899 : {
900 214228 : }
901 :
902 : size_t ASN1CALL
903 0 : length_HDBFlags(const HDBFlags *data)
904 : {
905 0 : size_t ret = 0;
906 : do {
907 0 : if((data)->do_not_store) { ret += 4; break; }
908 0 : if((data)->force_canonicalize) { ret += 4; break; }
909 0 : if((data)->no_auth_data_reqd) { ret += 3; break; }
910 0 : if((data)->synthetic) { ret += 3; break; }
911 0 : if((data)->virtual) { ret += 3; break; }
912 0 : if((data)->virtual_keys) { ret += 3; break; }
913 0 : if((data)->materialize) { ret += 3; break; }
914 0 : if((data)->require_pwchange) { ret += 3; break; }
915 0 : if((data)->locked_out) { ret += 3; break; }
916 0 : if((data)->allow_digest) { ret += 3; break; }
917 0 : if((data)->allow_kerberos4) { ret += 2; break; }
918 0 : if((data)->trusted_for_delegation) { ret += 2; break; }
919 0 : if((data)->immutable) { ret += 2; break; }
920 0 : if((data)->user_to_user) { ret += 2; break; }
921 0 : if((data)->ok_as_delegate) { ret += 2; break; }
922 0 : if((data)->require_hwauth) { ret += 2; break; }
923 0 : if((data)->change_pw) { ret += 2; break; }
924 0 : if((data)->require_preauth) { ret += 2; break; }
925 0 : if((data)->invalid) { ret += 1; break; }
926 0 : if((data)->client) { ret += 1; break; }
927 0 : if((data)->server) { ret += 1; break; }
928 0 : if((data)->postdate) { ret += 1; break; }
929 0 : if((data)->renewable) { ret += 1; break; }
930 0 : if((data)->proxiable) { ret += 1; break; }
931 0 : if((data)->forwardable) { ret += 1; break; }
932 0 : if((data)->initial) { ret += 1; break; }
933 : } while(0);
934 0 : ret += 1;
935 0 : ret += 1 + der_length_len (ret);
936 0 : return ret;
937 : }
938 :
939 : int ASN1CALL
940 0 : copy_HDBFlags(const HDBFlags *from, HDBFlags *to)
941 : {
942 0 : memset(to, 0, sizeof(*to));
943 0 : *(to) = *(from);
944 0 : return 0;
945 : }
946 :
947 : char * ASN1CALL
948 0 : print_HDBFlags(const HDBFlags *data, int flags)
949 0 : { errno = EINVAL; return 0; }
950 :
951 0 : uint64_t HDBFlags2int(HDBFlags f)
952 : {
953 0 : uint64_t r = 0;
954 0 : if(f.initial) r |= (1ULL << 0);
955 0 : if(f.forwardable) r |= (1ULL << 1);
956 0 : if(f.proxiable) r |= (1ULL << 2);
957 0 : if(f.renewable) r |= (1ULL << 3);
958 0 : if(f.postdate) r |= (1ULL << 4);
959 0 : if(f.server) r |= (1ULL << 5);
960 0 : if(f.client) r |= (1ULL << 6);
961 0 : if(f.invalid) r |= (1ULL << 7);
962 0 : if(f.require_preauth) r |= (1ULL << 8);
963 0 : if(f.change_pw) r |= (1ULL << 9);
964 0 : if(f.require_hwauth) r |= (1ULL << 10);
965 0 : if(f.ok_as_delegate) r |= (1ULL << 11);
966 0 : if(f.user_to_user) r |= (1ULL << 12);
967 0 : if(f.immutable) r |= (1ULL << 13);
968 0 : if(f.trusted_for_delegation) r |= (1ULL << 14);
969 0 : if(f.allow_kerberos4) r |= (1ULL << 15);
970 0 : if(f.allow_digest) r |= (1ULL << 16);
971 0 : if(f.locked_out) r |= (1ULL << 17);
972 0 : if(f.require_pwchange) r |= (1ULL << 18);
973 0 : if(f.materialize) r |= (1ULL << 19);
974 0 : if(f.virtual_keys) r |= (1ULL << 20);
975 0 : if(f.virtual) r |= (1ULL << 21);
976 0 : if(f.synthetic) r |= (1ULL << 22);
977 0 : if(f.no_auth_data_reqd) r |= (1ULL << 23);
978 0 : if(f.force_canonicalize) r |= (1ULL << 30);
979 0 : if(f.do_not_store) r |= (1ULL << 31);
980 0 : return r;
981 : }
982 :
983 0 : HDBFlags int2HDBFlags(uint64_t n)
984 : {
985 : HDBFlags flags;
986 :
987 0 : memset(&flags, 0, sizeof(flags));
988 :
989 0 : flags.initial = (n >> 0) & 1;
990 0 : flags.forwardable = (n >> 1) & 1;
991 0 : flags.proxiable = (n >> 2) & 1;
992 0 : flags.renewable = (n >> 3) & 1;
993 0 : flags.postdate = (n >> 4) & 1;
994 0 : flags.server = (n >> 5) & 1;
995 0 : flags.client = (n >> 6) & 1;
996 0 : flags.invalid = (n >> 7) & 1;
997 0 : flags.require_preauth = (n >> 8) & 1;
998 0 : flags.change_pw = (n >> 9) & 1;
999 0 : flags.require_hwauth = (n >> 10) & 1;
1000 0 : flags.ok_as_delegate = (n >> 11) & 1;
1001 0 : flags.user_to_user = (n >> 12) & 1;
1002 0 : flags.immutable = (n >> 13) & 1;
1003 0 : flags.trusted_for_delegation = (n >> 14) & 1;
1004 0 : flags.allow_kerberos4 = (n >> 15) & 1;
1005 0 : flags.allow_digest = (n >> 16) & 1;
1006 0 : flags.locked_out = (n >> 17) & 1;
1007 0 : flags.require_pwchange = (n >> 18) & 1;
1008 0 : flags.materialize = (n >> 19) & 1;
1009 0 : flags.virtual_keys = (n >> 20) & 1;
1010 0 : flags.virtual = (n >> 21) & 1;
1011 0 : flags.synthetic = (n >> 22) & 1;
1012 0 : flags.no_auth_data_reqd = (n >> 23) & 1;
1013 0 : flags.force_canonicalize = (n >> 30) & 1;
1014 0 : flags.do_not_store = (n >> 31) & 1;
1015 0 : return flags;
1016 : }
1017 :
1018 : static struct units HDBFlags_units[] = {
1019 : {"do-not-store", 1ULL << 31},
1020 : {"force-canonicalize", 1ULL << 30},
1021 : {"no-auth-data-reqd", 1ULL << 23},
1022 : {"synthetic", 1ULL << 22},
1023 : {"virtual", 1ULL << 21},
1024 : {"virtual-keys", 1ULL << 20},
1025 : {"materialize", 1ULL << 19},
1026 : {"require-pwchange", 1ULL << 18},
1027 : {"locked-out", 1ULL << 17},
1028 : {"allow-digest", 1ULL << 16},
1029 : {"allow-kerberos4", 1ULL << 15},
1030 : {"trusted-for-delegation", 1ULL << 14},
1031 : {"immutable", 1ULL << 13},
1032 : {"user-to-user", 1ULL << 12},
1033 : {"ok-as-delegate", 1ULL << 11},
1034 : {"require-hwauth", 1ULL << 10},
1035 : {"change-pw", 1ULL << 9},
1036 : {"require-preauth", 1ULL << 8},
1037 : {"invalid", 1ULL << 7},
1038 : {"client", 1ULL << 6},
1039 : {"server", 1ULL << 5},
1040 : {"postdate", 1ULL << 4},
1041 : {"renewable", 1ULL << 3},
1042 : {"proxiable", 1ULL << 2},
1043 : {"forwardable", 1ULL << 1},
1044 : {"initial", 1ULL << 0},
1045 : {NULL, 0}
1046 : };
1047 :
1048 0 : const struct units * asn1_HDBFlags_units(void){
1049 0 : return HDBFlags_units;
1050 : }
1051 :
1052 : int ASN1CALL
1053 0 : encode_GENERATION(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const GENERATION *data, size_t *size)
1054 : {
1055 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1056 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1057 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1058 :
1059 : /* gen */
1060 : {
1061 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1062 0 : ret = 0;
1063 0 : e = der_put_unsigned(p, len, &(data)->gen, &l);
1064 0 : if (e) return e;
1065 0 : p -= l; len -= l; ret += l;
1066 :
1067 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
1068 0 : if (e) return e;
1069 0 : p -= l; len -= l; ret += l;
1070 :
1071 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
1072 0 : if (e) return e;
1073 0 : p -= l; len -= l; ret += l;
1074 :
1075 0 : ret += Top_tag_oldret;
1076 : }
1077 : /* usec */
1078 : {
1079 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1080 0 : ret = 0;
1081 0 : e = der_put_unsigned(p, len, &(data)->usec, &l);
1082 0 : if (e) return e;
1083 0 : p -= l; len -= l; ret += l;
1084 :
1085 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
1086 0 : if (e) return e;
1087 0 : p -= l; len -= l; ret += l;
1088 :
1089 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
1090 0 : if (e) return e;
1091 0 : p -= l; len -= l; ret += l;
1092 :
1093 0 : ret += Top_tag_oldret;
1094 : }
1095 : /* time */
1096 : {
1097 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1098 0 : ret = 0;
1099 0 : e = encode_KerberosTime(p, len, &(data)->time, &l);
1100 0 : if (e) return e;
1101 0 : p -= l; len -= l; ret += l;
1102 :
1103 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1104 0 : if (e) return e;
1105 0 : p -= l; len -= l; ret += l;
1106 :
1107 0 : ret += Top_tag_oldret;
1108 : }
1109 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1110 0 : if (e) return e;
1111 0 : p -= l; len -= l; ret += l;
1112 :
1113 0 : *size = ret;
1114 0 : return 0;
1115 : }
1116 :
1117 : int ASN1CALL
1118 0 : decode_GENERATION(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, GENERATION *data, size_t *size)
1119 : {
1120 0 : size_t ret = 0;
1121 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1122 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1123 :
1124 0 : memset(data, 0, sizeof(*data));
1125 : {
1126 : size_t Top_datalen;
1127 : Der_type Top_type;
1128 : size_t Top_oldlen;
1129 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1130 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1131 0 : if (e) goto fail;
1132 0 : p += l; len -= l; ret += l;
1133 0 : Top_oldlen = len;
1134 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1135 0 : len = Top_datalen;
1136 : {
1137 : size_t time_datalen;
1138 : Der_type time_type;
1139 : size_t time_oldlen;
1140 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &time_type, 0, &time_datalen, &l);
1141 0 : if (e == 0 && time_type != CONS) { e = ASN1_BAD_ID; }
1142 0 : if (e) goto fail;
1143 0 : p += l; len -= l; ret += l;
1144 0 : time_oldlen = len;
1145 0 : if (time_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1146 0 : len = time_datalen;
1147 0 : e = decode_KerberosTime(p, len, &(data)->time, &l);
1148 0 : if(e) goto fail;
1149 0 : p += l; len -= l; ret += l;
1150 0 : len = time_oldlen - time_datalen;
1151 : }
1152 : {
1153 : size_t usec_datalen;
1154 : Der_type usec_type;
1155 : size_t usec_oldlen;
1156 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &usec_type, 1, &usec_datalen, &l);
1157 0 : if (e == 0 && usec_type != CONS) { e = ASN1_BAD_ID; }
1158 0 : if (e) goto fail;
1159 0 : p += l; len -= l; ret += l;
1160 0 : usec_oldlen = len;
1161 0 : if (usec_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1162 0 : len = usec_datalen;
1163 : {
1164 : size_t usec_Tag_datalen;
1165 : Der_type usec_Tag_type;
1166 : size_t usec_Tag_oldlen;
1167 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &usec_Tag_type, UT_Integer, &usec_Tag_datalen, &l);
1168 0 : if (e == 0 && usec_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1169 0 : if (e) goto fail;
1170 0 : p += l; len -= l; ret += l;
1171 0 : usec_Tag_oldlen = len;
1172 0 : if (usec_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1173 0 : len = usec_Tag_datalen;
1174 0 : e = der_get_unsigned(p, len, &(data)->usec, &l);
1175 0 : if(e) goto fail;
1176 0 : p += l; len -= l; ret += l;
1177 0 : len = usec_Tag_oldlen - usec_Tag_datalen;
1178 : }
1179 0 : len = usec_oldlen - usec_datalen;
1180 : }
1181 : {
1182 : size_t gen_datalen;
1183 : Der_type gen_type;
1184 : size_t gen_oldlen;
1185 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &gen_type, 2, &gen_datalen, &l);
1186 0 : if (e == 0 && gen_type != CONS) { e = ASN1_BAD_ID; }
1187 0 : if (e) goto fail;
1188 0 : p += l; len -= l; ret += l;
1189 0 : gen_oldlen = len;
1190 0 : if (gen_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1191 0 : len = gen_datalen;
1192 : {
1193 : size_t gen_Tag_datalen;
1194 : Der_type gen_Tag_type;
1195 : size_t gen_Tag_oldlen;
1196 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &gen_Tag_type, UT_Integer, &gen_Tag_datalen, &l);
1197 0 : if (e == 0 && gen_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1198 0 : if (e) goto fail;
1199 0 : p += l; len -= l; ret += l;
1200 0 : gen_Tag_oldlen = len;
1201 0 : if (gen_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1202 0 : len = gen_Tag_datalen;
1203 0 : e = der_get_unsigned(p, len, &(data)->gen, &l);
1204 0 : if(e) goto fail;
1205 0 : p += l; len -= l; ret += l;
1206 0 : len = gen_Tag_oldlen - gen_Tag_datalen;
1207 : }
1208 0 : len = gen_oldlen - gen_datalen;
1209 : }
1210 0 : len = Top_oldlen - Top_datalen;
1211 : }
1212 0 : if(size) *size = ret;
1213 0 : return 0;
1214 0 : fail:
1215 0 : free_GENERATION(data);
1216 0 : return e;
1217 : }
1218 :
1219 : void ASN1CALL
1220 0 : free_GENERATION(GENERATION *data)
1221 : {
1222 0 : free_KerberosTime(&(data)->time);
1223 0 : *&(data)->usec = 0;
1224 0 : *&(data)->gen = 0;
1225 0 : }
1226 :
1227 : size_t ASN1CALL
1228 0 : length_GENERATION(const GENERATION *data)
1229 : {
1230 0 : size_t ret = 0;
1231 : {
1232 0 : size_t Top_tag_oldret = ret;
1233 0 : ret = 0;
1234 0 : ret += length_KerberosTime(&(data)->time);
1235 0 : ret += 1 + der_length_len (ret);
1236 0 : ret += Top_tag_oldret;
1237 : }
1238 : {
1239 0 : size_t Top_tag_oldret = ret;
1240 0 : ret = 0;
1241 0 : ret += der_length_unsigned(&(data)->usec);
1242 0 : ret += 1 + der_length_len (ret);
1243 0 : ret += 1 + der_length_len (ret);
1244 0 : ret += Top_tag_oldret;
1245 : }
1246 : {
1247 0 : size_t Top_tag_oldret = ret;
1248 0 : ret = 0;
1249 0 : ret += der_length_unsigned(&(data)->gen);
1250 0 : ret += 1 + der_length_len (ret);
1251 0 : ret += 1 + der_length_len (ret);
1252 0 : ret += Top_tag_oldret;
1253 : }
1254 0 : ret += 1 + der_length_len (ret);
1255 0 : return ret;
1256 : }
1257 :
1258 : int ASN1CALL
1259 0 : copy_GENERATION(const GENERATION *from, GENERATION *to)
1260 : {
1261 0 : memset(to, 0, sizeof(*to));
1262 0 : if(copy_KerberosTime(&(from)->time, &(to)->time)) goto fail;
1263 0 : *(&(to)->usec) = *(&(from)->usec);
1264 0 : *(&(to)->gen) = *(&(from)->gen);
1265 0 : return 0;
1266 0 : fail:
1267 0 : free_GENERATION(to);
1268 0 : return ENOMEM;
1269 : }
1270 :
1271 : char * ASN1CALL
1272 0 : print_GENERATION(const GENERATION *data, int flags)
1273 0 : { errno = EINVAL; return 0; }
1274 :
1275 : int ASN1CALL
1276 0 : encode_HDB_Ext_PKINIT_acl(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_PKINIT_acl *data, size_t *size)
1277 : {
1278 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1279 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1280 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1281 :
1282 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
1283 0 : size_t Top_tag_for_oldret = ret;
1284 0 : ret = 0;
1285 : /* anchor */
1286 0 : if((&(data)->val[i])->anchor) {
1287 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1288 0 : ret = 0;
1289 0 : e = der_put_utf8string(p, len, (&(data)->val[i])->anchor, &l);
1290 0 : if (e) return e;
1291 0 : p -= l; len -= l; ret += l;
1292 :
1293 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_UTF8String, &l);
1294 0 : if (e) return e;
1295 0 : p -= l; len -= l; ret += l;
1296 :
1297 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
1298 0 : if (e) return e;
1299 0 : p -= l; len -= l; ret += l;
1300 :
1301 0 : ret += Top_tag_S_Of_tag_oldret;
1302 : }
1303 : /* issuer */
1304 0 : if((&(data)->val[i])->issuer) {
1305 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1306 0 : ret = 0;
1307 0 : e = der_put_utf8string(p, len, (&(data)->val[i])->issuer, &l);
1308 0 : if (e) return e;
1309 0 : p -= l; len -= l; ret += l;
1310 :
1311 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_UTF8String, &l);
1312 0 : if (e) return e;
1313 0 : p -= l; len -= l; ret += l;
1314 :
1315 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
1316 0 : if (e) return e;
1317 0 : p -= l; len -= l; ret += l;
1318 :
1319 0 : ret += Top_tag_S_Of_tag_oldret;
1320 : }
1321 : /* subject */
1322 : {
1323 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1324 0 : ret = 0;
1325 0 : e = der_put_utf8string(p, len, &(&(data)->val[i])->subject, &l);
1326 0 : if (e) return e;
1327 0 : p -= l; len -= l; ret += l;
1328 :
1329 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_UTF8String, &l);
1330 0 : if (e) return e;
1331 0 : p -= l; len -= l; ret += l;
1332 :
1333 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1334 0 : if (e) return e;
1335 0 : p -= l; len -= l; ret += l;
1336 :
1337 0 : ret += Top_tag_S_Of_tag_oldret;
1338 : }
1339 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1340 0 : if (e) return e;
1341 0 : p -= l; len -= l; ret += l;
1342 :
1343 0 : ret += Top_tag_for_oldret;
1344 : }
1345 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1346 0 : if (e) return e;
1347 0 : p -= l; len -= l; ret += l;
1348 :
1349 0 : *size = ret;
1350 0 : return 0;
1351 : }
1352 :
1353 : int ASN1CALL
1354 0 : decode_HDB_Ext_PKINIT_acl(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_PKINIT_acl *data, size_t *size)
1355 : {
1356 0 : size_t ret = 0;
1357 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1358 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1359 :
1360 0 : memset(data, 0, sizeof(*data));
1361 : {
1362 : size_t Top_datalen;
1363 : Der_type Top_type;
1364 : size_t Top_oldlen;
1365 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1366 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1367 0 : if (e) goto fail;
1368 0 : p += l; len -= l; ret += l;
1369 0 : Top_oldlen = len;
1370 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1371 0 : len = Top_datalen;
1372 : {
1373 0 : size_t Top_Tag_origlen = len;
1374 0 : size_t Top_Tag_oldret = ret;
1375 0 : size_t Top_Tag_olen = 0;
1376 : void *Top_Tag_tmp;
1377 0 : ret = 0;
1378 0 : (data)->len = 0;
1379 0 : (data)->val = NULL;
1380 0 : while(ret < Top_Tag_origlen) {
1381 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
1382 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
1383 0 : Top_Tag_olen = Top_Tag_nlen;
1384 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
1385 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
1386 0 : (data)->val = Top_Tag_tmp;
1387 : {
1388 : size_t Top_Tag_s_of_datalen;
1389 : Der_type Top_Tag_s_of_type;
1390 : size_t Top_Tag_s_of_oldlen;
1391 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_s_of_type, UT_Sequence, &Top_Tag_s_of_datalen, &l);
1392 0 : if (e == 0 && Top_Tag_s_of_type != CONS) { e = ASN1_BAD_ID; }
1393 0 : if (e) goto fail;
1394 0 : p += l; len -= l; ret += l;
1395 0 : Top_Tag_s_of_oldlen = len;
1396 0 : if (Top_Tag_s_of_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1397 0 : len = Top_Tag_s_of_datalen;
1398 : {
1399 : size_t subject_datalen;
1400 : Der_type subject_type;
1401 : size_t subject_oldlen;
1402 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &subject_type, 0, &subject_datalen, &l);
1403 0 : if (e == 0 && subject_type != CONS) { e = ASN1_BAD_ID; }
1404 0 : if (e) goto fail;
1405 0 : p += l; len -= l; ret += l;
1406 0 : subject_oldlen = len;
1407 0 : if (subject_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1408 0 : len = subject_datalen;
1409 : {
1410 : size_t subject_Tag_datalen;
1411 : Der_type subject_Tag_type;
1412 : size_t subject_Tag_oldlen;
1413 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &subject_Tag_type, UT_UTF8String, &subject_Tag_datalen, &l);
1414 0 : if (e == 0 && subject_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1415 0 : if (e) goto fail;
1416 0 : p += l; len -= l; ret += l;
1417 0 : subject_Tag_oldlen = len;
1418 0 : if (subject_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1419 0 : len = subject_Tag_datalen;
1420 0 : e = der_get_utf8string(p, len, &(&(data)->val[(data)->len])->subject, &l);
1421 0 : if(e) goto fail;
1422 0 : p += l; len -= l; ret += l;
1423 0 : len = subject_Tag_oldlen - subject_Tag_datalen;
1424 : }
1425 0 : len = subject_oldlen - subject_datalen;
1426 : }
1427 : {
1428 : size_t issuer_datalen;
1429 : Der_type issuer_type;
1430 : size_t issuer_oldlen;
1431 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &issuer_type, 1, &issuer_datalen, &l);
1432 0 : if (e == 0 && issuer_type != CONS) { e = ASN1_BAD_ID; }
1433 0 : if(e) {
1434 0 : (&(data)->val[(data)->len])->issuer = NULL;
1435 : } else {
1436 0 : (&(data)->val[(data)->len])->issuer = calloc(1, sizeof(*(&(data)->val[(data)->len])->issuer));
1437 0 : if ((&(data)->val[(data)->len])->issuer == NULL) { e = ENOMEM; goto fail; }
1438 0 : p += l; len -= l; ret += l;
1439 0 : issuer_oldlen = len;
1440 0 : if (issuer_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1441 0 : len = issuer_datalen;
1442 : {
1443 : size_t issuer_Tag_datalen;
1444 : Der_type issuer_Tag_type;
1445 : size_t issuer_Tag_oldlen;
1446 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &issuer_Tag_type, UT_UTF8String, &issuer_Tag_datalen, &l);
1447 0 : if (e == 0 && issuer_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1448 0 : if (e) goto fail;
1449 0 : p += l; len -= l; ret += l;
1450 0 : issuer_Tag_oldlen = len;
1451 0 : if (issuer_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1452 0 : len = issuer_Tag_datalen;
1453 0 : e = der_get_utf8string(p, len, (&(data)->val[(data)->len])->issuer, &l);
1454 0 : if(e) goto fail;
1455 0 : p += l; len -= l; ret += l;
1456 0 : len = issuer_Tag_oldlen - issuer_Tag_datalen;
1457 : }
1458 0 : len = issuer_oldlen - issuer_datalen;
1459 : }
1460 : }
1461 : {
1462 : size_t anchor_datalen;
1463 : Der_type anchor_type;
1464 : size_t anchor_oldlen;
1465 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &anchor_type, 2, &anchor_datalen, &l);
1466 0 : if (e == 0 && anchor_type != CONS) { e = ASN1_BAD_ID; }
1467 0 : if(e) {
1468 0 : (&(data)->val[(data)->len])->anchor = NULL;
1469 : } else {
1470 0 : (&(data)->val[(data)->len])->anchor = calloc(1, sizeof(*(&(data)->val[(data)->len])->anchor));
1471 0 : if ((&(data)->val[(data)->len])->anchor == NULL) { e = ENOMEM; goto fail; }
1472 0 : p += l; len -= l; ret += l;
1473 0 : anchor_oldlen = len;
1474 0 : if (anchor_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1475 0 : len = anchor_datalen;
1476 : {
1477 : size_t anchor_Tag_datalen;
1478 : Der_type anchor_Tag_type;
1479 : size_t anchor_Tag_oldlen;
1480 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &anchor_Tag_type, UT_UTF8String, &anchor_Tag_datalen, &l);
1481 0 : if (e == 0 && anchor_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1482 0 : if (e) goto fail;
1483 0 : p += l; len -= l; ret += l;
1484 0 : anchor_Tag_oldlen = len;
1485 0 : if (anchor_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1486 0 : len = anchor_Tag_datalen;
1487 0 : e = der_get_utf8string(p, len, (&(data)->val[(data)->len])->anchor, &l);
1488 0 : if(e) goto fail;
1489 0 : p += l; len -= l; ret += l;
1490 0 : len = anchor_Tag_oldlen - anchor_Tag_datalen;
1491 : }
1492 0 : len = anchor_oldlen - anchor_datalen;
1493 : }
1494 : }
1495 0 : len = Top_Tag_s_of_oldlen - Top_Tag_s_of_datalen;
1496 : }
1497 0 : (data)->len++;
1498 0 : len = Top_Tag_origlen - ret;
1499 : }
1500 0 : ret += Top_Tag_oldret;
1501 : }
1502 0 : len = Top_oldlen - Top_datalen;
1503 : }
1504 0 : if(size) *size = ret;
1505 0 : return 0;
1506 0 : fail:
1507 0 : free_HDB_Ext_PKINIT_acl(data);
1508 0 : return e;
1509 : }
1510 :
1511 : void ASN1CALL
1512 0 : free_HDB_Ext_PKINIT_acl(HDB_Ext_PKINIT_acl *data)
1513 : {
1514 0 : if ((data)->val)
1515 0 : while((data)->len){
1516 0 : der_free_utf8string(&(&(data)->val[(data)->len-1])->subject);
1517 0 : if((&(data)->val[(data)->len-1])->issuer) {
1518 0 : der_free_utf8string((&(data)->val[(data)->len-1])->issuer);
1519 0 : free((&(data)->val[(data)->len-1])->issuer);
1520 0 : (&(data)->val[(data)->len-1])->issuer = NULL;
1521 : }
1522 0 : if((&(data)->val[(data)->len-1])->anchor) {
1523 0 : der_free_utf8string((&(data)->val[(data)->len-1])->anchor);
1524 0 : free((&(data)->val[(data)->len-1])->anchor);
1525 0 : (&(data)->val[(data)->len-1])->anchor = NULL;
1526 : }
1527 0 : (data)->len--;
1528 0 : } else (data)->len = 0;
1529 0 : free((data)->val);
1530 0 : (data)->val = NULL;
1531 0 : }
1532 :
1533 : size_t ASN1CALL
1534 0 : length_HDB_Ext_PKINIT_acl(const HDB_Ext_PKINIT_acl *data)
1535 : {
1536 0 : size_t ret = 0;
1537 : {
1538 0 : size_t Top_tag_oldret = ret;
1539 : unsigned int n_Top_tag;
1540 0 : ret = 0;
1541 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
1542 0 : size_t Top_tag_for_oldret = ret;
1543 0 : ret = 0;
1544 : {
1545 0 : size_t Top_tag_S_Of_tag_oldret = ret;
1546 0 : ret = 0;
1547 0 : ret += der_length_utf8string(&(&(data)->val[n_Top_tag - 1])->subject);
1548 0 : ret += 1 + der_length_len (ret);
1549 0 : ret += 1 + der_length_len (ret);
1550 0 : ret += Top_tag_S_Of_tag_oldret;
1551 : }
1552 0 : if((&(data)->val[n_Top_tag - 1])->issuer){
1553 0 : size_t Top_tag_S_Of_tag_oldret = ret;
1554 0 : ret = 0;
1555 0 : ret += der_length_utf8string((&(data)->val[n_Top_tag - 1])->issuer);
1556 0 : ret += 1 + der_length_len (ret);
1557 0 : ret += 1 + der_length_len (ret);
1558 0 : ret += Top_tag_S_Of_tag_oldret;
1559 : }
1560 0 : if((&(data)->val[n_Top_tag - 1])->anchor){
1561 0 : size_t Top_tag_S_Of_tag_oldret = ret;
1562 0 : ret = 0;
1563 0 : ret += der_length_utf8string((&(data)->val[n_Top_tag - 1])->anchor);
1564 0 : ret += 1 + der_length_len (ret);
1565 0 : ret += 1 + der_length_len (ret);
1566 0 : ret += Top_tag_S_Of_tag_oldret;
1567 : }
1568 0 : ret += 1 + der_length_len (ret);
1569 0 : ret += Top_tag_for_oldret;
1570 : }
1571 0 : ret += Top_tag_oldret;
1572 : }
1573 0 : ret += 1 + der_length_len (ret);
1574 0 : return ret;
1575 : }
1576 :
1577 : int ASN1CALL
1578 0 : copy_HDB_Ext_PKINIT_acl(const HDB_Ext_PKINIT_acl *from, HDB_Ext_PKINIT_acl *to)
1579 : {
1580 0 : memset(to, 0, sizeof(*to));
1581 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
1582 0 : goto fail;
1583 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
1584 0 : if(der_copy_utf8string(&(&(from)->val[(to)->len])->subject, &(&(to)->val[(to)->len])->subject)) goto fail;
1585 0 : if((&(from)->val[(to)->len])->issuer) {
1586 0 : (&(to)->val[(to)->len])->issuer = calloc(1, sizeof(*(&(to)->val[(to)->len])->issuer));
1587 0 : if((&(to)->val[(to)->len])->issuer == NULL) goto fail;
1588 0 : if(der_copy_utf8string((&(from)->val[(to)->len])->issuer, (&(to)->val[(to)->len])->issuer)) goto fail;
1589 : }else
1590 0 : (&(to)->val[(to)->len])->issuer = NULL;
1591 0 : if((&(from)->val[(to)->len])->anchor) {
1592 0 : (&(to)->val[(to)->len])->anchor = calloc(1, sizeof(*(&(to)->val[(to)->len])->anchor));
1593 0 : if((&(to)->val[(to)->len])->anchor == NULL) goto fail;
1594 0 : if(der_copy_utf8string((&(from)->val[(to)->len])->anchor, (&(to)->val[(to)->len])->anchor)) goto fail;
1595 : }else
1596 0 : (&(to)->val[(to)->len])->anchor = NULL;
1597 : }
1598 0 : return 0;
1599 0 : fail:
1600 0 : free_HDB_Ext_PKINIT_acl(to);
1601 0 : return ENOMEM;
1602 : }
1603 :
1604 : char * ASN1CALL
1605 0 : print_HDB_Ext_PKINIT_acl(const HDB_Ext_PKINIT_acl *data, int flags)
1606 0 : { errno = EINVAL; return 0; }
1607 :
1608 : int ASN1CALL
1609 0 : encode_HDB_Ext_PKINIT_hash(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_PKINIT_hash *data, size_t *size)
1610 : {
1611 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1612 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1613 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1614 :
1615 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
1616 0 : size_t Top_tag_for_oldret = ret;
1617 0 : ret = 0;
1618 : /* digest */
1619 : {
1620 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1621 0 : ret = 0;
1622 0 : e = der_put_octet_string(p, len, &(&(data)->val[i])->digest, &l);
1623 0 : if (e) return e;
1624 0 : p -= l; len -= l; ret += l;
1625 :
1626 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
1627 0 : if (e) return e;
1628 0 : p -= l; len -= l; ret += l;
1629 :
1630 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
1631 0 : if (e) return e;
1632 0 : p -= l; len -= l; ret += l;
1633 :
1634 0 : ret += Top_tag_S_Of_tag_oldret;
1635 : }
1636 : /* digest-type */
1637 : {
1638 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1639 0 : ret = 0;
1640 0 : e = der_put_oid(p, len, &(&(data)->val[i])->digest_type, &l);
1641 0 : if (e) return e;
1642 0 : p -= l; len -= l; ret += l;
1643 :
1644 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OID, &l);
1645 0 : if (e) return e;
1646 0 : p -= l; len -= l; ret += l;
1647 :
1648 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1649 0 : if (e) return e;
1650 0 : p -= l; len -= l; ret += l;
1651 :
1652 0 : ret += Top_tag_S_Of_tag_oldret;
1653 : }
1654 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1655 0 : if (e) return e;
1656 0 : p -= l; len -= l; ret += l;
1657 :
1658 0 : ret += Top_tag_for_oldret;
1659 : }
1660 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1661 0 : if (e) return e;
1662 0 : p -= l; len -= l; ret += l;
1663 :
1664 0 : *size = ret;
1665 0 : return 0;
1666 : }
1667 :
1668 : int ASN1CALL
1669 0 : decode_HDB_Ext_PKINIT_hash(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_PKINIT_hash *data, size_t *size)
1670 : {
1671 0 : size_t ret = 0;
1672 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1673 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1674 :
1675 0 : memset(data, 0, sizeof(*data));
1676 : {
1677 : size_t Top_datalen;
1678 : Der_type Top_type;
1679 : size_t Top_oldlen;
1680 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1681 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1682 0 : if (e) goto fail;
1683 0 : p += l; len -= l; ret += l;
1684 0 : Top_oldlen = len;
1685 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1686 0 : len = Top_datalen;
1687 : {
1688 0 : size_t Top_Tag_origlen = len;
1689 0 : size_t Top_Tag_oldret = ret;
1690 0 : size_t Top_Tag_olen = 0;
1691 : void *Top_Tag_tmp;
1692 0 : ret = 0;
1693 0 : (data)->len = 0;
1694 0 : (data)->val = NULL;
1695 0 : while(ret < Top_Tag_origlen) {
1696 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
1697 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
1698 0 : Top_Tag_olen = Top_Tag_nlen;
1699 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
1700 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
1701 0 : (data)->val = Top_Tag_tmp;
1702 : {
1703 : size_t Top_Tag_s_of_datalen;
1704 : Der_type Top_Tag_s_of_type;
1705 : size_t Top_Tag_s_of_oldlen;
1706 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_s_of_type, UT_Sequence, &Top_Tag_s_of_datalen, &l);
1707 0 : if (e == 0 && Top_Tag_s_of_type != CONS) { e = ASN1_BAD_ID; }
1708 0 : if (e) goto fail;
1709 0 : p += l; len -= l; ret += l;
1710 0 : Top_Tag_s_of_oldlen = len;
1711 0 : if (Top_Tag_s_of_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1712 0 : len = Top_Tag_s_of_datalen;
1713 : {
1714 : size_t digest_type_datalen;
1715 : Der_type digest_type_type;
1716 : size_t digest_type_oldlen;
1717 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &digest_type_type, 0, &digest_type_datalen, &l);
1718 0 : if (e == 0 && digest_type_type != CONS) { e = ASN1_BAD_ID; }
1719 0 : if (e) goto fail;
1720 0 : p += l; len -= l; ret += l;
1721 0 : digest_type_oldlen = len;
1722 0 : if (digest_type_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1723 0 : len = digest_type_datalen;
1724 : {
1725 : size_t digest_type_Tag_datalen;
1726 : Der_type digest_type_Tag_type;
1727 : size_t digest_type_Tag_oldlen;
1728 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &digest_type_Tag_type, UT_OID, &digest_type_Tag_datalen, &l);
1729 0 : if (e == 0 && digest_type_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1730 0 : if (e) goto fail;
1731 0 : p += l; len -= l; ret += l;
1732 0 : digest_type_Tag_oldlen = len;
1733 0 : if (digest_type_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1734 0 : len = digest_type_Tag_datalen;
1735 0 : e = der_get_oid(p, len, &(&(data)->val[(data)->len])->digest_type, &l);
1736 0 : if(e) goto fail;
1737 0 : p += l; len -= l; ret += l;
1738 0 : len = digest_type_Tag_oldlen - digest_type_Tag_datalen;
1739 : }
1740 0 : len = digest_type_oldlen - digest_type_datalen;
1741 : }
1742 : {
1743 : size_t digest_datalen;
1744 : Der_type digest_type;
1745 : size_t digest_oldlen;
1746 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &digest_type, 1, &digest_datalen, &l);
1747 0 : if (e == 0 && digest_type != CONS) { e = ASN1_BAD_ID; }
1748 0 : if (e) goto fail;
1749 0 : p += l; len -= l; ret += l;
1750 0 : digest_oldlen = len;
1751 0 : if (digest_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1752 0 : len = digest_datalen;
1753 : {
1754 : size_t digest_Tag_datalen;
1755 : Der_type digest_Tag_type;
1756 : size_t digest_Tag_oldlen;
1757 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &digest_Tag_type, UT_OctetString, &digest_Tag_datalen, &l);
1758 0 : if (e == 0 && digest_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1759 0 : if (e) goto fail;
1760 0 : p += l; len -= l; ret += l;
1761 0 : digest_Tag_oldlen = len;
1762 0 : if (digest_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1763 0 : len = digest_Tag_datalen;
1764 0 : e = der_get_octet_string(p, len, &(&(data)->val[(data)->len])->digest, &l);
1765 0 : if(e) goto fail;
1766 0 : p += l; len -= l; ret += l;
1767 0 : len = digest_Tag_oldlen - digest_Tag_datalen;
1768 : }
1769 0 : len = digest_oldlen - digest_datalen;
1770 : }
1771 0 : len = Top_Tag_s_of_oldlen - Top_Tag_s_of_datalen;
1772 : }
1773 0 : (data)->len++;
1774 0 : len = Top_Tag_origlen - ret;
1775 : }
1776 0 : ret += Top_Tag_oldret;
1777 : }
1778 0 : len = Top_oldlen - Top_datalen;
1779 : }
1780 0 : if(size) *size = ret;
1781 0 : return 0;
1782 0 : fail:
1783 0 : free_HDB_Ext_PKINIT_hash(data);
1784 0 : return e;
1785 : }
1786 :
1787 : void ASN1CALL
1788 0 : free_HDB_Ext_PKINIT_hash(HDB_Ext_PKINIT_hash *data)
1789 : {
1790 0 : if ((data)->val)
1791 0 : while((data)->len){
1792 0 : der_free_oid(&(&(data)->val[(data)->len-1])->digest_type);
1793 0 : der_free_octet_string(&(&(data)->val[(data)->len-1])->digest);
1794 0 : (data)->len--;
1795 0 : } else (data)->len = 0;
1796 0 : free((data)->val);
1797 0 : (data)->val = NULL;
1798 0 : }
1799 :
1800 : size_t ASN1CALL
1801 0 : length_HDB_Ext_PKINIT_hash(const HDB_Ext_PKINIT_hash *data)
1802 : {
1803 0 : size_t ret = 0;
1804 : {
1805 0 : size_t Top_tag_oldret = ret;
1806 : unsigned int n_Top_tag;
1807 0 : ret = 0;
1808 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
1809 0 : size_t Top_tag_for_oldret = ret;
1810 0 : ret = 0;
1811 : {
1812 0 : size_t Top_tag_S_Of_tag_oldret = ret;
1813 0 : ret = 0;
1814 0 : ret += der_length_oid(&(&(data)->val[n_Top_tag - 1])->digest_type);
1815 0 : ret += 1 + der_length_len (ret);
1816 0 : ret += 1 + der_length_len (ret);
1817 0 : ret += Top_tag_S_Of_tag_oldret;
1818 : }
1819 : {
1820 0 : size_t Top_tag_S_Of_tag_oldret = ret;
1821 0 : ret = 0;
1822 0 : ret += der_length_octet_string(&(&(data)->val[n_Top_tag - 1])->digest);
1823 0 : ret += 1 + der_length_len (ret);
1824 0 : ret += 1 + der_length_len (ret);
1825 0 : ret += Top_tag_S_Of_tag_oldret;
1826 : }
1827 0 : ret += 1 + der_length_len (ret);
1828 0 : ret += Top_tag_for_oldret;
1829 : }
1830 0 : ret += Top_tag_oldret;
1831 : }
1832 0 : ret += 1 + der_length_len (ret);
1833 0 : return ret;
1834 : }
1835 :
1836 : int ASN1CALL
1837 0 : copy_HDB_Ext_PKINIT_hash(const HDB_Ext_PKINIT_hash *from, HDB_Ext_PKINIT_hash *to)
1838 : {
1839 0 : memset(to, 0, sizeof(*to));
1840 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
1841 0 : goto fail;
1842 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
1843 0 : if(der_copy_oid(&(&(from)->val[(to)->len])->digest_type, &(&(to)->val[(to)->len])->digest_type)) goto fail;
1844 0 : if(der_copy_octet_string(&(&(from)->val[(to)->len])->digest, &(&(to)->val[(to)->len])->digest)) goto fail;
1845 : }
1846 0 : return 0;
1847 0 : fail:
1848 0 : free_HDB_Ext_PKINIT_hash(to);
1849 0 : return ENOMEM;
1850 : }
1851 :
1852 : char * ASN1CALL
1853 0 : print_HDB_Ext_PKINIT_hash(const HDB_Ext_PKINIT_hash *data, int flags)
1854 0 : { errno = EINVAL; return 0; }
1855 :
1856 : int ASN1CALL
1857 0 : encode_HDB_Ext_PKINIT_cert(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_PKINIT_cert *data, size_t *size)
1858 : {
1859 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1860 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1861 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1862 :
1863 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
1864 0 : size_t Top_tag_for_oldret = ret;
1865 0 : ret = 0;
1866 : /* cert */
1867 : {
1868 0 : size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1869 0 : ret = 0;
1870 0 : e = der_put_octet_string(p, len, &(&(data)->val[i])->cert, &l);
1871 0 : if (e) return e;
1872 0 : p -= l; len -= l; ret += l;
1873 :
1874 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
1875 0 : if (e) return e;
1876 0 : p -= l; len -= l; ret += l;
1877 :
1878 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1879 0 : if (e) return e;
1880 0 : p -= l; len -= l; ret += l;
1881 :
1882 0 : ret += Top_tag_S_Of_tag_oldret;
1883 : }
1884 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1885 0 : if (e) return e;
1886 0 : p -= l; len -= l; ret += l;
1887 :
1888 0 : ret += Top_tag_for_oldret;
1889 : }
1890 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1891 0 : if (e) return e;
1892 0 : p -= l; len -= l; ret += l;
1893 :
1894 0 : *size = ret;
1895 0 : return 0;
1896 : }
1897 :
1898 : int ASN1CALL
1899 0 : decode_HDB_Ext_PKINIT_cert(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_PKINIT_cert *data, size_t *size)
1900 : {
1901 0 : size_t ret = 0;
1902 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1903 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1904 :
1905 0 : memset(data, 0, sizeof(*data));
1906 : {
1907 : size_t Top_datalen;
1908 : Der_type Top_type;
1909 : size_t Top_oldlen;
1910 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1911 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1912 0 : if (e) goto fail;
1913 0 : p += l; len -= l; ret += l;
1914 0 : Top_oldlen = len;
1915 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1916 0 : len = Top_datalen;
1917 : {
1918 0 : size_t Top_Tag_origlen = len;
1919 0 : size_t Top_Tag_oldret = ret;
1920 0 : size_t Top_Tag_olen = 0;
1921 : void *Top_Tag_tmp;
1922 0 : ret = 0;
1923 0 : (data)->len = 0;
1924 0 : (data)->val = NULL;
1925 0 : while(ret < Top_Tag_origlen) {
1926 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
1927 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
1928 0 : Top_Tag_olen = Top_Tag_nlen;
1929 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
1930 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
1931 0 : (data)->val = Top_Tag_tmp;
1932 : {
1933 : size_t Top_Tag_s_of_datalen;
1934 : Der_type Top_Tag_s_of_type;
1935 : size_t Top_Tag_s_of_oldlen;
1936 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_s_of_type, UT_Sequence, &Top_Tag_s_of_datalen, &l);
1937 0 : if (e == 0 && Top_Tag_s_of_type != CONS) { e = ASN1_BAD_ID; }
1938 0 : if (e) goto fail;
1939 0 : p += l; len -= l; ret += l;
1940 0 : Top_Tag_s_of_oldlen = len;
1941 0 : if (Top_Tag_s_of_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1942 0 : len = Top_Tag_s_of_datalen;
1943 : {
1944 : size_t cert_datalen;
1945 : Der_type cert_type;
1946 : size_t cert_oldlen;
1947 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &cert_type, 0, &cert_datalen, &l);
1948 0 : if (e == 0 && cert_type != CONS) { e = ASN1_BAD_ID; }
1949 0 : if (e) goto fail;
1950 0 : p += l; len -= l; ret += l;
1951 0 : cert_oldlen = len;
1952 0 : if (cert_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1953 0 : len = cert_datalen;
1954 : {
1955 : size_t cert_Tag_datalen;
1956 : Der_type cert_Tag_type;
1957 : size_t cert_Tag_oldlen;
1958 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &cert_Tag_type, UT_OctetString, &cert_Tag_datalen, &l);
1959 0 : if (e == 0 && cert_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1960 0 : if (e) goto fail;
1961 0 : p += l; len -= l; ret += l;
1962 0 : cert_Tag_oldlen = len;
1963 0 : if (cert_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1964 0 : len = cert_Tag_datalen;
1965 0 : e = der_get_octet_string(p, len, &(&(data)->val[(data)->len])->cert, &l);
1966 0 : if(e) goto fail;
1967 0 : p += l; len -= l; ret += l;
1968 0 : len = cert_Tag_oldlen - cert_Tag_datalen;
1969 : }
1970 0 : len = cert_oldlen - cert_datalen;
1971 : }
1972 0 : len = Top_Tag_s_of_oldlen - Top_Tag_s_of_datalen;
1973 : }
1974 0 : (data)->len++;
1975 0 : len = Top_Tag_origlen - ret;
1976 : }
1977 0 : ret += Top_Tag_oldret;
1978 : }
1979 0 : len = Top_oldlen - Top_datalen;
1980 : }
1981 0 : if(size) *size = ret;
1982 0 : return 0;
1983 0 : fail:
1984 0 : free_HDB_Ext_PKINIT_cert(data);
1985 0 : return e;
1986 : }
1987 :
1988 : void ASN1CALL
1989 0 : free_HDB_Ext_PKINIT_cert(HDB_Ext_PKINIT_cert *data)
1990 : {
1991 0 : if ((data)->val)
1992 0 : while((data)->len){
1993 0 : der_free_octet_string(&(&(data)->val[(data)->len-1])->cert);
1994 0 : (data)->len--;
1995 0 : } else (data)->len = 0;
1996 0 : free((data)->val);
1997 0 : (data)->val = NULL;
1998 0 : }
1999 :
2000 : size_t ASN1CALL
2001 0 : length_HDB_Ext_PKINIT_cert(const HDB_Ext_PKINIT_cert *data)
2002 : {
2003 0 : size_t ret = 0;
2004 : {
2005 0 : size_t Top_tag_oldret = ret;
2006 : unsigned int n_Top_tag;
2007 0 : ret = 0;
2008 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
2009 0 : size_t Top_tag_for_oldret = ret;
2010 0 : ret = 0;
2011 : {
2012 0 : size_t Top_tag_S_Of_tag_oldret = ret;
2013 0 : ret = 0;
2014 0 : ret += der_length_octet_string(&(&(data)->val[n_Top_tag - 1])->cert);
2015 0 : ret += 1 + der_length_len (ret);
2016 0 : ret += 1 + der_length_len (ret);
2017 0 : ret += Top_tag_S_Of_tag_oldret;
2018 : }
2019 0 : ret += 1 + der_length_len (ret);
2020 0 : ret += Top_tag_for_oldret;
2021 : }
2022 0 : ret += Top_tag_oldret;
2023 : }
2024 0 : ret += 1 + der_length_len (ret);
2025 0 : return ret;
2026 : }
2027 :
2028 : int ASN1CALL
2029 0 : copy_HDB_Ext_PKINIT_cert(const HDB_Ext_PKINIT_cert *from, HDB_Ext_PKINIT_cert *to)
2030 : {
2031 0 : memset(to, 0, sizeof(*to));
2032 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
2033 0 : goto fail;
2034 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
2035 0 : if(der_copy_octet_string(&(&(from)->val[(to)->len])->cert, &(&(to)->val[(to)->len])->cert)) goto fail;
2036 : }
2037 0 : return 0;
2038 0 : fail:
2039 0 : free_HDB_Ext_PKINIT_cert(to);
2040 0 : return ENOMEM;
2041 : }
2042 :
2043 : char * ASN1CALL
2044 0 : print_HDB_Ext_PKINIT_cert(const HDB_Ext_PKINIT_cert *data, int flags)
2045 0 : { errno = EINVAL; return 0; }
2046 :
2047 : int ASN1CALL
2048 0 : encode_HDB_Ext_Constrained_delegation_acl(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_Constrained_delegation_acl *data, size_t *size)
2049 : {
2050 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2051 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2052 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2053 :
2054 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
2055 0 : size_t Top_tag_for_oldret = ret;
2056 0 : ret = 0;
2057 0 : e = encode_Principal(p, len, &(data)->val[i], &l);
2058 0 : if (e) return e;
2059 0 : p -= l; len -= l; ret += l;
2060 :
2061 0 : ret += Top_tag_for_oldret;
2062 : }
2063 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2064 0 : if (e) return e;
2065 0 : p -= l; len -= l; ret += l;
2066 :
2067 0 : *size = ret;
2068 0 : return 0;
2069 : }
2070 :
2071 : int ASN1CALL
2072 0 : decode_HDB_Ext_Constrained_delegation_acl(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_Constrained_delegation_acl *data, size_t *size)
2073 : {
2074 0 : size_t ret = 0;
2075 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2076 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2077 :
2078 0 : memset(data, 0, sizeof(*data));
2079 : {
2080 : size_t Top_datalen;
2081 : Der_type Top_type;
2082 : size_t Top_oldlen;
2083 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
2084 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
2085 0 : if (e) goto fail;
2086 0 : p += l; len -= l; ret += l;
2087 0 : Top_oldlen = len;
2088 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2089 0 : len = Top_datalen;
2090 : {
2091 0 : size_t Top_Tag_origlen = len;
2092 0 : size_t Top_Tag_oldret = ret;
2093 0 : size_t Top_Tag_olen = 0;
2094 : void *Top_Tag_tmp;
2095 0 : ret = 0;
2096 0 : (data)->len = 0;
2097 0 : (data)->val = NULL;
2098 0 : while(ret < Top_Tag_origlen) {
2099 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
2100 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
2101 0 : Top_Tag_olen = Top_Tag_nlen;
2102 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
2103 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
2104 0 : (data)->val = Top_Tag_tmp;
2105 0 : e = decode_Principal(p, len, &(data)->val[(data)->len], &l);
2106 0 : if(e) goto fail;
2107 0 : p += l; len -= l; ret += l;
2108 0 : (data)->len++;
2109 0 : len = Top_Tag_origlen - ret;
2110 : }
2111 0 : ret += Top_Tag_oldret;
2112 : }
2113 0 : len = Top_oldlen - Top_datalen;
2114 : }
2115 0 : if(size) *size = ret;
2116 0 : return 0;
2117 0 : fail:
2118 0 : free_HDB_Ext_Constrained_delegation_acl(data);
2119 0 : return e;
2120 : }
2121 :
2122 : void ASN1CALL
2123 0 : free_HDB_Ext_Constrained_delegation_acl(HDB_Ext_Constrained_delegation_acl *data)
2124 : {
2125 0 : if ((data)->val)
2126 0 : while((data)->len){
2127 0 : free_Principal(&(data)->val[(data)->len-1]);
2128 0 : (data)->len--;
2129 0 : } else (data)->len = 0;
2130 0 : free((data)->val);
2131 0 : (data)->val = NULL;
2132 0 : }
2133 :
2134 : size_t ASN1CALL
2135 0 : length_HDB_Ext_Constrained_delegation_acl(const HDB_Ext_Constrained_delegation_acl *data)
2136 : {
2137 0 : size_t ret = 0;
2138 : {
2139 0 : size_t Top_tag_oldret = ret;
2140 : unsigned int n_Top_tag;
2141 0 : ret = 0;
2142 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
2143 0 : size_t Top_tag_for_oldret = ret;
2144 0 : ret = 0;
2145 0 : ret += length_Principal(&(data)->val[n_Top_tag - 1]);
2146 0 : ret += Top_tag_for_oldret;
2147 : }
2148 0 : ret += Top_tag_oldret;
2149 : }
2150 0 : ret += 1 + der_length_len (ret);
2151 0 : return ret;
2152 : }
2153 :
2154 : int ASN1CALL
2155 0 : copy_HDB_Ext_Constrained_delegation_acl(const HDB_Ext_Constrained_delegation_acl *from, HDB_Ext_Constrained_delegation_acl *to)
2156 : {
2157 0 : memset(to, 0, sizeof(*to));
2158 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
2159 0 : goto fail;
2160 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
2161 0 : if(copy_Principal(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
2162 : }
2163 0 : return 0;
2164 0 : fail:
2165 0 : free_HDB_Ext_Constrained_delegation_acl(to);
2166 0 : return ENOMEM;
2167 : }
2168 :
2169 : char * ASN1CALL
2170 0 : print_HDB_Ext_Constrained_delegation_acl(const HDB_Ext_Constrained_delegation_acl *data, int flags)
2171 0 : { errno = EINVAL; return 0; }
2172 :
2173 : int ASN1CALL
2174 0 : encode_HDB_Ext_Lan_Manager_OWF(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_Lan_Manager_OWF *data, size_t *size)
2175 : {
2176 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2177 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2178 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2179 :
2180 0 : e = der_put_octet_string(p, len, data, &l);
2181 0 : if (e) return e;
2182 0 : p -= l; len -= l; ret += l;
2183 :
2184 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
2185 0 : if (e) return e;
2186 0 : p -= l; len -= l; ret += l;
2187 :
2188 0 : *size = ret;
2189 0 : return 0;
2190 : }
2191 :
2192 : int ASN1CALL
2193 0 : decode_HDB_Ext_Lan_Manager_OWF(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_Lan_Manager_OWF *data, size_t *size)
2194 : {
2195 0 : size_t ret = 0;
2196 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2197 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2198 :
2199 0 : memset(data, 0, sizeof(*data));
2200 : {
2201 : size_t Top_datalen;
2202 : Der_type Top_type;
2203 : size_t Top_oldlen;
2204 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_OctetString, &Top_datalen, &l);
2205 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
2206 0 : if (e) goto fail;
2207 0 : p += l; len -= l; ret += l;
2208 0 : Top_oldlen = len;
2209 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2210 0 : len = Top_datalen;
2211 0 : e = der_get_octet_string(p, len, data, &l);
2212 0 : if(e) goto fail;
2213 0 : p += l; len -= l; ret += l;
2214 0 : len = Top_oldlen - Top_datalen;
2215 : }
2216 0 : if(size) *size = ret;
2217 0 : return 0;
2218 0 : fail:
2219 0 : free_HDB_Ext_Lan_Manager_OWF(data);
2220 0 : return e;
2221 : }
2222 :
2223 : void ASN1CALL
2224 0 : free_HDB_Ext_Lan_Manager_OWF(HDB_Ext_Lan_Manager_OWF *data)
2225 : {
2226 0 : der_free_octet_string(data);
2227 0 : }
2228 :
2229 : size_t ASN1CALL
2230 0 : length_HDB_Ext_Lan_Manager_OWF(const HDB_Ext_Lan_Manager_OWF *data)
2231 : {
2232 0 : size_t ret = 0;
2233 0 : ret += der_length_octet_string(data);
2234 0 : ret += 1 + der_length_len (ret);
2235 0 : return ret;
2236 : }
2237 :
2238 : int ASN1CALL
2239 0 : copy_HDB_Ext_Lan_Manager_OWF(const HDB_Ext_Lan_Manager_OWF *from, HDB_Ext_Lan_Manager_OWF *to)
2240 : {
2241 0 : memset(to, 0, sizeof(*to));
2242 0 : if(der_copy_octet_string(from, to)) goto fail;
2243 0 : return 0;
2244 0 : fail:
2245 0 : free_HDB_Ext_Lan_Manager_OWF(to);
2246 0 : return ENOMEM;
2247 : }
2248 :
2249 : char * ASN1CALL
2250 0 : print_HDB_Ext_Lan_Manager_OWF(const HDB_Ext_Lan_Manager_OWF *data, int flags)
2251 0 : { errno = EINVAL; return 0; }
2252 :
2253 : int ASN1CALL
2254 0 : encode_HDB_Ext_Password(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_Password *data, size_t *size)
2255 : {
2256 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2257 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2258 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2259 :
2260 : /* password */
2261 : {
2262 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2263 0 : ret = 0;
2264 0 : e = der_put_octet_string(p, len, &(data)->password, &l);
2265 0 : if (e) return e;
2266 0 : p -= l; len -= l; ret += l;
2267 :
2268 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
2269 0 : if (e) return e;
2270 0 : p -= l; len -= l; ret += l;
2271 :
2272 0 : ret += Top_tag_oldret;
2273 : }
2274 : /* mkvno */
2275 0 : if((data)->mkvno) {
2276 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2277 0 : ret = 0;
2278 0 : e = der_put_unsigned(p, len, (data)->mkvno, &l);
2279 0 : if (e) return e;
2280 0 : p -= l; len -= l; ret += l;
2281 :
2282 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
2283 0 : if (e) return e;
2284 0 : p -= l; len -= l; ret += l;
2285 :
2286 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
2287 0 : if (e) return e;
2288 0 : p -= l; len -= l; ret += l;
2289 :
2290 0 : ret += Top_tag_oldret;
2291 : }
2292 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2293 0 : if (e) return e;
2294 0 : p -= l; len -= l; ret += l;
2295 :
2296 0 : *size = ret;
2297 0 : return 0;
2298 : }
2299 :
2300 : int ASN1CALL
2301 0 : decode_HDB_Ext_Password(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_Password *data, size_t *size)
2302 : {
2303 0 : size_t ret = 0;
2304 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2305 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2306 :
2307 0 : memset(data, 0, sizeof(*data));
2308 : {
2309 : size_t Top_datalen;
2310 : Der_type Top_type;
2311 : size_t Top_oldlen;
2312 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
2313 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
2314 0 : if (e) goto fail;
2315 0 : p += l; len -= l; ret += l;
2316 0 : Top_oldlen = len;
2317 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2318 0 : len = Top_datalen;
2319 : {
2320 : size_t mkvno_datalen;
2321 : Der_type mkvno_type;
2322 : size_t mkvno_oldlen;
2323 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mkvno_type, 0, &mkvno_datalen, &l);
2324 0 : if (e == 0 && mkvno_type != CONS) { e = ASN1_BAD_ID; }
2325 0 : if(e) {
2326 0 : (data)->mkvno = NULL;
2327 : } else {
2328 0 : (data)->mkvno = calloc(1, sizeof(*(data)->mkvno));
2329 0 : if ((data)->mkvno == NULL) { e = ENOMEM; goto fail; }
2330 0 : p += l; len -= l; ret += l;
2331 0 : mkvno_oldlen = len;
2332 0 : if (mkvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2333 0 : len = mkvno_datalen;
2334 : {
2335 : size_t mkvno_Tag_datalen;
2336 : Der_type mkvno_Tag_type;
2337 : size_t mkvno_Tag_oldlen;
2338 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mkvno_Tag_type, UT_Integer, &mkvno_Tag_datalen, &l);
2339 0 : if (e == 0 && mkvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
2340 0 : if (e) goto fail;
2341 0 : p += l; len -= l; ret += l;
2342 0 : mkvno_Tag_oldlen = len;
2343 0 : if (mkvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2344 0 : len = mkvno_Tag_datalen;
2345 0 : e = der_get_unsigned(p, len, (data)->mkvno, &l);
2346 0 : if(e) goto fail;
2347 0 : p += l; len -= l; ret += l;
2348 0 : len = mkvno_Tag_oldlen - mkvno_Tag_datalen;
2349 : }
2350 0 : len = mkvno_oldlen - mkvno_datalen;
2351 : }
2352 : }
2353 : {
2354 : size_t password_datalen;
2355 : Der_type password_type;
2356 : size_t password_oldlen;
2357 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &password_type, UT_OctetString, &password_datalen, &l);
2358 0 : if (e == 0 && password_type != PRIM) { e = ASN1_BAD_ID; }
2359 0 : if (e) goto fail;
2360 0 : p += l; len -= l; ret += l;
2361 0 : password_oldlen = len;
2362 0 : if (password_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2363 0 : len = password_datalen;
2364 0 : e = der_get_octet_string(p, len, &(data)->password, &l);
2365 0 : if(e) goto fail;
2366 0 : p += l; len -= l; ret += l;
2367 0 : len = password_oldlen - password_datalen;
2368 : }
2369 0 : len = Top_oldlen - Top_datalen;
2370 : }
2371 0 : if(size) *size = ret;
2372 0 : return 0;
2373 0 : fail:
2374 0 : free_HDB_Ext_Password(data);
2375 0 : return e;
2376 : }
2377 :
2378 : void ASN1CALL
2379 0 : free_HDB_Ext_Password(HDB_Ext_Password *data)
2380 : {
2381 0 : if((data)->mkvno) {
2382 0 : *(data)->mkvno = 0;
2383 0 : free((data)->mkvno);
2384 0 : (data)->mkvno = NULL;
2385 : }
2386 0 : der_free_octet_string(&(data)->password);
2387 0 : }
2388 :
2389 : size_t ASN1CALL
2390 0 : length_HDB_Ext_Password(const HDB_Ext_Password *data)
2391 : {
2392 0 : size_t ret = 0;
2393 0 : if((data)->mkvno){
2394 0 : size_t Top_tag_oldret = ret;
2395 0 : ret = 0;
2396 0 : ret += der_length_unsigned((data)->mkvno);
2397 0 : ret += 1 + der_length_len (ret);
2398 0 : ret += 1 + der_length_len (ret);
2399 0 : ret += Top_tag_oldret;
2400 : }
2401 : {
2402 0 : size_t Top_tag_oldret = ret;
2403 0 : ret = 0;
2404 0 : ret += der_length_octet_string(&(data)->password);
2405 0 : ret += 1 + der_length_len (ret);
2406 0 : ret += Top_tag_oldret;
2407 : }
2408 0 : ret += 1 + der_length_len (ret);
2409 0 : return ret;
2410 : }
2411 :
2412 : int ASN1CALL
2413 0 : copy_HDB_Ext_Password(const HDB_Ext_Password *from, HDB_Ext_Password *to)
2414 : {
2415 0 : memset(to, 0, sizeof(*to));
2416 0 : if((from)->mkvno) {
2417 0 : (to)->mkvno = calloc(1, sizeof(*(to)->mkvno));
2418 0 : if((to)->mkvno == NULL) goto fail;
2419 0 : *((to)->mkvno) = *((from)->mkvno);
2420 : }else
2421 0 : (to)->mkvno = NULL;
2422 0 : if(der_copy_octet_string(&(from)->password, &(to)->password)) goto fail;
2423 0 : return 0;
2424 0 : fail:
2425 0 : free_HDB_Ext_Password(to);
2426 0 : return ENOMEM;
2427 : }
2428 :
2429 : char * ASN1CALL
2430 0 : print_HDB_Ext_Password(const HDB_Ext_Password *data, int flags)
2431 0 : { errno = EINVAL; return 0; }
2432 :
2433 : int ASN1CALL
2434 0 : encode_HDB_Ext_Aliases(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_Aliases *data, size_t *size)
2435 : {
2436 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2437 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2438 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2439 :
2440 : /* aliases */
2441 : {
2442 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2443 0 : ret = 0;
2444 0 : for(i = (int)(&(data)->aliases)->len - 1; i >= 0; --i) {
2445 0 : size_t aliases_tag_tag_for_oldret = ret;
2446 0 : ret = 0;
2447 0 : e = encode_Principal(p, len, &(&(data)->aliases)->val[i], &l);
2448 0 : if (e) return e;
2449 0 : p -= l; len -= l; ret += l;
2450 :
2451 0 : ret += aliases_tag_tag_for_oldret;
2452 : }
2453 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2454 0 : if (e) return e;
2455 0 : p -= l; len -= l; ret += l;
2456 :
2457 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
2458 0 : if (e) return e;
2459 0 : p -= l; len -= l; ret += l;
2460 :
2461 0 : ret += Top_tag_oldret;
2462 : }
2463 : /* case-insensitive */
2464 : {
2465 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2466 0 : ret = 0;
2467 0 : e = der_put_boolean(p, len, &(data)->case_insensitive, &l);
2468 0 : if (e) return e;
2469 0 : p -= l; len -= l; ret += l;
2470 :
2471 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Boolean, &l);
2472 0 : if (e) return e;
2473 0 : p -= l; len -= l; ret += l;
2474 :
2475 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
2476 0 : if (e) return e;
2477 0 : p -= l; len -= l; ret += l;
2478 :
2479 0 : ret += Top_tag_oldret;
2480 : }
2481 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2482 0 : if (e) return e;
2483 0 : p -= l; len -= l; ret += l;
2484 :
2485 0 : *size = ret;
2486 0 : return 0;
2487 : }
2488 :
2489 : int ASN1CALL
2490 0 : decode_HDB_Ext_Aliases(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_Aliases *data, size_t *size)
2491 : {
2492 0 : size_t ret = 0;
2493 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2494 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2495 :
2496 0 : memset(data, 0, sizeof(*data));
2497 : {
2498 : size_t Top_datalen;
2499 : Der_type Top_type;
2500 : size_t Top_oldlen;
2501 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
2502 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
2503 0 : if (e) goto fail;
2504 0 : p += l; len -= l; ret += l;
2505 0 : Top_oldlen = len;
2506 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2507 0 : len = Top_datalen;
2508 : {
2509 : size_t case_insensitive_datalen;
2510 : Der_type case_insensitive_type;
2511 : size_t case_insensitive_oldlen;
2512 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &case_insensitive_type, 0, &case_insensitive_datalen, &l);
2513 0 : if (e == 0 && case_insensitive_type != CONS) { e = ASN1_BAD_ID; }
2514 0 : if (e) goto fail;
2515 0 : p += l; len -= l; ret += l;
2516 0 : case_insensitive_oldlen = len;
2517 0 : if (case_insensitive_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2518 0 : len = case_insensitive_datalen;
2519 : {
2520 : size_t case_insensitive_Tag_datalen;
2521 : Der_type case_insensitive_Tag_type;
2522 : size_t case_insensitive_Tag_oldlen;
2523 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &case_insensitive_Tag_type, UT_Boolean, &case_insensitive_Tag_datalen, &l);
2524 0 : if (e == 0 && case_insensitive_Tag_type != PRIM) { e = ASN1_BAD_ID; }
2525 0 : if (e) goto fail;
2526 0 : p += l; len -= l; ret += l;
2527 0 : case_insensitive_Tag_oldlen = len;
2528 0 : if (case_insensitive_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2529 0 : len = case_insensitive_Tag_datalen;
2530 0 : e = der_get_boolean(p, len, &(data)->case_insensitive, &l);
2531 0 : if(e) goto fail;
2532 0 : p += l; len -= l; ret += l;
2533 0 : len = case_insensitive_Tag_oldlen - case_insensitive_Tag_datalen;
2534 : }
2535 0 : len = case_insensitive_oldlen - case_insensitive_datalen;
2536 : }
2537 : {
2538 : size_t aliases_datalen;
2539 : Der_type aliases_type;
2540 : size_t aliases_oldlen;
2541 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &aliases_type, 1, &aliases_datalen, &l);
2542 0 : if (e == 0 && aliases_type != CONS) { e = ASN1_BAD_ID; }
2543 0 : if (e) goto fail;
2544 0 : p += l; len -= l; ret += l;
2545 0 : aliases_oldlen = len;
2546 0 : if (aliases_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2547 0 : len = aliases_datalen;
2548 : {
2549 : size_t aliases_Tag_datalen;
2550 : Der_type aliases_Tag_type;
2551 : size_t aliases_Tag_oldlen;
2552 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &aliases_Tag_type, UT_Sequence, &aliases_Tag_datalen, &l);
2553 0 : if (e == 0 && aliases_Tag_type != CONS) { e = ASN1_BAD_ID; }
2554 0 : if (e) goto fail;
2555 0 : p += l; len -= l; ret += l;
2556 0 : aliases_Tag_oldlen = len;
2557 0 : if (aliases_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2558 0 : len = aliases_Tag_datalen;
2559 : {
2560 0 : size_t aliases_Tag_Tag_origlen = len;
2561 0 : size_t aliases_Tag_Tag_oldret = ret;
2562 0 : size_t aliases_Tag_Tag_olen = 0;
2563 : void *aliases_Tag_Tag_tmp;
2564 0 : ret = 0;
2565 0 : (&(data)->aliases)->len = 0;
2566 0 : (&(data)->aliases)->val = NULL;
2567 0 : while(ret < aliases_Tag_Tag_origlen) {
2568 0 : size_t aliases_Tag_Tag_nlen = aliases_Tag_Tag_olen + sizeof(*((&(data)->aliases)->val));
2569 0 : if (aliases_Tag_Tag_olen > aliases_Tag_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
2570 0 : aliases_Tag_Tag_olen = aliases_Tag_Tag_nlen;
2571 0 : aliases_Tag_Tag_tmp = realloc((&(data)->aliases)->val, aliases_Tag_Tag_olen);
2572 0 : if (aliases_Tag_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
2573 0 : (&(data)->aliases)->val = aliases_Tag_Tag_tmp;
2574 0 : e = decode_Principal(p, len, &(&(data)->aliases)->val[(&(data)->aliases)->len], &l);
2575 0 : if(e) goto fail;
2576 0 : p += l; len -= l; ret += l;
2577 0 : (&(data)->aliases)->len++;
2578 0 : len = aliases_Tag_Tag_origlen - ret;
2579 : }
2580 0 : ret += aliases_Tag_Tag_oldret;
2581 : }
2582 0 : len = aliases_Tag_oldlen - aliases_Tag_datalen;
2583 : }
2584 0 : len = aliases_oldlen - aliases_datalen;
2585 : }
2586 0 : len = Top_oldlen - Top_datalen;
2587 : }
2588 0 : if(size) *size = ret;
2589 0 : return 0;
2590 0 : fail:
2591 0 : free_HDB_Ext_Aliases(data);
2592 0 : return e;
2593 : }
2594 :
2595 : void ASN1CALL
2596 0 : free_HDB_Ext_Aliases(HDB_Ext_Aliases *data)
2597 : {
2598 0 : *&(data)->case_insensitive = 0;
2599 0 : if ((&(data)->aliases)->val)
2600 0 : while((&(data)->aliases)->len){
2601 0 : free_Principal(&(&(data)->aliases)->val[(&(data)->aliases)->len-1]);
2602 0 : (&(data)->aliases)->len--;
2603 0 : } else (&(data)->aliases)->len = 0;
2604 0 : free((&(data)->aliases)->val);
2605 0 : (&(data)->aliases)->val = NULL;
2606 0 : }
2607 :
2608 : size_t ASN1CALL
2609 0 : length_HDB_Ext_Aliases(const HDB_Ext_Aliases *data)
2610 : {
2611 0 : size_t ret = 0;
2612 : {
2613 0 : size_t Top_tag_oldret = ret;
2614 0 : ret = 0;
2615 0 : ret += 1;
2616 0 : ret += 1 + der_length_len (ret);
2617 0 : ret += 1 + der_length_len (ret);
2618 0 : ret += Top_tag_oldret;
2619 : }
2620 : {
2621 0 : size_t Top_tag_oldret = ret;
2622 0 : ret = 0;
2623 : {
2624 0 : size_t aliases_tag_tag_oldret = ret;
2625 : unsigned int n_aliases_tag_tag;
2626 0 : ret = 0;
2627 0 : for(n_aliases_tag_tag = (&(data)->aliases)->len; n_aliases_tag_tag > 0; --n_aliases_tag_tag){
2628 0 : size_t aliases_tag_tag_for_oldret = ret;
2629 0 : ret = 0;
2630 0 : ret += length_Principal(&(&(data)->aliases)->val[n_aliases_tag_tag - 1]);
2631 0 : ret += aliases_tag_tag_for_oldret;
2632 : }
2633 0 : ret += aliases_tag_tag_oldret;
2634 : }
2635 0 : ret += 1 + der_length_len (ret);
2636 0 : ret += 1 + der_length_len (ret);
2637 0 : ret += Top_tag_oldret;
2638 : }
2639 0 : ret += 1 + der_length_len (ret);
2640 0 : return ret;
2641 : }
2642 :
2643 : int ASN1CALL
2644 0 : copy_HDB_Ext_Aliases(const HDB_Ext_Aliases *from, HDB_Ext_Aliases *to)
2645 : {
2646 0 : memset(to, 0, sizeof(*to));
2647 0 : *(&(to)->case_insensitive) = *(&(from)->case_insensitive);
2648 0 : if(((&(to)->aliases)->val = calloc(1, (&(from)->aliases)->len * sizeof(*(&(to)->aliases)->val))) == NULL && (&(from)->aliases)->len != 0)
2649 0 : goto fail;
2650 0 : for((&(to)->aliases)->len = 0; (&(to)->aliases)->len < (&(from)->aliases)->len; (&(to)->aliases)->len++){
2651 0 : if(copy_Principal(&(&(from)->aliases)->val[(&(to)->aliases)->len], &(&(to)->aliases)->val[(&(to)->aliases)->len])) goto fail;
2652 : }
2653 0 : return 0;
2654 0 : fail:
2655 0 : free_HDB_Ext_Aliases(to);
2656 0 : return ENOMEM;
2657 : }
2658 :
2659 : char * ASN1CALL
2660 0 : print_HDB_Ext_Aliases(const HDB_Ext_Aliases *data, int flags)
2661 0 : { errno = EINVAL; return 0; }
2662 :
2663 : int ASN1CALL
2664 0 : encode_Keys(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Keys *data, size_t *size)
2665 : {
2666 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2667 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2668 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2669 :
2670 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
2671 0 : size_t Top_tag_for_oldret = ret;
2672 0 : ret = 0;
2673 0 : e = encode_Key(p, len, &(data)->val[i], &l);
2674 0 : if (e) return e;
2675 0 : p -= l; len -= l; ret += l;
2676 :
2677 0 : ret += Top_tag_for_oldret;
2678 : }
2679 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2680 0 : if (e) return e;
2681 0 : p -= l; len -= l; ret += l;
2682 :
2683 0 : *size = ret;
2684 0 : return 0;
2685 : }
2686 :
2687 : int ASN1CALL
2688 0 : decode_Keys(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, Keys *data, size_t *size)
2689 : {
2690 0 : size_t ret = 0;
2691 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2692 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2693 :
2694 0 : memset(data, 0, sizeof(*data));
2695 : {
2696 : size_t Top_datalen;
2697 : Der_type Top_type;
2698 : size_t Top_oldlen;
2699 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
2700 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
2701 0 : if (e) goto fail;
2702 0 : p += l; len -= l; ret += l;
2703 0 : Top_oldlen = len;
2704 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2705 0 : len = Top_datalen;
2706 : {
2707 0 : size_t Top_Tag_origlen = len;
2708 0 : size_t Top_Tag_oldret = ret;
2709 0 : size_t Top_Tag_olen = 0;
2710 : void *Top_Tag_tmp;
2711 0 : ret = 0;
2712 0 : (data)->len = 0;
2713 0 : (data)->val = NULL;
2714 0 : while(ret < Top_Tag_origlen) {
2715 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
2716 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
2717 0 : Top_Tag_olen = Top_Tag_nlen;
2718 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
2719 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
2720 0 : (data)->val = Top_Tag_tmp;
2721 0 : e = decode_Key(p, len, &(data)->val[(data)->len], &l);
2722 0 : if(e) goto fail;
2723 0 : p += l; len -= l; ret += l;
2724 0 : (data)->len++;
2725 0 : len = Top_Tag_origlen - ret;
2726 : }
2727 0 : ret += Top_Tag_oldret;
2728 : }
2729 0 : len = Top_oldlen - Top_datalen;
2730 : }
2731 0 : if(size) *size = ret;
2732 0 : return 0;
2733 0 : fail:
2734 0 : free_Keys(data);
2735 0 : return e;
2736 : }
2737 :
2738 : void ASN1CALL
2739 214228 : free_Keys(Keys *data)
2740 : {
2741 214228 : if ((data)->val)
2742 774039 : while((data)->len){
2743 356455 : free_Key(&(data)->val[(data)->len-1]);
2744 356455 : (data)->len--;
2745 5436 : } else (data)->len = 0;
2746 214228 : free((data)->val);
2747 214228 : (data)->val = NULL;
2748 214228 : }
2749 :
2750 : size_t ASN1CALL
2751 0 : length_Keys(const Keys *data)
2752 : {
2753 0 : size_t ret = 0;
2754 : {
2755 0 : size_t Top_tag_oldret = ret;
2756 : unsigned int n_Top_tag;
2757 0 : ret = 0;
2758 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
2759 0 : size_t Top_tag_for_oldret = ret;
2760 0 : ret = 0;
2761 0 : ret += length_Key(&(data)->val[n_Top_tag - 1]);
2762 0 : ret += Top_tag_for_oldret;
2763 : }
2764 0 : ret += Top_tag_oldret;
2765 : }
2766 0 : ret += 1 + der_length_len (ret);
2767 0 : return ret;
2768 : }
2769 :
2770 : int ASN1CALL
2771 0 : copy_Keys(const Keys *from, Keys *to)
2772 : {
2773 0 : memset(to, 0, sizeof(*to));
2774 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
2775 0 : goto fail;
2776 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
2777 0 : if(copy_Key(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
2778 : }
2779 0 : return 0;
2780 0 : fail:
2781 0 : free_Keys(to);
2782 0 : return ENOMEM;
2783 : }
2784 :
2785 : char * ASN1CALL
2786 0 : print_Keys(const Keys *data, int flags)
2787 0 : { errno = EINVAL; return 0; }
2788 :
2789 : int ASN1CALL
2790 0 : add_Keys(Keys *data, const Key *element)
2791 : {
2792 : int ret;
2793 : void *ptr;
2794 :
2795 0 : ptr = realloc(data->val,
2796 0 : (data->len + 1) * sizeof(data->val[0]));
2797 0 : if (ptr == NULL) return ENOMEM;
2798 0 : data->val = ptr;
2799 :
2800 0 : ret = copy_Key(element, &data->val[data->len]);
2801 0 : if (ret) return ret;
2802 0 : data->len++;
2803 0 : return 0;
2804 : }
2805 :
2806 : int ASN1CALL
2807 0 : remove_Keys(Keys *data, unsigned int element)
2808 : {
2809 : void *ptr;
2810 :
2811 0 : if (data->len == 0 || element >= data->len)
2812 0 : return ASN1_OVERRUN;
2813 0 : free_Key(&data->val[element]);
2814 0 : data->len--;
2815 0 : if (element < data->len)
2816 0 : memmove(&data->val[element], &data->val[element + 1],
2817 0 : sizeof(data->val[0]) * (data->len - element));
2818 0 : ptr = realloc(data->val, data->len * sizeof(data->val[0]));
2819 0 : if (ptr != NULL || data->len == 0) data->val = ptr;
2820 0 : return 0;
2821 : }
2822 :
2823 : int ASN1CALL
2824 0 : encode_HDB_keyset(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_keyset *data, size_t *size)
2825 : {
2826 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
2827 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2828 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
2829 :
2830 : /* set-time */
2831 0 : if((data)->set_time) {
2832 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2833 0 : ret = 0;
2834 0 : e = encode_KerberosTime(p, len, (data)->set_time, &l);
2835 0 : if (e) return e;
2836 0 : p -= l; len -= l; ret += l;
2837 :
2838 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
2839 0 : if (e) return e;
2840 0 : p -= l; len -= l; ret += l;
2841 :
2842 0 : ret += Top_tag_oldret;
2843 : }
2844 : /* keys */
2845 : {
2846 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2847 0 : ret = 0;
2848 0 : e = encode_Keys(p, len, &(data)->keys, &l);
2849 0 : if (e) return e;
2850 0 : p -= l; len -= l; ret += l;
2851 :
2852 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
2853 0 : if (e) return e;
2854 0 : p -= l; len -= l; ret += l;
2855 :
2856 0 : ret += Top_tag_oldret;
2857 : }
2858 : /* kvno */
2859 : {
2860 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
2861 0 : ret = 0;
2862 0 : e = der_put_unsigned(p, len, &(data)->kvno, &l);
2863 0 : if (e) return e;
2864 0 : p -= l; len -= l; ret += l;
2865 :
2866 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
2867 0 : if (e) return e;
2868 0 : p -= l; len -= l; ret += l;
2869 :
2870 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
2871 0 : if (e) return e;
2872 0 : p -= l; len -= l; ret += l;
2873 :
2874 0 : ret += Top_tag_oldret;
2875 : }
2876 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
2877 0 : if (e) return e;
2878 0 : p -= l; len -= l; ret += l;
2879 :
2880 0 : *size = ret;
2881 0 : return 0;
2882 : }
2883 :
2884 : int ASN1CALL
2885 0 : decode_HDB_keyset(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_keyset *data, size_t *size)
2886 : {
2887 0 : size_t ret = 0;
2888 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
2889 : int e HEIMDAL_UNUSED_ATTRIBUTE;
2890 :
2891 0 : memset(data, 0, sizeof(*data));
2892 : {
2893 : size_t Top_datalen;
2894 : Der_type Top_type;
2895 : size_t Top_oldlen;
2896 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
2897 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
2898 0 : if (e) goto fail;
2899 0 : p += l; len -= l; ret += l;
2900 0 : Top_oldlen = len;
2901 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2902 0 : len = Top_datalen;
2903 : {
2904 : size_t kvno_datalen;
2905 : Der_type kvno_type;
2906 : size_t kvno_oldlen;
2907 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &kvno_type, 0, &kvno_datalen, &l);
2908 0 : if (e == 0 && kvno_type != CONS) { e = ASN1_BAD_ID; }
2909 0 : if (e) goto fail;
2910 0 : p += l; len -= l; ret += l;
2911 0 : kvno_oldlen = len;
2912 0 : if (kvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2913 0 : len = kvno_datalen;
2914 : {
2915 : size_t kvno_Tag_datalen;
2916 : Der_type kvno_Tag_type;
2917 : size_t kvno_Tag_oldlen;
2918 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &kvno_Tag_type, UT_Integer, &kvno_Tag_datalen, &l);
2919 0 : if (e == 0 && kvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
2920 0 : if (e) goto fail;
2921 0 : p += l; len -= l; ret += l;
2922 0 : kvno_Tag_oldlen = len;
2923 0 : if (kvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2924 0 : len = kvno_Tag_datalen;
2925 0 : e = der_get_unsigned(p, len, &(data)->kvno, &l);
2926 0 : if(e) goto fail;
2927 0 : p += l; len -= l; ret += l;
2928 0 : len = kvno_Tag_oldlen - kvno_Tag_datalen;
2929 : }
2930 0 : len = kvno_oldlen - kvno_datalen;
2931 : }
2932 : {
2933 : size_t keys_datalen;
2934 : Der_type keys_type;
2935 : size_t keys_oldlen;
2936 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &keys_type, 1, &keys_datalen, &l);
2937 0 : if (e == 0 && keys_type != CONS) { e = ASN1_BAD_ID; }
2938 0 : if (e) goto fail;
2939 0 : p += l; len -= l; ret += l;
2940 0 : keys_oldlen = len;
2941 0 : if (keys_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2942 0 : len = keys_datalen;
2943 0 : e = decode_Keys(p, len, &(data)->keys, &l);
2944 0 : if(e) goto fail;
2945 0 : p += l; len -= l; ret += l;
2946 0 : len = keys_oldlen - keys_datalen;
2947 : }
2948 : {
2949 : size_t set_time_datalen;
2950 : Der_type set_time_type;
2951 : size_t set_time_oldlen;
2952 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &set_time_type, 2, &set_time_datalen, &l);
2953 0 : if (e == 0 && set_time_type != CONS) { e = ASN1_BAD_ID; }
2954 0 : if(e) {
2955 0 : (data)->set_time = NULL;
2956 : } else {
2957 0 : (data)->set_time = calloc(1, sizeof(*(data)->set_time));
2958 0 : if ((data)->set_time == NULL) { e = ENOMEM; goto fail; }
2959 0 : p += l; len -= l; ret += l;
2960 0 : set_time_oldlen = len;
2961 0 : if (set_time_datalen > len) { e = ASN1_OVERRUN; goto fail; }
2962 0 : len = set_time_datalen;
2963 0 : e = decode_KerberosTime(p, len, (data)->set_time, &l);
2964 0 : if(e) goto fail;
2965 0 : p += l; len -= l; ret += l;
2966 0 : len = set_time_oldlen - set_time_datalen;
2967 : }
2968 : }
2969 0 : len = Top_oldlen - Top_datalen;
2970 : }
2971 0 : if(size) *size = ret;
2972 0 : return 0;
2973 0 : fail:
2974 0 : free_HDB_keyset(data);
2975 0 : return e;
2976 : }
2977 :
2978 : void ASN1CALL
2979 0 : free_HDB_keyset(HDB_keyset *data)
2980 : {
2981 0 : *&(data)->kvno = 0;
2982 0 : free_Keys(&(data)->keys);
2983 0 : if((data)->set_time) {
2984 0 : free_KerberosTime((data)->set_time);
2985 0 : free((data)->set_time);
2986 0 : (data)->set_time = NULL;
2987 : }
2988 0 : }
2989 :
2990 : size_t ASN1CALL
2991 0 : length_HDB_keyset(const HDB_keyset *data)
2992 : {
2993 0 : size_t ret = 0;
2994 : {
2995 0 : size_t Top_tag_oldret = ret;
2996 0 : ret = 0;
2997 0 : ret += der_length_unsigned(&(data)->kvno);
2998 0 : ret += 1 + der_length_len (ret);
2999 0 : ret += 1 + der_length_len (ret);
3000 0 : ret += Top_tag_oldret;
3001 : }
3002 : {
3003 0 : size_t Top_tag_oldret = ret;
3004 0 : ret = 0;
3005 0 : ret += length_Keys(&(data)->keys);
3006 0 : ret += 1 + der_length_len (ret);
3007 0 : ret += Top_tag_oldret;
3008 : }
3009 0 : if((data)->set_time){
3010 0 : size_t Top_tag_oldret = ret;
3011 0 : ret = 0;
3012 0 : ret += length_KerberosTime((data)->set_time);
3013 0 : ret += 1 + der_length_len (ret);
3014 0 : ret += Top_tag_oldret;
3015 : }
3016 0 : ret += 1 + der_length_len (ret);
3017 0 : return ret;
3018 : }
3019 :
3020 : int ASN1CALL
3021 0 : copy_HDB_keyset(const HDB_keyset *from, HDB_keyset *to)
3022 : {
3023 0 : memset(to, 0, sizeof(*to));
3024 0 : *(&(to)->kvno) = *(&(from)->kvno);
3025 0 : if(copy_Keys(&(from)->keys, &(to)->keys)) goto fail;
3026 0 : if((from)->set_time) {
3027 0 : (to)->set_time = calloc(1, sizeof(*(to)->set_time));
3028 0 : if((to)->set_time == NULL) goto fail;
3029 0 : if(copy_KerberosTime((from)->set_time, (to)->set_time)) goto fail;
3030 : }else
3031 0 : (to)->set_time = NULL;
3032 0 : return 0;
3033 0 : fail:
3034 0 : free_HDB_keyset(to);
3035 0 : return ENOMEM;
3036 : }
3037 :
3038 : char * ASN1CALL
3039 0 : print_HDB_keyset(const HDB_keyset *data, int flags)
3040 0 : { errno = EINVAL; return 0; }
3041 :
3042 : int ASN1CALL
3043 0 : encode_HDB_Ext_KeySet(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_KeySet *data, size_t *size)
3044 : {
3045 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
3046 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3047 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
3048 :
3049 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
3050 0 : size_t Top_tag_for_oldret = ret;
3051 0 : ret = 0;
3052 0 : e = encode_HDB_keyset(p, len, &(data)->val[i], &l);
3053 0 : if (e) return e;
3054 0 : p -= l; len -= l; ret += l;
3055 :
3056 0 : ret += Top_tag_for_oldret;
3057 : }
3058 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
3059 0 : if (e) return e;
3060 0 : p -= l; len -= l; ret += l;
3061 :
3062 0 : *size = ret;
3063 0 : return 0;
3064 : }
3065 :
3066 : int ASN1CALL
3067 0 : decode_HDB_Ext_KeySet(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_KeySet *data, size_t *size)
3068 : {
3069 0 : size_t ret = 0;
3070 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3071 : int e HEIMDAL_UNUSED_ATTRIBUTE;
3072 :
3073 0 : memset(data, 0, sizeof(*data));
3074 : {
3075 : size_t Top_datalen;
3076 : Der_type Top_type;
3077 : size_t Top_oldlen;
3078 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
3079 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
3080 0 : if (e) goto fail;
3081 0 : p += l; len -= l; ret += l;
3082 0 : Top_oldlen = len;
3083 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3084 0 : len = Top_datalen;
3085 : {
3086 0 : size_t Top_Tag_origlen = len;
3087 0 : size_t Top_Tag_oldret = ret;
3088 0 : size_t Top_Tag_olen = 0;
3089 : void *Top_Tag_tmp;
3090 0 : ret = 0;
3091 0 : (data)->len = 0;
3092 0 : (data)->val = NULL;
3093 0 : while(ret < Top_Tag_origlen) {
3094 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
3095 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
3096 0 : Top_Tag_olen = Top_Tag_nlen;
3097 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
3098 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
3099 0 : (data)->val = Top_Tag_tmp;
3100 0 : e = decode_HDB_keyset(p, len, &(data)->val[(data)->len], &l);
3101 0 : if(e) goto fail;
3102 0 : p += l; len -= l; ret += l;
3103 0 : (data)->len++;
3104 0 : len = Top_Tag_origlen - ret;
3105 : }
3106 0 : ret += Top_Tag_oldret;
3107 : }
3108 0 : len = Top_oldlen - Top_datalen;
3109 : }
3110 0 : if(size) *size = ret;
3111 0 : return 0;
3112 0 : fail:
3113 0 : free_HDB_Ext_KeySet(data);
3114 0 : return e;
3115 : }
3116 :
3117 : void ASN1CALL
3118 0 : free_HDB_Ext_KeySet(HDB_Ext_KeySet *data)
3119 : {
3120 0 : if ((data)->val)
3121 0 : while((data)->len){
3122 0 : free_HDB_keyset(&(data)->val[(data)->len-1]);
3123 0 : (data)->len--;
3124 0 : } else (data)->len = 0;
3125 0 : free((data)->val);
3126 0 : (data)->val = NULL;
3127 0 : }
3128 :
3129 : size_t ASN1CALL
3130 0 : length_HDB_Ext_KeySet(const HDB_Ext_KeySet *data)
3131 : {
3132 0 : size_t ret = 0;
3133 : {
3134 0 : size_t Top_tag_oldret = ret;
3135 : unsigned int n_Top_tag;
3136 0 : ret = 0;
3137 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
3138 0 : size_t Top_tag_for_oldret = ret;
3139 0 : ret = 0;
3140 0 : ret += length_HDB_keyset(&(data)->val[n_Top_tag - 1]);
3141 0 : ret += Top_tag_for_oldret;
3142 : }
3143 0 : ret += Top_tag_oldret;
3144 : }
3145 0 : ret += 1 + der_length_len (ret);
3146 0 : return ret;
3147 : }
3148 :
3149 : int ASN1CALL
3150 0 : copy_HDB_Ext_KeySet(const HDB_Ext_KeySet *from, HDB_Ext_KeySet *to)
3151 : {
3152 0 : memset(to, 0, sizeof(*to));
3153 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
3154 0 : goto fail;
3155 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
3156 0 : if(copy_HDB_keyset(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
3157 : }
3158 0 : return 0;
3159 0 : fail:
3160 0 : free_HDB_Ext_KeySet(to);
3161 0 : return ENOMEM;
3162 : }
3163 :
3164 : char * ASN1CALL
3165 0 : print_HDB_Ext_KeySet(const HDB_Ext_KeySet *data, int flags)
3166 0 : { errno = EINVAL; return 0; }
3167 :
3168 : int ASN1CALL
3169 0 : add_HDB_Ext_KeySet(HDB_Ext_KeySet *data, const HDB_keyset *element)
3170 : {
3171 : int ret;
3172 : void *ptr;
3173 :
3174 0 : ptr = realloc(data->val,
3175 0 : (data->len + 1) * sizeof(data->val[0]));
3176 0 : if (ptr == NULL) return ENOMEM;
3177 0 : data->val = ptr;
3178 :
3179 0 : ret = copy_HDB_keyset(element, &data->val[data->len]);
3180 0 : if (ret) return ret;
3181 0 : data->len++;
3182 0 : return 0;
3183 : }
3184 :
3185 : int ASN1CALL
3186 0 : remove_HDB_Ext_KeySet(HDB_Ext_KeySet *data, unsigned int element)
3187 : {
3188 : void *ptr;
3189 :
3190 0 : if (data->len == 0 || element >= data->len)
3191 0 : return ASN1_OVERRUN;
3192 0 : free_HDB_keyset(&data->val[element]);
3193 0 : data->len--;
3194 0 : if (element < data->len)
3195 0 : memmove(&data->val[element], &data->val[element + 1],
3196 0 : sizeof(data->val[0]) * (data->len - element));
3197 0 : ptr = realloc(data->val, data->len * sizeof(data->val[0]));
3198 0 : if (ptr != NULL || data->len == 0) data->val = ptr;
3199 0 : return 0;
3200 : }
3201 :
3202 : int ASN1CALL
3203 0 : encode_KeyRotationFlags(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const KeyRotationFlags *data, size_t *size)
3204 : {
3205 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
3206 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3207 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
3208 :
3209 : {
3210 0 : unsigned char c = 0;
3211 0 : int rest = 0;
3212 0 : int bit_set = 0;
3213 0 : if((data)->parent) {
3214 0 : c |= 1<<6;
3215 : }
3216 0 : if((data)->deleted) {
3217 0 : c |= 1<<7;
3218 : }
3219 0 : if (c != 0 || bit_set) {
3220 0 : if (len < 1) return ASN1_OVERFLOW;
3221 0 : *p-- = c; len--; ret++;
3222 0 : if (!bit_set) {
3223 0 : rest = 0;
3224 0 : if(c) {
3225 0 : while(c) {
3226 0 : if (c & 1) break;
3227 0 : c = c >> 1;
3228 0 : rest++;
3229 : }
3230 : }
3231 : }
3232 : }
3233 0 : if (len < 1) return ASN1_OVERFLOW;
3234 0 : *p-- = rest;
3235 0 : len -= 1;
3236 0 : ret += 1;
3237 : }
3238 :
3239 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
3240 0 : if (e) return e;
3241 0 : p -= l; len -= l; ret += l;
3242 :
3243 0 : *size = ret;
3244 0 : return 0;
3245 : }
3246 :
3247 : int ASN1CALL
3248 0 : decode_KeyRotationFlags(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, KeyRotationFlags *data, size_t *size)
3249 : {
3250 0 : size_t ret = 0;
3251 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3252 : int e HEIMDAL_UNUSED_ATTRIBUTE;
3253 :
3254 0 : memset(data, 0, sizeof(*data));
3255 : {
3256 : size_t Top_datalen;
3257 : Der_type Top_type;
3258 : size_t Top_oldlen;
3259 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_BitString, &Top_datalen, &l);
3260 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
3261 0 : if (e) goto fail;
3262 0 : p += l; len -= l; ret += l;
3263 0 : Top_oldlen = len;
3264 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3265 0 : len = Top_datalen;
3266 0 : if (len < 1) return ASN1_OVERRUN;
3267 0 : p++; len--; ret++;
3268 : do {
3269 0 : if (len < 1) break;
3270 0 : (data)->deleted = (*p >> 7) & 1;
3271 0 : (data)->parent = (*p >> 6) & 1;
3272 : } while(0);
3273 0 : p += len; ret += len;
3274 0 : len = Top_oldlen - Top_datalen;
3275 : }
3276 0 : if(size) *size = ret;
3277 0 : return 0;
3278 0 : fail:
3279 0 : free_KeyRotationFlags(data);
3280 0 : return e;
3281 : }
3282 :
3283 : void ASN1CALL
3284 0 : free_KeyRotationFlags(KeyRotationFlags *data)
3285 : {
3286 0 : }
3287 :
3288 : size_t ASN1CALL
3289 0 : length_KeyRotationFlags(const KeyRotationFlags *data)
3290 : {
3291 0 : size_t ret = 0;
3292 : do {
3293 0 : if((data)->parent) { ret += 1; break; }
3294 0 : if((data)->deleted) { ret += 1; break; }
3295 : } while(0);
3296 0 : ret += 1;
3297 0 : ret += 1 + der_length_len (ret);
3298 0 : return ret;
3299 : }
3300 :
3301 : int ASN1CALL
3302 0 : copy_KeyRotationFlags(const KeyRotationFlags *from, KeyRotationFlags *to)
3303 : {
3304 0 : memset(to, 0, sizeof(*to));
3305 0 : *(to) = *(from);
3306 0 : return 0;
3307 : }
3308 :
3309 : char * ASN1CALL
3310 0 : print_KeyRotationFlags(const KeyRotationFlags *data, int flags)
3311 0 : { errno = EINVAL; return 0; }
3312 :
3313 0 : uint64_t KeyRotationFlags2int(KeyRotationFlags f)
3314 : {
3315 0 : uint64_t r = 0;
3316 0 : if(f.deleted) r |= (1ULL << 0);
3317 0 : if(f.parent) r |= (1ULL << 1);
3318 0 : return r;
3319 : }
3320 :
3321 0 : KeyRotationFlags int2KeyRotationFlags(uint64_t n)
3322 : {
3323 : KeyRotationFlags flags;
3324 :
3325 0 : memset(&flags, 0, sizeof(flags));
3326 :
3327 0 : flags.deleted = (n >> 0) & 1;
3328 0 : flags.parent = (n >> 1) & 1;
3329 0 : return flags;
3330 : }
3331 :
3332 : static struct units KeyRotationFlags_units[] = {
3333 : {"parent", 1ULL << 1},
3334 : {"deleted", 1ULL << 0},
3335 : {NULL, 0}
3336 : };
3337 :
3338 0 : const struct units * asn1_KeyRotationFlags_units(void){
3339 0 : return KeyRotationFlags_units;
3340 : }
3341 :
3342 : int ASN1CALL
3343 0 : encode_KeyRotation(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const KeyRotation *data, size_t *size)
3344 : {
3345 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
3346 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3347 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
3348 :
3349 : /* base-key-kvno */
3350 : {
3351 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3352 0 : ret = 0;
3353 0 : e = der_put_unsigned(p, len, &(data)->base_key_kvno, &l);
3354 0 : if (e) return e;
3355 0 : p -= l; len -= l; ret += l;
3356 :
3357 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3358 0 : if (e) return e;
3359 0 : p -= l; len -= l; ret += l;
3360 :
3361 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 4, &l);
3362 0 : if (e) return e;
3363 0 : p -= l; len -= l; ret += l;
3364 :
3365 0 : ret += Top_tag_oldret;
3366 : }
3367 : /* base-kvno */
3368 : {
3369 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3370 0 : ret = 0;
3371 0 : e = der_put_unsigned(p, len, &(data)->base_kvno, &l);
3372 0 : if (e) return e;
3373 0 : p -= l; len -= l; ret += l;
3374 :
3375 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3376 0 : if (e) return e;
3377 0 : p -= l; len -= l; ret += l;
3378 :
3379 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
3380 0 : if (e) return e;
3381 0 : p -= l; len -= l; ret += l;
3382 :
3383 0 : ret += Top_tag_oldret;
3384 : }
3385 : /* period */
3386 : {
3387 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3388 0 : ret = 0;
3389 0 : e = der_put_unsigned(p, len, &(data)->period, &l);
3390 0 : if (e) return e;
3391 0 : p -= l; len -= l; ret += l;
3392 :
3393 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3394 0 : if (e) return e;
3395 0 : p -= l; len -= l; ret += l;
3396 :
3397 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
3398 0 : if (e) return e;
3399 0 : p -= l; len -= l; ret += l;
3400 :
3401 0 : ret += Top_tag_oldret;
3402 : }
3403 : /* epoch */
3404 : {
3405 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3406 0 : ret = 0;
3407 0 : e = encode_KerberosTime(p, len, &(data)->epoch, &l);
3408 0 : if (e) return e;
3409 0 : p -= l; len -= l; ret += l;
3410 :
3411 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
3412 0 : if (e) return e;
3413 0 : p -= l; len -= l; ret += l;
3414 :
3415 0 : ret += Top_tag_oldret;
3416 : }
3417 : /* flags */
3418 : {
3419 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3420 0 : ret = 0;
3421 0 : e = encode_KeyRotationFlags(p, len, &(data)->flags, &l);
3422 0 : if (e) return e;
3423 0 : p -= l; len -= l; ret += l;
3424 :
3425 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
3426 0 : if (e) return e;
3427 0 : p -= l; len -= l; ret += l;
3428 :
3429 0 : ret += Top_tag_oldret;
3430 : }
3431 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
3432 0 : if (e) return e;
3433 0 : p -= l; len -= l; ret += l;
3434 :
3435 0 : *size = ret;
3436 0 : return 0;
3437 : }
3438 :
3439 : int ASN1CALL
3440 0 : decode_KeyRotation(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, KeyRotation *data, size_t *size)
3441 : {
3442 0 : size_t ret = 0;
3443 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3444 : int e HEIMDAL_UNUSED_ATTRIBUTE;
3445 :
3446 0 : memset(data, 0, sizeof(*data));
3447 : {
3448 : size_t Top_datalen;
3449 : Der_type Top_type;
3450 : size_t Top_oldlen;
3451 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
3452 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
3453 0 : if (e) goto fail;
3454 0 : p += l; len -= l; ret += l;
3455 0 : Top_oldlen = len;
3456 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3457 0 : len = Top_datalen;
3458 : {
3459 : size_t flags_datalen;
3460 : Der_type flags_type;
3461 : size_t flags_oldlen;
3462 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &flags_type, 0, &flags_datalen, &l);
3463 0 : if (e == 0 && flags_type != CONS) { e = ASN1_BAD_ID; }
3464 0 : if (e) goto fail;
3465 0 : p += l; len -= l; ret += l;
3466 0 : flags_oldlen = len;
3467 0 : if (flags_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3468 0 : len = flags_datalen;
3469 0 : e = decode_KeyRotationFlags(p, len, &(data)->flags, &l);
3470 0 : if(e) goto fail;
3471 0 : p += l; len -= l; ret += l;
3472 0 : len = flags_oldlen - flags_datalen;
3473 : }
3474 : {
3475 : size_t epoch_datalen;
3476 : Der_type epoch_type;
3477 : size_t epoch_oldlen;
3478 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &epoch_type, 1, &epoch_datalen, &l);
3479 0 : if (e == 0 && epoch_type != CONS) { e = ASN1_BAD_ID; }
3480 0 : if (e) goto fail;
3481 0 : p += l; len -= l; ret += l;
3482 0 : epoch_oldlen = len;
3483 0 : if (epoch_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3484 0 : len = epoch_datalen;
3485 0 : e = decode_KerberosTime(p, len, &(data)->epoch, &l);
3486 0 : if(e) goto fail;
3487 0 : p += l; len -= l; ret += l;
3488 0 : len = epoch_oldlen - epoch_datalen;
3489 : }
3490 : {
3491 : size_t period_datalen;
3492 : Der_type period_type;
3493 : size_t period_oldlen;
3494 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &period_type, 2, &period_datalen, &l);
3495 0 : if (e == 0 && period_type != CONS) { e = ASN1_BAD_ID; }
3496 0 : if (e) goto fail;
3497 0 : p += l; len -= l; ret += l;
3498 0 : period_oldlen = len;
3499 0 : if (period_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3500 0 : len = period_datalen;
3501 : {
3502 : size_t period_Tag_datalen;
3503 : Der_type period_Tag_type;
3504 : size_t period_Tag_oldlen;
3505 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &period_Tag_type, UT_Integer, &period_Tag_datalen, &l);
3506 0 : if (e == 0 && period_Tag_type != PRIM) { e = ASN1_BAD_ID; }
3507 0 : if (e) goto fail;
3508 0 : p += l; len -= l; ret += l;
3509 0 : period_Tag_oldlen = len;
3510 0 : if (period_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3511 0 : len = period_Tag_datalen;
3512 0 : e = der_get_unsigned(p, len, &(data)->period, &l);
3513 0 : if(e) goto fail;
3514 0 : p += l; len -= l; ret += l;
3515 0 : len = period_Tag_oldlen - period_Tag_datalen;
3516 : }
3517 0 : len = period_oldlen - period_datalen;
3518 : }
3519 : {
3520 : size_t base_kvno_datalen;
3521 : Der_type base_kvno_type;
3522 : size_t base_kvno_oldlen;
3523 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &base_kvno_type, 3, &base_kvno_datalen, &l);
3524 0 : if (e == 0 && base_kvno_type != CONS) { e = ASN1_BAD_ID; }
3525 0 : if (e) goto fail;
3526 0 : p += l; len -= l; ret += l;
3527 0 : base_kvno_oldlen = len;
3528 0 : if (base_kvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3529 0 : len = base_kvno_datalen;
3530 : {
3531 : size_t base_kvno_Tag_datalen;
3532 : Der_type base_kvno_Tag_type;
3533 : size_t base_kvno_Tag_oldlen;
3534 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &base_kvno_Tag_type, UT_Integer, &base_kvno_Tag_datalen, &l);
3535 0 : if (e == 0 && base_kvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
3536 0 : if (e) goto fail;
3537 0 : p += l; len -= l; ret += l;
3538 0 : base_kvno_Tag_oldlen = len;
3539 0 : if (base_kvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3540 0 : len = base_kvno_Tag_datalen;
3541 0 : e = der_get_unsigned(p, len, &(data)->base_kvno, &l);
3542 0 : if(e) goto fail;
3543 0 : p += l; len -= l; ret += l;
3544 0 : len = base_kvno_Tag_oldlen - base_kvno_Tag_datalen;
3545 : }
3546 0 : len = base_kvno_oldlen - base_kvno_datalen;
3547 : }
3548 : {
3549 : size_t base_key_kvno_datalen;
3550 : Der_type base_key_kvno_type;
3551 : size_t base_key_kvno_oldlen;
3552 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &base_key_kvno_type, 4, &base_key_kvno_datalen, &l);
3553 0 : if (e == 0 && base_key_kvno_type != CONS) { e = ASN1_BAD_ID; }
3554 0 : if (e) goto fail;
3555 0 : p += l; len -= l; ret += l;
3556 0 : base_key_kvno_oldlen = len;
3557 0 : if (base_key_kvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3558 0 : len = base_key_kvno_datalen;
3559 : {
3560 : size_t base_key_kvno_Tag_datalen;
3561 : Der_type base_key_kvno_Tag_type;
3562 : size_t base_key_kvno_Tag_oldlen;
3563 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &base_key_kvno_Tag_type, UT_Integer, &base_key_kvno_Tag_datalen, &l);
3564 0 : if (e == 0 && base_key_kvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
3565 0 : if (e) goto fail;
3566 0 : p += l; len -= l; ret += l;
3567 0 : base_key_kvno_Tag_oldlen = len;
3568 0 : if (base_key_kvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3569 0 : len = base_key_kvno_Tag_datalen;
3570 0 : e = der_get_unsigned(p, len, &(data)->base_key_kvno, &l);
3571 0 : if(e) goto fail;
3572 0 : p += l; len -= l; ret += l;
3573 0 : len = base_key_kvno_Tag_oldlen - base_key_kvno_Tag_datalen;
3574 : }
3575 0 : len = base_key_kvno_oldlen - base_key_kvno_datalen;
3576 : }
3577 0 : len = Top_oldlen - Top_datalen;
3578 : }
3579 0 : if(size) *size = ret;
3580 0 : return 0;
3581 0 : fail:
3582 0 : free_KeyRotation(data);
3583 0 : return e;
3584 : }
3585 :
3586 : void ASN1CALL
3587 0 : free_KeyRotation(KeyRotation *data)
3588 : {
3589 0 : free_KeyRotationFlags(&(data)->flags);
3590 0 : free_KerberosTime(&(data)->epoch);
3591 0 : *&(data)->period = 0;
3592 0 : *&(data)->base_kvno = 0;
3593 0 : *&(data)->base_key_kvno = 0;
3594 0 : }
3595 :
3596 : size_t ASN1CALL
3597 0 : length_KeyRotation(const KeyRotation *data)
3598 : {
3599 0 : size_t ret = 0;
3600 : {
3601 0 : size_t Top_tag_oldret = ret;
3602 0 : ret = 0;
3603 0 : ret += length_KeyRotationFlags(&(data)->flags);
3604 0 : ret += 1 + der_length_len (ret);
3605 0 : ret += Top_tag_oldret;
3606 : }
3607 : {
3608 0 : size_t Top_tag_oldret = ret;
3609 0 : ret = 0;
3610 0 : ret += length_KerberosTime(&(data)->epoch);
3611 0 : ret += 1 + der_length_len (ret);
3612 0 : ret += Top_tag_oldret;
3613 : }
3614 : {
3615 0 : size_t Top_tag_oldret = ret;
3616 0 : ret = 0;
3617 0 : ret += der_length_unsigned(&(data)->period);
3618 0 : ret += 1 + der_length_len (ret);
3619 0 : ret += 1 + der_length_len (ret);
3620 0 : ret += Top_tag_oldret;
3621 : }
3622 : {
3623 0 : size_t Top_tag_oldret = ret;
3624 0 : ret = 0;
3625 0 : ret += der_length_unsigned(&(data)->base_kvno);
3626 0 : ret += 1 + der_length_len (ret);
3627 0 : ret += 1 + der_length_len (ret);
3628 0 : ret += Top_tag_oldret;
3629 : }
3630 : {
3631 0 : size_t Top_tag_oldret = ret;
3632 0 : ret = 0;
3633 0 : ret += der_length_unsigned(&(data)->base_key_kvno);
3634 0 : ret += 1 + der_length_len (ret);
3635 0 : ret += 1 + der_length_len (ret);
3636 0 : ret += Top_tag_oldret;
3637 : }
3638 0 : ret += 1 + der_length_len (ret);
3639 0 : return ret;
3640 : }
3641 :
3642 : int ASN1CALL
3643 0 : copy_KeyRotation(const KeyRotation *from, KeyRotation *to)
3644 : {
3645 0 : memset(to, 0, sizeof(*to));
3646 0 : if(copy_KeyRotationFlags(&(from)->flags, &(to)->flags)) goto fail;
3647 0 : if(copy_KerberosTime(&(from)->epoch, &(to)->epoch)) goto fail;
3648 0 : *(&(to)->period) = *(&(from)->period);
3649 0 : *(&(to)->base_kvno) = *(&(from)->base_kvno);
3650 0 : *(&(to)->base_key_kvno) = *(&(from)->base_key_kvno);
3651 0 : return 0;
3652 0 : fail:
3653 0 : free_KeyRotation(to);
3654 0 : return ENOMEM;
3655 : }
3656 :
3657 : char * ASN1CALL
3658 0 : print_KeyRotation(const KeyRotation *data, int flags)
3659 0 : { errno = EINVAL; return 0; }
3660 :
3661 : int ASN1CALL
3662 0 : encode_HDB_Ext_KeyRotation(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_Ext_KeyRotation *data, size_t *size)
3663 : {
3664 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
3665 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3666 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
3667 :
3668 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
3669 0 : size_t Top_tag_for_oldret = ret;
3670 0 : ret = 0;
3671 0 : e = encode_KeyRotation(p, len, &(data)->val[i], &l);
3672 0 : if (e) return e;
3673 0 : p -= l; len -= l; ret += l;
3674 :
3675 0 : ret += Top_tag_for_oldret;
3676 : }
3677 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
3678 0 : if (e) return e;
3679 0 : p -= l; len -= l; ret += l;
3680 :
3681 0 : *size = ret;
3682 0 : return 0;
3683 : }
3684 :
3685 : int ASN1CALL
3686 0 : decode_HDB_Ext_KeyRotation(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_Ext_KeyRotation *data, size_t *size)
3687 : {
3688 0 : size_t ret = 0;
3689 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3690 : int e HEIMDAL_UNUSED_ATTRIBUTE;
3691 :
3692 0 : memset(data, 0, sizeof(*data));
3693 : {
3694 : size_t Top_datalen;
3695 : Der_type Top_type;
3696 : size_t Top_oldlen;
3697 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
3698 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
3699 0 : if (e) goto fail;
3700 0 : p += l; len -= l; ret += l;
3701 0 : Top_oldlen = len;
3702 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
3703 0 : len = Top_datalen;
3704 : {
3705 0 : size_t Top_Tag_origlen = len;
3706 0 : size_t Top_Tag_oldret = ret;
3707 0 : size_t Top_Tag_olen = 0;
3708 : void *Top_Tag_tmp;
3709 0 : ret = 0;
3710 0 : (data)->len = 0;
3711 0 : (data)->val = NULL;
3712 0 : while(ret < Top_Tag_origlen) {
3713 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
3714 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
3715 0 : Top_Tag_olen = Top_Tag_nlen;
3716 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
3717 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
3718 0 : (data)->val = Top_Tag_tmp;
3719 0 : e = decode_KeyRotation(p, len, &(data)->val[(data)->len], &l);
3720 0 : if(e) goto fail;
3721 0 : p += l; len -= l; ret += l;
3722 0 : (data)->len++;
3723 0 : len = Top_Tag_origlen - ret;
3724 : }
3725 0 : ret += Top_Tag_oldret;
3726 : }
3727 0 : if ((data)->len > 3) {
3728 0 : e = ASN1_MAX_CONSTRAINT; goto fail;
3729 : }
3730 0 : if ((data)->len < 1) {
3731 0 : e = ASN1_MIN_CONSTRAINT; goto fail;
3732 : }
3733 0 : len = Top_oldlen - Top_datalen;
3734 : }
3735 0 : if(size) *size = ret;
3736 0 : return 0;
3737 0 : fail:
3738 0 : free_HDB_Ext_KeyRotation(data);
3739 0 : return e;
3740 : }
3741 :
3742 : void ASN1CALL
3743 0 : free_HDB_Ext_KeyRotation(HDB_Ext_KeyRotation *data)
3744 : {
3745 0 : if ((data)->val)
3746 0 : while((data)->len){
3747 0 : free_KeyRotation(&(data)->val[(data)->len-1]);
3748 0 : (data)->len--;
3749 0 : } else (data)->len = 0;
3750 0 : free((data)->val);
3751 0 : (data)->val = NULL;
3752 0 : }
3753 :
3754 : size_t ASN1CALL
3755 0 : length_HDB_Ext_KeyRotation(const HDB_Ext_KeyRotation *data)
3756 : {
3757 0 : size_t ret = 0;
3758 : {
3759 0 : size_t Top_tag_oldret = ret;
3760 : unsigned int n_Top_tag;
3761 0 : ret = 0;
3762 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
3763 0 : size_t Top_tag_for_oldret = ret;
3764 0 : ret = 0;
3765 0 : ret += length_KeyRotation(&(data)->val[n_Top_tag - 1]);
3766 0 : ret += Top_tag_for_oldret;
3767 : }
3768 0 : ret += Top_tag_oldret;
3769 : }
3770 0 : ret += 1 + der_length_len (ret);
3771 0 : return ret;
3772 : }
3773 :
3774 : int ASN1CALL
3775 0 : copy_HDB_Ext_KeyRotation(const HDB_Ext_KeyRotation *from, HDB_Ext_KeyRotation *to)
3776 : {
3777 0 : memset(to, 0, sizeof(*to));
3778 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
3779 0 : goto fail;
3780 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
3781 0 : if(copy_KeyRotation(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
3782 : }
3783 0 : return 0;
3784 0 : fail:
3785 0 : free_HDB_Ext_KeyRotation(to);
3786 0 : return ENOMEM;
3787 : }
3788 :
3789 : char * ASN1CALL
3790 0 : print_HDB_Ext_KeyRotation(const HDB_Ext_KeyRotation *data, int flags)
3791 0 : { errno = EINVAL; return 0; }
3792 :
3793 : int ASN1CALL
3794 0 : add_HDB_Ext_KeyRotation(HDB_Ext_KeyRotation *data, const KeyRotation *element)
3795 : {
3796 : int ret;
3797 : void *ptr;
3798 :
3799 0 : ptr = realloc(data->val,
3800 0 : (data->len + 1) * sizeof(data->val[0]));
3801 0 : if (ptr == NULL) return ENOMEM;
3802 0 : data->val = ptr;
3803 :
3804 0 : ret = copy_KeyRotation(element, &data->val[data->len]);
3805 0 : if (ret) return ret;
3806 0 : data->len++;
3807 0 : return 0;
3808 : }
3809 :
3810 : int ASN1CALL
3811 0 : remove_HDB_Ext_KeyRotation(HDB_Ext_KeyRotation *data, unsigned int element)
3812 : {
3813 : void *ptr;
3814 :
3815 0 : if (data->len == 0 || element >= data->len)
3816 0 : return ASN1_OVERRUN;
3817 0 : free_KeyRotation(&data->val[element]);
3818 0 : data->len--;
3819 0 : if (element < data->len)
3820 0 : memmove(&data->val[element], &data->val[element + 1],
3821 0 : sizeof(data->val[0]) * (data->len - element));
3822 0 : ptr = realloc(data->val, data->len * sizeof(data->val[0]));
3823 0 : if (ptr != NULL || data->len == 0) data->val = ptr;
3824 0 : return 0;
3825 : }
3826 :
3827 : int ASN1CALL
3828 0 : encode_HDB_extension(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_extension *data, size_t *size)
3829 : {
3830 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
3831 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
3832 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
3833 :
3834 : /* data */
3835 : {
3836 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
3837 0 : ret = 0;
3838 :
3839 0 : switch((&(data)->data)->element) {
3840 0 : case choice_HDB_extension_data_krb5_config: {size_t data_tag_oldret = ret;
3841 0 : ret = 0;
3842 0 : e = der_put_octet_string(p, len, &((&(data)->data))->u.krb5_config, &l);
3843 0 : if (e) return e;
3844 0 : p -= l; len -= l; ret += l;
3845 :
3846 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
3847 0 : if (e) return e;
3848 0 : p -= l; len -= l; ret += l;
3849 :
3850 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 15, &l);
3851 0 : if (e) return e;
3852 0 : p -= l; len -= l; ret += l;
3853 :
3854 0 : ret += data_tag_oldret;
3855 0 : break;
3856 : }
3857 0 : case choice_HDB_extension_data_key_rotation: {size_t data_tag_oldret = ret;
3858 0 : ret = 0;
3859 0 : e = encode_HDB_Ext_KeyRotation(p, len, &((&(data)->data))->u.key_rotation, &l);
3860 0 : if (e) return e;
3861 0 : p -= l; len -= l; ret += l;
3862 :
3863 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 14, &l);
3864 0 : if (e) return e;
3865 0 : p -= l; len -= l; ret += l;
3866 :
3867 0 : ret += data_tag_oldret;
3868 0 : break;
3869 : }
3870 0 : case choice_HDB_extension_data_principal_id: {size_t data_tag_oldret = ret;
3871 0 : ret = 0;
3872 0 : e = der_put_integer64(p, len, &((&(data)->data))->u.principal_id, &l);
3873 0 : if (e) return e;
3874 0 : p -= l; len -= l; ret += l;
3875 :
3876 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3877 0 : if (e) return e;
3878 0 : p -= l; len -= l; ret += l;
3879 :
3880 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 13, &l);
3881 0 : if (e) return e;
3882 0 : p -= l; len -= l; ret += l;
3883 :
3884 0 : ret += data_tag_oldret;
3885 0 : break;
3886 : }
3887 0 : case choice_HDB_extension_data_policy: {size_t data_tag_oldret = ret;
3888 0 : ret = 0;
3889 0 : e = der_put_utf8string(p, len, &((&(data)->data))->u.policy, &l);
3890 0 : if (e) return e;
3891 0 : p -= l; len -= l; ret += l;
3892 :
3893 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_UTF8String, &l);
3894 0 : if (e) return e;
3895 0 : p -= l; len -= l; ret += l;
3896 :
3897 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 12, &l);
3898 0 : if (e) return e;
3899 0 : p -= l; len -= l; ret += l;
3900 :
3901 0 : ret += data_tag_oldret;
3902 0 : break;
3903 : }
3904 0 : case choice_HDB_extension_data_hist_kvno_diff_svc: {size_t data_tag_oldret = ret;
3905 0 : ret = 0;
3906 0 : e = der_put_unsigned(p, len, &((&(data)->data))->u.hist_kvno_diff_svc, &l);
3907 0 : if (e) return e;
3908 0 : p -= l; len -= l; ret += l;
3909 :
3910 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3911 0 : if (e) return e;
3912 0 : p -= l; len -= l; ret += l;
3913 :
3914 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 11, &l);
3915 0 : if (e) return e;
3916 0 : p -= l; len -= l; ret += l;
3917 :
3918 0 : ret += data_tag_oldret;
3919 0 : break;
3920 : }
3921 0 : case choice_HDB_extension_data_hist_kvno_diff_clnt: {size_t data_tag_oldret = ret;
3922 0 : ret = 0;
3923 0 : e = der_put_unsigned(p, len, &((&(data)->data))->u.hist_kvno_diff_clnt, &l);
3924 0 : if (e) return e;
3925 0 : p -= l; len -= l; ret += l;
3926 :
3927 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
3928 0 : if (e) return e;
3929 0 : p -= l; len -= l; ret += l;
3930 :
3931 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 10, &l);
3932 0 : if (e) return e;
3933 0 : p -= l; len -= l; ret += l;
3934 :
3935 0 : ret += data_tag_oldret;
3936 0 : break;
3937 : }
3938 0 : case choice_HDB_extension_data_hist_keys: {size_t data_tag_oldret = ret;
3939 0 : ret = 0;
3940 0 : e = encode_HDB_Ext_KeySet(p, len, &((&(data)->data))->u.hist_keys, &l);
3941 0 : if (e) return e;
3942 0 : p -= l; len -= l; ret += l;
3943 :
3944 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 9, &l);
3945 0 : if (e) return e;
3946 0 : p -= l; len -= l; ret += l;
3947 :
3948 0 : ret += data_tag_oldret;
3949 0 : break;
3950 : }
3951 0 : case choice_HDB_extension_data_pkinit_cert: {size_t data_tag_oldret = ret;
3952 0 : ret = 0;
3953 0 : e = encode_HDB_Ext_PKINIT_cert(p, len, &((&(data)->data))->u.pkinit_cert, &l);
3954 0 : if (e) return e;
3955 0 : p -= l; len -= l; ret += l;
3956 :
3957 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 8, &l);
3958 0 : if (e) return e;
3959 0 : p -= l; len -= l; ret += l;
3960 :
3961 0 : ret += data_tag_oldret;
3962 0 : break;
3963 : }
3964 0 : case choice_HDB_extension_data_last_pw_change: {size_t data_tag_oldret = ret;
3965 0 : ret = 0;
3966 0 : e = encode_KerberosTime(p, len, &((&(data)->data))->u.last_pw_change, &l);
3967 0 : if (e) return e;
3968 0 : p -= l; len -= l; ret += l;
3969 :
3970 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 7, &l);
3971 0 : if (e) return e;
3972 0 : p -= l; len -= l; ret += l;
3973 :
3974 0 : ret += data_tag_oldret;
3975 0 : break;
3976 : }
3977 0 : case choice_HDB_extension_data_aliases: {size_t data_tag_oldret = ret;
3978 0 : ret = 0;
3979 0 : e = encode_HDB_Ext_Aliases(p, len, &((&(data)->data))->u.aliases, &l);
3980 0 : if (e) return e;
3981 0 : p -= l; len -= l; ret += l;
3982 :
3983 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 6, &l);
3984 0 : if (e) return e;
3985 0 : p -= l; len -= l; ret += l;
3986 :
3987 0 : ret += data_tag_oldret;
3988 0 : break;
3989 : }
3990 0 : case choice_HDB_extension_data_password: {size_t data_tag_oldret = ret;
3991 0 : ret = 0;
3992 0 : e = encode_HDB_Ext_Password(p, len, &((&(data)->data))->u.password, &l);
3993 0 : if (e) return e;
3994 0 : p -= l; len -= l; ret += l;
3995 :
3996 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 5, &l);
3997 0 : if (e) return e;
3998 0 : p -= l; len -= l; ret += l;
3999 :
4000 0 : ret += data_tag_oldret;
4001 0 : break;
4002 : }
4003 0 : case choice_HDB_extension_data_lm_owf: {size_t data_tag_oldret = ret;
4004 0 : ret = 0;
4005 0 : e = encode_HDB_Ext_Lan_Manager_OWF(p, len, &((&(data)->data))->u.lm_owf, &l);
4006 0 : if (e) return e;
4007 0 : p -= l; len -= l; ret += l;
4008 :
4009 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 4, &l);
4010 0 : if (e) return e;
4011 0 : p -= l; len -= l; ret += l;
4012 :
4013 0 : ret += data_tag_oldret;
4014 0 : break;
4015 : }
4016 0 : case choice_HDB_extension_data_allowed_to_delegate_to: {size_t data_tag_oldret = ret;
4017 0 : ret = 0;
4018 0 : e = encode_HDB_Ext_Constrained_delegation_acl(p, len, &((&(data)->data))->u.allowed_to_delegate_to, &l);
4019 0 : if (e) return e;
4020 0 : p -= l; len -= l; ret += l;
4021 :
4022 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
4023 0 : if (e) return e;
4024 0 : p -= l; len -= l; ret += l;
4025 :
4026 0 : ret += data_tag_oldret;
4027 0 : break;
4028 : }
4029 0 : case choice_HDB_extension_data_pkinit_cert_hash: {size_t data_tag_oldret = ret;
4030 0 : ret = 0;
4031 0 : e = encode_HDB_Ext_PKINIT_hash(p, len, &((&(data)->data))->u.pkinit_cert_hash, &l);
4032 0 : if (e) return e;
4033 0 : p -= l; len -= l; ret += l;
4034 :
4035 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
4036 0 : if (e) return e;
4037 0 : p -= l; len -= l; ret += l;
4038 :
4039 0 : ret += data_tag_oldret;
4040 0 : break;
4041 : }
4042 0 : case choice_HDB_extension_data_pkinit_acl: {size_t data_tag_oldret = ret;
4043 0 : ret = 0;
4044 0 : e = encode_HDB_Ext_PKINIT_acl(p, len, &((&(data)->data))->u.pkinit_acl, &l);
4045 0 : if (e) return e;
4046 0 : p -= l; len -= l; ret += l;
4047 :
4048 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
4049 0 : if (e) return e;
4050 0 : p -= l; len -= l; ret += l;
4051 :
4052 0 : ret += data_tag_oldret;
4053 0 : break;
4054 : }
4055 0 : case choice_HDB_extension_data_asn1_ellipsis: {
4056 0 : if (len < (&(data)->data)->u.asn1_ellipsis.length)
4057 0 : return ASN1_OVERFLOW;
4058 0 : p -= (&(data)->data)->u.asn1_ellipsis.length;
4059 0 : ret += (&(data)->data)->u.asn1_ellipsis.length;
4060 0 : memcpy(p + 1, (&(data)->data)->u.asn1_ellipsis.data, (&(data)->data)->u.asn1_ellipsis.length);
4061 0 : break;
4062 : }
4063 : };
4064 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
4065 0 : if (e) return e;
4066 0 : p -= l; len -= l; ret += l;
4067 :
4068 0 : ret += Top_tag_oldret;
4069 : }
4070 : /* mandatory */
4071 : {
4072 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
4073 0 : ret = 0;
4074 0 : e = der_put_boolean(p, len, &(data)->mandatory, &l);
4075 0 : if (e) return e;
4076 0 : p -= l; len -= l; ret += l;
4077 :
4078 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Boolean, &l);
4079 0 : if (e) return e;
4080 0 : p -= l; len -= l; ret += l;
4081 :
4082 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
4083 0 : if (e) return e;
4084 0 : p -= l; len -= l; ret += l;
4085 :
4086 0 : ret += Top_tag_oldret;
4087 : }
4088 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
4089 0 : if (e) return e;
4090 0 : p -= l; len -= l; ret += l;
4091 :
4092 0 : *size = ret;
4093 0 : return 0;
4094 : }
4095 :
4096 : int ASN1CALL
4097 0 : decode_HDB_extension(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_extension *data, size_t *size)
4098 : {
4099 0 : size_t ret = 0;
4100 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
4101 : int e HEIMDAL_UNUSED_ATTRIBUTE;
4102 :
4103 0 : memset(data, 0, sizeof(*data));
4104 : {
4105 : size_t Top_datalen;
4106 : Der_type Top_type;
4107 : size_t Top_oldlen;
4108 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
4109 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
4110 0 : if (e) goto fail;
4111 0 : p += l; len -= l; ret += l;
4112 0 : Top_oldlen = len;
4113 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4114 0 : len = Top_datalen;
4115 : {
4116 : size_t mandatory_datalen;
4117 : Der_type mandatory_type;
4118 : size_t mandatory_oldlen;
4119 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mandatory_type, 0, &mandatory_datalen, &l);
4120 0 : if (e == 0 && mandatory_type != CONS) { e = ASN1_BAD_ID; }
4121 0 : if (e) goto fail;
4122 0 : p += l; len -= l; ret += l;
4123 0 : mandatory_oldlen = len;
4124 0 : if (mandatory_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4125 0 : len = mandatory_datalen;
4126 : {
4127 : size_t mandatory_Tag_datalen;
4128 : Der_type mandatory_Tag_type;
4129 : size_t mandatory_Tag_oldlen;
4130 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mandatory_Tag_type, UT_Boolean, &mandatory_Tag_datalen, &l);
4131 0 : if (e == 0 && mandatory_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4132 0 : if (e) goto fail;
4133 0 : p += l; len -= l; ret += l;
4134 0 : mandatory_Tag_oldlen = len;
4135 0 : if (mandatory_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4136 0 : len = mandatory_Tag_datalen;
4137 0 : e = der_get_boolean(p, len, &(data)->mandatory, &l);
4138 0 : if(e) goto fail;
4139 0 : p += l; len -= l; ret += l;
4140 0 : len = mandatory_Tag_oldlen - mandatory_Tag_datalen;
4141 : }
4142 0 : len = mandatory_oldlen - mandatory_datalen;
4143 : }
4144 : {
4145 : size_t data_datalen;
4146 : Der_type data_type;
4147 : size_t data_oldlen;
4148 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &data_type, 1, &data_datalen, &l);
4149 0 : if (e == 0 && data_type != CONS) { e = ASN1_BAD_ID; }
4150 0 : if (e) goto fail;
4151 0 : p += l; len -= l; ret += l;
4152 0 : data_oldlen = len;
4153 0 : if (data_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4154 0 : len = data_datalen;
4155 0 : if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, NULL) == 0) {
4156 0 : (&(data)->data)->element = choice_HDB_extension_data_pkinit_acl;
4157 : {
4158 : size_t pkinit_acl_datalen;
4159 : Der_type pkinit_acl_type;
4160 : size_t pkinit_acl_oldlen;
4161 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &pkinit_acl_type, 0, &pkinit_acl_datalen, &l);
4162 0 : if (e == 0 && pkinit_acl_type != CONS) { e = ASN1_BAD_ID; }
4163 0 : if (e) goto fail;
4164 0 : p += l; len -= l; ret += l;
4165 0 : pkinit_acl_oldlen = len;
4166 0 : if (pkinit_acl_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4167 0 : len = pkinit_acl_datalen;
4168 0 : e = decode_HDB_Ext_PKINIT_acl(p, len, &(&(data)->data)->u.pkinit_acl, &l);
4169 0 : if(e) goto fail;
4170 0 : p += l; len -= l; ret += l;
4171 0 : len = pkinit_acl_oldlen - pkinit_acl_datalen;
4172 : }
4173 : }
4174 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, NULL) == 0) {
4175 0 : (&(data)->data)->element = choice_HDB_extension_data_pkinit_cert_hash;
4176 : {
4177 : size_t pkinit_cert_hash_datalen;
4178 : Der_type pkinit_cert_hash_type;
4179 : size_t pkinit_cert_hash_oldlen;
4180 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &pkinit_cert_hash_type, 1, &pkinit_cert_hash_datalen, &l);
4181 0 : if (e == 0 && pkinit_cert_hash_type != CONS) { e = ASN1_BAD_ID; }
4182 0 : if (e) goto fail;
4183 0 : p += l; len -= l; ret += l;
4184 0 : pkinit_cert_hash_oldlen = len;
4185 0 : if (pkinit_cert_hash_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4186 0 : len = pkinit_cert_hash_datalen;
4187 0 : e = decode_HDB_Ext_PKINIT_hash(p, len, &(&(data)->data)->u.pkinit_cert_hash, &l);
4188 0 : if(e) goto fail;
4189 0 : p += l; len -= l; ret += l;
4190 0 : len = pkinit_cert_hash_oldlen - pkinit_cert_hash_datalen;
4191 : }
4192 : }
4193 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 2, NULL) == 0) {
4194 0 : (&(data)->data)->element = choice_HDB_extension_data_allowed_to_delegate_to;
4195 : {
4196 : size_t allowed_to_delegate_to_datalen;
4197 : Der_type allowed_to_delegate_to_type;
4198 : size_t allowed_to_delegate_to_oldlen;
4199 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &allowed_to_delegate_to_type, 2, &allowed_to_delegate_to_datalen, &l);
4200 0 : if (e == 0 && allowed_to_delegate_to_type != CONS) { e = ASN1_BAD_ID; }
4201 0 : if (e) goto fail;
4202 0 : p += l; len -= l; ret += l;
4203 0 : allowed_to_delegate_to_oldlen = len;
4204 0 : if (allowed_to_delegate_to_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4205 0 : len = allowed_to_delegate_to_datalen;
4206 0 : e = decode_HDB_Ext_Constrained_delegation_acl(p, len, &(&(data)->data)->u.allowed_to_delegate_to, &l);
4207 0 : if(e) goto fail;
4208 0 : p += l; len -= l; ret += l;
4209 0 : len = allowed_to_delegate_to_oldlen - allowed_to_delegate_to_datalen;
4210 : }
4211 : }
4212 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 4, NULL) == 0) {
4213 0 : (&(data)->data)->element = choice_HDB_extension_data_lm_owf;
4214 : {
4215 : size_t lm_owf_datalen;
4216 : Der_type lm_owf_type;
4217 : size_t lm_owf_oldlen;
4218 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &lm_owf_type, 4, &lm_owf_datalen, &l);
4219 0 : if (e == 0 && lm_owf_type != CONS) { e = ASN1_BAD_ID; }
4220 0 : if (e) goto fail;
4221 0 : p += l; len -= l; ret += l;
4222 0 : lm_owf_oldlen = len;
4223 0 : if (lm_owf_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4224 0 : len = lm_owf_datalen;
4225 0 : e = decode_HDB_Ext_Lan_Manager_OWF(p, len, &(&(data)->data)->u.lm_owf, &l);
4226 0 : if(e) goto fail;
4227 0 : p += l; len -= l; ret += l;
4228 0 : len = lm_owf_oldlen - lm_owf_datalen;
4229 : }
4230 : }
4231 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 5, NULL) == 0) {
4232 0 : (&(data)->data)->element = choice_HDB_extension_data_password;
4233 : {
4234 : size_t password_datalen;
4235 : Der_type password_type;
4236 : size_t password_oldlen;
4237 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &password_type, 5, &password_datalen, &l);
4238 0 : if (e == 0 && password_type != CONS) { e = ASN1_BAD_ID; }
4239 0 : if (e) goto fail;
4240 0 : p += l; len -= l; ret += l;
4241 0 : password_oldlen = len;
4242 0 : if (password_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4243 0 : len = password_datalen;
4244 0 : e = decode_HDB_Ext_Password(p, len, &(&(data)->data)->u.password, &l);
4245 0 : if(e) goto fail;
4246 0 : p += l; len -= l; ret += l;
4247 0 : len = password_oldlen - password_datalen;
4248 : }
4249 : }
4250 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 6, NULL) == 0) {
4251 0 : (&(data)->data)->element = choice_HDB_extension_data_aliases;
4252 : {
4253 : size_t aliases_datalen;
4254 : Der_type aliases_type;
4255 : size_t aliases_oldlen;
4256 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &aliases_type, 6, &aliases_datalen, &l);
4257 0 : if (e == 0 && aliases_type != CONS) { e = ASN1_BAD_ID; }
4258 0 : if (e) goto fail;
4259 0 : p += l; len -= l; ret += l;
4260 0 : aliases_oldlen = len;
4261 0 : if (aliases_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4262 0 : len = aliases_datalen;
4263 0 : e = decode_HDB_Ext_Aliases(p, len, &(&(data)->data)->u.aliases, &l);
4264 0 : if(e) goto fail;
4265 0 : p += l; len -= l; ret += l;
4266 0 : len = aliases_oldlen - aliases_datalen;
4267 : }
4268 : }
4269 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 7, NULL) == 0) {
4270 0 : (&(data)->data)->element = choice_HDB_extension_data_last_pw_change;
4271 : {
4272 : size_t last_pw_change_datalen;
4273 : Der_type last_pw_change_type;
4274 : size_t last_pw_change_oldlen;
4275 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &last_pw_change_type, 7, &last_pw_change_datalen, &l);
4276 0 : if (e == 0 && last_pw_change_type != CONS) { e = ASN1_BAD_ID; }
4277 0 : if (e) goto fail;
4278 0 : p += l; len -= l; ret += l;
4279 0 : last_pw_change_oldlen = len;
4280 0 : if (last_pw_change_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4281 0 : len = last_pw_change_datalen;
4282 0 : e = decode_KerberosTime(p, len, &(&(data)->data)->u.last_pw_change, &l);
4283 0 : if(e) goto fail;
4284 0 : p += l; len -= l; ret += l;
4285 0 : len = last_pw_change_oldlen - last_pw_change_datalen;
4286 : }
4287 : }
4288 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 8, NULL) == 0) {
4289 0 : (&(data)->data)->element = choice_HDB_extension_data_pkinit_cert;
4290 : {
4291 : size_t pkinit_cert_datalen;
4292 : Der_type pkinit_cert_type;
4293 : size_t pkinit_cert_oldlen;
4294 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &pkinit_cert_type, 8, &pkinit_cert_datalen, &l);
4295 0 : if (e == 0 && pkinit_cert_type != CONS) { e = ASN1_BAD_ID; }
4296 0 : if (e) goto fail;
4297 0 : p += l; len -= l; ret += l;
4298 0 : pkinit_cert_oldlen = len;
4299 0 : if (pkinit_cert_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4300 0 : len = pkinit_cert_datalen;
4301 0 : e = decode_HDB_Ext_PKINIT_cert(p, len, &(&(data)->data)->u.pkinit_cert, &l);
4302 0 : if(e) goto fail;
4303 0 : p += l; len -= l; ret += l;
4304 0 : len = pkinit_cert_oldlen - pkinit_cert_datalen;
4305 : }
4306 : }
4307 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 9, NULL) == 0) {
4308 0 : (&(data)->data)->element = choice_HDB_extension_data_hist_keys;
4309 : {
4310 : size_t hist_keys_datalen;
4311 : Der_type hist_keys_type;
4312 : size_t hist_keys_oldlen;
4313 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &hist_keys_type, 9, &hist_keys_datalen, &l);
4314 0 : if (e == 0 && hist_keys_type != CONS) { e = ASN1_BAD_ID; }
4315 0 : if (e) goto fail;
4316 0 : p += l; len -= l; ret += l;
4317 0 : hist_keys_oldlen = len;
4318 0 : if (hist_keys_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4319 0 : len = hist_keys_datalen;
4320 0 : e = decode_HDB_Ext_KeySet(p, len, &(&(data)->data)->u.hist_keys, &l);
4321 0 : if(e) goto fail;
4322 0 : p += l; len -= l; ret += l;
4323 0 : len = hist_keys_oldlen - hist_keys_datalen;
4324 : }
4325 : }
4326 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 10, NULL) == 0) {
4327 0 : (&(data)->data)->element = choice_HDB_extension_data_hist_kvno_diff_clnt;
4328 : {
4329 : size_t hist_kvno_diff_clnt_datalen;
4330 : Der_type hist_kvno_diff_clnt_type;
4331 : size_t hist_kvno_diff_clnt_oldlen;
4332 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &hist_kvno_diff_clnt_type, 10, &hist_kvno_diff_clnt_datalen, &l);
4333 0 : if (e == 0 && hist_kvno_diff_clnt_type != CONS) { e = ASN1_BAD_ID; }
4334 0 : if (e) goto fail;
4335 0 : p += l; len -= l; ret += l;
4336 0 : hist_kvno_diff_clnt_oldlen = len;
4337 0 : if (hist_kvno_diff_clnt_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4338 0 : len = hist_kvno_diff_clnt_datalen;
4339 : {
4340 : size_t hist_kvno_diff_clnt_Tag_datalen;
4341 : Der_type hist_kvno_diff_clnt_Tag_type;
4342 : size_t hist_kvno_diff_clnt_Tag_oldlen;
4343 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &hist_kvno_diff_clnt_Tag_type, UT_Integer, &hist_kvno_diff_clnt_Tag_datalen, &l);
4344 0 : if (e == 0 && hist_kvno_diff_clnt_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4345 0 : if (e) goto fail;
4346 0 : p += l; len -= l; ret += l;
4347 0 : hist_kvno_diff_clnt_Tag_oldlen = len;
4348 0 : if (hist_kvno_diff_clnt_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4349 0 : len = hist_kvno_diff_clnt_Tag_datalen;
4350 0 : e = der_get_unsigned(p, len, &(&(data)->data)->u.hist_kvno_diff_clnt, &l);
4351 0 : if(e) goto fail;
4352 0 : p += l; len -= l; ret += l;
4353 0 : len = hist_kvno_diff_clnt_Tag_oldlen - hist_kvno_diff_clnt_Tag_datalen;
4354 : }
4355 0 : len = hist_kvno_diff_clnt_oldlen - hist_kvno_diff_clnt_datalen;
4356 : }
4357 : }
4358 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 11, NULL) == 0) {
4359 0 : (&(data)->data)->element = choice_HDB_extension_data_hist_kvno_diff_svc;
4360 : {
4361 : size_t hist_kvno_diff_svc_datalen;
4362 : Der_type hist_kvno_diff_svc_type;
4363 : size_t hist_kvno_diff_svc_oldlen;
4364 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &hist_kvno_diff_svc_type, 11, &hist_kvno_diff_svc_datalen, &l);
4365 0 : if (e == 0 && hist_kvno_diff_svc_type != CONS) { e = ASN1_BAD_ID; }
4366 0 : if (e) goto fail;
4367 0 : p += l; len -= l; ret += l;
4368 0 : hist_kvno_diff_svc_oldlen = len;
4369 0 : if (hist_kvno_diff_svc_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4370 0 : len = hist_kvno_diff_svc_datalen;
4371 : {
4372 : size_t hist_kvno_diff_svc_Tag_datalen;
4373 : Der_type hist_kvno_diff_svc_Tag_type;
4374 : size_t hist_kvno_diff_svc_Tag_oldlen;
4375 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &hist_kvno_diff_svc_Tag_type, UT_Integer, &hist_kvno_diff_svc_Tag_datalen, &l);
4376 0 : if (e == 0 && hist_kvno_diff_svc_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4377 0 : if (e) goto fail;
4378 0 : p += l; len -= l; ret += l;
4379 0 : hist_kvno_diff_svc_Tag_oldlen = len;
4380 0 : if (hist_kvno_diff_svc_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4381 0 : len = hist_kvno_diff_svc_Tag_datalen;
4382 0 : e = der_get_unsigned(p, len, &(&(data)->data)->u.hist_kvno_diff_svc, &l);
4383 0 : if(e) goto fail;
4384 0 : p += l; len -= l; ret += l;
4385 0 : len = hist_kvno_diff_svc_Tag_oldlen - hist_kvno_diff_svc_Tag_datalen;
4386 : }
4387 0 : len = hist_kvno_diff_svc_oldlen - hist_kvno_diff_svc_datalen;
4388 : }
4389 : }
4390 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 12, NULL) == 0) {
4391 0 : (&(data)->data)->element = choice_HDB_extension_data_policy;
4392 : {
4393 : size_t policy_datalen;
4394 : Der_type policy_type;
4395 : size_t policy_oldlen;
4396 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &policy_type, 12, &policy_datalen, &l);
4397 0 : if (e == 0 && policy_type != CONS) { e = ASN1_BAD_ID; }
4398 0 : if (e) goto fail;
4399 0 : p += l; len -= l; ret += l;
4400 0 : policy_oldlen = len;
4401 0 : if (policy_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4402 0 : len = policy_datalen;
4403 : {
4404 : size_t policy_Tag_datalen;
4405 : Der_type policy_Tag_type;
4406 : size_t policy_Tag_oldlen;
4407 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &policy_Tag_type, UT_UTF8String, &policy_Tag_datalen, &l);
4408 0 : if (e == 0 && policy_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4409 0 : if (e) goto fail;
4410 0 : p += l; len -= l; ret += l;
4411 0 : policy_Tag_oldlen = len;
4412 0 : if (policy_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4413 0 : len = policy_Tag_datalen;
4414 0 : e = der_get_utf8string(p, len, &(&(data)->data)->u.policy, &l);
4415 0 : if(e) goto fail;
4416 0 : p += l; len -= l; ret += l;
4417 0 : len = policy_Tag_oldlen - policy_Tag_datalen;
4418 : }
4419 0 : len = policy_oldlen - policy_datalen;
4420 : }
4421 : }
4422 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 13, NULL) == 0) {
4423 0 : (&(data)->data)->element = choice_HDB_extension_data_principal_id;
4424 : {
4425 : size_t principal_id_datalen;
4426 : Der_type principal_id_type;
4427 : size_t principal_id_oldlen;
4428 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &principal_id_type, 13, &principal_id_datalen, &l);
4429 0 : if (e == 0 && principal_id_type != CONS) { e = ASN1_BAD_ID; }
4430 0 : if (e) goto fail;
4431 0 : p += l; len -= l; ret += l;
4432 0 : principal_id_oldlen = len;
4433 0 : if (principal_id_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4434 0 : len = principal_id_datalen;
4435 : {
4436 : size_t principal_id_Tag_datalen;
4437 : Der_type principal_id_Tag_type;
4438 : size_t principal_id_Tag_oldlen;
4439 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &principal_id_Tag_type, UT_Integer, &principal_id_Tag_datalen, &l);
4440 0 : if (e == 0 && principal_id_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4441 0 : if (e) goto fail;
4442 0 : p += l; len -= l; ret += l;
4443 0 : principal_id_Tag_oldlen = len;
4444 0 : if (principal_id_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4445 0 : len = principal_id_Tag_datalen;
4446 0 : e = der_get_integer64(p, len, &(&(data)->data)->u.principal_id, &l);
4447 0 : if(e) goto fail;
4448 0 : p += l; len -= l; ret += l;
4449 0 : len = principal_id_Tag_oldlen - principal_id_Tag_datalen;
4450 : }
4451 0 : len = principal_id_oldlen - principal_id_datalen;
4452 : }
4453 : }
4454 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 14, NULL) == 0) {
4455 0 : (&(data)->data)->element = choice_HDB_extension_data_key_rotation;
4456 : {
4457 : size_t key_rotation_datalen;
4458 : Der_type key_rotation_type;
4459 : size_t key_rotation_oldlen;
4460 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &key_rotation_type, 14, &key_rotation_datalen, &l);
4461 0 : if (e == 0 && key_rotation_type != CONS) { e = ASN1_BAD_ID; }
4462 0 : if (e) goto fail;
4463 0 : p += l; len -= l; ret += l;
4464 0 : key_rotation_oldlen = len;
4465 0 : if (key_rotation_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4466 0 : len = key_rotation_datalen;
4467 0 : e = decode_HDB_Ext_KeyRotation(p, len, &(&(data)->data)->u.key_rotation, &l);
4468 0 : if(e) goto fail;
4469 0 : p += l; len -= l; ret += l;
4470 0 : len = key_rotation_oldlen - key_rotation_datalen;
4471 : }
4472 : }
4473 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 15, NULL) == 0) {
4474 0 : (&(data)->data)->element = choice_HDB_extension_data_krb5_config;
4475 : {
4476 : size_t krb5_config_datalen;
4477 : Der_type krb5_config_type;
4478 : size_t krb5_config_oldlen;
4479 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &krb5_config_type, 15, &krb5_config_datalen, &l);
4480 0 : if (e == 0 && krb5_config_type != CONS) { e = ASN1_BAD_ID; }
4481 0 : if (e) goto fail;
4482 0 : p += l; len -= l; ret += l;
4483 0 : krb5_config_oldlen = len;
4484 0 : if (krb5_config_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4485 0 : len = krb5_config_datalen;
4486 : {
4487 : size_t krb5_config_Tag_datalen;
4488 : Der_type krb5_config_Tag_type;
4489 : size_t krb5_config_Tag_oldlen;
4490 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &krb5_config_Tag_type, UT_OctetString, &krb5_config_Tag_datalen, &l);
4491 0 : if (e == 0 && krb5_config_Tag_type != PRIM) { e = ASN1_BAD_ID; }
4492 0 : if (e) goto fail;
4493 0 : p += l; len -= l; ret += l;
4494 0 : krb5_config_Tag_oldlen = len;
4495 0 : if (krb5_config_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4496 0 : len = krb5_config_Tag_datalen;
4497 0 : e = der_get_octet_string(p, len, &(&(data)->data)->u.krb5_config, &l);
4498 0 : if(e) goto fail;
4499 0 : p += l; len -= l; ret += l;
4500 0 : len = krb5_config_Tag_oldlen - krb5_config_Tag_datalen;
4501 : }
4502 0 : len = krb5_config_oldlen - krb5_config_datalen;
4503 : }
4504 : }
4505 : else {
4506 0 : (&(data)->data)->element = choice_HDB_extension_data_asn1_ellipsis;
4507 0 : (&(data)->data)->u.asn1_ellipsis.data = calloc(1, len);
4508 0 : if ((&(data)->data)->u.asn1_ellipsis.data == NULL) {
4509 0 : e = ENOMEM; goto fail;
4510 : }
4511 0 : (&(data)->data)->u.asn1_ellipsis.length = len;
4512 0 : memcpy((&(data)->data)->u.asn1_ellipsis.data, p, len);
4513 0 : p += len;
4514 0 : ret += len;
4515 0 : len = 0;
4516 : }
4517 0 : len = data_oldlen - data_datalen;
4518 : }
4519 0 : len = Top_oldlen - Top_datalen;
4520 : }
4521 0 : if(size) *size = ret;
4522 0 : return 0;
4523 0 : fail:
4524 0 : free_HDB_extension(data);
4525 0 : return e;
4526 : }
4527 :
4528 : void ASN1CALL
4529 0 : free_HDB_extension(HDB_extension *data)
4530 : {
4531 0 : *&(data)->mandatory = 0;
4532 0 : switch((&(data)->data)->element) {
4533 0 : case choice_HDB_extension_data_pkinit_acl:
4534 0 : free_HDB_Ext_PKINIT_acl(&(&(data)->data)->u.pkinit_acl);
4535 0 : break;
4536 0 : case choice_HDB_extension_data_pkinit_cert_hash:
4537 0 : free_HDB_Ext_PKINIT_hash(&(&(data)->data)->u.pkinit_cert_hash);
4538 0 : break;
4539 0 : case choice_HDB_extension_data_allowed_to_delegate_to:
4540 0 : free_HDB_Ext_Constrained_delegation_acl(&(&(data)->data)->u.allowed_to_delegate_to);
4541 0 : break;
4542 0 : case choice_HDB_extension_data_lm_owf:
4543 0 : free_HDB_Ext_Lan_Manager_OWF(&(&(data)->data)->u.lm_owf);
4544 0 : break;
4545 0 : case choice_HDB_extension_data_password:
4546 0 : free_HDB_Ext_Password(&(&(data)->data)->u.password);
4547 0 : break;
4548 0 : case choice_HDB_extension_data_aliases:
4549 0 : free_HDB_Ext_Aliases(&(&(data)->data)->u.aliases);
4550 0 : break;
4551 0 : case choice_HDB_extension_data_last_pw_change:
4552 0 : free_KerberosTime(&(&(data)->data)->u.last_pw_change);
4553 0 : break;
4554 0 : case choice_HDB_extension_data_pkinit_cert:
4555 0 : free_HDB_Ext_PKINIT_cert(&(&(data)->data)->u.pkinit_cert);
4556 0 : break;
4557 0 : case choice_HDB_extension_data_hist_keys:
4558 0 : free_HDB_Ext_KeySet(&(&(data)->data)->u.hist_keys);
4559 0 : break;
4560 0 : case choice_HDB_extension_data_hist_kvno_diff_clnt:
4561 0 : *&(&(data)->data)->u.hist_kvno_diff_clnt = 0;
4562 0 : break;
4563 0 : case choice_HDB_extension_data_hist_kvno_diff_svc:
4564 0 : *&(&(data)->data)->u.hist_kvno_diff_svc = 0;
4565 0 : break;
4566 0 : case choice_HDB_extension_data_policy:
4567 0 : der_free_utf8string(&(&(data)->data)->u.policy);
4568 0 : break;
4569 0 : case choice_HDB_extension_data_principal_id:
4570 0 : *&(&(data)->data)->u.principal_id = 0;
4571 0 : break;
4572 0 : case choice_HDB_extension_data_key_rotation:
4573 0 : free_HDB_Ext_KeyRotation(&(&(data)->data)->u.key_rotation);
4574 0 : break;
4575 0 : case choice_HDB_extension_data_krb5_config:
4576 0 : der_free_octet_string(&(&(data)->data)->u.krb5_config);
4577 0 : break;
4578 0 : case choice_HDB_extension_data_asn1_ellipsis:
4579 0 : der_free_octet_string(&(&(data)->data)->u.asn1_ellipsis);
4580 0 : break;}
4581 0 : }
4582 :
4583 : size_t ASN1CALL
4584 0 : length_HDB_extension(const HDB_extension *data)
4585 : {
4586 0 : size_t ret = 0;
4587 : {
4588 0 : size_t Top_tag_oldret = ret;
4589 0 : ret = 0;
4590 0 : ret += 1;
4591 0 : ret += 1 + der_length_len (ret);
4592 0 : ret += 1 + der_length_len (ret);
4593 0 : ret += Top_tag_oldret;
4594 : }
4595 : {
4596 0 : size_t Top_tag_oldret = ret;
4597 0 : ret = 0;
4598 0 : switch((&(data)->data)->element) {
4599 0 : case choice_HDB_extension_data_pkinit_acl:
4600 : {
4601 0 : size_t data_tag_oldret = ret;
4602 0 : ret = 0;
4603 0 : ret += length_HDB_Ext_PKINIT_acl(&(&(data)->data)->u.pkinit_acl);
4604 0 : ret += 1 + der_length_len (ret);
4605 0 : ret += data_tag_oldret;
4606 : }
4607 0 : break;
4608 0 : case choice_HDB_extension_data_pkinit_cert_hash:
4609 : {
4610 0 : size_t data_tag_oldret = ret;
4611 0 : ret = 0;
4612 0 : ret += length_HDB_Ext_PKINIT_hash(&(&(data)->data)->u.pkinit_cert_hash);
4613 0 : ret += 1 + der_length_len (ret);
4614 0 : ret += data_tag_oldret;
4615 : }
4616 0 : break;
4617 0 : case choice_HDB_extension_data_allowed_to_delegate_to:
4618 : {
4619 0 : size_t data_tag_oldret = ret;
4620 0 : ret = 0;
4621 0 : ret += length_HDB_Ext_Constrained_delegation_acl(&(&(data)->data)->u.allowed_to_delegate_to);
4622 0 : ret += 1 + der_length_len (ret);
4623 0 : ret += data_tag_oldret;
4624 : }
4625 0 : break;
4626 0 : case choice_HDB_extension_data_lm_owf:
4627 : {
4628 0 : size_t data_tag_oldret = ret;
4629 0 : ret = 0;
4630 0 : ret += length_HDB_Ext_Lan_Manager_OWF(&(&(data)->data)->u.lm_owf);
4631 0 : ret += 1 + der_length_len (ret);
4632 0 : ret += data_tag_oldret;
4633 : }
4634 0 : break;
4635 0 : case choice_HDB_extension_data_password:
4636 : {
4637 0 : size_t data_tag_oldret = ret;
4638 0 : ret = 0;
4639 0 : ret += length_HDB_Ext_Password(&(&(data)->data)->u.password);
4640 0 : ret += 1 + der_length_len (ret);
4641 0 : ret += data_tag_oldret;
4642 : }
4643 0 : break;
4644 0 : case choice_HDB_extension_data_aliases:
4645 : {
4646 0 : size_t data_tag_oldret = ret;
4647 0 : ret = 0;
4648 0 : ret += length_HDB_Ext_Aliases(&(&(data)->data)->u.aliases);
4649 0 : ret += 1 + der_length_len (ret);
4650 0 : ret += data_tag_oldret;
4651 : }
4652 0 : break;
4653 0 : case choice_HDB_extension_data_last_pw_change:
4654 : {
4655 0 : size_t data_tag_oldret = ret;
4656 0 : ret = 0;
4657 0 : ret += length_KerberosTime(&(&(data)->data)->u.last_pw_change);
4658 0 : ret += 1 + der_length_len (ret);
4659 0 : ret += data_tag_oldret;
4660 : }
4661 0 : break;
4662 0 : case choice_HDB_extension_data_pkinit_cert:
4663 : {
4664 0 : size_t data_tag_oldret = ret;
4665 0 : ret = 0;
4666 0 : ret += length_HDB_Ext_PKINIT_cert(&(&(data)->data)->u.pkinit_cert);
4667 0 : ret += 1 + der_length_len (ret);
4668 0 : ret += data_tag_oldret;
4669 : }
4670 0 : break;
4671 0 : case choice_HDB_extension_data_hist_keys:
4672 : {
4673 0 : size_t data_tag_oldret = ret;
4674 0 : ret = 0;
4675 0 : ret += length_HDB_Ext_KeySet(&(&(data)->data)->u.hist_keys);
4676 0 : ret += 1 + der_length_len (ret);
4677 0 : ret += data_tag_oldret;
4678 : }
4679 0 : break;
4680 0 : case choice_HDB_extension_data_hist_kvno_diff_clnt:
4681 : {
4682 0 : size_t data_tag_oldret = ret;
4683 0 : ret = 0;
4684 0 : ret += der_length_unsigned(&(&(data)->data)->u.hist_kvno_diff_clnt);
4685 0 : ret += 1 + der_length_len (ret);
4686 0 : ret += 1 + der_length_len (ret);
4687 0 : ret += data_tag_oldret;
4688 : }
4689 0 : break;
4690 0 : case choice_HDB_extension_data_hist_kvno_diff_svc:
4691 : {
4692 0 : size_t data_tag_oldret = ret;
4693 0 : ret = 0;
4694 0 : ret += der_length_unsigned(&(&(data)->data)->u.hist_kvno_diff_svc);
4695 0 : ret += 1 + der_length_len (ret);
4696 0 : ret += 1 + der_length_len (ret);
4697 0 : ret += data_tag_oldret;
4698 : }
4699 0 : break;
4700 0 : case choice_HDB_extension_data_policy:
4701 : {
4702 0 : size_t data_tag_oldret = ret;
4703 0 : ret = 0;
4704 0 : ret += der_length_utf8string(&(&(data)->data)->u.policy);
4705 0 : ret += 1 + der_length_len (ret);
4706 0 : ret += 1 + der_length_len (ret);
4707 0 : ret += data_tag_oldret;
4708 : }
4709 0 : break;
4710 0 : case choice_HDB_extension_data_principal_id:
4711 : {
4712 0 : size_t data_tag_oldret = ret;
4713 0 : ret = 0;
4714 0 : ret += der_length_integer64(&(&(data)->data)->u.principal_id);
4715 0 : ret += 1 + der_length_len (ret);
4716 0 : ret += 1 + der_length_len (ret);
4717 0 : ret += data_tag_oldret;
4718 : }
4719 0 : break;
4720 0 : case choice_HDB_extension_data_key_rotation:
4721 : {
4722 0 : size_t data_tag_oldret = ret;
4723 0 : ret = 0;
4724 0 : ret += length_HDB_Ext_KeyRotation(&(&(data)->data)->u.key_rotation);
4725 0 : ret += 1 + der_length_len (ret);
4726 0 : ret += data_tag_oldret;
4727 : }
4728 0 : break;
4729 0 : case choice_HDB_extension_data_krb5_config:
4730 : {
4731 0 : size_t data_tag_oldret = ret;
4732 0 : ret = 0;
4733 0 : ret += der_length_octet_string(&(&(data)->data)->u.krb5_config);
4734 0 : ret += 1 + der_length_len (ret);
4735 0 : ret += 1 + der_length_len (ret);
4736 0 : ret += data_tag_oldret;
4737 : }
4738 0 : break;
4739 0 : case choice_HDB_extension_data_asn1_ellipsis:
4740 0 : ret += (&(data)->data)->u.asn1_ellipsis.length;
4741 0 : break;
4742 : }
4743 0 : ret += 1 + der_length_len (ret);
4744 0 : ret += Top_tag_oldret;
4745 : }
4746 0 : ret += 1 + der_length_len (ret);
4747 0 : return ret;
4748 : }
4749 :
4750 : int ASN1CALL
4751 0 : copy_HDB_extension(const HDB_extension *from, HDB_extension *to)
4752 : {
4753 0 : memset(to, 0, sizeof(*to));
4754 0 : *(&(to)->mandatory) = *(&(from)->mandatory);
4755 0 : (&(to)->data)->element = (&(from)->data)->element;
4756 0 : switch((&(from)->data)->element) {
4757 0 : case choice_HDB_extension_data_pkinit_acl:
4758 0 : if(copy_HDB_Ext_PKINIT_acl(&(&(from)->data)->u.pkinit_acl, &(&(to)->data)->u.pkinit_acl)) goto fail;
4759 0 : break;
4760 0 : case choice_HDB_extension_data_pkinit_cert_hash:
4761 0 : if(copy_HDB_Ext_PKINIT_hash(&(&(from)->data)->u.pkinit_cert_hash, &(&(to)->data)->u.pkinit_cert_hash)) goto fail;
4762 0 : break;
4763 0 : case choice_HDB_extension_data_allowed_to_delegate_to:
4764 0 : if(copy_HDB_Ext_Constrained_delegation_acl(&(&(from)->data)->u.allowed_to_delegate_to, &(&(to)->data)->u.allowed_to_delegate_to)) goto fail;
4765 0 : break;
4766 0 : case choice_HDB_extension_data_lm_owf:
4767 0 : if(copy_HDB_Ext_Lan_Manager_OWF(&(&(from)->data)->u.lm_owf, &(&(to)->data)->u.lm_owf)) goto fail;
4768 0 : break;
4769 0 : case choice_HDB_extension_data_password:
4770 0 : if(copy_HDB_Ext_Password(&(&(from)->data)->u.password, &(&(to)->data)->u.password)) goto fail;
4771 0 : break;
4772 0 : case choice_HDB_extension_data_aliases:
4773 0 : if(copy_HDB_Ext_Aliases(&(&(from)->data)->u.aliases, &(&(to)->data)->u.aliases)) goto fail;
4774 0 : break;
4775 0 : case choice_HDB_extension_data_last_pw_change:
4776 0 : if(copy_KerberosTime(&(&(from)->data)->u.last_pw_change, &(&(to)->data)->u.last_pw_change)) goto fail;
4777 0 : break;
4778 0 : case choice_HDB_extension_data_pkinit_cert:
4779 0 : if(copy_HDB_Ext_PKINIT_cert(&(&(from)->data)->u.pkinit_cert, &(&(to)->data)->u.pkinit_cert)) goto fail;
4780 0 : break;
4781 0 : case choice_HDB_extension_data_hist_keys:
4782 0 : if(copy_HDB_Ext_KeySet(&(&(from)->data)->u.hist_keys, &(&(to)->data)->u.hist_keys)) goto fail;
4783 0 : break;
4784 0 : case choice_HDB_extension_data_hist_kvno_diff_clnt:
4785 0 : *(&(&(to)->data)->u.hist_kvno_diff_clnt) = *(&(&(from)->data)->u.hist_kvno_diff_clnt);
4786 0 : break;
4787 0 : case choice_HDB_extension_data_hist_kvno_diff_svc:
4788 0 : *(&(&(to)->data)->u.hist_kvno_diff_svc) = *(&(&(from)->data)->u.hist_kvno_diff_svc);
4789 0 : break;
4790 0 : case choice_HDB_extension_data_policy:
4791 0 : if(der_copy_utf8string(&(&(from)->data)->u.policy, &(&(to)->data)->u.policy)) goto fail;
4792 0 : break;
4793 0 : case choice_HDB_extension_data_principal_id:
4794 0 : *(&(&(to)->data)->u.principal_id) = *(&(&(from)->data)->u.principal_id);
4795 0 : break;
4796 0 : case choice_HDB_extension_data_key_rotation:
4797 0 : if(copy_HDB_Ext_KeyRotation(&(&(from)->data)->u.key_rotation, &(&(to)->data)->u.key_rotation)) goto fail;
4798 0 : break;
4799 0 : case choice_HDB_extension_data_krb5_config:
4800 0 : if(der_copy_octet_string(&(&(from)->data)->u.krb5_config, &(&(to)->data)->u.krb5_config)) goto fail;
4801 0 : break;
4802 0 : case choice_HDB_extension_data_asn1_ellipsis: {
4803 : int ret;
4804 0 : ret=der_copy_octet_string(&(&(from)->data)->u.asn1_ellipsis, &(&(to)->data)->u.asn1_ellipsis);
4805 0 : if (ret) goto fail;
4806 0 : break;
4807 : }
4808 : }
4809 0 : return 0;
4810 0 : fail:
4811 0 : free_HDB_extension(to);
4812 0 : return ENOMEM;
4813 : }
4814 :
4815 : char * ASN1CALL
4816 0 : print_HDB_extension(const HDB_extension *data, int flags)
4817 0 : { errno = EINVAL; return 0; }
4818 :
4819 : int ASN1CALL
4820 0 : encode_HDB_extensions(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_extensions *data, size_t *size)
4821 : {
4822 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
4823 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
4824 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
4825 :
4826 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
4827 0 : size_t Top_tag_for_oldret = ret;
4828 0 : ret = 0;
4829 0 : e = encode_HDB_extension(p, len, &(data)->val[i], &l);
4830 0 : if (e) return e;
4831 0 : p -= l; len -= l; ret += l;
4832 :
4833 0 : ret += Top_tag_for_oldret;
4834 : }
4835 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
4836 0 : if (e) return e;
4837 0 : p -= l; len -= l; ret += l;
4838 :
4839 0 : *size = ret;
4840 0 : return 0;
4841 : }
4842 :
4843 : int ASN1CALL
4844 0 : decode_HDB_extensions(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_extensions *data, size_t *size)
4845 : {
4846 0 : size_t ret = 0;
4847 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
4848 : int e HEIMDAL_UNUSED_ATTRIBUTE;
4849 :
4850 0 : memset(data, 0, sizeof(*data));
4851 : {
4852 : size_t Top_datalen;
4853 : Der_type Top_type;
4854 : size_t Top_oldlen;
4855 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
4856 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
4857 0 : if (e) goto fail;
4858 0 : p += l; len -= l; ret += l;
4859 0 : Top_oldlen = len;
4860 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
4861 0 : len = Top_datalen;
4862 : {
4863 0 : size_t Top_Tag_origlen = len;
4864 0 : size_t Top_Tag_oldret = ret;
4865 0 : size_t Top_Tag_olen = 0;
4866 : void *Top_Tag_tmp;
4867 0 : ret = 0;
4868 0 : (data)->len = 0;
4869 0 : (data)->val = NULL;
4870 0 : while(ret < Top_Tag_origlen) {
4871 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
4872 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
4873 0 : Top_Tag_olen = Top_Tag_nlen;
4874 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
4875 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
4876 0 : (data)->val = Top_Tag_tmp;
4877 0 : e = decode_HDB_extension(p, len, &(data)->val[(data)->len], &l);
4878 0 : if(e) goto fail;
4879 0 : p += l; len -= l; ret += l;
4880 0 : (data)->len++;
4881 0 : len = Top_Tag_origlen - ret;
4882 : }
4883 0 : ret += Top_Tag_oldret;
4884 : }
4885 0 : len = Top_oldlen - Top_datalen;
4886 : }
4887 0 : if(size) *size = ret;
4888 0 : return 0;
4889 0 : fail:
4890 0 : free_HDB_extensions(data);
4891 0 : return e;
4892 : }
4893 :
4894 : void ASN1CALL
4895 0 : free_HDB_extensions(HDB_extensions *data)
4896 : {
4897 0 : if ((data)->val)
4898 0 : while((data)->len){
4899 0 : free_HDB_extension(&(data)->val[(data)->len-1]);
4900 0 : (data)->len--;
4901 0 : } else (data)->len = 0;
4902 0 : free((data)->val);
4903 0 : (data)->val = NULL;
4904 0 : }
4905 :
4906 : size_t ASN1CALL
4907 0 : length_HDB_extensions(const HDB_extensions *data)
4908 : {
4909 0 : size_t ret = 0;
4910 : {
4911 0 : size_t Top_tag_oldret = ret;
4912 : unsigned int n_Top_tag;
4913 0 : ret = 0;
4914 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
4915 0 : size_t Top_tag_for_oldret = ret;
4916 0 : ret = 0;
4917 0 : ret += length_HDB_extension(&(data)->val[n_Top_tag - 1]);
4918 0 : ret += Top_tag_for_oldret;
4919 : }
4920 0 : ret += Top_tag_oldret;
4921 : }
4922 0 : ret += 1 + der_length_len (ret);
4923 0 : return ret;
4924 : }
4925 :
4926 : int ASN1CALL
4927 0 : copy_HDB_extensions(const HDB_extensions *from, HDB_extensions *to)
4928 : {
4929 0 : memset(to, 0, sizeof(*to));
4930 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
4931 0 : goto fail;
4932 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
4933 0 : if(copy_HDB_extension(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
4934 : }
4935 0 : return 0;
4936 0 : fail:
4937 0 : free_HDB_extensions(to);
4938 0 : return ENOMEM;
4939 : }
4940 :
4941 : char * ASN1CALL
4942 0 : print_HDB_extensions(const HDB_extensions *data, int flags)
4943 0 : { errno = EINVAL; return 0; }
4944 :
4945 : int ASN1CALL
4946 0 : add_HDB_extensions(HDB_extensions *data, const HDB_extension *element)
4947 : {
4948 : int ret;
4949 : void *ptr;
4950 :
4951 0 : ptr = realloc(data->val,
4952 0 : (data->len + 1) * sizeof(data->val[0]));
4953 0 : if (ptr == NULL) return ENOMEM;
4954 0 : data->val = ptr;
4955 :
4956 0 : ret = copy_HDB_extension(element, &data->val[data->len]);
4957 0 : if (ret) return ret;
4958 0 : data->len++;
4959 0 : return 0;
4960 : }
4961 :
4962 : int ASN1CALL
4963 0 : remove_HDB_extensions(HDB_extensions *data, unsigned int element)
4964 : {
4965 : void *ptr;
4966 :
4967 0 : if (data->len == 0 || element >= data->len)
4968 0 : return ASN1_OVERRUN;
4969 0 : free_HDB_extension(&data->val[element]);
4970 0 : data->len--;
4971 0 : if (element < data->len)
4972 0 : memmove(&data->val[element], &data->val[element + 1],
4973 0 : sizeof(data->val[0]) * (data->len - element));
4974 0 : ptr = realloc(data->val, data->len * sizeof(data->val[0]));
4975 0 : if (ptr != NULL || data->len == 0) data->val = ptr;
4976 0 : return 0;
4977 : }
4978 :
4979 : int ASN1CALL
4980 0 : encode_HDB_EncTypeList(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_EncTypeList *data, size_t *size)
4981 : {
4982 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
4983 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
4984 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
4985 :
4986 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
4987 0 : size_t Top_tag_for_oldret = ret;
4988 0 : ret = 0;
4989 0 : e = der_put_unsigned(p, len, &(data)->val[i], &l);
4990 0 : if (e) return e;
4991 0 : p -= l; len -= l; ret += l;
4992 :
4993 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
4994 0 : if (e) return e;
4995 0 : p -= l; len -= l; ret += l;
4996 :
4997 0 : ret += Top_tag_for_oldret;
4998 : }
4999 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
5000 0 : if (e) return e;
5001 0 : p -= l; len -= l; ret += l;
5002 :
5003 0 : *size = ret;
5004 0 : return 0;
5005 : }
5006 :
5007 : int ASN1CALL
5008 0 : decode_HDB_EncTypeList(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_EncTypeList *data, size_t *size)
5009 : {
5010 0 : size_t ret = 0;
5011 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
5012 : int e HEIMDAL_UNUSED_ATTRIBUTE;
5013 :
5014 0 : memset(data, 0, sizeof(*data));
5015 : {
5016 : size_t Top_datalen;
5017 : Der_type Top_type;
5018 : size_t Top_oldlen;
5019 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
5020 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
5021 0 : if (e) goto fail;
5022 0 : p += l; len -= l; ret += l;
5023 0 : Top_oldlen = len;
5024 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5025 0 : len = Top_datalen;
5026 : {
5027 0 : size_t Top_Tag_origlen = len;
5028 0 : size_t Top_Tag_oldret = ret;
5029 0 : size_t Top_Tag_olen = 0;
5030 : void *Top_Tag_tmp;
5031 0 : ret = 0;
5032 0 : (data)->len = 0;
5033 0 : (data)->val = NULL;
5034 0 : while(ret < Top_Tag_origlen) {
5035 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
5036 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
5037 0 : Top_Tag_olen = Top_Tag_nlen;
5038 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
5039 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
5040 0 : (data)->val = Top_Tag_tmp;
5041 : {
5042 : size_t Top_Tag_s_of_datalen;
5043 : Der_type Top_Tag_s_of_type;
5044 : size_t Top_Tag_s_of_oldlen;
5045 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_s_of_type, UT_Integer, &Top_Tag_s_of_datalen, &l);
5046 0 : if (e == 0 && Top_Tag_s_of_type != PRIM) { e = ASN1_BAD_ID; }
5047 0 : if (e) goto fail;
5048 0 : p += l; len -= l; ret += l;
5049 0 : Top_Tag_s_of_oldlen = len;
5050 0 : if (Top_Tag_s_of_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5051 0 : len = Top_Tag_s_of_datalen;
5052 0 : e = der_get_unsigned(p, len, &(data)->val[(data)->len], &l);
5053 0 : if(e) goto fail;
5054 0 : p += l; len -= l; ret += l;
5055 0 : len = Top_Tag_s_of_oldlen - Top_Tag_s_of_datalen;
5056 : }
5057 0 : (data)->len++;
5058 0 : len = Top_Tag_origlen - ret;
5059 : }
5060 0 : ret += Top_Tag_oldret;
5061 : }
5062 0 : len = Top_oldlen - Top_datalen;
5063 : }
5064 0 : if(size) *size = ret;
5065 0 : return 0;
5066 0 : fail:
5067 0 : free_HDB_EncTypeList(data);
5068 0 : return e;
5069 : }
5070 :
5071 : void ASN1CALL
5072 362640 : free_HDB_EncTypeList(HDB_EncTypeList *data)
5073 : {
5074 362640 : if ((data)->val)
5075 1517156 : while((data)->len){
5076 791876 : *&(data)->val[(data)->len-1] = 0;
5077 791876 : (data)->len--;
5078 0 : } else (data)->len = 0;
5079 362640 : free((data)->val);
5080 362640 : (data)->val = NULL;
5081 362640 : }
5082 :
5083 : size_t ASN1CALL
5084 0 : length_HDB_EncTypeList(const HDB_EncTypeList *data)
5085 : {
5086 0 : size_t ret = 0;
5087 : {
5088 0 : size_t Top_tag_oldret = ret;
5089 : unsigned int n_Top_tag;
5090 0 : ret = 0;
5091 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
5092 0 : size_t Top_tag_for_oldret = ret;
5093 0 : ret = 0;
5094 0 : ret += der_length_unsigned(&(data)->val[n_Top_tag - 1]);
5095 0 : ret += 1 + der_length_len (ret);
5096 0 : ret += Top_tag_for_oldret;
5097 : }
5098 0 : ret += Top_tag_oldret;
5099 : }
5100 0 : ret += 1 + der_length_len (ret);
5101 0 : return ret;
5102 : }
5103 :
5104 : int ASN1CALL
5105 0 : copy_HDB_EncTypeList(const HDB_EncTypeList *from, HDB_EncTypeList *to)
5106 : {
5107 0 : memset(to, 0, sizeof(*to));
5108 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
5109 0 : goto fail;
5110 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
5111 0 : *(&(to)->val[(to)->len]) = *(&(from)->val[(to)->len]);
5112 : }
5113 0 : return 0;
5114 0 : fail:
5115 0 : free_HDB_EncTypeList(to);
5116 0 : return ENOMEM;
5117 : }
5118 :
5119 : char * ASN1CALL
5120 0 : print_HDB_EncTypeList(const HDB_EncTypeList *data, int flags)
5121 0 : { errno = EINVAL; return 0; }
5122 :
5123 : int ASN1CALL
5124 0 : encode_HDB_entry(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_entry *data, size_t *size)
5125 : {
5126 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
5127 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
5128 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
5129 :
5130 : /* session-etypes */
5131 0 : if((data)->session_etypes) {
5132 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5133 0 : ret = 0;
5134 0 : e = encode_HDB_EncTypeList(p, len, (data)->session_etypes, &l);
5135 0 : if (e) return e;
5136 0 : p -= l; len -= l; ret += l;
5137 :
5138 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 14, &l);
5139 0 : if (e) return e;
5140 0 : p -= l; len -= l; ret += l;
5141 :
5142 0 : ret += Top_tag_oldret;
5143 : }
5144 : /* extensions */
5145 0 : if((data)->extensions) {
5146 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5147 0 : ret = 0;
5148 0 : e = encode_HDB_extensions(p, len, (data)->extensions, &l);
5149 0 : if (e) return e;
5150 0 : p -= l; len -= l; ret += l;
5151 :
5152 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 13, &l);
5153 0 : if (e) return e;
5154 0 : p -= l; len -= l; ret += l;
5155 :
5156 0 : ret += Top_tag_oldret;
5157 : }
5158 : /* generation */
5159 0 : if((data)->generation) {
5160 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5161 0 : ret = 0;
5162 0 : e = encode_GENERATION(p, len, (data)->generation, &l);
5163 0 : if (e) return e;
5164 0 : p -= l; len -= l; ret += l;
5165 :
5166 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 12, &l);
5167 0 : if (e) return e;
5168 0 : p -= l; len -= l; ret += l;
5169 :
5170 0 : ret += Top_tag_oldret;
5171 : }
5172 : /* etypes */
5173 0 : if((data)->etypes) {
5174 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5175 0 : ret = 0;
5176 0 : e = encode_HDB_EncTypeList(p, len, (data)->etypes, &l);
5177 0 : if (e) return e;
5178 0 : p -= l; len -= l; ret += l;
5179 :
5180 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 11, &l);
5181 0 : if (e) return e;
5182 0 : p -= l; len -= l; ret += l;
5183 :
5184 0 : ret += Top_tag_oldret;
5185 : }
5186 : /* flags */
5187 : {
5188 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5189 0 : ret = 0;
5190 0 : e = encode_HDBFlags(p, len, &(data)->flags, &l);
5191 0 : if (e) return e;
5192 0 : p -= l; len -= l; ret += l;
5193 :
5194 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 10, &l);
5195 0 : if (e) return e;
5196 0 : p -= l; len -= l; ret += l;
5197 :
5198 0 : ret += Top_tag_oldret;
5199 : }
5200 : /* max-renew */
5201 0 : if((data)->max_renew) {
5202 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5203 0 : ret = 0;
5204 0 : e = der_put_unsigned(p, len, (data)->max_renew, &l);
5205 0 : if (e) return e;
5206 0 : p -= l; len -= l; ret += l;
5207 :
5208 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
5209 0 : if (e) return e;
5210 0 : p -= l; len -= l; ret += l;
5211 :
5212 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 9, &l);
5213 0 : if (e) return e;
5214 0 : p -= l; len -= l; ret += l;
5215 :
5216 0 : ret += Top_tag_oldret;
5217 : }
5218 : /* max-life */
5219 0 : if((data)->max_life) {
5220 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5221 0 : ret = 0;
5222 0 : e = der_put_unsigned(p, len, (data)->max_life, &l);
5223 0 : if (e) return e;
5224 0 : p -= l; len -= l; ret += l;
5225 :
5226 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
5227 0 : if (e) return e;
5228 0 : p -= l; len -= l; ret += l;
5229 :
5230 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 8, &l);
5231 0 : if (e) return e;
5232 0 : p -= l; len -= l; ret += l;
5233 :
5234 0 : ret += Top_tag_oldret;
5235 : }
5236 : /* pw-end */
5237 0 : if((data)->pw_end) {
5238 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5239 0 : ret = 0;
5240 0 : e = encode_KerberosTime(p, len, (data)->pw_end, &l);
5241 0 : if (e) return e;
5242 0 : p -= l; len -= l; ret += l;
5243 :
5244 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 7, &l);
5245 0 : if (e) return e;
5246 0 : p -= l; len -= l; ret += l;
5247 :
5248 0 : ret += Top_tag_oldret;
5249 : }
5250 : /* valid-end */
5251 0 : if((data)->valid_end) {
5252 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5253 0 : ret = 0;
5254 0 : e = encode_KerberosTime(p, len, (data)->valid_end, &l);
5255 0 : if (e) return e;
5256 0 : p -= l; len -= l; ret += l;
5257 :
5258 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 6, &l);
5259 0 : if (e) return e;
5260 0 : p -= l; len -= l; ret += l;
5261 :
5262 0 : ret += Top_tag_oldret;
5263 : }
5264 : /* valid-start */
5265 0 : if((data)->valid_start) {
5266 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5267 0 : ret = 0;
5268 0 : e = encode_KerberosTime(p, len, (data)->valid_start, &l);
5269 0 : if (e) return e;
5270 0 : p -= l; len -= l; ret += l;
5271 :
5272 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 5, &l);
5273 0 : if (e) return e;
5274 0 : p -= l; len -= l; ret += l;
5275 :
5276 0 : ret += Top_tag_oldret;
5277 : }
5278 : /* modified-by */
5279 0 : if((data)->modified_by) {
5280 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5281 0 : ret = 0;
5282 0 : e = encode_Event(p, len, (data)->modified_by, &l);
5283 0 : if (e) return e;
5284 0 : p -= l; len -= l; ret += l;
5285 :
5286 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 4, &l);
5287 0 : if (e) return e;
5288 0 : p -= l; len -= l; ret += l;
5289 :
5290 0 : ret += Top_tag_oldret;
5291 : }
5292 : /* created-by */
5293 : {
5294 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5295 0 : ret = 0;
5296 0 : e = encode_Event(p, len, &(data)->created_by, &l);
5297 0 : if (e) return e;
5298 0 : p -= l; len -= l; ret += l;
5299 :
5300 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
5301 0 : if (e) return e;
5302 0 : p -= l; len -= l; ret += l;
5303 :
5304 0 : ret += Top_tag_oldret;
5305 : }
5306 : /* keys */
5307 : {
5308 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5309 0 : ret = 0;
5310 0 : e = encode_Keys(p, len, &(data)->keys, &l);
5311 0 : if (e) return e;
5312 0 : p -= l; len -= l; ret += l;
5313 :
5314 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
5315 0 : if (e) return e;
5316 0 : p -= l; len -= l; ret += l;
5317 :
5318 0 : ret += Top_tag_oldret;
5319 : }
5320 : /* kvno */
5321 : {
5322 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5323 0 : ret = 0;
5324 0 : e = der_put_unsigned(p, len, &(data)->kvno, &l);
5325 0 : if (e) return e;
5326 0 : p -= l; len -= l; ret += l;
5327 :
5328 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
5329 0 : if (e) return e;
5330 0 : p -= l; len -= l; ret += l;
5331 :
5332 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
5333 0 : if (e) return e;
5334 0 : p -= l; len -= l; ret += l;
5335 :
5336 0 : ret += Top_tag_oldret;
5337 : }
5338 : /* principal */
5339 0 : if((data)->principal) {
5340 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5341 0 : ret = 0;
5342 0 : e = encode_Principal(p, len, (data)->principal, &l);
5343 0 : if (e) return e;
5344 0 : p -= l; len -= l; ret += l;
5345 :
5346 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
5347 0 : if (e) return e;
5348 0 : p -= l; len -= l; ret += l;
5349 :
5350 0 : ret += Top_tag_oldret;
5351 : }
5352 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
5353 0 : if (e) return e;
5354 0 : p -= l; len -= l; ret += l;
5355 :
5356 0 : *size = ret;
5357 0 : return 0;
5358 : }
5359 :
5360 : int ASN1CALL
5361 0 : decode_HDB_entry(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_entry *data, size_t *size)
5362 : {
5363 0 : size_t ret = 0;
5364 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
5365 : int e HEIMDAL_UNUSED_ATTRIBUTE;
5366 :
5367 0 : memset(data, 0, sizeof(*data));
5368 : {
5369 : size_t Top_datalen;
5370 : Der_type Top_type;
5371 : size_t Top_oldlen;
5372 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
5373 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
5374 0 : if (e) goto fail;
5375 0 : p += l; len -= l; ret += l;
5376 0 : Top_oldlen = len;
5377 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5378 0 : len = Top_datalen;
5379 : {
5380 : size_t principal_datalen;
5381 : Der_type principal_type;
5382 : size_t principal_oldlen;
5383 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &principal_type, 0, &principal_datalen, &l);
5384 0 : if (e == 0 && principal_type != CONS) { e = ASN1_BAD_ID; }
5385 0 : if(e) {
5386 0 : (data)->principal = NULL;
5387 : } else {
5388 0 : (data)->principal = calloc(1, sizeof(*(data)->principal));
5389 0 : if ((data)->principal == NULL) { e = ENOMEM; goto fail; }
5390 0 : p += l; len -= l; ret += l;
5391 0 : principal_oldlen = len;
5392 0 : if (principal_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5393 0 : len = principal_datalen;
5394 0 : e = decode_Principal(p, len, (data)->principal, &l);
5395 0 : if(e) goto fail;
5396 0 : p += l; len -= l; ret += l;
5397 0 : len = principal_oldlen - principal_datalen;
5398 : }
5399 : }
5400 : {
5401 : size_t kvno_datalen;
5402 : Der_type kvno_type;
5403 : size_t kvno_oldlen;
5404 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &kvno_type, 1, &kvno_datalen, &l);
5405 0 : if (e == 0 && kvno_type != CONS) { e = ASN1_BAD_ID; }
5406 0 : if (e) goto fail;
5407 0 : p += l; len -= l; ret += l;
5408 0 : kvno_oldlen = len;
5409 0 : if (kvno_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5410 0 : len = kvno_datalen;
5411 : {
5412 : size_t kvno_Tag_datalen;
5413 : Der_type kvno_Tag_type;
5414 : size_t kvno_Tag_oldlen;
5415 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &kvno_Tag_type, UT_Integer, &kvno_Tag_datalen, &l);
5416 0 : if (e == 0 && kvno_Tag_type != PRIM) { e = ASN1_BAD_ID; }
5417 0 : if (e) goto fail;
5418 0 : p += l; len -= l; ret += l;
5419 0 : kvno_Tag_oldlen = len;
5420 0 : if (kvno_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5421 0 : len = kvno_Tag_datalen;
5422 0 : e = der_get_unsigned(p, len, &(data)->kvno, &l);
5423 0 : if(e) goto fail;
5424 0 : p += l; len -= l; ret += l;
5425 0 : len = kvno_Tag_oldlen - kvno_Tag_datalen;
5426 : }
5427 0 : len = kvno_oldlen - kvno_datalen;
5428 : }
5429 : {
5430 : size_t keys_datalen;
5431 : Der_type keys_type;
5432 : size_t keys_oldlen;
5433 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &keys_type, 2, &keys_datalen, &l);
5434 0 : if (e == 0 && keys_type != CONS) { e = ASN1_BAD_ID; }
5435 0 : if (e) goto fail;
5436 0 : p += l; len -= l; ret += l;
5437 0 : keys_oldlen = len;
5438 0 : if (keys_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5439 0 : len = keys_datalen;
5440 0 : e = decode_Keys(p, len, &(data)->keys, &l);
5441 0 : if(e) goto fail;
5442 0 : p += l; len -= l; ret += l;
5443 0 : len = keys_oldlen - keys_datalen;
5444 : }
5445 : {
5446 : size_t created_by_datalen;
5447 : Der_type created_by_type;
5448 : size_t created_by_oldlen;
5449 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &created_by_type, 3, &created_by_datalen, &l);
5450 0 : if (e == 0 && created_by_type != CONS) { e = ASN1_BAD_ID; }
5451 0 : if (e) goto fail;
5452 0 : p += l; len -= l; ret += l;
5453 0 : created_by_oldlen = len;
5454 0 : if (created_by_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5455 0 : len = created_by_datalen;
5456 0 : e = decode_Event(p, len, &(data)->created_by, &l);
5457 0 : if(e) goto fail;
5458 0 : p += l; len -= l; ret += l;
5459 0 : len = created_by_oldlen - created_by_datalen;
5460 : }
5461 : {
5462 : size_t modified_by_datalen;
5463 : Der_type modified_by_type;
5464 : size_t modified_by_oldlen;
5465 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &modified_by_type, 4, &modified_by_datalen, &l);
5466 0 : if (e == 0 && modified_by_type != CONS) { e = ASN1_BAD_ID; }
5467 0 : if(e) {
5468 0 : (data)->modified_by = NULL;
5469 : } else {
5470 0 : (data)->modified_by = calloc(1, sizeof(*(data)->modified_by));
5471 0 : if ((data)->modified_by == NULL) { e = ENOMEM; goto fail; }
5472 0 : p += l; len -= l; ret += l;
5473 0 : modified_by_oldlen = len;
5474 0 : if (modified_by_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5475 0 : len = modified_by_datalen;
5476 0 : e = decode_Event(p, len, (data)->modified_by, &l);
5477 0 : if(e) goto fail;
5478 0 : p += l; len -= l; ret += l;
5479 0 : len = modified_by_oldlen - modified_by_datalen;
5480 : }
5481 : }
5482 : {
5483 : size_t valid_start_datalen;
5484 : Der_type valid_start_type;
5485 : size_t valid_start_oldlen;
5486 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &valid_start_type, 5, &valid_start_datalen, &l);
5487 0 : if (e == 0 && valid_start_type != CONS) { e = ASN1_BAD_ID; }
5488 0 : if(e) {
5489 0 : (data)->valid_start = NULL;
5490 : } else {
5491 0 : (data)->valid_start = calloc(1, sizeof(*(data)->valid_start));
5492 0 : if ((data)->valid_start == NULL) { e = ENOMEM; goto fail; }
5493 0 : p += l; len -= l; ret += l;
5494 0 : valid_start_oldlen = len;
5495 0 : if (valid_start_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5496 0 : len = valid_start_datalen;
5497 0 : e = decode_KerberosTime(p, len, (data)->valid_start, &l);
5498 0 : if(e) goto fail;
5499 0 : p += l; len -= l; ret += l;
5500 0 : len = valid_start_oldlen - valid_start_datalen;
5501 : }
5502 : }
5503 : {
5504 : size_t valid_end_datalen;
5505 : Der_type valid_end_type;
5506 : size_t valid_end_oldlen;
5507 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &valid_end_type, 6, &valid_end_datalen, &l);
5508 0 : if (e == 0 && valid_end_type != CONS) { e = ASN1_BAD_ID; }
5509 0 : if(e) {
5510 0 : (data)->valid_end = NULL;
5511 : } else {
5512 0 : (data)->valid_end = calloc(1, sizeof(*(data)->valid_end));
5513 0 : if ((data)->valid_end == NULL) { e = ENOMEM; goto fail; }
5514 0 : p += l; len -= l; ret += l;
5515 0 : valid_end_oldlen = len;
5516 0 : if (valid_end_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5517 0 : len = valid_end_datalen;
5518 0 : e = decode_KerberosTime(p, len, (data)->valid_end, &l);
5519 0 : if(e) goto fail;
5520 0 : p += l; len -= l; ret += l;
5521 0 : len = valid_end_oldlen - valid_end_datalen;
5522 : }
5523 : }
5524 : {
5525 : size_t pw_end_datalen;
5526 : Der_type pw_end_type;
5527 : size_t pw_end_oldlen;
5528 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &pw_end_type, 7, &pw_end_datalen, &l);
5529 0 : if (e == 0 && pw_end_type != CONS) { e = ASN1_BAD_ID; }
5530 0 : if(e) {
5531 0 : (data)->pw_end = NULL;
5532 : } else {
5533 0 : (data)->pw_end = calloc(1, sizeof(*(data)->pw_end));
5534 0 : if ((data)->pw_end == NULL) { e = ENOMEM; goto fail; }
5535 0 : p += l; len -= l; ret += l;
5536 0 : pw_end_oldlen = len;
5537 0 : if (pw_end_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5538 0 : len = pw_end_datalen;
5539 0 : e = decode_KerberosTime(p, len, (data)->pw_end, &l);
5540 0 : if(e) goto fail;
5541 0 : p += l; len -= l; ret += l;
5542 0 : len = pw_end_oldlen - pw_end_datalen;
5543 : }
5544 : }
5545 : {
5546 : size_t max_life_datalen;
5547 : Der_type max_life_type;
5548 : size_t max_life_oldlen;
5549 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &max_life_type, 8, &max_life_datalen, &l);
5550 0 : if (e == 0 && max_life_type != CONS) { e = ASN1_BAD_ID; }
5551 0 : if(e) {
5552 0 : (data)->max_life = NULL;
5553 : } else {
5554 0 : (data)->max_life = calloc(1, sizeof(*(data)->max_life));
5555 0 : if ((data)->max_life == NULL) { e = ENOMEM; goto fail; }
5556 0 : p += l; len -= l; ret += l;
5557 0 : max_life_oldlen = len;
5558 0 : if (max_life_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5559 0 : len = max_life_datalen;
5560 : {
5561 : size_t max_life_Tag_datalen;
5562 : Der_type max_life_Tag_type;
5563 : size_t max_life_Tag_oldlen;
5564 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &max_life_Tag_type, UT_Integer, &max_life_Tag_datalen, &l);
5565 0 : if (e == 0 && max_life_Tag_type != PRIM) { e = ASN1_BAD_ID; }
5566 0 : if (e) goto fail;
5567 0 : p += l; len -= l; ret += l;
5568 0 : max_life_Tag_oldlen = len;
5569 0 : if (max_life_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5570 0 : len = max_life_Tag_datalen;
5571 0 : e = der_get_unsigned(p, len, (data)->max_life, &l);
5572 0 : if(e) goto fail;
5573 0 : p += l; len -= l; ret += l;
5574 0 : len = max_life_Tag_oldlen - max_life_Tag_datalen;
5575 : }
5576 0 : len = max_life_oldlen - max_life_datalen;
5577 : }
5578 : }
5579 : {
5580 : size_t max_renew_datalen;
5581 : Der_type max_renew_type;
5582 : size_t max_renew_oldlen;
5583 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &max_renew_type, 9, &max_renew_datalen, &l);
5584 0 : if (e == 0 && max_renew_type != CONS) { e = ASN1_BAD_ID; }
5585 0 : if(e) {
5586 0 : (data)->max_renew = NULL;
5587 : } else {
5588 0 : (data)->max_renew = calloc(1, sizeof(*(data)->max_renew));
5589 0 : if ((data)->max_renew == NULL) { e = ENOMEM; goto fail; }
5590 0 : p += l; len -= l; ret += l;
5591 0 : max_renew_oldlen = len;
5592 0 : if (max_renew_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5593 0 : len = max_renew_datalen;
5594 : {
5595 : size_t max_renew_Tag_datalen;
5596 : Der_type max_renew_Tag_type;
5597 : size_t max_renew_Tag_oldlen;
5598 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &max_renew_Tag_type, UT_Integer, &max_renew_Tag_datalen, &l);
5599 0 : if (e == 0 && max_renew_Tag_type != PRIM) { e = ASN1_BAD_ID; }
5600 0 : if (e) goto fail;
5601 0 : p += l; len -= l; ret += l;
5602 0 : max_renew_Tag_oldlen = len;
5603 0 : if (max_renew_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5604 0 : len = max_renew_Tag_datalen;
5605 0 : e = der_get_unsigned(p, len, (data)->max_renew, &l);
5606 0 : if(e) goto fail;
5607 0 : p += l; len -= l; ret += l;
5608 0 : len = max_renew_Tag_oldlen - max_renew_Tag_datalen;
5609 : }
5610 0 : len = max_renew_oldlen - max_renew_datalen;
5611 : }
5612 : }
5613 : {
5614 : size_t flags_datalen;
5615 : Der_type flags_type;
5616 : size_t flags_oldlen;
5617 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &flags_type, 10, &flags_datalen, &l);
5618 0 : if (e == 0 && flags_type != CONS) { e = ASN1_BAD_ID; }
5619 0 : if (e) goto fail;
5620 0 : p += l; len -= l; ret += l;
5621 0 : flags_oldlen = len;
5622 0 : if (flags_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5623 0 : len = flags_datalen;
5624 0 : e = decode_HDBFlags(p, len, &(data)->flags, &l);
5625 0 : if(e) goto fail;
5626 0 : p += l; len -= l; ret += l;
5627 0 : len = flags_oldlen - flags_datalen;
5628 : }
5629 : {
5630 : size_t etypes_datalen;
5631 : Der_type etypes_type;
5632 : size_t etypes_oldlen;
5633 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &etypes_type, 11, &etypes_datalen, &l);
5634 0 : if (e == 0 && etypes_type != CONS) { e = ASN1_BAD_ID; }
5635 0 : if(e) {
5636 0 : (data)->etypes = NULL;
5637 : } else {
5638 0 : (data)->etypes = calloc(1, sizeof(*(data)->etypes));
5639 0 : if ((data)->etypes == NULL) { e = ENOMEM; goto fail; }
5640 0 : p += l; len -= l; ret += l;
5641 0 : etypes_oldlen = len;
5642 0 : if (etypes_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5643 0 : len = etypes_datalen;
5644 0 : e = decode_HDB_EncTypeList(p, len, (data)->etypes, &l);
5645 0 : if(e) goto fail;
5646 0 : p += l; len -= l; ret += l;
5647 0 : len = etypes_oldlen - etypes_datalen;
5648 : }
5649 : }
5650 : {
5651 : size_t generation_datalen;
5652 : Der_type generation_type;
5653 : size_t generation_oldlen;
5654 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &generation_type, 12, &generation_datalen, &l);
5655 0 : if (e == 0 && generation_type != CONS) { e = ASN1_BAD_ID; }
5656 0 : if(e) {
5657 0 : (data)->generation = NULL;
5658 : } else {
5659 0 : (data)->generation = calloc(1, sizeof(*(data)->generation));
5660 0 : if ((data)->generation == NULL) { e = ENOMEM; goto fail; }
5661 0 : p += l; len -= l; ret += l;
5662 0 : generation_oldlen = len;
5663 0 : if (generation_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5664 0 : len = generation_datalen;
5665 0 : e = decode_GENERATION(p, len, (data)->generation, &l);
5666 0 : if(e) goto fail;
5667 0 : p += l; len -= l; ret += l;
5668 0 : len = generation_oldlen - generation_datalen;
5669 : }
5670 : }
5671 : {
5672 : size_t extensions_datalen;
5673 : Der_type extensions_type;
5674 : size_t extensions_oldlen;
5675 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &extensions_type, 13, &extensions_datalen, &l);
5676 0 : if (e == 0 && extensions_type != CONS) { e = ASN1_BAD_ID; }
5677 0 : if(e) {
5678 0 : (data)->extensions = NULL;
5679 : } else {
5680 0 : (data)->extensions = calloc(1, sizeof(*(data)->extensions));
5681 0 : if ((data)->extensions == NULL) { e = ENOMEM; goto fail; }
5682 0 : p += l; len -= l; ret += l;
5683 0 : extensions_oldlen = len;
5684 0 : if (extensions_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5685 0 : len = extensions_datalen;
5686 0 : e = decode_HDB_extensions(p, len, (data)->extensions, &l);
5687 0 : if(e) goto fail;
5688 0 : p += l; len -= l; ret += l;
5689 0 : len = extensions_oldlen - extensions_datalen;
5690 : }
5691 : }
5692 : {
5693 : size_t session_etypes_datalen;
5694 : Der_type session_etypes_type;
5695 : size_t session_etypes_oldlen;
5696 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &session_etypes_type, 14, &session_etypes_datalen, &l);
5697 0 : if (e == 0 && session_etypes_type != CONS) { e = ASN1_BAD_ID; }
5698 0 : if(e) {
5699 0 : (data)->session_etypes = NULL;
5700 : } else {
5701 0 : (data)->session_etypes = calloc(1, sizeof(*(data)->session_etypes));
5702 0 : if ((data)->session_etypes == NULL) { e = ENOMEM; goto fail; }
5703 0 : p += l; len -= l; ret += l;
5704 0 : session_etypes_oldlen = len;
5705 0 : if (session_etypes_datalen > len) { e = ASN1_OVERRUN; goto fail; }
5706 0 : len = session_etypes_datalen;
5707 0 : e = decode_HDB_EncTypeList(p, len, (data)->session_etypes, &l);
5708 0 : if(e) goto fail;
5709 0 : p += l; len -= l; ret += l;
5710 0 : len = session_etypes_oldlen - session_etypes_datalen;
5711 : }
5712 : }
5713 0 : len = Top_oldlen - Top_datalen;
5714 : }
5715 0 : if(size) *size = ret;
5716 0 : return 0;
5717 0 : fail:
5718 0 : free_HDB_entry(data);
5719 0 : return e;
5720 : }
5721 :
5722 : void ASN1CALL
5723 214228 : free_HDB_entry(HDB_entry *data)
5724 : {
5725 214228 : if((data)->principal) {
5726 209651 : free_Principal((data)->principal);
5727 209651 : free((data)->principal);
5728 209651 : (data)->principal = NULL;
5729 : }
5730 214228 : *&(data)->kvno = 0;
5731 214228 : free_Keys(&(data)->keys);
5732 214228 : free_Event(&(data)->created_by);
5733 214228 : if((data)->modified_by) {
5734 0 : free_Event((data)->modified_by);
5735 0 : free((data)->modified_by);
5736 0 : (data)->modified_by = NULL;
5737 : }
5738 214228 : if((data)->valid_start) {
5739 0 : free_KerberosTime((data)->valid_start);
5740 0 : free((data)->valid_start);
5741 0 : (data)->valid_start = NULL;
5742 : }
5743 214228 : if((data)->valid_end) {
5744 0 : free_KerberosTime((data)->valid_end);
5745 0 : free((data)->valid_end);
5746 0 : (data)->valid_end = NULL;
5747 : }
5748 214228 : if((data)->pw_end) {
5749 54790 : free_KerberosTime((data)->pw_end);
5750 54790 : free((data)->pw_end);
5751 54790 : (data)->pw_end = NULL;
5752 : }
5753 214228 : if((data)->max_life) {
5754 206468 : *(data)->max_life = 0;
5755 206468 : free((data)->max_life);
5756 206468 : (data)->max_life = NULL;
5757 : }
5758 214228 : if((data)->max_renew) {
5759 206468 : *(data)->max_renew = 0;
5760 206468 : free((data)->max_renew);
5761 206468 : (data)->max_renew = NULL;
5762 : }
5763 214228 : free_HDBFlags(&(data)->flags);
5764 214228 : if((data)->etypes) {
5765 207615 : free_HDB_EncTypeList((data)->etypes);
5766 207615 : free((data)->etypes);
5767 207615 : (data)->etypes = NULL;
5768 : }
5769 214228 : if((data)->generation) {
5770 0 : free_GENERATION((data)->generation);
5771 0 : free((data)->generation);
5772 0 : (data)->generation = NULL;
5773 : }
5774 214228 : if((data)->extensions) {
5775 0 : free_HDB_extensions((data)->extensions);
5776 0 : free((data)->extensions);
5777 0 : (data)->extensions = NULL;
5778 : }
5779 214228 : if((data)->session_etypes) {
5780 155025 : free_HDB_EncTypeList((data)->session_etypes);
5781 155025 : free((data)->session_etypes);
5782 155025 : (data)->session_etypes = NULL;
5783 : }
5784 214228 : memset(&(data)->context, 0, sizeof((data)->context));
5785 214228 : }
5786 :
5787 : size_t ASN1CALL
5788 0 : length_HDB_entry(const HDB_entry *data)
5789 : {
5790 0 : size_t ret = 0;
5791 0 : if((data)->principal){
5792 0 : size_t Top_tag_oldret = ret;
5793 0 : ret = 0;
5794 0 : ret += length_Principal((data)->principal);
5795 0 : ret += 1 + der_length_len (ret);
5796 0 : ret += Top_tag_oldret;
5797 : }
5798 : {
5799 0 : size_t Top_tag_oldret = ret;
5800 0 : ret = 0;
5801 0 : ret += der_length_unsigned(&(data)->kvno);
5802 0 : ret += 1 + der_length_len (ret);
5803 0 : ret += 1 + der_length_len (ret);
5804 0 : ret += Top_tag_oldret;
5805 : }
5806 : {
5807 0 : size_t Top_tag_oldret = ret;
5808 0 : ret = 0;
5809 0 : ret += length_Keys(&(data)->keys);
5810 0 : ret += 1 + der_length_len (ret);
5811 0 : ret += Top_tag_oldret;
5812 : }
5813 : {
5814 0 : size_t Top_tag_oldret = ret;
5815 0 : ret = 0;
5816 0 : ret += length_Event(&(data)->created_by);
5817 0 : ret += 1 + der_length_len (ret);
5818 0 : ret += Top_tag_oldret;
5819 : }
5820 0 : if((data)->modified_by){
5821 0 : size_t Top_tag_oldret = ret;
5822 0 : ret = 0;
5823 0 : ret += length_Event((data)->modified_by);
5824 0 : ret += 1 + der_length_len (ret);
5825 0 : ret += Top_tag_oldret;
5826 : }
5827 0 : if((data)->valid_start){
5828 0 : size_t Top_tag_oldret = ret;
5829 0 : ret = 0;
5830 0 : ret += length_KerberosTime((data)->valid_start);
5831 0 : ret += 1 + der_length_len (ret);
5832 0 : ret += Top_tag_oldret;
5833 : }
5834 0 : if((data)->valid_end){
5835 0 : size_t Top_tag_oldret = ret;
5836 0 : ret = 0;
5837 0 : ret += length_KerberosTime((data)->valid_end);
5838 0 : ret += 1 + der_length_len (ret);
5839 0 : ret += Top_tag_oldret;
5840 : }
5841 0 : if((data)->pw_end){
5842 0 : size_t Top_tag_oldret = ret;
5843 0 : ret = 0;
5844 0 : ret += length_KerberosTime((data)->pw_end);
5845 0 : ret += 1 + der_length_len (ret);
5846 0 : ret += Top_tag_oldret;
5847 : }
5848 0 : if((data)->max_life){
5849 0 : size_t Top_tag_oldret = ret;
5850 0 : ret = 0;
5851 0 : ret += der_length_unsigned((data)->max_life);
5852 0 : ret += 1 + der_length_len (ret);
5853 0 : ret += 1 + der_length_len (ret);
5854 0 : ret += Top_tag_oldret;
5855 : }
5856 0 : if((data)->max_renew){
5857 0 : size_t Top_tag_oldret = ret;
5858 0 : ret = 0;
5859 0 : ret += der_length_unsigned((data)->max_renew);
5860 0 : ret += 1 + der_length_len (ret);
5861 0 : ret += 1 + der_length_len (ret);
5862 0 : ret += Top_tag_oldret;
5863 : }
5864 : {
5865 0 : size_t Top_tag_oldret = ret;
5866 0 : ret = 0;
5867 0 : ret += length_HDBFlags(&(data)->flags);
5868 0 : ret += 1 + der_length_len (ret);
5869 0 : ret += Top_tag_oldret;
5870 : }
5871 0 : if((data)->etypes){
5872 0 : size_t Top_tag_oldret = ret;
5873 0 : ret = 0;
5874 0 : ret += length_HDB_EncTypeList((data)->etypes);
5875 0 : ret += 1 + der_length_len (ret);
5876 0 : ret += Top_tag_oldret;
5877 : }
5878 0 : if((data)->generation){
5879 0 : size_t Top_tag_oldret = ret;
5880 0 : ret = 0;
5881 0 : ret += length_GENERATION((data)->generation);
5882 0 : ret += 1 + der_length_len (ret);
5883 0 : ret += Top_tag_oldret;
5884 : }
5885 0 : if((data)->extensions){
5886 0 : size_t Top_tag_oldret = ret;
5887 0 : ret = 0;
5888 0 : ret += length_HDB_extensions((data)->extensions);
5889 0 : ret += 1 + der_length_len (ret);
5890 0 : ret += Top_tag_oldret;
5891 : }
5892 0 : if((data)->session_etypes){
5893 0 : size_t Top_tag_oldret = ret;
5894 0 : ret = 0;
5895 0 : ret += length_HDB_EncTypeList((data)->session_etypes);
5896 0 : ret += 1 + der_length_len (ret);
5897 0 : ret += Top_tag_oldret;
5898 : }
5899 0 : ret += 1 + der_length_len (ret);
5900 0 : return ret;
5901 : }
5902 :
5903 : int ASN1CALL
5904 0 : copy_HDB_entry(const HDB_entry *from, HDB_entry *to)
5905 : {
5906 0 : memset(to, 0, sizeof(*to));
5907 0 : if((from)->principal) {
5908 0 : (to)->principal = calloc(1, sizeof(*(to)->principal));
5909 0 : if((to)->principal == NULL) goto fail;
5910 0 : if(copy_Principal((from)->principal, (to)->principal)) goto fail;
5911 : }else
5912 0 : (to)->principal = NULL;
5913 0 : *(&(to)->kvno) = *(&(from)->kvno);
5914 0 : if(copy_Keys(&(from)->keys, &(to)->keys)) goto fail;
5915 0 : if(copy_Event(&(from)->created_by, &(to)->created_by)) goto fail;
5916 0 : if((from)->modified_by) {
5917 0 : (to)->modified_by = calloc(1, sizeof(*(to)->modified_by));
5918 0 : if((to)->modified_by == NULL) goto fail;
5919 0 : if(copy_Event((from)->modified_by, (to)->modified_by)) goto fail;
5920 : }else
5921 0 : (to)->modified_by = NULL;
5922 0 : if((from)->valid_start) {
5923 0 : (to)->valid_start = calloc(1, sizeof(*(to)->valid_start));
5924 0 : if((to)->valid_start == NULL) goto fail;
5925 0 : if(copy_KerberosTime((from)->valid_start, (to)->valid_start)) goto fail;
5926 : }else
5927 0 : (to)->valid_start = NULL;
5928 0 : if((from)->valid_end) {
5929 0 : (to)->valid_end = calloc(1, sizeof(*(to)->valid_end));
5930 0 : if((to)->valid_end == NULL) goto fail;
5931 0 : if(copy_KerberosTime((from)->valid_end, (to)->valid_end)) goto fail;
5932 : }else
5933 0 : (to)->valid_end = NULL;
5934 0 : if((from)->pw_end) {
5935 0 : (to)->pw_end = calloc(1, sizeof(*(to)->pw_end));
5936 0 : if((to)->pw_end == NULL) goto fail;
5937 0 : if(copy_KerberosTime((from)->pw_end, (to)->pw_end)) goto fail;
5938 : }else
5939 0 : (to)->pw_end = NULL;
5940 0 : if((from)->max_life) {
5941 0 : (to)->max_life = calloc(1, sizeof(*(to)->max_life));
5942 0 : if((to)->max_life == NULL) goto fail;
5943 0 : *((to)->max_life) = *((from)->max_life);
5944 : }else
5945 0 : (to)->max_life = NULL;
5946 0 : if((from)->max_renew) {
5947 0 : (to)->max_renew = calloc(1, sizeof(*(to)->max_renew));
5948 0 : if((to)->max_renew == NULL) goto fail;
5949 0 : *((to)->max_renew) = *((from)->max_renew);
5950 : }else
5951 0 : (to)->max_renew = NULL;
5952 0 : if(copy_HDBFlags(&(from)->flags, &(to)->flags)) goto fail;
5953 0 : if((from)->etypes) {
5954 0 : (to)->etypes = calloc(1, sizeof(*(to)->etypes));
5955 0 : if((to)->etypes == NULL) goto fail;
5956 0 : if(copy_HDB_EncTypeList((from)->etypes, (to)->etypes)) goto fail;
5957 : }else
5958 0 : (to)->etypes = NULL;
5959 0 : if((from)->generation) {
5960 0 : (to)->generation = calloc(1, sizeof(*(to)->generation));
5961 0 : if((to)->generation == NULL) goto fail;
5962 0 : if(copy_GENERATION((from)->generation, (to)->generation)) goto fail;
5963 : }else
5964 0 : (to)->generation = NULL;
5965 0 : if((from)->extensions) {
5966 0 : (to)->extensions = calloc(1, sizeof(*(to)->extensions));
5967 0 : if((to)->extensions == NULL) goto fail;
5968 0 : if(copy_HDB_extensions((from)->extensions, (to)->extensions)) goto fail;
5969 : }else
5970 0 : (to)->extensions = NULL;
5971 0 : if((from)->session_etypes) {
5972 0 : (to)->session_etypes = calloc(1, sizeof(*(to)->session_etypes));
5973 0 : if((to)->session_etypes == NULL) goto fail;
5974 0 : if(copy_HDB_EncTypeList((from)->session_etypes, (to)->session_etypes)) goto fail;
5975 : }else
5976 0 : (to)->session_etypes = NULL;
5977 0 : memset(&(to)->context, 0, sizeof((to)->context));
5978 0 : return 0;
5979 0 : fail:
5980 0 : free_HDB_entry(to);
5981 0 : return ENOMEM;
5982 : }
5983 :
5984 : char * ASN1CALL
5985 0 : print_HDB_entry(const HDB_entry *data, int flags)
5986 0 : { errno = EINVAL; return 0; }
5987 :
5988 : int ASN1CALL
5989 0 : encode_HDB_entry_alias(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_entry_alias *data, size_t *size)
5990 : {
5991 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
5992 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
5993 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
5994 :
5995 : /* principal */
5996 0 : if((data)->principal) {
5997 0 : size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
5998 0 : ret = 0;
5999 0 : e = encode_Principal(p, len, (data)->principal, &l);
6000 0 : if (e) return e;
6001 0 : p -= l; len -= l; ret += l;
6002 :
6003 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
6004 0 : if (e) return e;
6005 0 : p -= l; len -= l; ret += l;
6006 :
6007 0 : ret += Top_tag_tag_oldret;
6008 : }
6009 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
6010 0 : if (e) return e;
6011 0 : p -= l; len -= l; ret += l;
6012 :
6013 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_APPL, CONS, 0, &l);
6014 0 : if (e) return e;
6015 0 : p -= l; len -= l; ret += l;
6016 :
6017 0 : *size = ret;
6018 0 : return 0;
6019 : }
6020 :
6021 : int ASN1CALL
6022 0 : decode_HDB_entry_alias(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_entry_alias *data, size_t *size)
6023 : {
6024 0 : size_t ret = 0;
6025 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
6026 : int e HEIMDAL_UNUSED_ATTRIBUTE;
6027 :
6028 0 : memset(data, 0, sizeof(*data));
6029 : {
6030 : size_t Top_datalen;
6031 : Der_type Top_type;
6032 : size_t Top_oldlen;
6033 0 : e = der_match_tag_and_length(p, len, ASN1_C_APPL, &Top_type, 0, &Top_datalen, &l);
6034 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
6035 0 : if (e) goto fail;
6036 0 : p += l; len -= l; ret += l;
6037 0 : Top_oldlen = len;
6038 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
6039 0 : len = Top_datalen;
6040 : {
6041 : size_t Top_Tag_datalen;
6042 : Der_type Top_Tag_type;
6043 : size_t Top_Tag_oldlen;
6044 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_type, UT_Sequence, &Top_Tag_datalen, &l);
6045 0 : if (e == 0 && Top_Tag_type != CONS) { e = ASN1_BAD_ID; }
6046 0 : if (e) goto fail;
6047 0 : p += l; len -= l; ret += l;
6048 0 : Top_Tag_oldlen = len;
6049 0 : if (Top_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
6050 0 : len = Top_Tag_datalen;
6051 : {
6052 : size_t principal_datalen;
6053 : Der_type principal_type;
6054 : size_t principal_oldlen;
6055 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &principal_type, 0, &principal_datalen, &l);
6056 0 : if (e == 0 && principal_type != CONS) { e = ASN1_BAD_ID; }
6057 0 : if(e) {
6058 0 : (data)->principal = NULL;
6059 : } else {
6060 0 : (data)->principal = calloc(1, sizeof(*(data)->principal));
6061 0 : if ((data)->principal == NULL) { e = ENOMEM; goto fail; }
6062 0 : p += l; len -= l; ret += l;
6063 0 : principal_oldlen = len;
6064 0 : if (principal_datalen > len) { e = ASN1_OVERRUN; goto fail; }
6065 0 : len = principal_datalen;
6066 0 : e = decode_Principal(p, len, (data)->principal, &l);
6067 0 : if(e) goto fail;
6068 0 : p += l; len -= l; ret += l;
6069 0 : len = principal_oldlen - principal_datalen;
6070 : }
6071 : }
6072 0 : len = Top_Tag_oldlen - Top_Tag_datalen;
6073 : }
6074 0 : len = Top_oldlen - Top_datalen;
6075 : }
6076 0 : if(size) *size = ret;
6077 0 : return 0;
6078 0 : fail:
6079 0 : free_HDB_entry_alias(data);
6080 0 : return e;
6081 : }
6082 :
6083 : void ASN1CALL
6084 0 : free_HDB_entry_alias(HDB_entry_alias *data)
6085 : {
6086 0 : if((data)->principal) {
6087 0 : free_Principal((data)->principal);
6088 0 : free((data)->principal);
6089 0 : (data)->principal = NULL;
6090 : }
6091 0 : }
6092 :
6093 : size_t ASN1CALL
6094 0 : length_HDB_entry_alias(const HDB_entry_alias *data)
6095 : {
6096 0 : size_t ret = 0;
6097 0 : if((data)->principal){
6098 0 : size_t Top_tag_tag_oldret = ret;
6099 0 : ret = 0;
6100 0 : ret += length_Principal((data)->principal);
6101 0 : ret += 1 + der_length_len (ret);
6102 0 : ret += Top_tag_tag_oldret;
6103 : }
6104 0 : ret += 1 + der_length_len (ret);
6105 0 : ret += 1 + der_length_len (ret);
6106 0 : return ret;
6107 : }
6108 :
6109 : int ASN1CALL
6110 0 : copy_HDB_entry_alias(const HDB_entry_alias *from, HDB_entry_alias *to)
6111 : {
6112 0 : memset(to, 0, sizeof(*to));
6113 0 : if((from)->principal) {
6114 0 : (to)->principal = calloc(1, sizeof(*(to)->principal));
6115 0 : if((to)->principal == NULL) goto fail;
6116 0 : if(copy_Principal((from)->principal, (to)->principal)) goto fail;
6117 : }else
6118 0 : (to)->principal = NULL;
6119 0 : return 0;
6120 0 : fail:
6121 0 : free_HDB_entry_alias(to);
6122 0 : return ENOMEM;
6123 : }
6124 :
6125 : char * ASN1CALL
6126 0 : print_HDB_entry_alias(const HDB_entry_alias *data, int flags)
6127 0 : { errno = EINVAL; return 0; }
6128 :
6129 : int ASN1CALL
6130 0 : encode_HDB_EntryOrAlias(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const HDB_EntryOrAlias *data, size_t *size)
6131 : {
6132 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
6133 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
6134 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
6135 :
6136 :
6137 0 : switch((data)->element) {
6138 0 : case choice_HDB_EntryOrAlias_alias: {size_t Top_oldret = ret;
6139 0 : ret = 0;
6140 0 : e = encode_HDB_entry_alias(p, len, &((data))->u.alias, &l);
6141 0 : if (e) return e;
6142 0 : p -= l; len -= l; ret += l;
6143 :
6144 0 : ret += Top_oldret;
6145 0 : break;
6146 : }
6147 0 : case choice_HDB_EntryOrAlias_entry: {size_t Top_oldret = ret;
6148 0 : ret = 0;
6149 0 : e = encode_HDB_entry(p, len, &((data))->u.entry, &l);
6150 0 : if (e) return e;
6151 0 : p -= l; len -= l; ret += l;
6152 :
6153 0 : ret += Top_oldret;
6154 0 : break;
6155 : }
6156 : };
6157 0 : *size = ret;
6158 0 : return 0;
6159 : }
6160 :
6161 : int ASN1CALL
6162 0 : decode_HDB_EntryOrAlias(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, HDB_EntryOrAlias *data, size_t *size)
6163 : {
6164 0 : size_t ret = 0;
6165 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
6166 : int e HEIMDAL_UNUSED_ATTRIBUTE;
6167 :
6168 0 : memset(data, 0, sizeof(*data));
6169 0 : if (der_match_tag(p, len, ASN1_C_UNIV, CONS, UT_Sequence, NULL) == 0) {
6170 0 : (data)->element = choice_HDB_EntryOrAlias_entry;
6171 0 : e = decode_HDB_entry(p, len, &(data)->u.entry, &l);
6172 0 : if(e) goto fail;
6173 0 : p += l; len -= l; ret += l;
6174 : }
6175 0 : else if (der_match_tag(p, len, ASN1_C_APPL, CONS, 0, NULL) == 0) {
6176 0 : (data)->element = choice_HDB_EntryOrAlias_alias;
6177 0 : e = decode_HDB_entry_alias(p, len, &(data)->u.alias, &l);
6178 0 : if(e) goto fail;
6179 0 : p += l; len -= l; ret += l;
6180 : }
6181 : else {
6182 0 : e = ASN1_PARSE_ERROR;
6183 0 : goto fail;
6184 : }
6185 0 : if(size) *size = ret;
6186 0 : return 0;
6187 0 : fail:
6188 0 : free_HDB_EntryOrAlias(data);
6189 0 : return e;
6190 : }
6191 :
6192 : void ASN1CALL
6193 0 : free_HDB_EntryOrAlias(HDB_EntryOrAlias *data)
6194 : {
6195 0 : switch((data)->element) {
6196 0 : case choice_HDB_EntryOrAlias_entry:
6197 0 : free_HDB_entry(&(data)->u.entry);
6198 0 : break;
6199 0 : case choice_HDB_EntryOrAlias_alias:
6200 0 : free_HDB_entry_alias(&(data)->u.alias);
6201 0 : break;
6202 : }
6203 0 : }
6204 :
6205 : size_t ASN1CALL
6206 0 : length_HDB_EntryOrAlias(const HDB_EntryOrAlias *data)
6207 : {
6208 0 : size_t ret = 0;
6209 0 : switch((data)->element) {
6210 0 : case choice_HDB_EntryOrAlias_entry:
6211 : {
6212 0 : size_t Top_oldret = ret;
6213 0 : ret = 0;
6214 0 : ret += length_HDB_entry(&(data)->u.entry);
6215 0 : ret += Top_oldret;
6216 : }
6217 0 : break;
6218 0 : case choice_HDB_EntryOrAlias_alias:
6219 : {
6220 0 : size_t Top_oldret = ret;
6221 0 : ret = 0;
6222 0 : ret += length_HDB_entry_alias(&(data)->u.alias);
6223 0 : ret += Top_oldret;
6224 : }
6225 0 : break;
6226 : }
6227 0 : return ret;
6228 : }
6229 :
6230 : int ASN1CALL
6231 0 : copy_HDB_EntryOrAlias(const HDB_EntryOrAlias *from, HDB_EntryOrAlias *to)
6232 : {
6233 0 : memset(to, 0, sizeof(*to));
6234 0 : (to)->element = (from)->element;
6235 0 : switch((from)->element) {
6236 0 : case choice_HDB_EntryOrAlias_entry:
6237 0 : if(copy_HDB_entry(&(from)->u.entry, &(to)->u.entry)) goto fail;
6238 0 : break;
6239 0 : case choice_HDB_EntryOrAlias_alias:
6240 0 : if(copy_HDB_entry_alias(&(from)->u.alias, &(to)->u.alias)) goto fail;
6241 0 : break;
6242 : }
6243 0 : return 0;
6244 0 : fail:
6245 0 : free_HDB_EntryOrAlias(to);
6246 0 : return ENOMEM;
6247 : }
6248 :
6249 : char * ASN1CALL
6250 0 : print_HDB_EntryOrAlias(const HDB_EntryOrAlias *data, int flags)
6251 0 : { errno = EINVAL; return 0; }
6252 :
|