Line data Source code
1 : /* Generated from /builds/eaglegai/samba/third_party/heimdal/lib/gssapi/spnego/spnego.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 "spnego_asn1.h"
15 : #include "spnego_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_MechType(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const MechType *data, size_t *size)
24 : {
25 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
26 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
27 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
28 :
29 0 : e = der_put_oid(p, len, data, &l);
30 0 : if (e) return e;
31 0 : p -= l; len -= l; ret += l;
32 :
33 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OID, &l);
34 0 : if (e) return e;
35 0 : p -= l; len -= l; ret += l;
36 :
37 0 : *size = ret;
38 0 : return 0;
39 : }
40 :
41 : int ASN1CALL
42 0 : decode_MechType(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, MechType *data, size_t *size)
43 : {
44 0 : size_t ret = 0;
45 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
46 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
47 :
48 0 : memset(data, 0, sizeof(*data));
49 : {
50 0 : size_t Top_datalen;
51 0 : Der_type Top_type;
52 0 : size_t Top_oldlen;
53 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_OID, &Top_datalen, &l);
54 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
55 0 : if (e) goto fail;
56 0 : p += l; len -= l; ret += l;
57 0 : Top_oldlen = len;
58 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
59 0 : len = Top_datalen;
60 0 : e = der_get_oid(p, len, data, &l);
61 0 : if(e) goto fail;
62 0 : p += l; len -= l; ret += l;
63 0 : len = Top_oldlen - Top_datalen;
64 : }
65 0 : if(size) *size = ret;
66 0 : return 0;
67 0 : fail:
68 0 : free_MechType(data);
69 0 : return e;
70 : }
71 :
72 : void ASN1CALL
73 0 : free_MechType(MechType *data)
74 : {
75 0 : der_free_oid(data);
76 0 : }
77 :
78 : size_t ASN1CALL
79 0 : length_MechType(const MechType *data)
80 : {
81 0 : size_t ret = 0;
82 0 : ret += der_length_oid(data);
83 0 : ret += 1 + der_length_len (ret);
84 0 : return ret;
85 : }
86 :
87 : int ASN1CALL
88 0 : copy_MechType(const MechType *from, MechType *to)
89 : {
90 0 : memset(to, 0, sizeof(*to));
91 0 : if(der_copy_oid(from, to)) goto fail;
92 0 : return 0;
93 0 : fail:
94 0 : free_MechType(to);
95 0 : return ENOMEM;
96 : }
97 :
98 : char * ASN1CALL
99 0 : print_MechType(const MechType *data, int flags)
100 0 : { errno = EINVAL; return 0; }
101 :
102 : int ASN1CALL
103 0 : encode_MechTypeList(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const MechTypeList *data, size_t *size)
104 : {
105 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
106 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
107 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
108 :
109 0 : for(i = (int)(data)->len - 1; i >= 0; --i) {
110 0 : size_t Top_tag_for_oldret = ret;
111 0 : ret = 0;
112 0 : e = encode_MechType(p, len, &(data)->val[i], &l);
113 0 : if (e) return e;
114 0 : p -= l; len -= l; ret += l;
115 :
116 0 : ret += Top_tag_for_oldret;
117 : }
118 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
119 0 : if (e) return e;
120 0 : p -= l; len -= l; ret += l;
121 :
122 0 : *size = ret;
123 0 : return 0;
124 : }
125 :
126 : int ASN1CALL
127 0 : decode_MechTypeList(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, MechTypeList *data, size_t *size)
128 : {
129 0 : size_t ret = 0;
130 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
131 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
132 :
133 0 : memset(data, 0, sizeof(*data));
134 : {
135 0 : size_t Top_datalen;
136 0 : Der_type Top_type;
137 0 : size_t Top_oldlen;
138 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
139 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
140 0 : if (e) goto fail;
141 0 : p += l; len -= l; ret += l;
142 0 : Top_oldlen = len;
143 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
144 0 : len = Top_datalen;
145 : {
146 0 : size_t Top_Tag_origlen = len;
147 0 : size_t Top_Tag_oldret = ret;
148 0 : size_t Top_Tag_olen = 0;
149 0 : void *Top_Tag_tmp;
150 0 : ret = 0;
151 0 : (data)->len = 0;
152 0 : (data)->val = NULL;
153 0 : while(ret < Top_Tag_origlen) {
154 0 : size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
155 0 : if (Top_Tag_olen > Top_Tag_nlen) { e = ASN1_OVERFLOW; goto fail; }
156 0 : Top_Tag_olen = Top_Tag_nlen;
157 0 : Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
158 0 : if (Top_Tag_tmp == NULL) { e = ENOMEM; goto fail; }
159 0 : (data)->val = Top_Tag_tmp;
160 0 : e = decode_MechType(p, len, &(data)->val[(data)->len], &l);
161 0 : if(e) goto fail;
162 0 : p += l; len -= l; ret += l;
163 0 : (data)->len++;
164 0 : len = Top_Tag_origlen - ret;
165 : }
166 0 : ret += Top_Tag_oldret;
167 : }
168 0 : len = Top_oldlen - Top_datalen;
169 : }
170 0 : if(size) *size = ret;
171 0 : return 0;
172 0 : fail:
173 0 : free_MechTypeList(data);
174 0 : return e;
175 : }
176 :
177 : void ASN1CALL
178 0 : free_MechTypeList(MechTypeList *data)
179 : {
180 0 : if ((data)->val)
181 0 : while((data)->len){
182 0 : free_MechType(&(data)->val[(data)->len-1]);
183 0 : (data)->len--;
184 0 : } else (data)->len = 0;
185 0 : free((data)->val);
186 0 : (data)->val = NULL;
187 0 : }
188 :
189 : size_t ASN1CALL
190 0 : length_MechTypeList(const MechTypeList *data)
191 : {
192 0 : size_t ret = 0;
193 : {
194 0 : size_t Top_tag_oldret = ret;
195 0 : unsigned int n_Top_tag;
196 0 : ret = 0;
197 0 : for(n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag){
198 0 : size_t Top_tag_for_oldret = ret;
199 0 : ret = 0;
200 0 : ret += length_MechType(&(data)->val[n_Top_tag - 1]);
201 0 : ret += Top_tag_for_oldret;
202 : }
203 0 : ret += Top_tag_oldret;
204 : }
205 0 : ret += 1 + der_length_len (ret);
206 0 : return ret;
207 : }
208 :
209 : int ASN1CALL
210 0 : copy_MechTypeList(const MechTypeList *from, MechTypeList *to)
211 : {
212 0 : memset(to, 0, sizeof(*to));
213 0 : if(((to)->val = calloc(1, (from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
214 0 : goto fail;
215 0 : for((to)->len = 0; (to)->len < (from)->len; (to)->len++){
216 0 : if(copy_MechType(&(from)->val[(to)->len], &(to)->val[(to)->len])) goto fail;
217 : }
218 0 : return 0;
219 0 : fail:
220 0 : free_MechTypeList(to);
221 0 : return ENOMEM;
222 : }
223 :
224 : char * ASN1CALL
225 0 : print_MechTypeList(const MechTypeList *data, int flags)
226 0 : { errno = EINVAL; return 0; }
227 :
228 : int ASN1CALL
229 0 : add_MechTypeList(MechTypeList *data, const MechType *element)
230 : {
231 0 : int ret;
232 0 : void *ptr;
233 :
234 0 : ptr = realloc(data->val,
235 0 : (data->len + 1) * sizeof(data->val[0]));
236 0 : if (ptr == NULL) return ENOMEM;
237 0 : data->val = ptr;
238 :
239 0 : ret = copy_MechType(element, &data->val[data->len]);
240 0 : if (ret) return ret;
241 0 : data->len++;
242 0 : return 0;
243 : }
244 :
245 : int ASN1CALL
246 0 : remove_MechTypeList(MechTypeList *data, unsigned int element)
247 : {
248 0 : void *ptr;
249 :
250 0 : if (data->len == 0 || element >= data->len)
251 0 : return ASN1_OVERRUN;
252 0 : free_MechType(&data->val[element]);
253 0 : data->len--;
254 0 : if (element < data->len)
255 0 : memmove(&data->val[element], &data->val[element + 1],
256 0 : sizeof(data->val[0]) * (data->len - element));
257 0 : ptr = realloc(data->val, data->len * sizeof(data->val[0]));
258 0 : if (ptr != NULL || data->len == 0) data->val = ptr;
259 0 : return 0;
260 : }
261 :
262 : int ASN1CALL
263 0 : encode_ContextFlags(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const ContextFlags *data, size_t *size)
264 : {
265 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
266 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
267 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
268 :
269 : {
270 0 : unsigned char c = 0;
271 0 : int rest = 0;
272 0 : int bit_set = 0;
273 0 : if((data)->integFlag) {
274 0 : c |= 1<<1;
275 : }
276 0 : if((data)->confFlag) {
277 0 : c |= 1<<2;
278 : }
279 0 : if((data)->anonFlag) {
280 0 : c |= 1<<3;
281 : }
282 0 : if((data)->sequenceFlag) {
283 0 : c |= 1<<4;
284 : }
285 0 : if((data)->replayFlag) {
286 0 : c |= 1<<5;
287 : }
288 0 : if((data)->mutualFlag) {
289 0 : c |= 1<<6;
290 : }
291 0 : if((data)->delegFlag) {
292 0 : c |= 1<<7;
293 : }
294 0 : if (c != 0 || bit_set) {
295 0 : if (len < 1) return ASN1_OVERFLOW;
296 0 : *p-- = c; len--; ret++;
297 0 : if (!bit_set) {
298 0 : rest = 0;
299 0 : if(c) {
300 0 : while(c) {
301 0 : if (c & 1) break;
302 0 : c = c >> 1;
303 0 : rest++;
304 : }
305 : }
306 : }
307 : }
308 0 : if (len < 1) return ASN1_OVERFLOW;
309 0 : *p-- = rest;
310 0 : len -= 1;
311 0 : ret += 1;
312 : }
313 :
314 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
315 0 : if (e) return e;
316 0 : p -= l; len -= l; ret += l;
317 :
318 0 : *size = ret;
319 0 : return 0;
320 : }
321 :
322 : int ASN1CALL
323 0 : decode_ContextFlags(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, ContextFlags *data, size_t *size)
324 : {
325 0 : size_t ret = 0;
326 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
327 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
328 :
329 0 : memset(data, 0, sizeof(*data));
330 : {
331 0 : size_t Top_datalen;
332 0 : Der_type Top_type;
333 0 : size_t Top_oldlen;
334 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_BitString, &Top_datalen, &l);
335 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
336 0 : if (e) goto fail;
337 0 : p += l; len -= l; ret += l;
338 0 : Top_oldlen = len;
339 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
340 0 : len = Top_datalen;
341 0 : if (len < 1) return ASN1_OVERRUN;
342 0 : p++; len--; ret++;
343 0 : do {
344 0 : if (len < 1) break;
345 0 : (data)->delegFlag = (*p >> 7) & 1;
346 0 : (data)->mutualFlag = (*p >> 6) & 1;
347 0 : (data)->replayFlag = (*p >> 5) & 1;
348 0 : (data)->sequenceFlag = (*p >> 4) & 1;
349 0 : (data)->anonFlag = (*p >> 3) & 1;
350 0 : (data)->confFlag = (*p >> 2) & 1;
351 0 : (data)->integFlag = (*p >> 1) & 1;
352 : } while(0);
353 0 : p += len; ret += len;
354 0 : len = Top_oldlen - Top_datalen;
355 : }
356 0 : if(size) *size = ret;
357 0 : return 0;
358 0 : fail:
359 0 : free_ContextFlags(data);
360 0 : return e;
361 : }
362 :
363 : void ASN1CALL
364 0 : free_ContextFlags(ContextFlags *data)
365 : {
366 0 : }
367 :
368 : size_t ASN1CALL
369 0 : length_ContextFlags(const ContextFlags *data)
370 : {
371 0 : size_t ret = 0;
372 0 : do {
373 0 : if((data)->integFlag) { ret += 1; break; }
374 0 : if((data)->confFlag) { ret += 1; break; }
375 0 : if((data)->anonFlag) { ret += 1; break; }
376 0 : if((data)->sequenceFlag) { ret += 1; break; }
377 0 : if((data)->replayFlag) { ret += 1; break; }
378 0 : if((data)->mutualFlag) { ret += 1; break; }
379 0 : if((data)->delegFlag) { ret += 1; break; }
380 : } while(0);
381 0 : ret += 1;
382 0 : ret += 1 + der_length_len (ret);
383 0 : return ret;
384 : }
385 :
386 : int ASN1CALL
387 0 : copy_ContextFlags(const ContextFlags *from, ContextFlags *to)
388 : {
389 0 : memset(to, 0, sizeof(*to));
390 0 : *(to) = *(from);
391 0 : return 0;
392 : }
393 :
394 : char * ASN1CALL
395 0 : print_ContextFlags(const ContextFlags *data, int flags)
396 0 : { errno = EINVAL; return 0; }
397 :
398 0 : uint64_t ContextFlags2int(ContextFlags f)
399 : {
400 0 : uint64_t r = 0;
401 0 : if(f.delegFlag) r |= (1ULL << 0);
402 0 : if(f.mutualFlag) r |= (1ULL << 1);
403 0 : if(f.replayFlag) r |= (1ULL << 2);
404 0 : if(f.sequenceFlag) r |= (1ULL << 3);
405 0 : if(f.anonFlag) r |= (1ULL << 4);
406 0 : if(f.confFlag) r |= (1ULL << 5);
407 0 : if(f.integFlag) r |= (1ULL << 6);
408 0 : return r;
409 : }
410 :
411 0 : ContextFlags int2ContextFlags(uint64_t n)
412 : {
413 0 : ContextFlags flags;
414 :
415 0 : memset(&flags, 0, sizeof(flags));
416 :
417 0 : flags.delegFlag = (n >> 0) & 1;
418 0 : flags.mutualFlag = (n >> 1) & 1;
419 0 : flags.replayFlag = (n >> 2) & 1;
420 0 : flags.sequenceFlag = (n >> 3) & 1;
421 0 : flags.anonFlag = (n >> 4) & 1;
422 0 : flags.confFlag = (n >> 5) & 1;
423 0 : flags.integFlag = (n >> 6) & 1;
424 0 : return flags;
425 : }
426 :
427 : static struct units ContextFlags_units[] = {
428 : {"integFlag", 1ULL << 6},
429 : {"confFlag", 1ULL << 5},
430 : {"anonFlag", 1ULL << 4},
431 : {"sequenceFlag", 1ULL << 3},
432 : {"replayFlag", 1ULL << 2},
433 : {"mutualFlag", 1ULL << 1},
434 : {"delegFlag", 1ULL << 0},
435 : {NULL, 0}
436 : };
437 :
438 0 : const struct units * asn1_ContextFlags_units(void){
439 0 : return ContextFlags_units;
440 : }
441 :
442 : int ASN1CALL
443 0 : encode_NegHints(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegHints *data, size_t *size)
444 : {
445 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
446 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
447 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
448 :
449 : /* hintAddress */
450 0 : if((data)->hintAddress) {
451 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
452 0 : ret = 0;
453 0 : e = der_put_octet_string(p, len, (data)->hintAddress, &l);
454 0 : if (e) return e;
455 0 : p -= l; len -= l; ret += l;
456 :
457 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
458 0 : if (e) return e;
459 0 : p -= l; len -= l; ret += l;
460 :
461 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
462 0 : if (e) return e;
463 0 : p -= l; len -= l; ret += l;
464 :
465 0 : ret += Top_tag_oldret;
466 : }
467 : /* hintName */
468 0 : if((data)->hintName) {
469 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
470 0 : ret = 0;
471 0 : e = der_put_general_string(p, len, (data)->hintName, &l);
472 0 : if (e) return e;
473 0 : p -= l; len -= l; ret += l;
474 :
475 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_GeneralString, &l);
476 0 : if (e) return e;
477 0 : p -= l; len -= l; ret += l;
478 :
479 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
480 0 : if (e) return e;
481 0 : p -= l; len -= l; ret += l;
482 :
483 0 : ret += Top_tag_oldret;
484 : }
485 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
486 0 : if (e) return e;
487 0 : p -= l; len -= l; ret += l;
488 :
489 0 : *size = ret;
490 0 : return 0;
491 : }
492 :
493 : int ASN1CALL
494 0 : decode_NegHints(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegHints *data, size_t *size)
495 : {
496 0 : size_t ret = 0;
497 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
498 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
499 :
500 0 : memset(data, 0, sizeof(*data));
501 : {
502 0 : size_t Top_datalen;
503 0 : Der_type Top_type;
504 0 : size_t Top_oldlen;
505 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
506 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
507 0 : if (e) goto fail;
508 0 : p += l; len -= l; ret += l;
509 0 : Top_oldlen = len;
510 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
511 0 : len = Top_datalen;
512 : {
513 0 : size_t hintName_datalen;
514 0 : Der_type hintName_type;
515 0 : size_t hintName_oldlen;
516 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &hintName_type, 0, &hintName_datalen, &l);
517 0 : if (e == 0 && hintName_type != CONS) { e = ASN1_BAD_ID; }
518 0 : if(e) {
519 0 : (data)->hintName = NULL;
520 : } else {
521 0 : (data)->hintName = calloc(1, sizeof(*(data)->hintName));
522 0 : if ((data)->hintName == NULL) { e = ENOMEM; goto fail; }
523 0 : p += l; len -= l; ret += l;
524 0 : hintName_oldlen = len;
525 0 : if (hintName_datalen > len) { e = ASN1_OVERRUN; goto fail; }
526 0 : len = hintName_datalen;
527 : {
528 0 : size_t hintName_Tag_datalen;
529 0 : Der_type hintName_Tag_type;
530 0 : size_t hintName_Tag_oldlen;
531 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &hintName_Tag_type, UT_GeneralString, &hintName_Tag_datalen, &l);
532 0 : if (e == 0 && hintName_Tag_type != PRIM) { e = ASN1_BAD_ID; }
533 0 : if (e) goto fail;
534 0 : p += l; len -= l; ret += l;
535 0 : hintName_Tag_oldlen = len;
536 0 : if (hintName_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
537 0 : len = hintName_Tag_datalen;
538 0 : e = der_get_general_string(p, len, (data)->hintName, &l);
539 0 : if(e) goto fail;
540 0 : p += l; len -= l; ret += l;
541 0 : len = hintName_Tag_oldlen - hintName_Tag_datalen;
542 : }
543 0 : len = hintName_oldlen - hintName_datalen;
544 : }
545 : }
546 : {
547 0 : size_t hintAddress_datalen;
548 0 : Der_type hintAddress_type;
549 0 : size_t hintAddress_oldlen;
550 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &hintAddress_type, 1, &hintAddress_datalen, &l);
551 0 : if (e == 0 && hintAddress_type != CONS) { e = ASN1_BAD_ID; }
552 0 : if(e) {
553 0 : (data)->hintAddress = NULL;
554 : } else {
555 0 : (data)->hintAddress = calloc(1, sizeof(*(data)->hintAddress));
556 0 : if ((data)->hintAddress == NULL) { e = ENOMEM; goto fail; }
557 0 : p += l; len -= l; ret += l;
558 0 : hintAddress_oldlen = len;
559 0 : if (hintAddress_datalen > len) { e = ASN1_OVERRUN; goto fail; }
560 0 : len = hintAddress_datalen;
561 : {
562 0 : size_t hintAddress_Tag_datalen;
563 0 : Der_type hintAddress_Tag_type;
564 0 : size_t hintAddress_Tag_oldlen;
565 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &hintAddress_Tag_type, UT_OctetString, &hintAddress_Tag_datalen, &l);
566 0 : if (e == 0 && hintAddress_Tag_type != PRIM) { e = ASN1_BAD_ID; }
567 0 : if (e) goto fail;
568 0 : p += l; len -= l; ret += l;
569 0 : hintAddress_Tag_oldlen = len;
570 0 : if (hintAddress_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
571 0 : len = hintAddress_Tag_datalen;
572 0 : e = der_get_octet_string(p, len, (data)->hintAddress, &l);
573 0 : if(e) goto fail;
574 0 : p += l; len -= l; ret += l;
575 0 : len = hintAddress_Tag_oldlen - hintAddress_Tag_datalen;
576 : }
577 0 : len = hintAddress_oldlen - hintAddress_datalen;
578 : }
579 : }
580 0 : len = Top_oldlen - Top_datalen;
581 : }
582 0 : if(size) *size = ret;
583 0 : return 0;
584 0 : fail:
585 0 : free_NegHints(data);
586 0 : return e;
587 : }
588 :
589 : void ASN1CALL
590 0 : free_NegHints(NegHints *data)
591 : {
592 0 : if((data)->hintName) {
593 0 : der_free_general_string((data)->hintName);
594 0 : free((data)->hintName);
595 0 : (data)->hintName = NULL;
596 : }
597 0 : if((data)->hintAddress) {
598 0 : der_free_octet_string((data)->hintAddress);
599 0 : free((data)->hintAddress);
600 0 : (data)->hintAddress = NULL;
601 : }
602 0 : }
603 :
604 : size_t ASN1CALL
605 0 : length_NegHints(const NegHints *data)
606 : {
607 0 : size_t ret = 0;
608 0 : if((data)->hintName){
609 0 : size_t Top_tag_oldret = ret;
610 0 : ret = 0;
611 0 : ret += der_length_general_string((data)->hintName);
612 0 : ret += 1 + der_length_len (ret);
613 0 : ret += 1 + der_length_len (ret);
614 0 : ret += Top_tag_oldret;
615 : }
616 0 : if((data)->hintAddress){
617 0 : size_t Top_tag_oldret = ret;
618 0 : ret = 0;
619 0 : ret += der_length_octet_string((data)->hintAddress);
620 0 : ret += 1 + der_length_len (ret);
621 0 : ret += 1 + der_length_len (ret);
622 0 : ret += Top_tag_oldret;
623 : }
624 0 : ret += 1 + der_length_len (ret);
625 0 : return ret;
626 : }
627 :
628 : int ASN1CALL
629 0 : copy_NegHints(const NegHints *from, NegHints *to)
630 : {
631 0 : memset(to, 0, sizeof(*to));
632 0 : if((from)->hintName) {
633 0 : (to)->hintName = calloc(1, sizeof(*(to)->hintName));
634 0 : if((to)->hintName == NULL) goto fail;
635 0 : if(der_copy_general_string((from)->hintName, (to)->hintName)) goto fail;
636 : }else
637 0 : (to)->hintName = NULL;
638 0 : if((from)->hintAddress) {
639 0 : (to)->hintAddress = calloc(1, sizeof(*(to)->hintAddress));
640 0 : if((to)->hintAddress == NULL) goto fail;
641 0 : if(der_copy_octet_string((from)->hintAddress, (to)->hintAddress)) goto fail;
642 : }else
643 0 : (to)->hintAddress = NULL;
644 0 : return 0;
645 0 : fail:
646 0 : free_NegHints(to);
647 0 : return ENOMEM;
648 : }
649 :
650 : char * ASN1CALL
651 0 : print_NegHints(const NegHints *data, int flags)
652 0 : { errno = EINVAL; return 0; }
653 :
654 : int ASN1CALL
655 0 : encode_NegTokenInit2(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegTokenInit2 *data, size_t *size)
656 : {
657 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
658 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
659 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
660 :
661 : /* negHints */
662 0 : if((data)->negHints) {
663 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
664 0 : ret = 0;
665 0 : e = encode_NegHints(p, len, (data)->negHints, &l);
666 0 : if (e) return e;
667 0 : p -= l; len -= l; ret += l;
668 :
669 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
670 0 : if (e) return e;
671 0 : p -= l; len -= l; ret += l;
672 :
673 0 : ret += Top_tag_oldret;
674 : }
675 : /* mechToken */
676 0 : if((data)->mechToken) {
677 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
678 0 : ret = 0;
679 0 : e = der_put_octet_string(p, len, (data)->mechToken, &l);
680 0 : if (e) return e;
681 0 : p -= l; len -= l; ret += l;
682 :
683 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
684 0 : if (e) return e;
685 0 : p -= l; len -= l; ret += l;
686 :
687 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
688 0 : if (e) return e;
689 0 : p -= l; len -= l; ret += l;
690 :
691 0 : ret += Top_tag_oldret;
692 : }
693 : /* reqFlags */
694 0 : if((data)->reqFlags) {
695 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
696 0 : ret = 0;
697 0 : e = encode_ContextFlags(p, len, (data)->reqFlags, &l);
698 0 : if (e) return e;
699 0 : p -= l; len -= l; ret += l;
700 :
701 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
702 0 : if (e) return e;
703 0 : p -= l; len -= l; ret += l;
704 :
705 0 : ret += Top_tag_oldret;
706 : }
707 : /* mechTypes */
708 : {
709 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
710 0 : ret = 0;
711 0 : e = encode_MechTypeList(p, len, &(data)->mechTypes, &l);
712 0 : if (e) return e;
713 0 : p -= l; len -= l; ret += l;
714 :
715 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
716 0 : if (e) return e;
717 0 : p -= l; len -= l; ret += l;
718 :
719 0 : ret += Top_tag_oldret;
720 : }
721 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
722 0 : if (e) return e;
723 0 : p -= l; len -= l; ret += l;
724 :
725 0 : *size = ret;
726 0 : return 0;
727 : }
728 :
729 : int ASN1CALL
730 0 : decode_NegTokenInit2(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegTokenInit2 *data, size_t *size)
731 : {
732 0 : size_t ret = 0;
733 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
734 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
735 :
736 0 : memset(data, 0, sizeof(*data));
737 : {
738 0 : size_t Top_datalen;
739 0 : Der_type Top_type;
740 0 : size_t Top_oldlen;
741 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
742 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
743 0 : if (e) goto fail;
744 0 : p += l; len -= l; ret += l;
745 0 : Top_oldlen = len;
746 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
747 0 : len = Top_datalen;
748 : {
749 0 : size_t mechTypes_datalen;
750 0 : Der_type mechTypes_type;
751 0 : size_t mechTypes_oldlen;
752 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechTypes_type, 0, &mechTypes_datalen, &l);
753 0 : if (e == 0 && mechTypes_type != CONS) { e = ASN1_BAD_ID; }
754 0 : if (e) goto fail;
755 0 : p += l; len -= l; ret += l;
756 0 : mechTypes_oldlen = len;
757 0 : if (mechTypes_datalen > len) { e = ASN1_OVERRUN; goto fail; }
758 0 : len = mechTypes_datalen;
759 0 : e = decode_MechTypeList(p, len, &(data)->mechTypes, &l);
760 0 : if(e) goto fail;
761 0 : p += l; len -= l; ret += l;
762 0 : len = mechTypes_oldlen - mechTypes_datalen;
763 : }
764 : {
765 0 : size_t reqFlags_datalen;
766 0 : Der_type reqFlags_type;
767 0 : size_t reqFlags_oldlen;
768 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &reqFlags_type, 1, &reqFlags_datalen, &l);
769 0 : if (e == 0 && reqFlags_type != CONS) { e = ASN1_BAD_ID; }
770 0 : if(e) {
771 0 : (data)->reqFlags = NULL;
772 : } else {
773 0 : (data)->reqFlags = calloc(1, sizeof(*(data)->reqFlags));
774 0 : if ((data)->reqFlags == NULL) { e = ENOMEM; goto fail; }
775 0 : p += l; len -= l; ret += l;
776 0 : reqFlags_oldlen = len;
777 0 : if (reqFlags_datalen > len) { e = ASN1_OVERRUN; goto fail; }
778 0 : len = reqFlags_datalen;
779 0 : e = decode_ContextFlags(p, len, (data)->reqFlags, &l);
780 0 : if(e) goto fail;
781 0 : p += l; len -= l; ret += l;
782 0 : len = reqFlags_oldlen - reqFlags_datalen;
783 : }
784 : }
785 : {
786 0 : size_t mechToken_datalen;
787 0 : Der_type mechToken_type;
788 0 : size_t mechToken_oldlen;
789 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechToken_type, 2, &mechToken_datalen, &l);
790 0 : if (e == 0 && mechToken_type != CONS) { e = ASN1_BAD_ID; }
791 0 : if(e) {
792 0 : (data)->mechToken = NULL;
793 : } else {
794 0 : (data)->mechToken = calloc(1, sizeof(*(data)->mechToken));
795 0 : if ((data)->mechToken == NULL) { e = ENOMEM; goto fail; }
796 0 : p += l; len -= l; ret += l;
797 0 : mechToken_oldlen = len;
798 0 : if (mechToken_datalen > len) { e = ASN1_OVERRUN; goto fail; }
799 0 : len = mechToken_datalen;
800 : {
801 0 : size_t mechToken_Tag_datalen;
802 0 : Der_type mechToken_Tag_type;
803 0 : size_t mechToken_Tag_oldlen;
804 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mechToken_Tag_type, UT_OctetString, &mechToken_Tag_datalen, &l);
805 0 : if (e == 0 && mechToken_Tag_type != PRIM) { e = ASN1_BAD_ID; }
806 0 : if (e) goto fail;
807 0 : p += l; len -= l; ret += l;
808 0 : mechToken_Tag_oldlen = len;
809 0 : if (mechToken_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
810 0 : len = mechToken_Tag_datalen;
811 0 : e = der_get_octet_string(p, len, (data)->mechToken, &l);
812 0 : if(e) goto fail;
813 0 : p += l; len -= l; ret += l;
814 0 : len = mechToken_Tag_oldlen - mechToken_Tag_datalen;
815 : }
816 0 : len = mechToken_oldlen - mechToken_datalen;
817 : }
818 : }
819 : {
820 0 : size_t negHints_datalen;
821 0 : Der_type negHints_type;
822 0 : size_t negHints_oldlen;
823 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &negHints_type, 3, &negHints_datalen, &l);
824 0 : if (e == 0 && negHints_type != CONS) { e = ASN1_BAD_ID; }
825 0 : if(e) {
826 0 : (data)->negHints = NULL;
827 : } else {
828 0 : (data)->negHints = calloc(1, sizeof(*(data)->negHints));
829 0 : if ((data)->negHints == NULL) { e = ENOMEM; goto fail; }
830 0 : p += l; len -= l; ret += l;
831 0 : negHints_oldlen = len;
832 0 : if (negHints_datalen > len) { e = ASN1_OVERRUN; goto fail; }
833 0 : len = negHints_datalen;
834 0 : e = decode_NegHints(p, len, (data)->negHints, &l);
835 0 : if(e) goto fail;
836 0 : p += l; len -= l; ret += l;
837 0 : len = negHints_oldlen - negHints_datalen;
838 : }
839 : }
840 0 : len = Top_oldlen - Top_datalen;
841 : }
842 0 : if(size) *size = ret;
843 0 : return 0;
844 0 : fail:
845 0 : free_NegTokenInit2(data);
846 0 : return e;
847 : }
848 :
849 : void ASN1CALL
850 0 : free_NegTokenInit2(NegTokenInit2 *data)
851 : {
852 0 : free_MechTypeList(&(data)->mechTypes);
853 0 : if((data)->reqFlags) {
854 0 : free_ContextFlags((data)->reqFlags);
855 0 : free((data)->reqFlags);
856 0 : (data)->reqFlags = NULL;
857 : }
858 0 : if((data)->mechToken) {
859 0 : der_free_octet_string((data)->mechToken);
860 0 : free((data)->mechToken);
861 0 : (data)->mechToken = NULL;
862 : }
863 0 : if((data)->negHints) {
864 0 : free_NegHints((data)->negHints);
865 0 : free((data)->negHints);
866 0 : (data)->negHints = NULL;
867 : }
868 0 : }
869 :
870 : size_t ASN1CALL
871 0 : length_NegTokenInit2(const NegTokenInit2 *data)
872 : {
873 0 : size_t ret = 0;
874 : {
875 0 : size_t Top_tag_oldret = ret;
876 0 : ret = 0;
877 0 : ret += length_MechTypeList(&(data)->mechTypes);
878 0 : ret += 1 + der_length_len (ret);
879 0 : ret += Top_tag_oldret;
880 : }
881 0 : if((data)->reqFlags){
882 0 : size_t Top_tag_oldret = ret;
883 0 : ret = 0;
884 0 : ret += length_ContextFlags((data)->reqFlags);
885 0 : ret += 1 + der_length_len (ret);
886 0 : ret += Top_tag_oldret;
887 : }
888 0 : if((data)->mechToken){
889 0 : size_t Top_tag_oldret = ret;
890 0 : ret = 0;
891 0 : ret += der_length_octet_string((data)->mechToken);
892 0 : ret += 1 + der_length_len (ret);
893 0 : ret += 1 + der_length_len (ret);
894 0 : ret += Top_tag_oldret;
895 : }
896 0 : if((data)->negHints){
897 0 : size_t Top_tag_oldret = ret;
898 0 : ret = 0;
899 0 : ret += length_NegHints((data)->negHints);
900 0 : ret += 1 + der_length_len (ret);
901 0 : ret += Top_tag_oldret;
902 : }
903 0 : ret += 1 + der_length_len (ret);
904 0 : return ret;
905 : }
906 :
907 : int ASN1CALL
908 0 : copy_NegTokenInit2(const NegTokenInit2 *from, NegTokenInit2 *to)
909 : {
910 0 : memset(to, 0, sizeof(*to));
911 0 : if(copy_MechTypeList(&(from)->mechTypes, &(to)->mechTypes)) goto fail;
912 0 : if((from)->reqFlags) {
913 0 : (to)->reqFlags = calloc(1, sizeof(*(to)->reqFlags));
914 0 : if((to)->reqFlags == NULL) goto fail;
915 0 : if(copy_ContextFlags((from)->reqFlags, (to)->reqFlags)) goto fail;
916 : }else
917 0 : (to)->reqFlags = NULL;
918 0 : if((from)->mechToken) {
919 0 : (to)->mechToken = calloc(1, sizeof(*(to)->mechToken));
920 0 : if((to)->mechToken == NULL) goto fail;
921 0 : if(der_copy_octet_string((from)->mechToken, (to)->mechToken)) goto fail;
922 : }else
923 0 : (to)->mechToken = NULL;
924 0 : if((from)->negHints) {
925 0 : (to)->negHints = calloc(1, sizeof(*(to)->negHints));
926 0 : if((to)->negHints == NULL) goto fail;
927 0 : if(copy_NegHints((from)->negHints, (to)->negHints)) goto fail;
928 : }else
929 0 : (to)->negHints = NULL;
930 0 : return 0;
931 0 : fail:
932 0 : free_NegTokenInit2(to);
933 0 : return ENOMEM;
934 : }
935 :
936 : char * ASN1CALL
937 0 : print_NegTokenInit2(const NegTokenInit2 *data, int flags)
938 0 : { errno = EINVAL; return 0; }
939 :
940 : int ASN1CALL
941 0 : encode_NegTokenInit(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegTokenInit *data, size_t *size)
942 : {
943 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
944 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
945 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
946 :
947 : /* mechListMIC */
948 0 : if((data)->mechListMIC) {
949 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
950 0 : ret = 0;
951 0 : e = der_put_octet_string(p, len, (data)->mechListMIC, &l);
952 0 : if (e) return e;
953 0 : p -= l; len -= l; ret += l;
954 :
955 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
956 0 : if (e) return e;
957 0 : p -= l; len -= l; ret += l;
958 :
959 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
960 0 : if (e) return e;
961 0 : p -= l; len -= l; ret += l;
962 :
963 0 : ret += Top_tag_oldret;
964 : }
965 : /* mechToken */
966 0 : if((data)->mechToken) {
967 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
968 0 : ret = 0;
969 0 : e = der_put_octet_string(p, len, (data)->mechToken, &l);
970 0 : if (e) return e;
971 0 : p -= l; len -= l; ret += l;
972 :
973 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
974 0 : if (e) return e;
975 0 : p -= l; len -= l; ret += l;
976 :
977 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
978 0 : if (e) return e;
979 0 : p -= l; len -= l; ret += l;
980 :
981 0 : ret += Top_tag_oldret;
982 : }
983 : /* reqFlags */
984 0 : if((data)->reqFlags) {
985 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
986 0 : ret = 0;
987 0 : e = encode_ContextFlags(p, len, (data)->reqFlags, &l);
988 0 : if (e) return e;
989 0 : p -= l; len -= l; ret += l;
990 :
991 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
992 0 : if (e) return e;
993 0 : p -= l; len -= l; ret += l;
994 :
995 0 : ret += Top_tag_oldret;
996 : }
997 : /* mechTypes */
998 : {
999 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1000 0 : ret = 0;
1001 0 : e = encode_MechTypeList(p, len, &(data)->mechTypes, &l);
1002 0 : if (e) return e;
1003 0 : p -= l; len -= l; ret += l;
1004 :
1005 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1006 0 : if (e) return e;
1007 0 : p -= l; len -= l; ret += l;
1008 :
1009 0 : ret += Top_tag_oldret;
1010 : }
1011 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1012 0 : if (e) return e;
1013 0 : p -= l; len -= l; ret += l;
1014 :
1015 0 : *size = ret;
1016 0 : return 0;
1017 : }
1018 :
1019 : int ASN1CALL
1020 0 : decode_NegTokenInit(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegTokenInit *data, size_t *size)
1021 : {
1022 0 : size_t ret = 0;
1023 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1024 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1025 :
1026 0 : memset(data, 0, sizeof(*data));
1027 : {
1028 0 : size_t Top_datalen;
1029 0 : Der_type Top_type;
1030 0 : size_t Top_oldlen;
1031 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1032 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1033 0 : if (e) goto fail;
1034 0 : p += l; len -= l; ret += l;
1035 0 : Top_oldlen = len;
1036 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1037 0 : len = Top_datalen;
1038 : {
1039 0 : size_t mechTypes_datalen;
1040 0 : Der_type mechTypes_type;
1041 0 : size_t mechTypes_oldlen;
1042 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechTypes_type, 0, &mechTypes_datalen, &l);
1043 0 : if (e == 0 && mechTypes_type != CONS) { e = ASN1_BAD_ID; }
1044 0 : if (e) goto fail;
1045 0 : p += l; len -= l; ret += l;
1046 0 : mechTypes_oldlen = len;
1047 0 : if (mechTypes_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1048 0 : len = mechTypes_datalen;
1049 0 : e = decode_MechTypeList(p, len, &(data)->mechTypes, &l);
1050 0 : if(e) goto fail;
1051 0 : p += l; len -= l; ret += l;
1052 0 : len = mechTypes_oldlen - mechTypes_datalen;
1053 : }
1054 : {
1055 0 : size_t reqFlags_datalen;
1056 0 : Der_type reqFlags_type;
1057 0 : size_t reqFlags_oldlen;
1058 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &reqFlags_type, 1, &reqFlags_datalen, &l);
1059 0 : if (e == 0 && reqFlags_type != CONS) { e = ASN1_BAD_ID; }
1060 0 : if(e) {
1061 0 : (data)->reqFlags = NULL;
1062 : } else {
1063 0 : (data)->reqFlags = calloc(1, sizeof(*(data)->reqFlags));
1064 0 : if ((data)->reqFlags == NULL) { e = ENOMEM; goto fail; }
1065 0 : p += l; len -= l; ret += l;
1066 0 : reqFlags_oldlen = len;
1067 0 : if (reqFlags_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1068 0 : len = reqFlags_datalen;
1069 0 : e = decode_ContextFlags(p, len, (data)->reqFlags, &l);
1070 0 : if(e) goto fail;
1071 0 : p += l; len -= l; ret += l;
1072 0 : len = reqFlags_oldlen - reqFlags_datalen;
1073 : }
1074 : }
1075 : {
1076 0 : size_t mechToken_datalen;
1077 0 : Der_type mechToken_type;
1078 0 : size_t mechToken_oldlen;
1079 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechToken_type, 2, &mechToken_datalen, &l);
1080 0 : if (e == 0 && mechToken_type != CONS) { e = ASN1_BAD_ID; }
1081 0 : if(e) {
1082 0 : (data)->mechToken = NULL;
1083 : } else {
1084 0 : (data)->mechToken = calloc(1, sizeof(*(data)->mechToken));
1085 0 : if ((data)->mechToken == NULL) { e = ENOMEM; goto fail; }
1086 0 : p += l; len -= l; ret += l;
1087 0 : mechToken_oldlen = len;
1088 0 : if (mechToken_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1089 0 : len = mechToken_datalen;
1090 : {
1091 0 : size_t mechToken_Tag_datalen;
1092 0 : Der_type mechToken_Tag_type;
1093 0 : size_t mechToken_Tag_oldlen;
1094 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mechToken_Tag_type, UT_OctetString, &mechToken_Tag_datalen, &l);
1095 0 : if (e == 0 && mechToken_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1096 0 : if (e) goto fail;
1097 0 : p += l; len -= l; ret += l;
1098 0 : mechToken_Tag_oldlen = len;
1099 0 : if (mechToken_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1100 0 : len = mechToken_Tag_datalen;
1101 0 : e = der_get_octet_string(p, len, (data)->mechToken, &l);
1102 0 : if(e) goto fail;
1103 0 : p += l; len -= l; ret += l;
1104 0 : len = mechToken_Tag_oldlen - mechToken_Tag_datalen;
1105 : }
1106 0 : len = mechToken_oldlen - mechToken_datalen;
1107 : }
1108 : }
1109 : {
1110 0 : size_t mechListMIC_datalen;
1111 0 : Der_type mechListMIC_type;
1112 0 : size_t mechListMIC_oldlen;
1113 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechListMIC_type, 3, &mechListMIC_datalen, &l);
1114 0 : if (e == 0 && mechListMIC_type != CONS) { e = ASN1_BAD_ID; }
1115 0 : if(e) {
1116 0 : (data)->mechListMIC = NULL;
1117 : } else {
1118 0 : (data)->mechListMIC = calloc(1, sizeof(*(data)->mechListMIC));
1119 0 : if ((data)->mechListMIC == NULL) { e = ENOMEM; goto fail; }
1120 0 : p += l; len -= l; ret += l;
1121 0 : mechListMIC_oldlen = len;
1122 0 : if (mechListMIC_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1123 0 : len = mechListMIC_datalen;
1124 : {
1125 0 : size_t mechListMIC_Tag_datalen;
1126 0 : Der_type mechListMIC_Tag_type;
1127 0 : size_t mechListMIC_Tag_oldlen;
1128 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mechListMIC_Tag_type, UT_OctetString, &mechListMIC_Tag_datalen, &l);
1129 0 : if (e == 0 && mechListMIC_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1130 0 : if (e) goto fail;
1131 0 : p += l; len -= l; ret += l;
1132 0 : mechListMIC_Tag_oldlen = len;
1133 0 : if (mechListMIC_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1134 0 : len = mechListMIC_Tag_datalen;
1135 0 : e = der_get_octet_string(p, len, (data)->mechListMIC, &l);
1136 0 : if(e) goto fail;
1137 0 : p += l; len -= l; ret += l;
1138 0 : len = mechListMIC_Tag_oldlen - mechListMIC_Tag_datalen;
1139 : }
1140 0 : len = mechListMIC_oldlen - mechListMIC_datalen;
1141 : }
1142 : }
1143 0 : len = Top_oldlen - Top_datalen;
1144 : }
1145 0 : if(size) *size = ret;
1146 0 : return 0;
1147 0 : fail:
1148 0 : free_NegTokenInit(data);
1149 0 : return e;
1150 : }
1151 :
1152 : void ASN1CALL
1153 0 : free_NegTokenInit(NegTokenInit *data)
1154 : {
1155 0 : free_MechTypeList(&(data)->mechTypes);
1156 0 : if((data)->reqFlags) {
1157 0 : free_ContextFlags((data)->reqFlags);
1158 0 : free((data)->reqFlags);
1159 0 : (data)->reqFlags = NULL;
1160 : }
1161 0 : if((data)->mechToken) {
1162 0 : der_free_octet_string((data)->mechToken);
1163 0 : free((data)->mechToken);
1164 0 : (data)->mechToken = NULL;
1165 : }
1166 0 : if((data)->mechListMIC) {
1167 0 : der_free_octet_string((data)->mechListMIC);
1168 0 : free((data)->mechListMIC);
1169 0 : (data)->mechListMIC = NULL;
1170 : }
1171 0 : }
1172 :
1173 : size_t ASN1CALL
1174 0 : length_NegTokenInit(const NegTokenInit *data)
1175 : {
1176 0 : size_t ret = 0;
1177 : {
1178 0 : size_t Top_tag_oldret = ret;
1179 0 : ret = 0;
1180 0 : ret += length_MechTypeList(&(data)->mechTypes);
1181 0 : ret += 1 + der_length_len (ret);
1182 0 : ret += Top_tag_oldret;
1183 : }
1184 0 : if((data)->reqFlags){
1185 0 : size_t Top_tag_oldret = ret;
1186 0 : ret = 0;
1187 0 : ret += length_ContextFlags((data)->reqFlags);
1188 0 : ret += 1 + der_length_len (ret);
1189 0 : ret += Top_tag_oldret;
1190 : }
1191 0 : if((data)->mechToken){
1192 0 : size_t Top_tag_oldret = ret;
1193 0 : ret = 0;
1194 0 : ret += der_length_octet_string((data)->mechToken);
1195 0 : ret += 1 + der_length_len (ret);
1196 0 : ret += 1 + der_length_len (ret);
1197 0 : ret += Top_tag_oldret;
1198 : }
1199 0 : if((data)->mechListMIC){
1200 0 : size_t Top_tag_oldret = ret;
1201 0 : ret = 0;
1202 0 : ret += der_length_octet_string((data)->mechListMIC);
1203 0 : ret += 1 + der_length_len (ret);
1204 0 : ret += 1 + der_length_len (ret);
1205 0 : ret += Top_tag_oldret;
1206 : }
1207 0 : ret += 1 + der_length_len (ret);
1208 0 : return ret;
1209 : }
1210 :
1211 : int ASN1CALL
1212 0 : copy_NegTokenInit(const NegTokenInit *from, NegTokenInit *to)
1213 : {
1214 0 : memset(to, 0, sizeof(*to));
1215 0 : if(copy_MechTypeList(&(from)->mechTypes, &(to)->mechTypes)) goto fail;
1216 0 : if((from)->reqFlags) {
1217 0 : (to)->reqFlags = calloc(1, sizeof(*(to)->reqFlags));
1218 0 : if((to)->reqFlags == NULL) goto fail;
1219 0 : if(copy_ContextFlags((from)->reqFlags, (to)->reqFlags)) goto fail;
1220 : }else
1221 0 : (to)->reqFlags = NULL;
1222 0 : if((from)->mechToken) {
1223 0 : (to)->mechToken = calloc(1, sizeof(*(to)->mechToken));
1224 0 : if((to)->mechToken == NULL) goto fail;
1225 0 : if(der_copy_octet_string((from)->mechToken, (to)->mechToken)) goto fail;
1226 : }else
1227 0 : (to)->mechToken = NULL;
1228 0 : if((from)->mechListMIC) {
1229 0 : (to)->mechListMIC = calloc(1, sizeof(*(to)->mechListMIC));
1230 0 : if((to)->mechListMIC == NULL) goto fail;
1231 0 : if(der_copy_octet_string((from)->mechListMIC, (to)->mechListMIC)) goto fail;
1232 : }else
1233 0 : (to)->mechListMIC = NULL;
1234 0 : return 0;
1235 0 : fail:
1236 0 : free_NegTokenInit(to);
1237 0 : return ENOMEM;
1238 : }
1239 :
1240 : char * ASN1CALL
1241 0 : print_NegTokenInit(const NegTokenInit *data, int flags)
1242 0 : { errno = EINVAL; return 0; }
1243 :
1244 : int ASN1CALL
1245 0 : encode_NegStateEnum(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegStateEnum *data, size_t *size)
1246 : {
1247 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1248 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1249 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1250 :
1251 : {
1252 0 : int enumint = (int)*data;
1253 0 : e = der_put_integer(p, len, &enumint, &l);
1254 0 : if (e) return e;
1255 0 : p -= l; len -= l; ret += l;
1256 :
1257 : }
1258 0 : ;e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_Enumerated, &l);
1259 0 : if (e) return e;
1260 0 : p -= l; len -= l; ret += l;
1261 :
1262 0 : *size = ret;
1263 0 : return 0;
1264 : }
1265 :
1266 : int ASN1CALL
1267 0 : decode_NegStateEnum(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegStateEnum *data, size_t *size)
1268 : {
1269 0 : size_t ret = 0;
1270 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1271 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1272 :
1273 0 : memset(data, 0, sizeof(*data));
1274 : {
1275 0 : size_t Top_datalen;
1276 0 : Der_type Top_type;
1277 0 : size_t Top_oldlen;
1278 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Enumerated, &Top_datalen, &l);
1279 0 : if (e == 0 && Top_type != PRIM) { e = ASN1_BAD_ID; }
1280 0 : if (e) goto fail;
1281 0 : p += l; len -= l; ret += l;
1282 0 : Top_oldlen = len;
1283 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1284 0 : len = Top_datalen;
1285 : {
1286 0 : int enumint;
1287 0 : e = der_get_integer(p, len, &enumint, &l);
1288 0 : if(e) goto fail;
1289 0 : p += l; len -= l; ret += l;
1290 0 : *data = enumint;
1291 : }
1292 0 : len = Top_oldlen - Top_datalen;
1293 : }
1294 0 : if(size) *size = ret;
1295 0 : return 0;
1296 0 : fail:
1297 0 : free_NegStateEnum(data);
1298 0 : return e;
1299 : }
1300 :
1301 : void ASN1CALL
1302 0 : free_NegStateEnum(NegStateEnum *data)
1303 : {
1304 0 : *data = 0;
1305 0 : }
1306 :
1307 : size_t ASN1CALL
1308 0 : length_NegStateEnum(const NegStateEnum *data)
1309 : {
1310 0 : size_t ret = 0;
1311 : {
1312 0 : int enumint = *data;
1313 0 : ret += der_length_integer(&enumint);
1314 : }
1315 0 : ret += 1 + der_length_len (ret);
1316 0 : return ret;
1317 : }
1318 :
1319 : int ASN1CALL
1320 0 : copy_NegStateEnum(const NegStateEnum *from, NegStateEnum *to)
1321 : {
1322 0 : memset(to, 0, sizeof(*to));
1323 0 : *(to) = *(from);
1324 0 : return 0;
1325 : }
1326 :
1327 : char * ASN1CALL
1328 0 : print_NegStateEnum(const NegStateEnum *data, int flags)
1329 0 : { errno = EINVAL; return 0; }
1330 :
1331 : int ASN1CALL
1332 0 : encode_NegTokenResp(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegTokenResp *data, size_t *size)
1333 : {
1334 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1335 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1336 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1337 :
1338 : /* mechListMIC */
1339 0 : if((data)->mechListMIC) {
1340 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1341 0 : ret = 0;
1342 0 : e = der_put_octet_string(p, len, (data)->mechListMIC, &l);
1343 0 : if (e) return e;
1344 0 : p -= l; len -= l; ret += l;
1345 :
1346 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
1347 0 : if (e) return e;
1348 0 : p -= l; len -= l; ret += l;
1349 :
1350 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
1351 0 : if (e) return e;
1352 0 : p -= l; len -= l; ret += l;
1353 :
1354 0 : ret += Top_tag_oldret;
1355 : }
1356 : /* responseToken */
1357 0 : if((data)->responseToken) {
1358 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1359 0 : ret = 0;
1360 0 : e = der_put_octet_string(p, len, (data)->responseToken, &l);
1361 0 : if (e) return e;
1362 0 : p -= l; len -= l; ret += l;
1363 :
1364 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
1365 0 : if (e) return e;
1366 0 : p -= l; len -= l; ret += l;
1367 :
1368 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
1369 0 : if (e) return e;
1370 0 : p -= l; len -= l; ret += l;
1371 :
1372 0 : ret += Top_tag_oldret;
1373 : }
1374 : /* supportedMech */
1375 0 : if((data)->supportedMech) {
1376 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1377 0 : ret = 0;
1378 0 : e = encode_MechType(p, len, (data)->supportedMech, &l);
1379 0 : if (e) return e;
1380 0 : p -= l; len -= l; ret += l;
1381 :
1382 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
1383 0 : if (e) return e;
1384 0 : p -= l; len -= l; ret += l;
1385 :
1386 0 : ret += Top_tag_oldret;
1387 : }
1388 : /* negState */
1389 0 : if((data)->negState) {
1390 0 : size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
1391 0 : ret = 0;
1392 0 : e = encode_NegStateEnum(p, len, (data)->negState, &l);
1393 0 : if (e) return e;
1394 0 : p -= l; len -= l; ret += l;
1395 :
1396 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1397 0 : if (e) return e;
1398 0 : p -= l; len -= l; ret += l;
1399 :
1400 0 : ret += Top_tag_oldret;
1401 : }
1402 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
1403 0 : if (e) return e;
1404 0 : p -= l; len -= l; ret += l;
1405 :
1406 0 : *size = ret;
1407 0 : return 0;
1408 : }
1409 :
1410 : int ASN1CALL
1411 0 : decode_NegTokenResp(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegTokenResp *data, size_t *size)
1412 : {
1413 0 : size_t ret = 0;
1414 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1415 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1416 :
1417 0 : memset(data, 0, sizeof(*data));
1418 : {
1419 0 : size_t Top_datalen;
1420 0 : Der_type Top_type;
1421 0 : size_t Top_oldlen;
1422 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
1423 0 : if (e == 0 && Top_type != CONS) { e = ASN1_BAD_ID; }
1424 0 : if (e) goto fail;
1425 0 : p += l; len -= l; ret += l;
1426 0 : Top_oldlen = len;
1427 0 : if (Top_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1428 0 : len = Top_datalen;
1429 : {
1430 0 : size_t negState_datalen;
1431 0 : Der_type negState_type;
1432 0 : size_t negState_oldlen;
1433 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &negState_type, 0, &negState_datalen, &l);
1434 0 : if (e == 0 && negState_type != CONS) { e = ASN1_BAD_ID; }
1435 0 : if(e) {
1436 0 : (data)->negState = NULL;
1437 : } else {
1438 0 : (data)->negState = calloc(1, sizeof(*(data)->negState));
1439 0 : if ((data)->negState == NULL) { e = ENOMEM; goto fail; }
1440 0 : p += l; len -= l; ret += l;
1441 0 : negState_oldlen = len;
1442 0 : if (negState_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1443 0 : len = negState_datalen;
1444 0 : e = decode_NegStateEnum(p, len, (data)->negState, &l);
1445 0 : if(e) goto fail;
1446 0 : p += l; len -= l; ret += l;
1447 0 : len = negState_oldlen - negState_datalen;
1448 : }
1449 : }
1450 : {
1451 0 : size_t supportedMech_datalen;
1452 0 : Der_type supportedMech_type;
1453 0 : size_t supportedMech_oldlen;
1454 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &supportedMech_type, 1, &supportedMech_datalen, &l);
1455 0 : if (e == 0 && supportedMech_type != CONS) { e = ASN1_BAD_ID; }
1456 0 : if(e) {
1457 0 : (data)->supportedMech = NULL;
1458 : } else {
1459 0 : (data)->supportedMech = calloc(1, sizeof(*(data)->supportedMech));
1460 0 : if ((data)->supportedMech == NULL) { e = ENOMEM; goto fail; }
1461 0 : p += l; len -= l; ret += l;
1462 0 : supportedMech_oldlen = len;
1463 0 : if (supportedMech_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1464 0 : len = supportedMech_datalen;
1465 0 : e = decode_MechType(p, len, (data)->supportedMech, &l);
1466 0 : if(e) goto fail;
1467 0 : p += l; len -= l; ret += l;
1468 0 : len = supportedMech_oldlen - supportedMech_datalen;
1469 : }
1470 : }
1471 : {
1472 0 : size_t responseToken_datalen;
1473 0 : Der_type responseToken_type;
1474 0 : size_t responseToken_oldlen;
1475 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &responseToken_type, 2, &responseToken_datalen, &l);
1476 0 : if (e == 0 && responseToken_type != CONS) { e = ASN1_BAD_ID; }
1477 0 : if(e) {
1478 0 : (data)->responseToken = NULL;
1479 : } else {
1480 0 : (data)->responseToken = calloc(1, sizeof(*(data)->responseToken));
1481 0 : if ((data)->responseToken == NULL) { e = ENOMEM; goto fail; }
1482 0 : p += l; len -= l; ret += l;
1483 0 : responseToken_oldlen = len;
1484 0 : if (responseToken_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1485 0 : len = responseToken_datalen;
1486 : {
1487 0 : size_t responseToken_Tag_datalen;
1488 0 : Der_type responseToken_Tag_type;
1489 0 : size_t responseToken_Tag_oldlen;
1490 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &responseToken_Tag_type, UT_OctetString, &responseToken_Tag_datalen, &l);
1491 0 : if (e == 0 && responseToken_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1492 0 : if (e) goto fail;
1493 0 : p += l; len -= l; ret += l;
1494 0 : responseToken_Tag_oldlen = len;
1495 0 : if (responseToken_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1496 0 : len = responseToken_Tag_datalen;
1497 0 : e = der_get_octet_string(p, len, (data)->responseToken, &l);
1498 0 : if(e) goto fail;
1499 0 : p += l; len -= l; ret += l;
1500 0 : len = responseToken_Tag_oldlen - responseToken_Tag_datalen;
1501 : }
1502 0 : len = responseToken_oldlen - responseToken_datalen;
1503 : }
1504 : }
1505 : {
1506 0 : size_t mechListMIC_datalen;
1507 0 : Der_type mechListMIC_type;
1508 0 : size_t mechListMIC_oldlen;
1509 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &mechListMIC_type, 3, &mechListMIC_datalen, &l);
1510 0 : if (e == 0 && mechListMIC_type != CONS) { e = ASN1_BAD_ID; }
1511 0 : if(e) {
1512 0 : (data)->mechListMIC = NULL;
1513 : } else {
1514 0 : (data)->mechListMIC = calloc(1, sizeof(*(data)->mechListMIC));
1515 0 : if ((data)->mechListMIC == NULL) { e = ENOMEM; goto fail; }
1516 0 : p += l; len -= l; ret += l;
1517 0 : mechListMIC_oldlen = len;
1518 0 : if (mechListMIC_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1519 0 : len = mechListMIC_datalen;
1520 : {
1521 0 : size_t mechListMIC_Tag_datalen;
1522 0 : Der_type mechListMIC_Tag_type;
1523 0 : size_t mechListMIC_Tag_oldlen;
1524 0 : e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &mechListMIC_Tag_type, UT_OctetString, &mechListMIC_Tag_datalen, &l);
1525 0 : if (e == 0 && mechListMIC_Tag_type != PRIM) { e = ASN1_BAD_ID; }
1526 0 : if (e) goto fail;
1527 0 : p += l; len -= l; ret += l;
1528 0 : mechListMIC_Tag_oldlen = len;
1529 0 : if (mechListMIC_Tag_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1530 0 : len = mechListMIC_Tag_datalen;
1531 0 : e = der_get_octet_string(p, len, (data)->mechListMIC, &l);
1532 0 : if(e) goto fail;
1533 0 : p += l; len -= l; ret += l;
1534 0 : len = mechListMIC_Tag_oldlen - mechListMIC_Tag_datalen;
1535 : }
1536 0 : len = mechListMIC_oldlen - mechListMIC_datalen;
1537 : }
1538 : }
1539 0 : len = Top_oldlen - Top_datalen;
1540 : }
1541 0 : if(size) *size = ret;
1542 0 : return 0;
1543 0 : fail:
1544 0 : free_NegTokenResp(data);
1545 0 : return e;
1546 : }
1547 :
1548 : void ASN1CALL
1549 0 : free_NegTokenResp(NegTokenResp *data)
1550 : {
1551 0 : if((data)->negState) {
1552 0 : free_NegStateEnum((data)->negState);
1553 0 : free((data)->negState);
1554 0 : (data)->negState = NULL;
1555 : }
1556 0 : if((data)->supportedMech) {
1557 0 : free_MechType((data)->supportedMech);
1558 0 : free((data)->supportedMech);
1559 0 : (data)->supportedMech = NULL;
1560 : }
1561 0 : if((data)->responseToken) {
1562 0 : der_free_octet_string((data)->responseToken);
1563 0 : free((data)->responseToken);
1564 0 : (data)->responseToken = NULL;
1565 : }
1566 0 : if((data)->mechListMIC) {
1567 0 : der_free_octet_string((data)->mechListMIC);
1568 0 : free((data)->mechListMIC);
1569 0 : (data)->mechListMIC = NULL;
1570 : }
1571 0 : }
1572 :
1573 : size_t ASN1CALL
1574 0 : length_NegTokenResp(const NegTokenResp *data)
1575 : {
1576 0 : size_t ret = 0;
1577 0 : if((data)->negState){
1578 0 : size_t Top_tag_oldret = ret;
1579 0 : ret = 0;
1580 0 : ret += length_NegStateEnum((data)->negState);
1581 0 : ret += 1 + der_length_len (ret);
1582 0 : ret += Top_tag_oldret;
1583 : }
1584 0 : if((data)->supportedMech){
1585 0 : size_t Top_tag_oldret = ret;
1586 0 : ret = 0;
1587 0 : ret += length_MechType((data)->supportedMech);
1588 0 : ret += 1 + der_length_len (ret);
1589 0 : ret += Top_tag_oldret;
1590 : }
1591 0 : if((data)->responseToken){
1592 0 : size_t Top_tag_oldret = ret;
1593 0 : ret = 0;
1594 0 : ret += der_length_octet_string((data)->responseToken);
1595 0 : ret += 1 + der_length_len (ret);
1596 0 : ret += 1 + der_length_len (ret);
1597 0 : ret += Top_tag_oldret;
1598 : }
1599 0 : if((data)->mechListMIC){
1600 0 : size_t Top_tag_oldret = ret;
1601 0 : ret = 0;
1602 0 : ret += der_length_octet_string((data)->mechListMIC);
1603 0 : ret += 1 + der_length_len (ret);
1604 0 : ret += 1 + der_length_len (ret);
1605 0 : ret += Top_tag_oldret;
1606 : }
1607 0 : ret += 1 + der_length_len (ret);
1608 0 : return ret;
1609 : }
1610 :
1611 : int ASN1CALL
1612 0 : copy_NegTokenResp(const NegTokenResp *from, NegTokenResp *to)
1613 : {
1614 0 : memset(to, 0, sizeof(*to));
1615 0 : if((from)->negState) {
1616 0 : (to)->negState = calloc(1, sizeof(*(to)->negState));
1617 0 : if((to)->negState == NULL) goto fail;
1618 0 : if(copy_NegStateEnum((from)->negState, (to)->negState)) goto fail;
1619 : }else
1620 0 : (to)->negState = NULL;
1621 0 : if((from)->supportedMech) {
1622 0 : (to)->supportedMech = calloc(1, sizeof(*(to)->supportedMech));
1623 0 : if((to)->supportedMech == NULL) goto fail;
1624 0 : if(copy_MechType((from)->supportedMech, (to)->supportedMech)) goto fail;
1625 : }else
1626 0 : (to)->supportedMech = NULL;
1627 0 : if((from)->responseToken) {
1628 0 : (to)->responseToken = calloc(1, sizeof(*(to)->responseToken));
1629 0 : if((to)->responseToken == NULL) goto fail;
1630 0 : if(der_copy_octet_string((from)->responseToken, (to)->responseToken)) goto fail;
1631 : }else
1632 0 : (to)->responseToken = NULL;
1633 0 : if((from)->mechListMIC) {
1634 0 : (to)->mechListMIC = calloc(1, sizeof(*(to)->mechListMIC));
1635 0 : if((to)->mechListMIC == NULL) goto fail;
1636 0 : if(der_copy_octet_string((from)->mechListMIC, (to)->mechListMIC)) goto fail;
1637 : }else
1638 0 : (to)->mechListMIC = NULL;
1639 0 : return 0;
1640 0 : fail:
1641 0 : free_NegTokenResp(to);
1642 0 : return ENOMEM;
1643 : }
1644 :
1645 : char * ASN1CALL
1646 0 : print_NegTokenResp(const NegTokenResp *data, int flags)
1647 0 : { errno = EINVAL; return 0; }
1648 :
1649 : int ASN1CALL
1650 0 : encode_NegotiationToken(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegotiationToken *data, size_t *size)
1651 : {
1652 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1653 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1654 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1655 :
1656 :
1657 0 : switch((data)->element) {
1658 0 : case choice_NegotiationToken_negTokenResp: {size_t Top_oldret = ret;
1659 0 : ret = 0;
1660 0 : e = encode_NegTokenResp(p, len, &((data))->u.negTokenResp, &l);
1661 0 : if (e) return e;
1662 0 : p -= l; len -= l; ret += l;
1663 :
1664 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
1665 0 : if (e) return e;
1666 0 : p -= l; len -= l; ret += l;
1667 :
1668 0 : ret += Top_oldret;
1669 0 : break;
1670 : }
1671 0 : case choice_NegotiationToken_negTokenInit: {size_t Top_oldret = ret;
1672 0 : ret = 0;
1673 0 : e = encode_NegTokenInit(p, len, &((data))->u.negTokenInit, &l);
1674 0 : if (e) return e;
1675 0 : p -= l; len -= l; ret += l;
1676 :
1677 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1678 0 : if (e) return e;
1679 0 : p -= l; len -= l; ret += l;
1680 :
1681 0 : ret += Top_oldret;
1682 0 : break;
1683 : }
1684 0 : };
1685 0 : *size = ret;
1686 0 : return 0;
1687 : }
1688 :
1689 : int ASN1CALL
1690 0 : decode_NegotiationToken(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegotiationToken *data, size_t *size)
1691 : {
1692 0 : size_t ret = 0;
1693 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1694 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1695 :
1696 0 : memset(data, 0, sizeof(*data));
1697 0 : if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, NULL) == 0) {
1698 0 : (data)->element = choice_NegotiationToken_negTokenInit;
1699 : {
1700 0 : size_t negTokenInit_datalen;
1701 0 : Der_type negTokenInit_type;
1702 0 : size_t negTokenInit_oldlen;
1703 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &negTokenInit_type, 0, &negTokenInit_datalen, &l);
1704 0 : if (e == 0 && negTokenInit_type != CONS) { e = ASN1_BAD_ID; }
1705 0 : if (e) goto fail;
1706 0 : p += l; len -= l; ret += l;
1707 0 : negTokenInit_oldlen = len;
1708 0 : if (negTokenInit_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1709 0 : len = negTokenInit_datalen;
1710 0 : e = decode_NegTokenInit(p, len, &(data)->u.negTokenInit, &l);
1711 0 : if(e) goto fail;
1712 0 : p += l; len -= l; ret += l;
1713 0 : len = negTokenInit_oldlen - negTokenInit_datalen;
1714 : }
1715 : }
1716 0 : else if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, NULL) == 0) {
1717 0 : (data)->element = choice_NegotiationToken_negTokenResp;
1718 : {
1719 0 : size_t negTokenResp_datalen;
1720 0 : Der_type negTokenResp_type;
1721 0 : size_t negTokenResp_oldlen;
1722 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &negTokenResp_type, 1, &negTokenResp_datalen, &l);
1723 0 : if (e == 0 && negTokenResp_type != CONS) { e = ASN1_BAD_ID; }
1724 0 : if (e) goto fail;
1725 0 : p += l; len -= l; ret += l;
1726 0 : negTokenResp_oldlen = len;
1727 0 : if (negTokenResp_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1728 0 : len = negTokenResp_datalen;
1729 0 : e = decode_NegTokenResp(p, len, &(data)->u.negTokenResp, &l);
1730 0 : if(e) goto fail;
1731 0 : p += l; len -= l; ret += l;
1732 0 : len = negTokenResp_oldlen - negTokenResp_datalen;
1733 : }
1734 : }
1735 : else {
1736 0 : e = ASN1_PARSE_ERROR;
1737 0 : goto fail;
1738 : }
1739 0 : if(size) *size = ret;
1740 0 : return 0;
1741 0 : fail:
1742 0 : free_NegotiationToken(data);
1743 0 : return e;
1744 : }
1745 :
1746 : void ASN1CALL
1747 0 : free_NegotiationToken(NegotiationToken *data)
1748 : {
1749 0 : switch((data)->element) {
1750 0 : case choice_NegotiationToken_negTokenInit:
1751 0 : free_NegTokenInit(&(data)->u.negTokenInit);
1752 0 : break;
1753 0 : case choice_NegotiationToken_negTokenResp:
1754 0 : free_NegTokenResp(&(data)->u.negTokenResp);
1755 0 : break;
1756 : }
1757 0 : }
1758 :
1759 : size_t ASN1CALL
1760 0 : length_NegotiationToken(const NegotiationToken *data)
1761 : {
1762 0 : size_t ret = 0;
1763 0 : switch((data)->element) {
1764 0 : case choice_NegotiationToken_negTokenInit:
1765 : {
1766 0 : size_t Top_oldret = ret;
1767 0 : ret = 0;
1768 0 : ret += length_NegTokenInit(&(data)->u.negTokenInit);
1769 0 : ret += 1 + der_length_len (ret);
1770 0 : ret += Top_oldret;
1771 : }
1772 0 : break;
1773 0 : case choice_NegotiationToken_negTokenResp:
1774 : {
1775 0 : size_t Top_oldret = ret;
1776 0 : ret = 0;
1777 0 : ret += length_NegTokenResp(&(data)->u.negTokenResp);
1778 0 : ret += 1 + der_length_len (ret);
1779 0 : ret += Top_oldret;
1780 : }
1781 0 : break;
1782 : }
1783 0 : return ret;
1784 : }
1785 :
1786 : int ASN1CALL
1787 0 : copy_NegotiationToken(const NegotiationToken *from, NegotiationToken *to)
1788 : {
1789 0 : memset(to, 0, sizeof(*to));
1790 0 : (to)->element = (from)->element;
1791 0 : switch((from)->element) {
1792 0 : case choice_NegotiationToken_negTokenInit:
1793 0 : if(copy_NegTokenInit(&(from)->u.negTokenInit, &(to)->u.negTokenInit)) goto fail;
1794 0 : break;
1795 0 : case choice_NegotiationToken_negTokenResp:
1796 0 : if(copy_NegTokenResp(&(from)->u.negTokenResp, &(to)->u.negTokenResp)) goto fail;
1797 0 : break;
1798 : }
1799 0 : return 0;
1800 0 : fail:
1801 0 : free_NegotiationToken(to);
1802 0 : return ENOMEM;
1803 : }
1804 :
1805 : char * ASN1CALL
1806 0 : print_NegotiationToken(const NegotiationToken *data, int flags)
1807 0 : { errno = EINVAL; return 0; }
1808 :
1809 : int ASN1CALL
1810 0 : encode_NegotiationToken2(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NegotiationToken2 *data, size_t *size)
1811 : {
1812 0 : size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
1813 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1814 0 : int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
1815 :
1816 :
1817 0 : switch((data)->element) {
1818 0 : case choice_NegotiationToken2_negTokenInit: {size_t Top_oldret = ret;
1819 0 : ret = 0;
1820 0 : e = encode_NegTokenInit2(p, len, &((data))->u.negTokenInit, &l);
1821 0 : if (e) return e;
1822 0 : p -= l; len -= l; ret += l;
1823 :
1824 0 : e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
1825 0 : if (e) return e;
1826 0 : p -= l; len -= l; ret += l;
1827 :
1828 0 : ret += Top_oldret;
1829 0 : break;
1830 : }
1831 0 : };
1832 0 : *size = ret;
1833 0 : return 0;
1834 : }
1835 :
1836 : int ASN1CALL
1837 0 : decode_NegotiationToken2(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, NegotiationToken2 *data, size_t *size)
1838 : {
1839 0 : size_t ret = 0;
1840 0 : size_t l HEIMDAL_UNUSED_ATTRIBUTE;
1841 0 : int e HEIMDAL_UNUSED_ATTRIBUTE;
1842 :
1843 0 : memset(data, 0, sizeof(*data));
1844 0 : if (der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, NULL) == 0) {
1845 0 : (data)->element = choice_NegotiationToken2_negTokenInit;
1846 : {
1847 0 : size_t negTokenInit_datalen;
1848 0 : Der_type negTokenInit_type;
1849 0 : size_t negTokenInit_oldlen;
1850 0 : e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &negTokenInit_type, 0, &negTokenInit_datalen, &l);
1851 0 : if (e == 0 && negTokenInit_type != CONS) { e = ASN1_BAD_ID; }
1852 0 : if (e) goto fail;
1853 0 : p += l; len -= l; ret += l;
1854 0 : negTokenInit_oldlen = len;
1855 0 : if (negTokenInit_datalen > len) { e = ASN1_OVERRUN; goto fail; }
1856 0 : len = negTokenInit_datalen;
1857 0 : e = decode_NegTokenInit2(p, len, &(data)->u.negTokenInit, &l);
1858 0 : if(e) goto fail;
1859 0 : p += l; len -= l; ret += l;
1860 0 : len = negTokenInit_oldlen - negTokenInit_datalen;
1861 : }
1862 : }
1863 : else {
1864 0 : e = ASN1_PARSE_ERROR;
1865 0 : goto fail;
1866 : }
1867 0 : if(size) *size = ret;
1868 0 : return 0;
1869 0 : fail:
1870 0 : free_NegotiationToken2(data);
1871 0 : return e;
1872 : }
1873 :
1874 : void ASN1CALL
1875 0 : free_NegotiationToken2(NegotiationToken2 *data)
1876 : {
1877 0 : switch((data)->element) {
1878 0 : case choice_NegotiationToken2_negTokenInit:
1879 0 : free_NegTokenInit2(&(data)->u.negTokenInit);
1880 0 : break;
1881 : }
1882 0 : }
1883 :
1884 : size_t ASN1CALL
1885 0 : length_NegotiationToken2(const NegotiationToken2 *data)
1886 : {
1887 0 : size_t ret = 0;
1888 0 : switch((data)->element) {
1889 0 : case choice_NegotiationToken2_negTokenInit:
1890 : {
1891 0 : size_t Top_oldret = ret;
1892 0 : ret = 0;
1893 0 : ret += length_NegTokenInit2(&(data)->u.negTokenInit);
1894 0 : ret += 1 + der_length_len (ret);
1895 0 : ret += Top_oldret;
1896 : }
1897 0 : break;
1898 : }
1899 0 : return ret;
1900 : }
1901 :
1902 : int ASN1CALL
1903 0 : copy_NegotiationToken2(const NegotiationToken2 *from, NegotiationToken2 *to)
1904 : {
1905 0 : memset(to, 0, sizeof(*to));
1906 0 : (to)->element = (from)->element;
1907 0 : switch((from)->element) {
1908 0 : case choice_NegotiationToken2_negTokenInit:
1909 0 : if(copy_NegTokenInit2(&(from)->u.negTokenInit, &(to)->u.negTokenInit)) goto fail;
1910 0 : break;
1911 : }
1912 0 : return 0;
1913 0 : fail:
1914 0 : free_NegotiationToken2(to);
1915 0 : return ENOMEM;
1916 : }
1917 :
1918 : char * ASN1CALL
1919 0 : print_NegotiationToken2(const NegotiationToken2 *data, int flags)
1920 0 : { errno = EINVAL; return 0; }
1921 :
|