"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/spnego_asn1.c" (7 Sep 2020, 20055 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "spnego_asn1.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 
   13 /*! \file
   14  * \brief Method routines generated from SPNEGO ASN.1 module.
   15  * See spnego_asn1.pl for details.  Do not edit.
   16  */
   17 
   18 /* Generated from spnego.asn1 */
   19 /* Do not edit */
   20 
   21 #ifndef __asn1_h__
   22 #define __asn1_h__
   23 
   24 
   25 #ifndef __asn1_common_definitions__
   26 #define __asn1_common_definitions__
   27 
   28 typedef struct octet_string {
   29     size_t length;
   30     void *data;
   31 } octet_string;
   32 
   33 typedef char *general_string;
   34 
   35 typedef char *utf8_string;
   36 
   37 typedef struct oid {
   38     size_t length;
   39     unsigned *components;
   40 } oid;
   41 
   42 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R)                  \
   43   do {                                                         \
   44     (BL) = length_##T((S));                                    \
   45     (B) = malloc((BL));                                        \
   46     if((B) == NULL) {                                          \
   47       (R) = ENOMEM;                                            \
   48     } else {                                                   \
   49       (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
   50                (S), (L));                              \
   51       if((R) != 0) {                                           \
   52     free((B));                                             \
   53     (B) = NULL;                                            \
   54       }                                                        \
   55     }                                                          \
   56   } while (0)
   57 
   58 #endif
   59 
   60 /*
   61  * MechType ::= OBJECT IDENTIFIER
   62  */
   63 
   64 typedef oid MechType;
   65 
   66 static int encode_MechType(unsigned char *, size_t, const MechType *, size_t *);
   67 static int decode_MechType(const unsigned char *, size_t, MechType *, size_t *);
   68 static void free_MechType(MechType *);
   69 /* unused declaration: length_MechType */
   70 /* unused declaration: copy_MechType */
   71 
   72 
   73 /*
   74  * MechTypeList ::= SEQUENCE OF MechType
   75  */
   76 
   77 typedef struct MechTypeList {
   78     unsigned int len;
   79     MechType *val;
   80 } MechTypeList;
   81 
   82 static int encode_MechTypeList(unsigned char *, size_t, const MechTypeList *, size_t *);
   83 static int decode_MechTypeList(const unsigned char *, size_t, MechTypeList *, size_t *);
   84 static void free_MechTypeList(MechTypeList *);
   85 /* unused declaration: length_MechTypeList */
   86 /* unused declaration: copy_MechTypeList */
   87 
   88 
   89 /*
   90  * ContextFlags ::= BIT STRING { delegFlag(0), mutualFlag(1), replayFlag(2),
   91  * sequenceFlag(3), anonFlag(4), confFlag(5), integFlag(6) }
   92  */
   93 
   94 typedef struct ContextFlags {
   95     unsigned int delegFlag:1;
   96     unsigned int mutualFlag:1;
   97     unsigned int replayFlag:1;
   98     unsigned int sequenceFlag:1;
   99     unsigned int anonFlag:1;
  100     unsigned int confFlag:1;
  101     unsigned int integFlag:1;
  102 } ContextFlags;
  103 
  104 
  105 static int encode_ContextFlags(unsigned char *, size_t, const ContextFlags *, size_t *);
  106 static int decode_ContextFlags(const unsigned char *, size_t, ContextFlags *, size_t *);
  107 static void free_ContextFlags(ContextFlags *);
  108 /* unused declaration: length_ContextFlags */
  109 /* unused declaration: copy_ContextFlags */
  110 /* unused declaration: ContextFlags2int */
  111 /* unused declaration: int2ContextFlags */
  112 /* unused declaration: asn1_ContextFlags_units */
  113 
  114 /*
  115  * NegTokenInit ::= SEQUENCE { mechTypes[0]    MechTypeList, reqFlags[1]
  116  * ContextFlags OPTIONAL, mechToken[2]    OCTET STRING OPTIONAL,
  117  * mechListMIC[3]  OCTET STRING OPTIONAL }
  118  */
  119 
  120 typedef struct NegTokenInit {
  121     MechTypeList mechTypes;
  122     ContextFlags *reqFlags;
  123     octet_string *mechToken;
  124     octet_string *mechListMIC;
  125 } NegTokenInit;
  126 
  127 static int encode_NegTokenInit(unsigned char *, size_t, const NegTokenInit *, size_t *);
  128 static int decode_NegTokenInit(const unsigned char *, size_t, NegTokenInit *, size_t *);
  129 static void free_NegTokenInit(NegTokenInit *);
  130 /* unused declaration: length_NegTokenInit */
  131 /* unused declaration: copy_NegTokenInit */
  132 
  133 
  134 /*
  135  * NegTokenResp ::= SEQUENCE { negState[0]       ENUMERATED {
  136  * accept-completed(0), accept-incomplete(1), reject(2), request-mic(3) }
  137  * OPTIONAL, supportedMech[1]  MechType OPTIONAL, responseToken[2]  OCTET
  138  * STRING OPTIONAL, mechListMIC[3]    OCTET STRING OPTIONAL }
  139  */
  140 
  141 typedef struct NegTokenResp {
  142     enum {
  143         accept_completed = 0,
  144         accept_incomplete = 1,
  145         reject = 2,
  146         request_mic = 3
  147     } *negState;
  148 
  149     MechType *supportedMech;
  150     octet_string *responseToken;
  151     octet_string *mechListMIC;
  152 } NegTokenResp;
  153 
  154 static int encode_NegTokenResp(unsigned char *, size_t, const NegTokenResp *, size_t *);
  155 static int decode_NegTokenResp(const unsigned char *, size_t, NegTokenResp *, size_t *);
  156 static void free_NegTokenResp(NegTokenResp *);
  157 /* unused declaration: length_NegTokenResp */
  158 /* unused declaration: copy_NegTokenResp */
  159 
  160 
  161 
  162 
  163 #endif              /* __asn1_h__ */
  164 /* Generated from spnego.asn1 */
  165 /* Do not edit */
  166 
  167 
  168 #define BACK if (e) return e; p -= l; len -= l; ret += l; POST(p); POST(len); POST(ret)
  169 
  170 static int
  171 encode_MechType(unsigned char *p, size_t len, const MechType * data, size_t * size)
  172 {
  173     size_t ret = 0;
  174     size_t l;
  175     int e;
  176 
  177     e = encode_oid(p, len, data, &l);
  178     BACK;
  179     *size = ret;
  180     return 0;
  181 }
  182 
  183 #define FORW if(e) goto fail; p += l; len -= l; ret += l; POST(p); POST(len); POST(ret)
  184 
  185 static int
  186 decode_MechType(const unsigned char *p, size_t len, MechType * data, size_t * size)
  187 {
  188     size_t ret = 0;
  189     size_t l;
  190     int e;
  191 
  192     memset(data, 0, sizeof(*data));
  193     e = decode_oid(p, len, data, &l);
  194     FORW;
  195     if (size)
  196         *size = ret;
  197     return 0;
  198 fail:
  199     free_MechType(data);
  200     return e;
  201 }
  202 
  203 static void
  204 free_MechType(MechType * data)
  205 {
  206     free_oid(data);
  207 }
  208 
  209 /* unused function: length_MechType */
  210 
  211 
  212 /* unused function: copy_MechType */
  213 
  214 /* Generated from spnego.asn1 */
  215 /* Do not edit */
  216 
  217 
  218 static int
  219 encode_MechTypeList(unsigned char *p, size_t len, const MechTypeList * data, size_t * size)
  220 {
  221     size_t ret = 0;
  222     size_t l;
  223     int i, e;
  224 
  225     for (i = (data)->len - 1; i >= 0; --i) {
  226         size_t oldret = ret;
  227         ret = 0;
  228         e = encode_MechType(p, len, &(data)->val[i], &l);
  229         BACK;
  230         ret += oldret;
  231     }
  232     e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
  233     BACK;
  234     *size = ret;
  235     return 0;
  236 }
  237 
  238 static int
  239 decode_MechTypeList(const unsigned char *p, size_t len, MechTypeList * data, size_t * size)
  240 {
  241     size_t ret = 0, reallen;
  242     size_t l;
  243     int e;
  244 
  245     memset(data, 0, sizeof(*data));
  246     reallen = 0;
  247     e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
  248     FORW;
  249     if (len < reallen)
  250         return ASN1_OVERRUN;
  251     len = reallen;
  252     {
  253         size_t origlen = len;
  254         size_t oldret = ret;
  255         ret = 0;
  256         (data)->len = 0;
  257         (data)->val = NULL;
  258         while (ret < origlen) {
  259             void *old = (data)->val;
  260             (data)->len++;
  261             (data)->val = realloc((data)->val, sizeof(*((data)->val)) * (data)->len);
  262             if ((data)->val == NULL) {
  263                 (data)->val = old;
  264                 (data)->len--;
  265                 return ENOMEM;
  266             }
  267             e = decode_MechType(p, len, &(data)->val[(data)->len - 1], &l);
  268             FORW;
  269             len = origlen - ret;
  270         }
  271         ret += oldret;
  272     }
  273     if (size)
  274         *size = ret;
  275     return 0;
  276 fail:
  277     free_MechTypeList(data);
  278     return e;
  279 }
  280 
  281 static void
  282 free_MechTypeList(MechTypeList * data)
  283 {
  284     while ((data)->len) {
  285         free_MechType(&(data)->val[(data)->len - 1]);
  286         (data)->len--;
  287     }
  288     free((data)->val);
  289     (data)->val = NULL;
  290 }
  291 
  292 /* unused function: length_MechTypeList */
  293 
  294 
  295 /* unused function: copy_MechTypeList */
  296 
  297 /* Generated from spnego.asn1 */
  298 /* Do not edit */
  299 
  300 
  301 static int
  302 encode_ContextFlags(unsigned char *p, size_t len, const ContextFlags * data, size_t * size)
  303 {
  304     size_t ret = 0;
  305     size_t l;
  306     int e;
  307 
  308     {
  309         unsigned char c = 0;
  310         *p-- = c;
  311         len--;
  312         ret++;
  313         c = 0;
  314         *p-- = c;
  315         len--;
  316         ret++;
  317         c = 0;
  318         *p-- = c;
  319         len--;
  320         ret++;
  321         c = 0;
  322         if (data->integFlag)
  323             c |= 1 << 1;
  324         if (data->confFlag)
  325             c |= 1 << 2;
  326         if (data->anonFlag)
  327             c |= 1 << 3;
  328         if (data->sequenceFlag)
  329             c |= 1 << 4;
  330         if (data->replayFlag)
  331             c |= 1 << 5;
  332         if (data->mutualFlag)
  333             c |= 1 << 6;
  334         if (data->delegFlag)
  335             c |= 1 << 7;
  336         *p-- = c;
  337         *p-- = 0;
  338         len -= 2;
  339         ret += 2;
  340     }
  341 
  342     e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
  343     BACK;
  344     *size = ret;
  345     return 0;
  346 }
  347 
  348 static int
  349 decode_ContextFlags(const unsigned char *p, size_t len, ContextFlags * data, size_t * size)
  350 {
  351     size_t ret = 0, reallen;
  352     size_t l;
  353     int e;
  354 
  355     memset(data, 0, sizeof(*data));
  356     reallen = 0;
  357     e = der_match_tag_and_length(p, len, ASN1_C_UNIV, PRIM, UT_BitString, &reallen, &l);
  358     FORW;
  359     if (len < reallen)
  360         return ASN1_OVERRUN;
  361     p++;
  362     len--;
  363     POST(len);
  364     reallen--;
  365     ret++;
  366     data->delegFlag = (*p >> 7) & 1;
  367     data->mutualFlag = (*p >> 6) & 1;
  368     data->replayFlag = (*p >> 5) & 1;
  369     data->sequenceFlag = (*p >> 4) & 1;
  370     data->anonFlag = (*p >> 3) & 1;
  371     data->confFlag = (*p >> 2) & 1;
  372     data->integFlag = (*p >> 1) & 1;
  373     ret += reallen;
  374     if (size)
  375         *size = ret;
  376     return 0;
  377 fail:
  378     free_ContextFlags(data);
  379     return e;
  380 }
  381 
  382 static void
  383 free_ContextFlags(ContextFlags * data)
  384 {
  385     (void)data;
  386 }
  387 
  388 /* unused function: length_ContextFlags */
  389 
  390 
  391 /* unused function: copy_ContextFlags */
  392 
  393 
  394 /* unused function: ContextFlags2int */
  395 
  396 
  397 /* unused function: int2ContextFlags */
  398 
  399 
  400 /* unused variable: ContextFlags_units */
  401 
  402 /* unused function: asn1_ContextFlags_units */
  403 
  404 /* Generated from spnego.asn1 */
  405 /* Do not edit */
  406 
  407 
  408 static int
  409 encode_NegTokenInit(unsigned char *p, size_t len, const NegTokenInit * data, size_t * size)
  410 {
  411     size_t ret = 0;
  412     size_t l;
  413     int e;
  414 
  415     if ((data)->mechListMIC) {
  416         size_t oldret = ret;
  417         ret = 0;
  418         e = encode_octet_string(p, len, (data)->mechListMIC, &l);
  419         BACK;
  420         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
  421         BACK;
  422         ret += oldret;
  423     }
  424     if ((data)->mechToken) {
  425         size_t oldret = ret;
  426         ret = 0;
  427         e = encode_octet_string(p, len, (data)->mechToken, &l);
  428         BACK;
  429         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
  430         BACK;
  431         ret += oldret;
  432     }
  433     if ((data)->reqFlags) {
  434         size_t oldret = ret;
  435         ret = 0;
  436         e = encode_ContextFlags(p, len, (data)->reqFlags, &l);
  437         BACK;
  438         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
  439         BACK;
  440         ret += oldret;
  441     } {
  442         size_t oldret = ret;
  443         ret = 0;
  444         e = encode_MechTypeList(p, len, &(data)->mechTypes, &l);
  445         BACK;
  446         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
  447         BACK;
  448         ret += oldret;
  449     }
  450     e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
  451     BACK;
  452     *size = ret;
  453     return 0;
  454 }
  455 
  456 static int
  457 decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, size_t * size)
  458 {
  459     size_t ret = 0, reallen;
  460     size_t l;
  461     int e;
  462 
  463     memset(data, 0, sizeof(*data));
  464     reallen = 0;
  465     e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
  466     FORW;
  467     {
  468         int dce_fix;
  469         if ((dce_fix = fix_dce(reallen, &len)) < 0) {
  470             e = ASN1_BAD_FORMAT;
  471             goto fail;
  472         }
  473         {
  474             size_t newlen, oldlen;
  475 
  476             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, &l);
  477             FORW;
  478             {
  479                 e = der_get_length(p, len, &newlen, &l);
  480                 FORW;
  481                 {
  482                     int mydce_fix;
  483                     oldlen = len;
  484                     if ((mydce_fix = fix_dce(newlen, &len)) < 0) {
  485                         e = ASN1_BAD_FORMAT;
  486                         goto fail;
  487                     }
  488                     e = decode_MechTypeList(p, len, &(data)->mechTypes, &l);
  489                     FORW;
  490                     if (mydce_fix) {
  491                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  492                         FORW;
  493                     } else
  494                         len = oldlen - newlen;
  495                 }
  496             }
  497         }
  498         {
  499             size_t newlen, oldlen;
  500 
  501             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, &l);
  502             if (e)
  503                 (data)->reqFlags = NULL;
  504             else {
  505                 p += l;
  506                 len -= l;
  507                 ret += l;
  508                 e = der_get_length(p, len, &newlen, &l);
  509                 FORW;
  510                 {
  511                     int mydce_fix;
  512                     oldlen = len;
  513                     if ((mydce_fix = fix_dce(newlen, &len)) < 0) {
  514                         e = ASN1_BAD_FORMAT;
  515                         goto fail;
  516                     }
  517                     (data)->reqFlags = malloc(sizeof(*(data)->reqFlags));
  518                     if ((data)->reqFlags == NULL) {
  519                         e = ENOMEM;
  520                         goto fail;
  521                     }
  522                     e = decode_ContextFlags(p, len, (data)->reqFlags, &l);
  523                     FORW;
  524                     if (mydce_fix) {
  525                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  526                         FORW;
  527                     } else
  528                         len = oldlen - newlen;
  529                 }
  530             }
  531         }
  532         {
  533             size_t newlen, oldlen;
  534 
  535             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 2, &l);
  536             if (e)
  537                 (data)->mechToken = NULL;
  538             else {
  539                 p += l;
  540                 len -= l;
  541                 ret += l;
  542                 e = der_get_length(p, len, &newlen, &l);
  543                 FORW;
  544                 {
  545                     int mydce_fix;
  546                     oldlen = len;
  547                     if ((mydce_fix = fix_dce(newlen, &len)) < 0) {
  548                         e = ASN1_BAD_FORMAT;
  549                         goto fail;
  550                     }
  551                     (data)->mechToken = malloc(sizeof(*(data)->mechToken));
  552                     if ((data)->mechToken == NULL) {
  553                         e = ENOMEM;
  554                         goto fail;
  555                     }
  556                     e = decode_octet_string(p, len, (data)->mechToken, &l);
  557                     FORW;
  558                     if (mydce_fix) {
  559                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  560                         FORW;
  561                     } else
  562                         len = oldlen - newlen;
  563                 }
  564             }
  565         }
  566         {
  567             size_t newlen, oldlen;
  568 
  569             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 3, &l);
  570             if (e)
  571                 (data)->mechListMIC = NULL;
  572             else {
  573                 p += l;
  574                 len -= l;
  575                 ret += l;
  576                 e = der_get_length(p, len, &newlen, &l);
  577                 FORW;
  578                 {
  579                     int mydce_fix;
  580                     oldlen = len;
  581                     if ((mydce_fix = fix_dce(newlen, &len)) < 0) {
  582                         e = ASN1_BAD_FORMAT;
  583                         goto fail;
  584                     }
  585                     (data)->mechListMIC = malloc(sizeof(*(data)->mechListMIC));
  586                     if ((data)->mechListMIC == NULL) {
  587                         e = ENOMEM;
  588                         goto fail;
  589                     }
  590                     e = decode_octet_string(p, len, (data)->mechListMIC, &l);
  591                     FORW;
  592                     if (mydce_fix) {
  593                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  594                         FORW;
  595                     } else
  596                         len = oldlen - newlen;
  597                 }
  598             }
  599         }
  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         }
  604     }
  605     if (size)
  606         *size = ret;
  607     return 0;
  608 fail:
  609     free_NegTokenInit(data);
  610     return e;
  611 }
  612 
  613 static void
  614 free_NegTokenInit(NegTokenInit * data)
  615 {
  616     free_MechTypeList(&(data)->mechTypes);
  617     if ((data)->reqFlags) {
  618         free_ContextFlags((data)->reqFlags);
  619         free((data)->reqFlags);
  620         (data)->reqFlags = NULL;
  621     }
  622     if ((data)->mechToken) {
  623         free_octet_string((data)->mechToken);
  624         free((data)->mechToken);
  625         (data)->mechToken = NULL;
  626     }
  627     if ((data)->mechListMIC) {
  628         free_octet_string((data)->mechListMIC);
  629         free((data)->mechListMIC);
  630         (data)->mechListMIC = NULL;
  631     }
  632 }
  633 
  634 /* unused function: length_NegTokenInit */
  635 
  636 
  637 /* unused function: copy_NegTokenInit */
  638 
  639 /* Generated from spnego.asn1 */
  640 /* Do not edit */
  641 
  642 
  643 static int
  644 encode_NegTokenResp(unsigned char *p, size_t len, const NegTokenResp * data, size_t * size)
  645 {
  646     size_t ret = 0;
  647     size_t l;
  648     int e;
  649 
  650     if ((data)->mechListMIC) {
  651         size_t oldret = ret;
  652         ret = 0;
  653         e = encode_octet_string(p, len, (data)->mechListMIC, &l);
  654         BACK;
  655         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
  656         BACK;
  657         ret += oldret;
  658     }
  659     if ((data)->responseToken) {
  660         size_t oldret = ret;
  661         ret = 0;
  662         e = encode_octet_string(p, len, (data)->responseToken, &l);
  663         BACK;
  664         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
  665         BACK;
  666         ret += oldret;
  667     }
  668     if ((data)->supportedMech) {
  669         size_t oldret = ret;
  670         ret = 0;
  671         e = encode_MechType(p, len, (data)->supportedMech, &l);
  672         BACK;
  673         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
  674         BACK;
  675         ret += oldret;
  676     }
  677     if ((data)->negState) {
  678         size_t oldret = ret;
  679         ret = 0;
  680         e = encode_enumerated(p, len, (data)->negState, &l);
  681         BACK;
  682         e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
  683         BACK;
  684         ret += oldret;
  685     }
  686     e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
  687     BACK;
  688     *size = ret;
  689     return 0;
  690 }
  691 
  692 static int
  693 decode_NegTokenResp(const unsigned char *p, size_t len, NegTokenResp * data, size_t * size)
  694 {
  695     size_t ret = 0, reallen;
  696     size_t l;
  697     int e;
  698 
  699     memset(data, 0, sizeof(*data));
  700     reallen = 0;
  701     e = der_match_tag_and_length(p, len, ASN1_C_UNIV, CONS, UT_Sequence, &reallen, &l);
  702     FORW;
  703     {
  704         int dce_fix;
  705         if ((dce_fix = fix_dce(reallen, &len)) < 0)
  706             return ASN1_BAD_FORMAT;
  707         {
  708             size_t newlen, oldlen;
  709 
  710             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, &l);
  711             if (e)
  712                 (data)->negState = NULL;
  713             else {
  714                 p += l;
  715                 len -= l;
  716                 ret += l;
  717                 e = der_get_length(p, len, &newlen, &l);
  718                 FORW;
  719                 {
  720                     int mydce_fix;
  721                     oldlen = len;
  722                     if ((mydce_fix = fix_dce(newlen, &len)) < 0)
  723                         return ASN1_BAD_FORMAT;
  724                     (data)->negState = malloc(sizeof(*(data)->negState));
  725                     if ((data)->negState == NULL)
  726                         return ENOMEM;
  727                     e = decode_enumerated(p, len, (data)->negState, &l);
  728                     FORW;
  729                     if (mydce_fix) {
  730                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  731                         FORW;
  732                     } else
  733                         len = oldlen - newlen;
  734                 }
  735             }
  736         }
  737         {
  738             size_t newlen, oldlen;
  739 
  740             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 1, &l);
  741             if (e)
  742                 (data)->supportedMech = NULL;
  743             else {
  744                 p += l;
  745                 len -= l;
  746                 ret += l;
  747                 e = der_get_length(p, len, &newlen, &l);
  748                 FORW;
  749                 {
  750                     int mydce_fix;
  751                     oldlen = len;
  752                     if ((mydce_fix = fix_dce(newlen, &len)) < 0)
  753                         return ASN1_BAD_FORMAT;
  754                     (data)->supportedMech = malloc(sizeof(*(data)->supportedMech));
  755                     if ((data)->supportedMech == NULL)
  756                         return ENOMEM;
  757                     e = decode_MechType(p, len, (data)->supportedMech, &l);
  758                     FORW;
  759                     if (mydce_fix) {
  760                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  761                         FORW;
  762                     } else
  763                         len = oldlen - newlen;
  764                 }
  765             }
  766         }
  767         {
  768             size_t newlen, oldlen;
  769 
  770             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 2, &l);
  771             if (e)
  772                 (data)->responseToken = NULL;
  773             else {
  774                 p += l;
  775                 len -= l;
  776                 ret += l;
  777                 e = der_get_length(p, len, &newlen, &l);
  778                 FORW;
  779                 {
  780                     int mydce_fix;
  781                     oldlen = len;
  782                     if ((mydce_fix = fix_dce(newlen, &len)) < 0)
  783                         return ASN1_BAD_FORMAT;
  784                     (data)->responseToken = malloc(sizeof(*(data)->responseToken));
  785                     if ((data)->responseToken == NULL)
  786                         return ENOMEM;
  787                     e = decode_octet_string(p, len, (data)->responseToken, &l);
  788                     FORW;
  789                     if (mydce_fix) {
  790                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  791                         FORW;
  792                     } else
  793                         len = oldlen - newlen;
  794                 }
  795             }
  796         }
  797         {
  798             size_t newlen, oldlen;
  799 
  800             e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 3, &l);
  801             if (e)
  802                 (data)->mechListMIC = NULL;
  803             else {
  804                 p += l;
  805                 len -= l;
  806                 ret += l;
  807                 e = der_get_length(p, len, &newlen, &l);
  808                 FORW;
  809                 {
  810                     int mydce_fix;
  811                     oldlen = len;
  812                     if ((mydce_fix = fix_dce(newlen, &len)) < 0)
  813                         return ASN1_BAD_FORMAT;
  814                     (data)->mechListMIC = malloc(sizeof(*(data)->mechListMIC));
  815                     if ((data)->mechListMIC == NULL)
  816                         return ENOMEM;
  817                     e = decode_octet_string(p, len, (data)->mechListMIC, &l);
  818                     FORW;
  819                     if (mydce_fix) {
  820                         e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  821                         FORW;
  822                     } else
  823                         len = oldlen - newlen;
  824                 }
  825             }
  826         }
  827         if (dce_fix) {
  828             e = der_match_tag_and_length(p, len, (Der_class) 0, (Der_type) 0, 0, &reallen, &l);
  829             FORW;
  830         }
  831     }
  832     if (size)
  833         *size = ret;
  834     return 0;
  835 fail:
  836     free_NegTokenResp(data);
  837     return e;
  838 }
  839 
  840 static void
  841 free_NegTokenResp(NegTokenResp * data)
  842 {
  843     if ((data)->negState) {
  844         free((data)->negState);
  845         (data)->negState = NULL;
  846     }
  847     if ((data)->supportedMech) {
  848         free_MechType((data)->supportedMech);
  849         free((data)->supportedMech);
  850         (data)->supportedMech = NULL;
  851     }
  852     if ((data)->responseToken) {
  853         free_octet_string((data)->responseToken);
  854         free((data)->responseToken);
  855         (data)->responseToken = NULL;
  856     }
  857     if ((data)->mechListMIC) {
  858         free_octet_string((data)->mechListMIC);
  859         free((data)->mechListMIC);
  860         (data)->mechListMIC = NULL;
  861     }
  862 }
  863 
  864 /* unused function: length_NegTokenResp */
  865 
  866 
  867 /* unused function: copy_NegTokenResp */
  868 
  869 /* Generated from spnego.asn1 */
  870 /* Do not edit */
  871 
  872 
  873 /* CHOICE */
  874 /* unused variable: asn1_NegotiationToken_dummy_holder */