Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / bind / dist / lib / dns / spnego_asn1.c
blob4be473580de0b57830781092569340ced5cc5dc3
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2006, 2007 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 /* Id: spnego_asn1.c,v 1.4 2007/06/19 23:47:16 tbox Exp */
21 /*! \file
22 * \brief Method routines generated from SPNEGO ASN.1 module.
23 * See spnego_asn1.pl for details. Do not edit.
26 /* Generated from spnego.asn1 */
27 /* Do not edit */
29 #ifndef __asn1_h__
30 #define __asn1_h__
33 #ifndef __asn1_common_definitions__
34 #define __asn1_common_definitions__
36 typedef struct octet_string {
37 size_t length;
38 void *data;
39 } octet_string;
41 typedef char *general_string;
43 typedef char *utf8_string;
45 typedef struct oid {
46 size_t length;
47 unsigned *components;
48 } oid;
50 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \
51 do { \
52 (BL) = length_##T((S)); \
53 (B) = malloc((BL)); \
54 if((B) == NULL) { \
55 (R) = ENOMEM; \
56 } else { \
57 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
58 (S), (L)); \
59 if((R) != 0) { \
60 free((B)); \
61 (B) = NULL; \
62 } \
63 } \
64 } while (0)
66 #endif
69 * MechType ::= OBJECT IDENTIFIER
72 typedef oid MechType;
74 static int encode_MechType(unsigned char *, size_t, const MechType *, size_t *);
75 static int decode_MechType(const unsigned char *, size_t, MechType *, size_t *);
76 static void free_MechType(MechType *);
77 /* unused declaration: length_MechType */
78 /* unused declaration: copy_MechType */
82 * MechTypeList ::= SEQUENCE OF MechType
85 typedef struct MechTypeList {
86 unsigned int len;
87 MechType *val;
88 } MechTypeList;
90 static int encode_MechTypeList(unsigned char *, size_t, const MechTypeList *, size_t *);
91 static int decode_MechTypeList(const unsigned char *, size_t, MechTypeList *, size_t *);
92 static void free_MechTypeList(MechTypeList *);
93 /* unused declaration: length_MechTypeList */
94 /* unused declaration: copy_MechTypeList */
98 * ContextFlags ::= BIT STRING { delegFlag(0), mutualFlag(1), replayFlag(2),
99 * sequenceFlag(3), anonFlag(4), confFlag(5), integFlag(6) }
102 typedef struct ContextFlags {
103 unsigned int delegFlag:1;
104 unsigned int mutualFlag:1;
105 unsigned int replayFlag:1;
106 unsigned int sequenceFlag:1;
107 unsigned int anonFlag:1;
108 unsigned int confFlag:1;
109 unsigned int integFlag:1;
110 } ContextFlags;
113 static int encode_ContextFlags(unsigned char *, size_t, const ContextFlags *, size_t *);
114 static int decode_ContextFlags(const unsigned char *, size_t, ContextFlags *, size_t *);
115 static void free_ContextFlags(ContextFlags *);
116 /* unused declaration: length_ContextFlags */
117 /* unused declaration: copy_ContextFlags */
118 /* unused declaration: ContextFlags2int */
119 /* unused declaration: int2ContextFlags */
120 /* unused declaration: asn1_ContextFlags_units */
123 * NegTokenInit ::= SEQUENCE { mechTypes[0] MechTypeList, reqFlags[1]
124 * ContextFlags OPTIONAL, mechToken[2] OCTET STRING OPTIONAL,
125 * mechListMIC[3] OCTET STRING OPTIONAL }
128 typedef struct NegTokenInit {
129 MechTypeList mechTypes;
130 ContextFlags *reqFlags;
131 octet_string *mechToken;
132 octet_string *mechListMIC;
133 } NegTokenInit;
135 static int encode_NegTokenInit(unsigned char *, size_t, const NegTokenInit *, size_t *);
136 static int decode_NegTokenInit(const unsigned char *, size_t, NegTokenInit *, size_t *);
137 static void free_NegTokenInit(NegTokenInit *);
138 /* unused declaration: length_NegTokenInit */
139 /* unused declaration: copy_NegTokenInit */
143 * NegTokenResp ::= SEQUENCE { negState[0] ENUMERATED {
144 * accept-completed(0), accept-incomplete(1), reject(2), request-mic(3) }
145 * OPTIONAL, supportedMech[1] MechType OPTIONAL, responseToken[2] OCTET
146 * STRING OPTIONAL, mechListMIC[3] OCTET STRING OPTIONAL }
149 typedef struct NegTokenResp {
150 enum {
151 accept_completed = 0,
152 accept_incomplete = 1,
153 reject = 2,
154 request_mic = 3
155 } *negState;
157 MechType *supportedMech;
158 octet_string *responseToken;
159 octet_string *mechListMIC;
160 } NegTokenResp;
162 static int encode_NegTokenResp(unsigned char *, size_t, const NegTokenResp *, size_t *);
163 static int decode_NegTokenResp(const unsigned char *, size_t, NegTokenResp *, size_t *);
164 static void free_NegTokenResp(NegTokenResp *);
165 /* unused declaration: length_NegTokenResp */
166 /* unused declaration: copy_NegTokenResp */
171 #endif /* __asn1_h__ */
172 /* Generated from spnego.asn1 */
173 /* Do not edit */
176 #define BACK if (e) return e; p -= l; len -= l; ret += l
178 static int
179 encode_MechType(unsigned char *p, size_t len, const MechType * data, size_t * size)
181 size_t ret = 0;
182 size_t l;
183 int i, e;
185 i = 0;
186 e = encode_oid(p, len, data, &l);
187 BACK;
188 *size = ret;
189 return 0;
192 #define FORW if(e) goto fail; p += l; len -= l; ret += l
194 static int
195 decode_MechType(const unsigned char *p, size_t len, MechType * data, size_t * size)
197 size_t ret = 0, reallen;
198 size_t l;
199 int e;
201 memset(data, 0, sizeof(*data));
202 reallen = 0;
203 e = decode_oid(p, len, data, &l);
204 FORW;
205 if (size)
206 *size = ret;
207 return 0;
208 fail:
209 free_MechType(data);
210 return e;
213 static void
214 free_MechType(MechType * data)
216 free_oid(data);
219 /* unused function: length_MechType */
222 /* unused function: copy_MechType */
224 /* Generated from spnego.asn1 */
225 /* Do not edit */
228 #define BACK if (e) return e; p -= l; len -= l; ret += l
230 static int
231 encode_MechTypeList(unsigned char *p, size_t len, const MechTypeList * data, size_t * size)
233 size_t ret = 0;
234 size_t l;
235 int i, e;
237 i = 0;
238 for (i = (data)->len - 1; i >= 0; --i) {
239 int oldret = ret;
240 ret = 0;
241 e = encode_MechType(p, len, &(data)->val[i], &l);
242 BACK;
243 ret += oldret;
245 e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
246 BACK;
247 *size = ret;
248 return 0;
251 #define FORW if(e) goto fail; p += l; len -= l; ret += l
253 static int
254 decode_MechTypeList(const unsigned char *p, size_t len, MechTypeList * data, size_t * size)
256 size_t ret = 0, reallen;
257 size_t l;
258 int e;
260 memset(data, 0, sizeof(*data));
261 reallen = 0;
262 e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
263 FORW;
264 if (len < reallen)
265 return ASN1_OVERRUN;
266 len = reallen;
268 size_t origlen = len;
269 int oldret = ret;
270 ret = 0;
271 (data)->len = 0;
272 (data)->val = NULL;
273 while (ret < origlen) {
274 (data)->len++;
275 (data)->val = realloc((data)->val, sizeof(*((data)->val)) * (data)->len);
276 e = decode_MechType(p, len, &(data)->val[(data)->len - 1], &l);
277 FORW;
278 len = origlen - ret;
280 ret += oldret;
282 if (size)
283 *size = ret;
284 return 0;
285 fail:
286 free_MechTypeList(data);
287 return e;
290 static void
291 free_MechTypeList(MechTypeList * data)
293 while ((data)->len) {
294 free_MechType(&(data)->val[(data)->len - 1]);
295 (data)->len--;
297 free((data)->val);
298 (data)->val = NULL;
301 /* unused function: length_MechTypeList */
304 /* unused function: copy_MechTypeList */
306 /* Generated from spnego.asn1 */
307 /* Do not edit */
310 #define BACK if (e) return e; p -= l; len -= l; ret += l
312 static int
313 encode_ContextFlags(unsigned char *p, size_t len, const ContextFlags * data, size_t * size)
315 size_t ret = 0;
316 size_t l;
317 int i, e;
319 i = 0;
321 unsigned char c = 0;
322 *p-- = c;
323 len--;
324 ret++;
325 c = 0;
326 *p-- = c;
327 len--;
328 ret++;
329 c = 0;
330 *p-- = c;
331 len--;
332 ret++;
333 c = 0;
334 if (data->integFlag)
335 c |= 1 << 1;
336 if (data->confFlag)
337 c |= 1 << 2;
338 if (data->anonFlag)
339 c |= 1 << 3;
340 if (data->sequenceFlag)
341 c |= 1 << 4;
342 if (data->replayFlag)
343 c |= 1 << 5;
344 if (data->mutualFlag)
345 c |= 1 << 6;
346 if (data->delegFlag)
347 c |= 1 << 7;
348 *p-- = c;
349 *p-- = 0;
350 len -= 2;
351 ret += 2;
354 e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
355 BACK;
356 *size = ret;
357 return 0;
360 #define FORW if(e) goto fail; p += l; len -= l; ret += l
362 static int
363 decode_ContextFlags(const unsigned char *p, size_t len, ContextFlags * data, size_t * size)
365 size_t ret = 0, reallen;
366 size_t l;
367 int e;
369 memset(data, 0, sizeof(*data));
370 reallen = 0;
371 e = der_match_tag_and_length(p, len, ASN1_C_UNIV, PRIM, UT_BitString, &reallen, &l);
372 FORW;
373 if (len < reallen)
374 return ASN1_OVERRUN;
375 p++;
376 len--;
377 reallen--;
378 ret++;
379 data->delegFlag = (*p >> 7) & 1;
380 data->mutualFlag = (*p >> 6) & 1;
381 data->replayFlag = (*p >> 5) & 1;
382 data->sequenceFlag = (*p >> 4) & 1;
383 data->anonFlag = (*p >> 3) & 1;
384 data->confFlag = (*p >> 2) & 1;
385 data->integFlag = (*p >> 1) & 1;
386 p += reallen;
387 len -= reallen;
388 ret += reallen;
389 if (size)
390 *size = ret;
391 return 0;
392 fail:
393 free_ContextFlags(data);
394 return e;
397 static void
398 free_ContextFlags(ContextFlags * data)
400 (void)data;
403 /* unused function: length_ContextFlags */
406 /* unused function: copy_ContextFlags */
409 /* unused function: ContextFlags2int */
412 /* unused function: int2ContextFlags */
415 /* unused variable: ContextFlags_units */
417 /* unused function: asn1_ContextFlags_units */
419 /* Generated from spnego.asn1 */
420 /* Do not edit */
423 #define BACK if (e) return e; p -= l; len -= l; ret += l
425 static int
426 encode_NegTokenInit(unsigned char *p, size_t len, const NegTokenInit * data, size_t * size)
428 size_t ret = 0;
429 size_t l;
430 int i, e;
432 i = 0;
433 if ((data)->mechListMIC) {
434 int oldret = ret;
435 ret = 0;
436 e = encode_octet_string(p, len, (data)->mechListMIC, &l);
437 BACK;
438 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
439 BACK;
440 ret += oldret;
442 if ((data)->mechToken) {
443 int oldret = ret;
444 ret = 0;
445 e = encode_octet_string(p, len, (data)->mechToken, &l);
446 BACK;
447 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
448 BACK;
449 ret += oldret;
451 if ((data)->reqFlags) {
452 int oldret = ret;
453 ret = 0;
454 e = encode_ContextFlags(p, len, (data)->reqFlags, &l);
455 BACK;
456 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
457 BACK;
458 ret += oldret;
460 int oldret = ret;
461 ret = 0;
462 e = encode_MechTypeList(p, len, &(data)->mechTypes, &l);
463 BACK;
464 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
465 BACK;
466 ret += oldret;
468 e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
469 BACK;
470 *size = ret;
471 return 0;
474 #define FORW if(e) goto fail; p += l; len -= l; ret += l
476 static int
477 decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, size_t * size)
479 size_t ret = 0, reallen;
480 size_t l;
481 int e;
483 memset(data, 0, sizeof(*data));
484 reallen = 0;
485 e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
486 FORW;
488 int dce_fix;
489 if ((dce_fix = fix_dce(reallen, &len)) < 0)
490 return ASN1_BAD_FORMAT;
492 size_t newlen, oldlen;
494 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, &l);
495 if (e)
496 return e;
497 else {
498 p += l;
499 len -= l;
500 ret += l;
501 e = der_get_length(p, len, &newlen, &l);
502 FORW;
504 int dce_fix;
505 oldlen = len;
506 if ((dce_fix = fix_dce(newlen, &len)) < 0)
507 return ASN1_BAD_FORMAT;
508 e = decode_MechTypeList(p, len, &(data)->mechTypes, &l);
509 FORW;
510 if (dce_fix) {
511 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
512 FORW;
513 } else
514 len = oldlen - newlen;
519 size_t newlen, oldlen;
521 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, &l);
522 if (e)
523 (data)->reqFlags = NULL;
524 else {
525 p += l;
526 len -= l;
527 ret += l;
528 e = der_get_length(p, len, &newlen, &l);
529 FORW;
531 int dce_fix;
532 oldlen = len;
533 if ((dce_fix = fix_dce(newlen, &len)) < 0)
534 return ASN1_BAD_FORMAT;
535 (data)->reqFlags = malloc(sizeof(*(data)->reqFlags));
536 if ((data)->reqFlags == NULL)
537 return ENOMEM;
538 e = decode_ContextFlags(p, len, (data)->reqFlags, &l);
539 FORW;
540 if (dce_fix) {
541 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
542 FORW;
543 } else
544 len = oldlen - newlen;
549 size_t newlen, oldlen;
551 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 2, &l);
552 if (e)
553 (data)->mechToken = NULL;
554 else {
555 p += l;
556 len -= l;
557 ret += l;
558 e = der_get_length(p, len, &newlen, &l);
559 FORW;
561 int dce_fix;
562 oldlen = len;
563 if ((dce_fix = fix_dce(newlen, &len)) < 0)
564 return ASN1_BAD_FORMAT;
565 (data)->mechToken = malloc(sizeof(*(data)->mechToken));
566 if ((data)->mechToken == NULL)
567 return ENOMEM;
568 e = decode_octet_string(p, len, (data)->mechToken, &l);
569 FORW;
570 if (dce_fix) {
571 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
572 FORW;
573 } else
574 len = oldlen - newlen;
579 size_t newlen, oldlen;
581 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 3, &l);
582 if (e)
583 (data)->mechListMIC = NULL;
584 else {
585 p += l;
586 len -= l;
587 ret += l;
588 e = der_get_length(p, len, &newlen, &l);
589 FORW;
591 int dce_fix;
592 oldlen = len;
593 if ((dce_fix = fix_dce(newlen, &len)) < 0)
594 return ASN1_BAD_FORMAT;
595 (data)->mechListMIC = malloc(sizeof(*(data)->mechListMIC));
596 if ((data)->mechListMIC == NULL)
597 return ENOMEM;
598 e = decode_octet_string(p, len, (data)->mechListMIC, &l);
599 FORW;
600 if (dce_fix) {
601 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
602 FORW;
603 } else
604 len = oldlen - newlen;
608 if (dce_fix) {
609 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
610 FORW;
613 if (size)
614 *size = ret;
615 return 0;
616 fail:
617 free_NegTokenInit(data);
618 return e;
621 static void
622 free_NegTokenInit(NegTokenInit * data)
624 free_MechTypeList(&(data)->mechTypes);
625 if ((data)->reqFlags) {
626 free_ContextFlags((data)->reqFlags);
627 free((data)->reqFlags);
628 (data)->reqFlags = NULL;
630 if ((data)->mechToken) {
631 free_octet_string((data)->mechToken);
632 free((data)->mechToken);
633 (data)->mechToken = NULL;
635 if ((data)->mechListMIC) {
636 free_octet_string((data)->mechListMIC);
637 free((data)->mechListMIC);
638 (data)->mechListMIC = NULL;
642 /* unused function: length_NegTokenInit */
645 /* unused function: copy_NegTokenInit */
647 /* Generated from spnego.asn1 */
648 /* Do not edit */
651 #define BACK if (e) return e; p -= l; len -= l; ret += l
653 static int
654 encode_NegTokenResp(unsigned char *p, size_t len, const NegTokenResp * data, size_t * size)
656 size_t ret = 0;
657 size_t l;
658 int i, e;
660 i = 0;
661 if ((data)->mechListMIC) {
662 int oldret = ret;
663 ret = 0;
664 e = encode_octet_string(p, len, (data)->mechListMIC, &l);
665 BACK;
666 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
667 BACK;
668 ret += oldret;
670 if ((data)->responseToken) {
671 int oldret = ret;
672 ret = 0;
673 e = encode_octet_string(p, len, (data)->responseToken, &l);
674 BACK;
675 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
676 BACK;
677 ret += oldret;
679 if ((data)->supportedMech) {
680 int oldret = ret;
681 ret = 0;
682 e = encode_MechType(p, len, (data)->supportedMech, &l);
683 BACK;
684 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
685 BACK;
686 ret += oldret;
688 if ((data)->negState) {
689 int oldret = ret;
690 ret = 0;
691 e = encode_enumerated(p, len, (data)->negState, &l);
692 BACK;
693 e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
694 BACK;
695 ret += oldret;
697 e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
698 BACK;
699 *size = ret;
700 return 0;
703 #define FORW if(e) goto fail; p += l; len -= l; ret += l
705 static int
706 decode_NegTokenResp(const unsigned char *p, size_t len, NegTokenResp * data, size_t * size)
708 size_t ret = 0, reallen;
709 size_t l;
710 int e;
712 memset(data, 0, sizeof(*data));
713 reallen = 0;
714 e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
715 FORW;
717 int dce_fix;
718 if ((dce_fix = fix_dce(reallen, &len)) < 0)
719 return ASN1_BAD_FORMAT;
721 size_t newlen, oldlen;
723 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, &l);
724 if (e)
725 (data)->negState = NULL;
726 else {
727 p += l;
728 len -= l;
729 ret += l;
730 e = der_get_length(p, len, &newlen, &l);
731 FORW;
733 int dce_fix;
734 oldlen = len;
735 if ((dce_fix = fix_dce(newlen, &len)) < 0)
736 return ASN1_BAD_FORMAT;
737 (data)->negState = malloc(sizeof(*(data)->negState));
738 if ((data)->negState == NULL)
739 return ENOMEM;
740 e = decode_enumerated(p, len, (data)->negState, &l);
741 FORW;
742 if (dce_fix) {
743 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
744 FORW;
745 } else
746 len = oldlen - newlen;
751 size_t newlen, oldlen;
753 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, &l);
754 if (e)
755 (data)->supportedMech = NULL;
756 else {
757 p += l;
758 len -= l;
759 ret += l;
760 e = der_get_length(p, len, &newlen, &l);
761 FORW;
763 int dce_fix;
764 oldlen = len;
765 if ((dce_fix = fix_dce(newlen, &len)) < 0)
766 return ASN1_BAD_FORMAT;
767 (data)->supportedMech = malloc(sizeof(*(data)->supportedMech));
768 if ((data)->supportedMech == NULL)
769 return ENOMEM;
770 e = decode_MechType(p, len, (data)->supportedMech, &l);
771 FORW;
772 if (dce_fix) {
773 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
774 FORW;
775 } else
776 len = oldlen - newlen;
781 size_t newlen, oldlen;
783 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 2, &l);
784 if (e)
785 (data)->responseToken = NULL;
786 else {
787 p += l;
788 len -= l;
789 ret += l;
790 e = der_get_length(p, len, &newlen, &l);
791 FORW;
793 int dce_fix;
794 oldlen = len;
795 if ((dce_fix = fix_dce(newlen, &len)) < 0)
796 return ASN1_BAD_FORMAT;
797 (data)->responseToken = malloc(sizeof(*(data)->responseToken));
798 if ((data)->responseToken == NULL)
799 return ENOMEM;
800 e = decode_octet_string(p, len, (data)->responseToken, &l);
801 FORW;
802 if (dce_fix) {
803 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
804 FORW;
805 } else
806 len = oldlen - newlen;
811 size_t newlen, oldlen;
813 e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 3, &l);
814 if (e)
815 (data)->mechListMIC = NULL;
816 else {
817 p += l;
818 len -= l;
819 ret += l;
820 e = der_get_length(p, len, &newlen, &l);
821 FORW;
823 int dce_fix;
824 oldlen = len;
825 if ((dce_fix = fix_dce(newlen, &len)) < 0)
826 return ASN1_BAD_FORMAT;
827 (data)->mechListMIC = malloc(sizeof(*(data)->mechListMIC));
828 if ((data)->mechListMIC == NULL)
829 return ENOMEM;
830 e = decode_octet_string(p, len, (data)->mechListMIC, &l);
831 FORW;
832 if (dce_fix) {
833 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
834 FORW;
835 } else
836 len = oldlen - newlen;
840 if (dce_fix) {
841 e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
842 FORW;
845 if (size)
846 *size = ret;
847 return 0;
848 fail:
849 free_NegTokenResp(data);
850 return e;
853 static void
854 free_NegTokenResp(NegTokenResp * data)
856 if ((data)->negState) {
857 free((data)->negState);
858 (data)->negState = NULL;
860 if ((data)->supportedMech) {
861 free_MechType((data)->supportedMech);
862 free((data)->supportedMech);
863 (data)->supportedMech = NULL;
865 if ((data)->responseToken) {
866 free_octet_string((data)->responseToken);
867 free((data)->responseToken);
868 (data)->responseToken = NULL;
870 if ((data)->mechListMIC) {
871 free_octet_string((data)->mechListMIC);
872 free((data)->mechListMIC);
873 (data)->mechListMIC = NULL;
877 /* unused function: length_NegTokenResp */
880 /* unused function: copy_NegTokenResp */
882 /* Generated from spnego.asn1 */
883 /* Do not edit */
886 /* CHOICE */
887 /* unused variable: asn1_NegotiationToken_dummy_holder */