Back to index

openldap  2.4.31
certificate.c
Go to the documentation of this file.
00001 /*
00002  *    certificate.c
00003  *    "AuthenticationFramework" ASN.1 module encode/decode/extracting/matching/free C src.
00004  *    This file was generated by modified eSMACC compiler Sat Dec 11 11:22:49 2004
00005  *    The generated files are supposed to be compiled as a module for OpenLDAP Software
00006  */
00007 
00008 #include "certificate.h"
00009 
00010 BDecComponentCertificateTop( void* mem_op, GenBuf* b, void **v, AsnLen* bytesDecoded,int mode) {
00011        AsnTag tag;
00012        AsnLen elmtLen;
00013 
00014        tag = BDecTag ( b, bytesDecoded );
00015        elmtLen = BDecLen ( b, bytesDecoded );
00016        if ( elmtLen <= 0 ) return (-1);
00017        if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {
00018               return (-1);
00019        }
00020               
00021        return BDecComponentCertificate( mem_op, b, tag, elmtLen, (ComponentCertificate**)v,(AsnLen*)bytesDecoded, mode );
00022 }
00023 
00024 void init_module_AuthenticationFramework() {
00025        /* Register Certificate OID and its decoder */
00026        InstallOidDecoderMapping( "2.5.4.36", NULL,
00027                             GDecComponentCertificate,
00028                             BDecComponentCertificateTop,
00029                             ExtractingComponentCertificate,
00030                             MatchingComponentCertificate );
00031        InitAnyAuthenticationFramework();
00032 }
00033 
00034 void InitAnyAuthenticationFramework()
00035 {
00036     AsnOid oid0 ={ 9, "\52\206\110\206\367\15\1\1\4" };
00037     AsnOid oid1 ={ 9, "\52\206\110\206\367\15\1\1\1" };
00038     AsnOid oid2 ={ 9, "\52\206\110\206\367\15\1\1\5" };
00039     AsnOid oid3 ={ 3, "\125\4\3" };
00040     AsnOid oid4 ={ 3, "\125\4\6" };
00041     AsnOid oid5 ={ 3, "\125\4\7" };
00042     AsnOid oid6 ={ 3, "\125\4\10" };
00043     AsnOid oid7 ={ 3, "\125\4\12" };
00044     AsnOid oid8 ={ 3, "\125\4\13" };
00045     AsnOid oid9 ={ 10, "\11\222\46\211\223\362\54\144\1\3" };
00046     AsnOid oid10 ={ 9, "\52\206\110\206\367\15\1\11\1" };
00047     AsnOid oid11 ={ 3, "\125\35\23" };
00048     AsnOid oid12 ={ 9, "\140\206\110\1\206\370\102\1\15" };
00049     AsnOid oid13 ={ 3, "\125\35\16" };
00050     AsnOid oid14 ={ 3, "\125\35\25" };
00051     AsnOid oid15 ={ 3, "\125\35\24" };
00052     AsnOid oid17 ={ 3, "\125\35\34" };
00053 
00054 
00055     InstallAnyByComponentOid (nullOid_ANY_ID, &oid0, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
00056 
00057     InstallAnyByComponentOid (nullOid2_ANY_ID, &oid1, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
00058 
00059     InstallAnyByComponentOid (nullOid3_ANY_ID, &oid2, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
00060 
00061     InstallAnyByComponentOid (printableStringOid_ANY_ID, &oid3, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00062 
00063     InstallAnyByComponentOid (printableStringOid2_ANY_ID, &oid4, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00064 
00065     InstallAnyByComponentOid (printableStringOid3_ANY_ID, &oid5, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00066 
00067     InstallAnyByComponentOid (printableStringOid4_ANY_ID, &oid6, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00068 
00069     InstallAnyByComponentOid (printableStringOid5_ANY_ID, &oid7, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00070 
00071     InstallAnyByComponentOid (printableStringOid6_ANY_ID, &oid8, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
00072 
00073     InstallAnyByComponentOid (printableStringOid7_ANY_ID, &oid9, sizeof (ComponentTeletexString), (EncodeFcn)BEncTeletexString, (gser_decoder_func*)GDecComponentTeletexString, (ber_tag_decoder_func*)BDecComponentTeletexStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentTeletexString,(FreeFcn)FreeComponentTeletexString, (PrintFcn)NULL);
00074 
00075     InstallAnyByComponentOid (iA5StringOid_ANY_ID, &oid10, sizeof (ComponentIA5String), (EncodeFcn)BEncIA5String, (gser_decoder_func*)GDecComponentIA5String, (ber_tag_decoder_func*)BDecComponentIA5StringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentIA5String,(FreeFcn)FreeComponentIA5String, (PrintFcn)NULL);
00076 
00077     InstallAnyByComponentOid (octetStringOid_ANY_ID, &oid11, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00078 
00079     InstallAnyByComponentOid (octetStringOid2_ANY_ID, &oid12, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00080 
00081     InstallAnyByComponentOid (octetStringOid3_ANY_ID, &oid13, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00082 
00083     InstallAnyByComponentOid (octetStringOid4_ANY_ID, &oid14, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00084 
00085     InstallAnyByComponentOid (octetStringOid5_ANY_ID, &oid15, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00086 
00087     InstallAnyByComponentOid (octetStringOid7_ANY_ID, &oid17, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
00088 
00089 }  /* InitAnyAuthenticationFramework */
00090 
00091 int
00092 MatchingComponentAlgorithmIdentifier ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00093        int rc;
00094        MatchingRule* mr;
00095 
00096        if ( oid ) {
00097               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00098               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00099        }
00100 
00101        rc = 1;
00102        rc =   MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_assert)->algorithm );
00103        if ( rc != LDAP_COMPARE_TRUE )
00104               return rc;
00105        rc =   SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm));
00106        rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_assert)->parameters);
00107        if ( rc != LDAP_COMPARE_TRUE )
00108               return rc;
00109        return LDAP_COMPARE_TRUE;
00110 }  /* BMatchingComponentAlgorithmIdentifier */
00111 
00112 void*
00113 ExtractingComponentAlgorithmIdentifier ( void* mem_op, ComponentReference* cr, ComponentAlgorithmIdentifier *comp )
00114 {
00115 
00116        if ( ( comp->algorithm.identifier.bv_val && strncmp(comp->algorithm.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->algorithm.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00117               if ( cr->cr_curr->ci_next == NULL )
00118               return &comp->algorithm;
00119               else
00120               return NULL;
00121        }
00122        if ( ( comp->parameters.identifier.bv_val && strncmp(comp->parameters.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->parameters.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00123               if ( cr->cr_curr->ci_next == NULL )
00124               return &comp->parameters;
00125        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
00126                      cr->cr_curr = cr->cr_curr->ci_next;
00127               return &comp->parameters;
00128         } else {
00129               return NULL;
00130               }
00131        }
00132        return NULL;
00133 }  /* ExtractingComponentAlgorithmIdentifier */
00134 
00135 int
00136 BDecComponentAlgorithmIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00137 void* mem_op _AND_
00138 GenBuf * b _AND_
00139 AsnTag tagId0 _AND_
00140 AsnLen elmtLen0 _AND_
00141 ComponentAlgorithmIdentifier **v _AND_
00142 AsnLen *bytesDecoded _AND_
00143 int mode)
00144 {
00145        int seqDone = FALSE;
00146        AsnLen totalElmtsLen1 = 0;
00147        AsnLen elmtLen1;
00148        AsnTag tagId1;
00149        int mandatoryElmtCount1 = 0;
00150        int old_mode = mode;
00151        int rc;
00152        ComponentAlgorithmIdentifier *k, *t, c_temp;
00153 
00154 
00155        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00156               memset(&c_temp,0,sizeof(c_temp));
00157                k = &c_temp;
00158        } else
00159                k = t = *v;
00160        mode = DEC_ALLOC_MODE_2;
00161     tagId1 = BDecTag (b, &totalElmtsLen1 );
00162 
00163     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
00164     {
00165     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00166        rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
00167               if ( rc != LDAP_SUCCESS ) return rc;
00168               (&k->algorithm)->identifier.bv_val = (&k->algorithm)->id_buf;
00169               (&k->algorithm)->identifier.bv_len = strlen("algorithm");
00170               strcpy( (&k->algorithm)->identifier.bv_val, "algorithm");
00171     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
00172         seqDone = TRUE;
00173     else
00174     {
00175          tagId1 = BufPeekByte (b);
00176          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
00177         {
00178             BDecEoc (b, &totalElmtsLen1 );
00179             seqDone = TRUE;
00180         }
00181     }
00182     }
00183     else
00184         return -1;
00185 
00186 
00187 
00188     if (!seqDone)    {
00189        rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
00190        rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->parameters), &totalElmtsLen1, mode );
00191               if ( rc != LDAP_SUCCESS ) return rc;
00192               (&k->parameters)->identifier.bv_val = (&k->parameters)->id_buf;
00193               (&k->parameters)->identifier.bv_len = strlen("parameters");
00194               strcpy( (&k->parameters)->identifier.bv_val, "parameters");
00195         seqDone = TRUE;
00196         if (elmtLen0 == INDEFINITE_LEN)
00197             BDecEoc (b, &totalElmtsLen1 );
00198         else if (totalElmtsLen1 != elmtLen0)
00199         return -1;
00200 
00201     }
00202 
00203 
00204     if (!seqDone)
00205         return -1;
00206 
00207        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00208        *v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
00209        if ( !t ) return -1;
00210        *t = *k;
00211        }
00212        t->syntax = (Syntax*)NULL;
00213        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00214        if ( !t->comp_desc ) {
00215               free ( t );
00216               return -1;
00217        }
00218        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
00219        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
00220        t->comp_desc->cd_free = (comp_free_func*)NULL;
00221        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
00222        t->comp_desc->cd_type = ASN_COMPOSITE;
00223        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00224        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
00225     (*bytesDecoded) += totalElmtsLen1;
00226        return LDAP_SUCCESS;
00227 }  /* BDecAlgorithmIdentifier*/
00228 
00229 int
00230 GDecComponentAlgorithmIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode),
00231 void* mem_op _AND_
00232 GenBuf * b _AND_
00233 ComponentAlgorithmIdentifier **v _AND_
00234 AsnLen *bytesDecoded _AND_
00235 int mode)
00236 {
00237        char* peek_head,*peek_head2;
00238        int i, strLen,strLen2, rc, old_mode = mode;
00239        ComponentAlgorithmIdentifier *k,*t, c_temp;
00240 
00241 
00242        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00243               memset(&c_temp,0,sizeof(c_temp));
00244                k = &c_temp;
00245        } else
00246                k = t = *v;
00247        mode = DEC_ALLOC_MODE_2;
00248        *bytesDecoded = 0;
00249        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00250               Asn1Error("Error during Reading { in encoded data");
00251               return LDAP_PROTOCOL_ERROR;
00252        }
00253        if(*peek_head != '{'){
00254               Asn1Error("Missing { in encoded data");
00255               return LDAP_PROTOCOL_ERROR;
00256        }
00257 
00258        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00259               Asn1Error("Error during Reading identifier");
00260               return LDAP_PROTOCOL_ERROR;
00261        }
00262        if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
00263               rc =   GDecComponentOid (mem_op, b, (&k->algorithm), bytesDecoded, mode);
00264               if ( rc != LDAP_SUCCESS ) return rc;
00265        (&k->algorithm)->identifier.bv_val = peek_head;
00266        (&k->algorithm)->identifier.bv_len = strLen;
00267        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00268               Asn1Error("Error during Reading , ");
00269               return LDAP_PROTOCOL_ERROR;
00270        }
00271        if(*peek_head != ','){
00272               Asn1Error("Missing , in encoding");
00273               return LDAP_PROTOCOL_ERROR;
00274        }
00275        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00276          Asn1Error("Error during Reading identifier");
00277               return LDAP_PROTOCOL_ERROR;
00278        }
00279        }
00280        if ( strncmp( peek_head, "parameters", strlen("parameters") ) == 0 ) {
00281               rc =   rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
00282        rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->parameters), bytesDecoded, mode );
00283               if ( rc != LDAP_SUCCESS ) return rc;
00284        (&k->parameters)->identifier.bv_val = peek_head;
00285        (&k->parameters)->identifier.bv_len = strLen;
00286        }
00287        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
00288               Asn1Error("Error during Reading } in encoding");
00289               return LDAP_PROTOCOL_ERROR;
00290        }
00291        if(*peek_head != '}'){
00292               Asn1Error("Missing } in encoding");
00293               return LDAP_PROTOCOL_ERROR;
00294        }
00295        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00296        *v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
00297        if ( !t ) return -1;
00298        *t = *k;
00299        }
00300        t->syntax = (Syntax*)NULL;
00301        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00302        if ( !t->comp_desc ) {
00303               free ( t );
00304               return -1;
00305        }
00306        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
00307        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
00308        t->comp_desc->cd_free = (comp_free_func*)NULL;
00309        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
00310        t->comp_desc->cd_type = ASN_COMPOSITE;
00311        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00312        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
00313        return LDAP_SUCCESS;
00314 }  /* GDecAlgorithmIdentifier*/
00315 
00316 
00317 int
00318 MatchingComponentTime ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00319        int rc;
00320        MatchingRule* mr;
00321        ComponentTime *v1, *v2;
00322 
00323 
00324        v1 = (ComponentTime*)csi_attr;
00325        v2 = (ComponentTime*)csi_assert;
00326        if ( oid ) {
00327               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00328               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00329        }
00330 
00331        if( (v1->choiceId != v2->choiceId ) )
00332               return LDAP_COMPARE_FALSE;
00333        switch( v1->choiceId )
00334        {
00335           case TIME_UTCTIME :
00336               rc =   MatchingComponentUTCTime ( oid, (ComponentSyntaxInfo*)(v1->a.utcTime), (ComponentSyntaxInfo*)(v2->a.utcTime) );
00337               break;
00338           case TIME_GENERALIZEDTIME :
00339               rc =   MatchingComponentGeneralizedTime ( oid, (ComponentSyntaxInfo*)(v1->a.generalizedTime), (ComponentSyntaxInfo*)(v2->a.generalizedTime) );
00340               break;
00341        default : 
00342                return LDAP_PROTOCOL_ERROR;
00343        }
00344        return rc;
00345 }  /* BMatchingComponentTimeContent */
00346 
00347 void*
00348 ExtractingComponentTime ( void* mem_op, ComponentReference* cr, ComponentTime *comp )
00349 {
00350 
00351 
00352        if( (comp->choiceId) ==  TIME_UTCTIME &&
00353                (( comp->a.utcTime->identifier.bv_val && strncmp(comp->a.utcTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
00354                ( strncmp(comp->a.utcTime->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
00355               if ( cr->cr_curr->ci_next == NULL )
00356                      return (comp->a.utcTime);
00357               else {
00358                      cr->cr_curr = cr->cr_curr->ci_next;
00359                      return        ExtractingComponentUTCTime ( mem_op, cr, (comp->a.utcTime) );
00360               };
00361        }
00362        if( (comp->choiceId) ==  TIME_GENERALIZEDTIME &&
00363                (( comp->a.generalizedTime->identifier.bv_val && strncmp(comp->a.generalizedTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
00364                ( strncmp(comp->a.generalizedTime->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
00365               if ( cr->cr_curr->ci_next == NULL )
00366                      return (comp->a.generalizedTime);
00367               else {
00368                      cr->cr_curr = cr->cr_curr->ci_next;
00369                      return        ExtractingComponentGeneralizedTime ( mem_op, cr, (comp->a.generalizedTime) );
00370               };
00371        }
00372        return NULL;
00373 }  /* ExtractingComponentTime */
00374 
00375 int
00376 BDecComponentTime PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00377 void* mem_op _AND_
00378 GenBuf * b _AND_
00379 AsnTag tagId0 _AND_
00380 AsnLen elmtLen0 _AND_
00381 ComponentTime **v _AND_
00382 AsnLen *bytesDecoded _AND_
00383 int mode)
00384 {
00385        int seqDone = FALSE;
00386        AsnLen totalElmtsLen1 = 0;
00387        AsnLen elmtLen1;
00388        AsnTag tagId1;
00389        int mandatoryElmtCount1 = 0;
00390        int old_mode = mode;
00391        int rc;
00392        ComponentTime *k, *t, c_temp;
00393 
00394 
00395        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00396               memset(&c_temp,0,sizeof(c_temp));
00397                k = &c_temp;
00398        } else
00399                k = t = *v;
00400        mode = DEC_ALLOC_MODE_2;
00401     switch (tagId0)
00402     {
00403        case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE):
00404        case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE):
00405         (k->choiceId) = TIME_UTCTIME;
00406        rc = BDecComponentUTCTime (mem_op, b, tagId0, elmtLen0, (&k->a.utcTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00407               if ( rc != LDAP_SUCCESS ) return rc;
00408               (k->a.utcTime)->identifier.bv_val = (k->a.utcTime)->id_buf;
00409               (k->a.utcTime)->identifier.bv_len = strlen("utcTime");
00410               strcpy( (k->a.utcTime)->identifier.bv_val, "utcTime");
00411     break;
00412 
00413        case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE):
00414        case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE):
00415         (k->choiceId) = TIME_GENERALIZEDTIME;
00416        rc = BDecComponentGeneralizedTime (mem_op, b, tagId0, elmtLen0, (&k->a.generalizedTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00417               if ( rc != LDAP_SUCCESS ) return rc;
00418               (k->a.generalizedTime)->identifier.bv_val = (k->a.generalizedTime)->id_buf;
00419               (k->a.generalizedTime)->identifier.bv_len = strlen("generalizedTime");
00420               strcpy( (k->a.generalizedTime)->identifier.bv_val, "generalizedTime");
00421     break;
00422 
00423     default:
00424         Asn1Error ("ERROR - unexpected tag in CHOICE\n");
00425         return -1;
00426         break;
00427     } /* end switch */
00428        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00429        *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
00430        if ( !t ) return -1;
00431        *t = *k;
00432        }
00433        t->syntax = (Syntax*)NULL;
00434        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00435        if ( !t->comp_desc ) {
00436               free ( t );
00437               return -1;
00438        }
00439        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
00440        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
00441        t->comp_desc->cd_free = (comp_free_func*)NULL;
00442        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
00443        t->comp_desc->cd_type = ASN_COMPOSITE;
00444        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00445        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
00446     (*bytesDecoded) += totalElmtsLen1;
00447        return LDAP_SUCCESS;
00448 }  /* BDecTimeContent */
00449 
00450 int
00451 GDecComponentTime PARAMS (( mem_op,b, v, bytesDecoded, mode),
00452 void* mem_op _AND_
00453 GenBuf * b _AND_
00454 ComponentTime **v _AND_
00455 AsnLen *bytesDecoded _AND_
00456 int mode)
00457 {
00458        char* peek_head,*peek_head2;
00459        int i, strLen,strLen2, rc, old_mode = mode;
00460        ComponentTime *k,*t, c_temp;
00461 
00462 
00463        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00464               memset(&c_temp,0,sizeof(c_temp));
00465                k = &c_temp;
00466        } else
00467                k = t = *v;
00468        mode = DEC_ALLOC_MODE_2;
00469        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00470               Asn1Error("Error during Reading identifier");
00471               return LDAP_PROTOCOL_ERROR;
00472        }
00473        if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
00474               Asn1Error("Error during Reading identifier");
00475               return LDAP_PROTOCOL_ERROR;
00476        }
00477        if(*peek_head2 != ':'){
00478               Asn1Error("Missing : in encoded data");
00479               return LDAP_PROTOCOL_ERROR;
00480        }
00481        if( strncmp("utcTime",peek_head, strlen("utcTime")) == 0){
00482               (k->choiceId) = TIME_UTCTIME;
00483               rc =   GDecComponentUTCTime (mem_op, b, (&k->a.utcTime), bytesDecoded, DEC_ALLOC_MODE_0 );
00484               if ( rc != LDAP_SUCCESS ) return rc;
00485               (k->a.utcTime)->identifier.bv_val = peek_head;
00486               (k->a.utcTime)->identifier.bv_len = strLen;
00487        }
00488        else if( strncmp("generalizedTime",peek_head,strlen("generalizedTime")) == 0){
00489               (k->choiceId) = TIME_GENERALIZEDTIME;
00490               rc =   GDecComponentGeneralizedTime (mem_op, b, (&k->a.generalizedTime), bytesDecoded, DEC_ALLOC_MODE_0 );
00491               if ( rc != LDAP_SUCCESS ) return rc;
00492               (k->a.generalizedTime)->identifier.bv_val = peek_head;
00493               (k->a.generalizedTime)->identifier.bv_len = strLen;
00494        }
00495        else {
00496               Asn1Error("Undefined Identifier");
00497               return LDAP_PROTOCOL_ERROR;
00498        }
00499        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00500        *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
00501        if ( !t ) return -1;
00502        *t = *k;
00503        }
00504        t->syntax = (Syntax*)NULL;
00505        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00506        if ( !t->comp_desc ) {
00507               free ( t );
00508               return -1;
00509        }
00510        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
00511        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
00512        t->comp_desc->cd_free = (comp_free_func*)NULL;
00513        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
00514        t->comp_desc->cd_type = ASN_COMPOSITE;
00515        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00516        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
00517        return LDAP_SUCCESS;
00518 }  /* GDecTimeContent */
00519 
00520 
00521 int
00522 MatchingComponentExtension ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00523        int rc;
00524        MatchingRule* mr;
00525 
00526        if ( oid ) {
00527               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00528               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00529        }
00530 
00531        rc = 1;
00532        rc =   MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnID, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnID );
00533        if ( rc != LDAP_COMPARE_TRUE )
00534               return rc;
00535        rc =   MatchingComponentBool ( oid, (ComponentSyntaxInfo*)((ComponentExtension*)csi_attr)->critical, (ComponentSyntaxInfo*)((ComponentExtension*)csi_assert)->critical );
00536        if ( rc != LDAP_COMPARE_TRUE )
00537               return rc;
00538        rc =   MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnValue, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnValue );
00539        if ( rc != LDAP_COMPARE_TRUE )
00540               return rc;
00541        return LDAP_COMPARE_TRUE;
00542 }  /* BMatchingComponentExtension */
00543 
00544 void*
00545 ExtractingComponentExtension ( void* mem_op, ComponentReference* cr, ComponentExtension *comp )
00546 {
00547 
00548        if ( ( comp->extnID.identifier.bv_val && strncmp(comp->extnID.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnID.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00549               if ( cr->cr_curr->ci_next == NULL )
00550               return &comp->extnID;
00551               else
00552               return NULL;
00553        }
00554        if ( ( comp->critical->identifier.bv_val && strncmp(comp->critical->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->critical->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00555               if ( cr->cr_curr->ci_next == NULL )
00556                      return comp->critical;
00557               else {
00558                      cr->cr_curr = cr->cr_curr->ci_next;
00559                      return        ExtractingComponentBool ( mem_op, cr, comp->critical );
00560               }
00561        }
00562        if ( ( comp->extnValue.identifier.bv_val && strncmp(comp->extnValue.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnValue.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00563               if ( cr->cr_curr->ci_next == NULL )
00564               return &comp->extnValue;
00565        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
00566                      cr->cr_curr = cr->cr_curr->ci_next;
00567               return &comp->extnValue;
00568         } else {
00569               return NULL;
00570               }
00571        }
00572        return NULL;
00573 }  /* ExtractingComponentExtension */
00574 
00575 int
00576 BDecComponentExtension PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00577 void* mem_op _AND_
00578 GenBuf * b _AND_
00579 AsnTag tagId0 _AND_
00580 AsnLen elmtLen0 _AND_
00581 ComponentExtension **v _AND_
00582 AsnLen *bytesDecoded _AND_
00583 int mode)
00584 {
00585        int seqDone = FALSE;
00586        AsnLen totalElmtsLen1 = 0;
00587        AsnLen elmtLen1;
00588        AsnTag tagId1;
00589        int mandatoryElmtCount1 = 0;
00590        int old_mode = mode;
00591        int rc;
00592        ComponentExtension *k, *t, c_temp;
00593 
00594 
00595        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00596               memset(&c_temp,0,sizeof(c_temp));
00597                k = &c_temp;
00598        } else
00599                k = t = *v;
00600        mode = DEC_ALLOC_MODE_2;
00601     tagId1 = BDecTag (b, &totalElmtsLen1 );
00602 
00603     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
00604     {
00605     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00606        rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->extnID), &totalElmtsLen1, mode);
00607               if ( rc != LDAP_SUCCESS ) return rc;
00608               (&k->extnID)->identifier.bv_val = (&k->extnID)->id_buf;
00609               (&k->extnID)->identifier.bv_len = strlen("extnID");
00610               strcpy( (&k->extnID)->identifier.bv_val, "extnID");
00611     tagId1 = BDecTag (b, &totalElmtsLen1);
00612     }
00613     else
00614         return -1;
00615 
00616 
00617 
00618     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))))
00619     {
00620     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00621        rc = BDecComponentBool (mem_op, b, tagId1, elmtLen1, (&k->critical), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00622               if ( rc != LDAP_SUCCESS ) return rc;
00623               (k->critical)->identifier.bv_val = (k->critical)->id_buf;
00624               (k->critical)->identifier.bv_len = strlen("critical");
00625               strcpy( (k->critical)->identifier.bv_val, "critical");
00626     tagId1 = BDecTag (b, &totalElmtsLen1);
00627     }
00628 
00629 
00630     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||
00631 (tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))))
00632     {
00633     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00634        rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extnValue), &totalElmtsLen1, mode);
00635               if ( rc != LDAP_SUCCESS ) return rc;
00636               (&k->extnValue)->identifier.bv_val = (&k->extnValue)->id_buf;
00637               (&k->extnValue)->identifier.bv_len = strlen("extnValue");
00638               strcpy( (&k->extnValue)->identifier.bv_val, "extnValue");
00639         seqDone = TRUE;
00640         if (elmtLen0 == INDEFINITE_LEN)
00641             BDecEoc (b, &totalElmtsLen1 );
00642         else if (totalElmtsLen1 != elmtLen0)
00643         return -1;
00644 
00645     }
00646     else
00647         return -1;
00648 
00649 
00650 
00651     if (!seqDone)
00652         return -1;
00653 
00654        if(!COMPONENTNOT_NULL ((k->critical)))
00655        {
00656 (k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
00657               (k->critical)->identifier.bv_val = (k->critical)->id_buf;
00658               (k->critical)->identifier.bv_len = strlen("critical");
00659               strcpy( (k->critical)->identifier.bv_val, "critical");
00660        (k->critical)->value = 0;
00661        }
00662        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00663        *v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
00664        if ( !t ) return -1;
00665        *t = *k;
00666        }
00667        t->syntax = (Syntax*)NULL;
00668        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00669        if ( !t->comp_desc ) {
00670               free ( t );
00671               return -1;
00672        }
00673        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
00674        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
00675        t->comp_desc->cd_free = (comp_free_func*)NULL;
00676        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
00677        t->comp_desc->cd_type = ASN_COMPOSITE;
00678        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00679        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
00680     (*bytesDecoded) += totalElmtsLen1;
00681        return LDAP_SUCCESS;
00682 }  /* BDecExtension*/
00683 
00684 int
00685 GDecComponentExtension PARAMS (( mem_op,b, v, bytesDecoded, mode),
00686 void* mem_op _AND_
00687 GenBuf * b _AND_
00688 ComponentExtension **v _AND_
00689 AsnLen *bytesDecoded _AND_
00690 int mode)
00691 {
00692        char* peek_head,*peek_head2;
00693        int i, strLen,strLen2, rc, old_mode = mode;
00694        ComponentExtension *k,*t, c_temp;
00695 
00696 
00697        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00698               memset(&c_temp,0,sizeof(c_temp));
00699                k = &c_temp;
00700        } else
00701                k = t = *v;
00702        mode = DEC_ALLOC_MODE_2;
00703        *bytesDecoded = 0;
00704        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00705               Asn1Error("Error during Reading { in encoded data");
00706               return LDAP_PROTOCOL_ERROR;
00707        }
00708        if(*peek_head != '{'){
00709               Asn1Error("Missing { in encoded data");
00710               return LDAP_PROTOCOL_ERROR;
00711        }
00712 
00713        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00714               Asn1Error("Error during Reading identifier");
00715               return LDAP_PROTOCOL_ERROR;
00716        }
00717        if ( strncmp( peek_head, "extnID", strlen("extnID") ) == 0 ) {
00718               rc =   GDecComponentOid (mem_op, b, (&k->extnID), bytesDecoded, mode);
00719               if ( rc != LDAP_SUCCESS ) return rc;
00720        (&k->extnID)->identifier.bv_val = peek_head;
00721        (&k->extnID)->identifier.bv_len = strLen;
00722        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00723               Asn1Error("Error during Reading , ");
00724               return LDAP_PROTOCOL_ERROR;
00725        }
00726        if(*peek_head != ','){
00727               Asn1Error("Missing , in encoding");
00728               return LDAP_PROTOCOL_ERROR;
00729        }
00730        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00731          Asn1Error("Error during Reading identifier");
00732               return LDAP_PROTOCOL_ERROR;
00733        }
00734        }
00735        if ( strncmp( peek_head, "critical", strlen("critical") ) == 0 ) {
00736               rc =   GDecComponentBool (mem_op, b, (&k->critical), bytesDecoded, DEC_ALLOC_MODE_0 );
00737               if ( rc != LDAP_SUCCESS ) return rc;
00738        ( k->critical)->identifier.bv_val = peek_head;
00739        ( k->critical)->identifier.bv_len = strLen;
00740        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00741               Asn1Error("Error during Reading , ");
00742               return LDAP_PROTOCOL_ERROR;
00743        }
00744        if(*peek_head != ','){
00745               Asn1Error("Missing , in encoding");
00746               return LDAP_PROTOCOL_ERROR;
00747        }
00748        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00749          Asn1Error("Error during Reading identifier");
00750               return LDAP_PROTOCOL_ERROR;
00751        }
00752        }
00753        else {
00754 (k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
00755                      (k->critical)->value = 0;
00756        }
00757        if ( strncmp( peek_head, "extnValue", strlen("extnValue") ) == 0 ) {
00758               rc =   GDecComponentOcts (mem_op, b, (&k->extnValue), bytesDecoded, mode);
00759               if ( rc != LDAP_SUCCESS ) return rc;
00760        (&k->extnValue)->identifier.bv_val = peek_head;
00761        (&k->extnValue)->identifier.bv_len = strLen;
00762        }
00763        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
00764               Asn1Error("Error during Reading } in encoding");
00765               return LDAP_PROTOCOL_ERROR;
00766        }
00767        if(*peek_head != '}'){
00768               Asn1Error("Missing } in encoding");
00769               return LDAP_PROTOCOL_ERROR;
00770        }
00771        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00772        *v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
00773        if ( !t ) return -1;
00774        *t = *k;
00775        }
00776        t->syntax = (Syntax*)NULL;
00777        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00778        if ( !t->comp_desc ) {
00779               free ( t );
00780               return -1;
00781        }
00782        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
00783        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
00784        t->comp_desc->cd_free = (comp_free_func*)NULL;
00785        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
00786        t->comp_desc->cd_type = ASN_COMPOSITE;
00787        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00788        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
00789        return LDAP_SUCCESS;
00790 }  /* GDecExtension*/
00791 
00792 
00793 int
00794 MatchingComponentAttributeTypeAndValue ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00795        int rc;
00796        MatchingRule* mr;
00797 
00798        if ( oid ) {
00799               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00800               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00801        }
00802 
00803        rc = 1;
00804        rc =   MatchingComponentAttributeType ( oid, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->type, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_assert)->type );
00805        if ( rc != LDAP_COMPARE_TRUE )
00806               return rc;
00807        rc =   SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (&((ComponentAttributeTypeAndValue*)csi_attr)->type));
00808        rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (ComponentAny*)&((ComponentAttributeTypeAndValue*)csi_assert)->value);
00809        if ( rc != LDAP_COMPARE_TRUE )
00810               return rc;
00811        return LDAP_COMPARE_TRUE;
00812 }  /* BMatchingComponentAttributeTypeAndValue */
00813 
00814 void*
00815 ExtractingComponentAttributeTypeAndValue ( void* mem_op, ComponentReference* cr, ComponentAttributeTypeAndValue *comp )
00816 {
00817 
00818        if ( ( comp->type.identifier.bv_val && strncmp(comp->type.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->type.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00819               if ( cr->cr_curr->ci_next == NULL )
00820               return &comp->type;
00821               else
00822               return NULL;
00823        }
00824        if ( ( comp->value.identifier.bv_val && strncmp(comp->value.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->value.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00825               if ( cr->cr_curr->ci_next == NULL )
00826               return &comp->value;
00827               else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_SELECT ) {
00828                      cr->cr_curr = cr->cr_curr->ci_next;
00829                      return &comp->value;
00830         } else {
00831               return NULL;
00832               }
00833        }
00834        return NULL;
00835 }  /* ExtractingComponentAttributeTypeAndValue */
00836 
00837 int
00838 BDecComponentAttributeTypeAndValue PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00839 void* mem_op _AND_
00840 GenBuf * b _AND_
00841 AsnTag tagId0 _AND_
00842 AsnLen elmtLen0 _AND_
00843 ComponentAttributeTypeAndValue **v _AND_
00844 AsnLen *bytesDecoded _AND_
00845 int mode)
00846 {
00847        int seqDone = FALSE;
00848        AsnLen totalElmtsLen1 = 0;
00849        AsnLen elmtLen1;
00850        AsnTag tagId1;
00851        int mandatoryElmtCount1 = 0;
00852        int old_mode = mode;
00853        int rc;
00854        ComponentAttributeTypeAndValue *k, *t, c_temp;
00855 
00856 
00857        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00858               memset(&c_temp,0,sizeof(c_temp));
00859                k = &c_temp;
00860        } else
00861                k = t = *v;
00862        mode = DEC_ALLOC_MODE_2;
00863     tagId1 = BDecTag (b, &totalElmtsLen1 );
00864 
00865     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
00866     {
00867     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00868        rc = BDecComponentAttributeType (mem_op, b, tagId1, elmtLen1, (&k->type), &totalElmtsLen1, mode);
00869               if ( rc != LDAP_SUCCESS ) return rc;
00870               (&k->type)->identifier.bv_val = (&k->type)->id_buf;
00871               (&k->type)->identifier.bv_len = strlen("type");
00872               strcpy( (&k->type)->identifier.bv_val, "type");
00873     }
00874     else
00875         return -1;
00876 
00877 
00878 
00879     {
00880        rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
00881        rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );
00882               if ( rc != LDAP_SUCCESS ) return rc;
00883               (&k->value)->identifier.bv_val = (&k->value)->id_buf;
00884               (&k->value)->identifier.bv_len = strlen("value");
00885               strcpy( (&k->value)->identifier.bv_val, "value");
00886         seqDone = TRUE;
00887         if (elmtLen0 == INDEFINITE_LEN)
00888             BDecEoc (b, &totalElmtsLen1 );
00889         else if (totalElmtsLen1 != elmtLen0)
00890         return -1;
00891 
00892     }
00893 
00894 
00895     if (!seqDone)
00896         return -1;
00897 
00898        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00899        *v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
00900        if ( !t ) return -1;
00901        *t = *k;
00902        }
00903        t->syntax = (Syntax*)NULL;
00904        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00905        if ( !t->comp_desc ) {
00906               free ( t );
00907               return -1;
00908        }
00909        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
00910        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
00911        t->comp_desc->cd_free = (comp_free_func*)NULL;
00912        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
00913        t->comp_desc->cd_type = ASN_COMPOSITE;
00914        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00915        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
00916     (*bytesDecoded) += totalElmtsLen1;
00917        return LDAP_SUCCESS;
00918 }  /* BDecAttributeTypeAndValue*/
00919 
00920 int
00921 GDecComponentAttributeTypeAndValue PARAMS (( mem_op,b, v, bytesDecoded, mode),
00922 void* mem_op _AND_
00923 GenBuf * b _AND_
00924 ComponentAttributeTypeAndValue **v _AND_
00925 AsnLen *bytesDecoded _AND_
00926 int mode)
00927 {
00928        char* peek_head,*peek_head2;
00929        int i, strLen,strLen2, rc, old_mode = mode;
00930        ComponentAttributeTypeAndValue *k,*t, c_temp;
00931 
00932 
00933        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00934               memset(&c_temp,0,sizeof(c_temp));
00935                k = &c_temp;
00936        } else
00937                k = t = *v;
00938        mode = DEC_ALLOC_MODE_2;
00939        *bytesDecoded = 0;
00940        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00941               Asn1Error("Error during Reading { in encoded data");
00942               return LDAP_PROTOCOL_ERROR;
00943        }
00944        if(*peek_head != '{'){
00945               Asn1Error("Missing { in encoded data");
00946               return LDAP_PROTOCOL_ERROR;
00947        }
00948 
00949        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00950               Asn1Error("Error during Reading identifier");
00951               return LDAP_PROTOCOL_ERROR;
00952        }
00953        if ( strncmp( peek_head, "type", strlen("type") ) == 0 ) {
00954               rc =   GDecComponentAttributeType (mem_op, b, (&k->type), bytesDecoded, mode);
00955               if ( rc != LDAP_SUCCESS ) return rc;
00956        (&k->type)->identifier.bv_val = peek_head;
00957        (&k->type)->identifier.bv_len = strLen;
00958        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00959               Asn1Error("Error during Reading , ");
00960               return LDAP_PROTOCOL_ERROR;
00961        }
00962        if(*peek_head != ','){
00963               Asn1Error("Missing , in encoding");
00964               return LDAP_PROTOCOL_ERROR;
00965        }
00966        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00967          Asn1Error("Error during Reading identifier");
00968               return LDAP_PROTOCOL_ERROR;
00969        }
00970        }
00971        if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {
00972               rc =   rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
00973        rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );
00974               if ( rc != LDAP_SUCCESS ) return rc;
00975        (&k->value)->identifier.bv_val = peek_head;
00976        (&k->value)->identifier.bv_len = strLen;
00977        }
00978        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
00979               Asn1Error("Error during Reading } in encoding");
00980               return LDAP_PROTOCOL_ERROR;
00981        }
00982        if(*peek_head != '}'){
00983               Asn1Error("Missing } in encoding");
00984               return LDAP_PROTOCOL_ERROR;
00985        }
00986        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00987        *v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
00988        if ( !t ) return -1;
00989        *t = *k;
00990        }
00991        t->syntax = (Syntax*)NULL;
00992        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00993        if ( !t->comp_desc ) {
00994               free ( t );
00995               return -1;
00996        }
00997        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
00998        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
00999        t->comp_desc->cd_free = (comp_free_func*)NULL;
01000        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
01001        t->comp_desc->cd_type = ASN_COMPOSITE;
01002        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01003        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
01004        return LDAP_SUCCESS;
01005 }  /* GDecAttributeTypeAndValue*/
01006 
01007 
01008 int
01009 MatchingComponentValidity ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01010        int rc;
01011        MatchingRule* mr;
01012 
01013        if ( oid ) {
01014               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01015               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01016        }
01017 
01018        rc = 1;
01019        rc =   MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notBefore, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notBefore );
01020        if ( rc != LDAP_COMPARE_TRUE )
01021               return rc;
01022        rc =   MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notAfter, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notAfter );
01023        if ( rc != LDAP_COMPARE_TRUE )
01024               return rc;
01025        return LDAP_COMPARE_TRUE;
01026 }  /* BMatchingComponentValidity */
01027 
01028 void*
01029 ExtractingComponentValidity ( void* mem_op, ComponentReference* cr, ComponentValidity *comp )
01030 {
01031 
01032        if ( ( comp->notBefore->identifier.bv_val && strncmp(comp->notBefore->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->notBefore->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01033               if ( cr->cr_curr->ci_next == NULL )
01034                      return comp->notBefore;
01035               else {
01036                      cr->cr_curr = cr->cr_curr->ci_next;
01037                      return        ExtractingComponentTime ( mem_op, cr, comp->notBefore );
01038               }
01039        }
01040        if ( ( comp->notAfter->identifier.bv_val && strncmp(comp->notAfter->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->notAfter->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01041               if ( cr->cr_curr->ci_next == NULL )
01042                      return comp->notAfter;
01043               else {
01044                      cr->cr_curr = cr->cr_curr->ci_next;
01045                      return        ExtractingComponentTime ( mem_op, cr, comp->notAfter );
01046               }
01047        }
01048        return NULL;
01049 }  /* ExtractingComponentValidity */
01050 
01051 int
01052 BDecComponentValidity PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01053 void* mem_op _AND_
01054 GenBuf * b _AND_
01055 AsnTag tagId0 _AND_
01056 AsnLen elmtLen0 _AND_
01057 ComponentValidity **v _AND_
01058 AsnLen *bytesDecoded _AND_
01059 int mode)
01060 {
01061        int seqDone = FALSE;
01062        AsnLen totalElmtsLen1 = 0;
01063        AsnLen elmtLen1;
01064        AsnTag tagId1;
01065        int mandatoryElmtCount1 = 0;
01066        AsnLen totalElmtsLen2 = 0;
01067        AsnLen elmtLen2;
01068        AsnTag tagId2;
01069        int old_mode = mode;
01070        int rc;
01071        ComponentValidity *k, *t, c_temp;
01072 
01073 
01074        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01075               memset(&c_temp,0,sizeof(c_temp));
01076                k = &c_temp;
01077        } else
01078                k = t = *v;
01079        mode = DEC_ALLOC_MODE_2;
01080     tagId1 = BDecTag (b, &totalElmtsLen1 );
01081 
01082     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
01083 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
01084      (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
01085     (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
01086     {
01087         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01088        rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notBefore), &totalElmtsLen1, mode);
01089               if ( rc != LDAP_SUCCESS ) return rc;
01090               (k->notBefore)->identifier.bv_val = (k->notBefore)->id_buf;
01091               (k->notBefore)->identifier.bv_len = strlen("notBefore");
01092               strcpy( (k->notBefore)->identifier.bv_val, "notBefore");
01093     tagId1 = BDecTag (b, &totalElmtsLen1);
01094     }
01095     else
01096         return -1;
01097 
01098 
01099 
01100     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
01101 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
01102      (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
01103     (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
01104     {
01105         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01106        rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notAfter), &totalElmtsLen1, mode);
01107               if ( rc != LDAP_SUCCESS ) return rc;
01108               (k->notAfter)->identifier.bv_val = (k->notAfter)->id_buf;
01109               (k->notAfter)->identifier.bv_len = strlen("notAfter");
01110               strcpy( (k->notAfter)->identifier.bv_val, "notAfter");
01111         seqDone = TRUE;
01112         if (elmtLen0 == INDEFINITE_LEN)
01113             BDecEoc (b, &totalElmtsLen1 );
01114         else if (totalElmtsLen1 != elmtLen0)
01115         return -1;
01116 
01117     }
01118     else
01119         return -1;
01120 
01121 
01122 
01123     if (!seqDone)
01124         return -1;
01125 
01126        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01127        *v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
01128        if ( !t ) return -1;
01129        *t = *k;
01130        }
01131        t->syntax = (Syntax*)NULL;
01132        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01133        if ( !t->comp_desc ) {
01134               free ( t );
01135               return -1;
01136        }
01137        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
01138        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
01139        t->comp_desc->cd_free = (comp_free_func*)NULL;
01140        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
01141        t->comp_desc->cd_type = ASN_COMPOSITE;
01142        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01143        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
01144     (*bytesDecoded) += totalElmtsLen1;
01145        return LDAP_SUCCESS;
01146 }  /* BDecValidity*/
01147 
01148 int
01149 GDecComponentValidity PARAMS (( mem_op,b, v, bytesDecoded, mode),
01150 void* mem_op _AND_
01151 GenBuf * b _AND_
01152 ComponentValidity **v _AND_
01153 AsnLen *bytesDecoded _AND_
01154 int mode)
01155 {
01156        char* peek_head,*peek_head2;
01157        int i, strLen,strLen2, rc, old_mode = mode;
01158        ComponentValidity *k,*t, c_temp;
01159 
01160 
01161        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01162               memset(&c_temp,0,sizeof(c_temp));
01163                k = &c_temp;
01164        } else
01165                k = t = *v;
01166        mode = DEC_ALLOC_MODE_2;
01167        *bytesDecoded = 0;
01168        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01169               Asn1Error("Error during Reading { in encoded data");
01170               return LDAP_PROTOCOL_ERROR;
01171        }
01172        if(*peek_head != '{'){
01173               Asn1Error("Missing { in encoded data");
01174               return LDAP_PROTOCOL_ERROR;
01175        }
01176 
01177        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01178               Asn1Error("Error during Reading identifier");
01179               return LDAP_PROTOCOL_ERROR;
01180        }
01181        if ( strncmp( peek_head, "notBefore", strlen("notBefore") ) == 0 ) {
01182               rc =   GDecComponentTime (mem_op, b, (&k->notBefore), bytesDecoded, mode);
01183               if ( rc != LDAP_SUCCESS ) return rc;
01184        ( k->notBefore)->identifier.bv_val = peek_head;
01185        ( k->notBefore)->identifier.bv_len = strLen;
01186        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01187               Asn1Error("Error during Reading , ");
01188               return LDAP_PROTOCOL_ERROR;
01189        }
01190        if(*peek_head != ','){
01191               Asn1Error("Missing , in encoding");
01192               return LDAP_PROTOCOL_ERROR;
01193        }
01194        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01195          Asn1Error("Error during Reading identifier");
01196               return LDAP_PROTOCOL_ERROR;
01197        }
01198        }
01199        if ( strncmp( peek_head, "notAfter", strlen("notAfter") ) == 0 ) {
01200               rc =   GDecComponentTime (mem_op, b, (&k->notAfter), bytesDecoded, mode);
01201               if ( rc != LDAP_SUCCESS ) return rc;
01202        ( k->notAfter)->identifier.bv_val = peek_head;
01203        ( k->notAfter)->identifier.bv_len = strLen;
01204        }
01205        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
01206               Asn1Error("Error during Reading } in encoding");
01207               return LDAP_PROTOCOL_ERROR;
01208        }
01209        if(*peek_head != '}'){
01210               Asn1Error("Missing } in encoding");
01211               return LDAP_PROTOCOL_ERROR;
01212        }
01213        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01214        *v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
01215        if ( !t ) return -1;
01216        *t = *k;
01217        }
01218        t->syntax = (Syntax*)NULL;
01219        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01220        if ( !t->comp_desc ) {
01221               free ( t );
01222               return -1;
01223        }
01224        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
01225        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
01226        t->comp_desc->cd_free = (comp_free_func*)NULL;
01227        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
01228        t->comp_desc->cd_type = ASN_COMPOSITE;
01229        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01230        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
01231        return LDAP_SUCCESS;
01232 }  /* GDecValidity*/
01233 
01234 
01235 int
01236 MatchingComponentSubjectPublicKeyInfo ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01237        int rc;
01238        MatchingRule* mr;
01239 
01240        if ( oid ) {
01241               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01242               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01243        }
01244 
01245        rc = 1;
01246        rc =   MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_attr)->algorithm, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_assert)->algorithm );
01247        if ( rc != LDAP_COMPARE_TRUE )
01248               return rc;
01249        rc =   MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_attr)->subjectPublicKey, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_assert)->subjectPublicKey );
01250        if ( rc != LDAP_COMPARE_TRUE )
01251               return rc;
01252        return LDAP_COMPARE_TRUE;
01253 }  /* BMatchingComponentSubjectPublicKeyInfo */
01254 
01255 void*
01256 ExtractingComponentSubjectPublicKeyInfo ( void* mem_op, ComponentReference* cr, ComponentSubjectPublicKeyInfo *comp )
01257 {
01258 
01259        if ( ( comp->algorithm->identifier.bv_val && strncmp(comp->algorithm->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->algorithm->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01260               if ( cr->cr_curr->ci_next == NULL )
01261                      return comp->algorithm;
01262               else {
01263                      cr->cr_curr = cr->cr_curr->ci_next;
01264                      return        ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->algorithm );
01265               }
01266        }
01267        if ( ( comp->subjectPublicKey.identifier.bv_val && strncmp(comp->subjectPublicKey.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectPublicKey.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01268               if ( cr->cr_curr->ci_next == NULL )
01269               return &comp->subjectPublicKey;
01270        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
01271                      cr->cr_curr = cr->cr_curr->ci_next;
01272               return &comp->subjectPublicKey;
01273         } else {
01274               return NULL;
01275               }
01276        }
01277        return NULL;
01278 }  /* ExtractingComponentSubjectPublicKeyInfo */
01279 
01280 int
01281 BDecComponentSubjectPublicKeyInfo PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01282 void* mem_op _AND_
01283 GenBuf * b _AND_
01284 AsnTag tagId0 _AND_
01285 AsnLen elmtLen0 _AND_
01286 ComponentSubjectPublicKeyInfo **v _AND_
01287 AsnLen *bytesDecoded _AND_
01288 int mode)
01289 {
01290        int seqDone = FALSE;
01291        AsnLen totalElmtsLen1 = 0;
01292        AsnLen elmtLen1;
01293        AsnTag tagId1;
01294        int mandatoryElmtCount1 = 0;
01295        int old_mode = mode;
01296        int rc;
01297        ComponentSubjectPublicKeyInfo *k, *t, c_temp;
01298 
01299 
01300        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01301               memset(&c_temp,0,sizeof(c_temp));
01302                k = &c_temp;
01303        } else
01304                k = t = *v;
01305        mode = DEC_ALLOC_MODE_2;
01306     tagId1 = BDecTag (b, &totalElmtsLen1 );
01307 
01308     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
01309     {
01310     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01311        rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
01312               if ( rc != LDAP_SUCCESS ) return rc;
01313               (k->algorithm)->identifier.bv_val = (k->algorithm)->id_buf;
01314               (k->algorithm)->identifier.bv_len = strlen("algorithm");
01315               strcpy( (k->algorithm)->identifier.bv_val, "algorithm");
01316     tagId1 = BDecTag (b, &totalElmtsLen1);
01317     }
01318     else
01319         return -1;
01320 
01321 
01322 
01323     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
01324 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
01325     {
01326     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01327        rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKey), &totalElmtsLen1, mode);
01328               if ( rc != LDAP_SUCCESS ) return rc;
01329               (&k->subjectPublicKey)->identifier.bv_val = (&k->subjectPublicKey)->id_buf;
01330               (&k->subjectPublicKey)->identifier.bv_len = strlen("subjectPublicKey");
01331               strcpy( (&k->subjectPublicKey)->identifier.bv_val, "subjectPublicKey");
01332         seqDone = TRUE;
01333         if (elmtLen0 == INDEFINITE_LEN)
01334             BDecEoc (b, &totalElmtsLen1 );
01335         else if (totalElmtsLen1 != elmtLen0)
01336         return -1;
01337 
01338     }
01339     else
01340         return -1;
01341 
01342 
01343 
01344     if (!seqDone)
01345         return -1;
01346 
01347        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01348        *v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
01349        if ( !t ) return -1;
01350        *t = *k;
01351        }
01352        t->syntax = (Syntax*)NULL;
01353        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01354        if ( !t->comp_desc ) {
01355               free ( t );
01356               return -1;
01357        }
01358        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
01359        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
01360        t->comp_desc->cd_free = (comp_free_func*)NULL;
01361        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
01362        t->comp_desc->cd_type = ASN_COMPOSITE;
01363        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01364        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
01365     (*bytesDecoded) += totalElmtsLen1;
01366        return LDAP_SUCCESS;
01367 }  /* BDecSubjectPublicKeyInfo*/
01368 
01369 int
01370 GDecComponentSubjectPublicKeyInfo PARAMS (( mem_op,b, v, bytesDecoded, mode),
01371 void* mem_op _AND_
01372 GenBuf * b _AND_
01373 ComponentSubjectPublicKeyInfo **v _AND_
01374 AsnLen *bytesDecoded _AND_
01375 int mode)
01376 {
01377        char* peek_head,*peek_head2;
01378        int i, strLen,strLen2, rc, old_mode = mode;
01379        ComponentSubjectPublicKeyInfo *k,*t, c_temp;
01380 
01381 
01382        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01383               memset(&c_temp,0,sizeof(c_temp));
01384                k = &c_temp;
01385        } else
01386                k = t = *v;
01387        mode = DEC_ALLOC_MODE_2;
01388        *bytesDecoded = 0;
01389        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01390               Asn1Error("Error during Reading { in encoded data");
01391               return LDAP_PROTOCOL_ERROR;
01392        }
01393        if(*peek_head != '{'){
01394               Asn1Error("Missing { in encoded data");
01395               return LDAP_PROTOCOL_ERROR;
01396        }
01397 
01398        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01399               Asn1Error("Error during Reading identifier");
01400               return LDAP_PROTOCOL_ERROR;
01401        }
01402        if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
01403               rc =   GDecComponentAlgorithmIdentifier (mem_op, b, (&k->algorithm), bytesDecoded, mode);
01404               if ( rc != LDAP_SUCCESS ) return rc;
01405        ( k->algorithm)->identifier.bv_val = peek_head;
01406        ( k->algorithm)->identifier.bv_len = strLen;
01407        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01408               Asn1Error("Error during Reading , ");
01409               return LDAP_PROTOCOL_ERROR;
01410        }
01411        if(*peek_head != ','){
01412               Asn1Error("Missing , in encoding");
01413               return LDAP_PROTOCOL_ERROR;
01414        }
01415        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01416          Asn1Error("Error during Reading identifier");
01417               return LDAP_PROTOCOL_ERROR;
01418        }
01419        }
01420        if ( strncmp( peek_head, "subjectPublicKey", strlen("subjectPublicKey") ) == 0 ) {
01421               rc =   GDecComponentBits (mem_op, b, (&k->subjectPublicKey), bytesDecoded, mode);
01422               if ( rc != LDAP_SUCCESS ) return rc;
01423        (&k->subjectPublicKey)->identifier.bv_val = peek_head;
01424        (&k->subjectPublicKey)->identifier.bv_len = strLen;
01425        }
01426        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
01427               Asn1Error("Error during Reading } in encoding");
01428               return LDAP_PROTOCOL_ERROR;
01429        }
01430        if(*peek_head != '}'){
01431               Asn1Error("Missing } in encoding");
01432               return LDAP_PROTOCOL_ERROR;
01433        }
01434        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01435        *v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
01436        if ( !t ) return -1;
01437        *t = *k;
01438        }
01439        t->syntax = (Syntax*)NULL;
01440        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01441        if ( !t->comp_desc ) {
01442               free ( t );
01443               return -1;
01444        }
01445        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
01446        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
01447        t->comp_desc->cd_free = (comp_free_func*)NULL;
01448        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
01449        t->comp_desc->cd_type = ASN_COMPOSITE;
01450        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01451        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
01452        return LDAP_SUCCESS;
01453 }  /* GDecSubjectPublicKeyInfo*/
01454 
01455 
01456 int
01457 MatchingComponentExtensions ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01458        int rc;
01459        MatchingRule* mr;
01460        void* component1, *component2;
01461        AsnList *v1, *v2, t_list;
01462 
01463 
01464        if ( oid ) {
01465               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01466               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01467        }
01468 
01469        v1 = &((ComponentExtensions*)csi_attr)->comp_list;
01470        v2 = &((ComponentExtensions*)csi_assert)->comp_list;
01471        FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
01472        {
01473               if( MatchingComponentExtension(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
01474                      return LDAP_COMPARE_FALSE;
01475               }
01476        } /* end of for */
01477 
01478        AsnListFirst( v1 );
01479        AsnListFirst( v2 );
01480        if( (!component1 && component2) || (component1 && !component2))
01481               return LDAP_COMPARE_FALSE;
01482        else
01483               return LDAP_COMPARE_TRUE;
01484 }  /* BMatchingComponentExtensionsContent */
01485 
01486 void*
01487 ExtractingComponentExtensions ( void* mem_op, ComponentReference* cr, ComponentExtensions *comp )
01488 {
01489        int count = 0;
01490        int total;
01491        AsnList *v = &comp->comp_list;
01492        ComponentInt *k;
01493        ComponentExtension *component;
01494 
01495 
01496        switch ( cr->cr_curr->ci_type ) {
01497        case LDAP_COMPREF_FROM_BEGINNING :
01498               count = cr->cr_curr->ci_val.ci_from_beginning;
01499               FOR_EACH_LIST_ELMT( component , v ) {
01500                      if( --count == 0 ) {
01501                             if( cr->cr_curr->ci_next == NULL )
01502                                    return component;
01503                             else {
01504                                    cr->cr_curr = cr->cr_curr->ci_next;
01505                                    return        ExtractingComponentExtension ( mem_op, cr, component );
01506                             }
01507                      }
01508               }
01509               break;
01510        case LDAP_COMPREF_FROM_END :
01511               total = AsnListCount ( v );
01512               count = cr->cr_curr->ci_val.ci_from_end;
01513               count = total + count +1;
01514               FOR_EACH_LIST_ELMT ( component, v ) {
01515                      if( --count == 0 ) {
01516                             if( cr->cr_curr->ci_next == NULL ) 
01517                                    return component;
01518                             else {
01519                                    cr->cr_curr = cr->cr_curr->ci_next;
01520                                    return        ExtractingComponentExtension ( mem_op, cr, component );
01521                             }
01522                      }
01523               }
01524               break;
01525        case LDAP_COMPREF_ALL :
01526               return comp;
01527        case LDAP_COMPREF_COUNT :
01528               k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
01529               k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01530               k->comp_desc->cd_tag = (-1);
01531               k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
01532               k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
01533               k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
01534               k->comp_desc->cd_type = ASN_BASIC;
01535               k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
01536               k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
01537               k->value = AsnListCount(v);
01538               return k;
01539        default :
01540               return NULL;
01541        }
01542 }  /* ExtractingComponentExtensions */
01543 
01544 int
01545 BDecComponentExtensions PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01546 void* mem_op _AND_
01547 GenBuf * b _AND_
01548 AsnTag tagId0 _AND_
01549 AsnLen elmtLen0 _AND_
01550 ComponentExtensions **v _AND_
01551 AsnLen *bytesDecoded _AND_
01552 int mode)
01553 {
01554        int seqDone = FALSE;
01555        AsnLen totalElmtsLen1 = 0;
01556        AsnLen elmtLen1;
01557        AsnTag tagId1;
01558        int mandatoryElmtCount1 = 0;
01559        int old_mode = mode;
01560        int rc;
01561        ComponentExtensions *k, *t, c_temp;
01562 
01563 
01564        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01565               memset(&c_temp,0,sizeof(c_temp));
01566                k = &c_temp;
01567        } else
01568                k = t = *v;
01569        mode = DEC_ALLOC_MODE_2;
01570        AsnListInit(&k->comp_list,sizeof(ComponentExtension));
01571     for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
01572     {
01573         ComponentExtension **tmpVar;
01574     tagId1 = BDecTag (b, &totalElmtsLen1 );
01575 
01576     if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
01577     {
01578         BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01579         break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
01580     }
01581     if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
01582     {
01583         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01584     tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op,&k->comp_list);
01585        rc = BDecComponentExtension (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
01586               if ( rc != LDAP_SUCCESS ) return rc;
01587     }  /* end of tag check if */
01588     else  /* wrong tag */
01589     {
01590          Asn1Error ("Unexpected Tag\n");
01591          return -1;
01592     }
01593     } /* end of for */
01594 
01595        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01596        *v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
01597        if ( !t ) return -1;
01598        *t = *k;
01599        }
01600        t->syntax = (Syntax*)NULL;
01601        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01602        if ( !t->comp_desc ) {
01603               free ( t );
01604               return -1;
01605        }
01606        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
01607        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
01608        t->comp_desc->cd_free = (comp_free_func*)NULL;
01609        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
01610        t->comp_desc->cd_type = ASN_COMPOSITE;
01611        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01612        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
01613     (*bytesDecoded) += totalElmtsLen1;
01614        return LDAP_SUCCESS;
01615 }  /* BDecExtensionsContent */
01616 
01617 int
01618 GDecComponentExtensions PARAMS (( mem_op,b, v, bytesDecoded, mode),
01619 void* mem_op _AND_
01620 GenBuf * b _AND_
01621 ComponentExtensions **v _AND_
01622 AsnLen *bytesDecoded _AND_
01623 int mode)
01624 {
01625        char* peek_head,*peek_head2;
01626        int i, strLen,strLen2, rc, old_mode = mode;
01627        ComponentExtensions *k,*t, c_temp;
01628 
01629 
01630        int ElmtsLen1;
01631        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01632               memset(&c_temp,0,sizeof(c_temp));
01633                k = &c_temp;
01634        } else
01635                k = t = *v;
01636        mode = DEC_ALLOC_MODE_2;
01637        AsnListInit( &k->comp_list, sizeof( ComponentExtension ) );
01638        *bytesDecoded = 0;
01639        if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
01640               Asn1Error("Error during Reading { in encoding");
01641               return LDAP_PROTOCOL_ERROR;
01642        }
01643        if(*peek_head != '{'){
01644               Asn1Error("Missing { in encoded data");
01645               return LDAP_PROTOCOL_ERROR;
01646        }
01647 
01648        for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
01649        {
01650               ComponentExtension **tmpVar;
01651               if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
01652                      Asn1Error("Error during Reading{ in encoding");
01653                      return LDAP_PROTOCOL_ERROR;
01654               }
01655               if(*peek_head == '}') break;
01656               if( !(*peek_head == '{' || *peek_head ==',') ) {
01657                      return LDAP_PROTOCOL_ERROR;
01658               }
01659               tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op, &k->comp_list);
01660               if ( tmpVar == NULL ) {
01661                      Asn1Error("Error during Reading{ in encoding");
01662                      return LDAP_PROTOCOL_ERROR;
01663               }
01664               rc =   GDecComponentExtension (mem_op, b, tmpVar, bytesDecoded, mode);
01665               if ( rc != LDAP_SUCCESS ) return rc;
01666        } /* end of for */
01667 
01668        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01669        *v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
01670        if ( !t ) return -1;
01671        *t = *k;
01672        }
01673        t->syntax = (Syntax*)NULL;
01674        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01675        if ( !t->comp_desc ) {
01676               free ( t );
01677               return -1;
01678        }
01679        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
01680        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
01681        t->comp_desc->cd_free = (comp_free_func*)NULL;
01682        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
01683        t->comp_desc->cd_type = ASN_COMPOSITE;
01684        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01685        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
01686        return LDAP_SUCCESS;
01687 }  /* GDecExtensionsContent */
01688 
01689 
01690 int
01691 MatchingComponentRelativeDistinguishedName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01692        int rc;
01693        MatchingRule* mr;
01694        void* component1, *component2;
01695        AsnList *v1, *v2, t_list;
01696 
01697 
01698        if ( oid ) {
01699               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01700               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01701        }
01702 
01703        v1 = &((ComponentRelativeDistinguishedName*)csi_attr)->comp_list;
01704        v2 = &((ComponentRelativeDistinguishedName*)csi_assert)->comp_list;
01705        AsnListInit( &t_list, 0 );
01706        if( AsnListCount( v1 ) != AsnListCount( v2 ) )
01707               return LDAP_COMPARE_FALSE;
01708        FOR_EACH_LIST_ELMT (component1, v1)
01709        {
01710               FOR_EACH_LIST_ELMT(component2, v2)
01711               {
01712                      if( MatchingComponentAttributeTypeAndValue(oid, (ComponentSyntaxInfo*)component1,(ComponentSyntaxInfo*)component2) == LDAP_COMPARE_TRUE ) {
01713                      AsnElmtMove( v2, &t_list );
01714                         break;
01715                      }
01716               } /* end of inner for */
01717        } /* end of outer for */
01718 
01719        if( AsnListCount( v2 ) == 0 )
01720                rc = LDAP_COMPARE_TRUE;
01721        else
01722                rc = LDAP_COMPARE_FALSE;
01723        AsnListMove( &t_list, v2 );
01724        AsnListFirst( v1 );
01725        AsnListFirst( v2 );
01726        return rc;
01727 }  /* BMatchingComponentRelativeDistinguishedNameContent */
01728 
01729 void*
01730 ExtractingComponentRelativeDistinguishedName ( void* mem_op, ComponentReference* cr, ComponentRelativeDistinguishedName *comp )
01731 {
01732        int count = 0;
01733        int total;
01734        AsnList *v = &comp->comp_list;
01735        ComponentInt *k;
01736        ComponentAttributeTypeAndValue *component;
01737 
01738 
01739        switch ( cr->cr_curr->ci_type ) {
01740        case LDAP_COMPREF_FROM_BEGINNING :
01741               count = cr->cr_curr->ci_val.ci_from_beginning;
01742               FOR_EACH_LIST_ELMT( component , v ) {
01743                      if( --count == 0 ) {
01744                             if( cr->cr_curr->ci_next == NULL )
01745                                    return component;
01746                             else {
01747                                    cr->cr_curr = cr->cr_curr->ci_next;
01748                                    return        ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
01749                             }
01750                      }
01751               }
01752               break;
01753        case LDAP_COMPREF_FROM_END :
01754               total = AsnListCount ( v );
01755               count = cr->cr_curr->ci_val.ci_from_end;
01756               count = total + count +1;
01757               FOR_EACH_LIST_ELMT ( component, v ) {
01758                      if( --count == 0 ) {
01759                             if( cr->cr_curr->ci_next == NULL )
01760                                    return component;
01761                             else {
01762                                    cr->cr_curr = cr->cr_curr->ci_next;
01763                                    return        ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
01764                             }
01765                      }
01766               }
01767               break;
01768        case LDAP_COMPREF_ALL :
01769               return comp;
01770        case LDAP_COMPREF_COUNT :
01771               k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
01772               k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01773               k->comp_desc->cd_tag = (-1);
01774               k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
01775               k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
01776               k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
01777               k->comp_desc->cd_type = ASN_BASIC;
01778               k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
01779               k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
01780               k->value = AsnListCount(v);
01781               return k;
01782        default :
01783               return NULL;
01784        }
01785 }  /* ExtractingComponentRelativeDistinguishedName */
01786 
01787 int
01788 BDecComponentRelativeDistinguishedName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01789 void* mem_op _AND_
01790 GenBuf * b _AND_
01791 AsnTag tagId0 _AND_
01792 AsnLen elmtLen0 _AND_
01793 ComponentRelativeDistinguishedName **v _AND_
01794 AsnLen *bytesDecoded _AND_
01795 int mode)
01796 {
01797        int seqDone = FALSE;
01798        AsnLen totalElmtsLen1 = 0;
01799        AsnLen elmtLen1;
01800        AsnTag tagId1;
01801        int mandatoryElmtCount1 = 0;
01802        int old_mode = mode;
01803        int rc;
01804        ComponentRelativeDistinguishedName *k, *t, c_temp;
01805 
01806 
01807        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01808               memset(&c_temp,0,sizeof(c_temp));
01809                k = &c_temp;
01810        } else
01811                k = t = *v;
01812        mode = DEC_ALLOC_MODE_2;
01813        AsnListInit(&k->comp_list,sizeof(ComponentAttributeTypeAndValue));
01814     for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
01815     {
01816         ComponentAttributeTypeAndValue **tmpVar;
01817     tagId1 = BDecTag (b, &totalElmtsLen1 );
01818 
01819     if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
01820     {
01821         BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01822         break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
01823     }
01824     if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
01825     {
01826         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01827     tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op,&k->comp_list);
01828        rc = BDecComponentAttributeTypeAndValue (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
01829               if ( rc != LDAP_SUCCESS ) return rc;
01830     }  /* end of tag check if */
01831     else  /* wrong tag */
01832     {
01833          Asn1Error ("Unexpected Tag\n");
01834          return -1;
01835     }
01836     } /* end of for */
01837 
01838        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01839        *v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
01840        if ( !t ) return -1;
01841        *t = *k;
01842        }
01843        t->syntax = (Syntax*)NULL;
01844        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01845        if ( !t->comp_desc ) {
01846               free ( t );
01847               return -1;
01848        }
01849 
01850        t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
01851        t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
01852        t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDN2RFC2253;
01853        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
01854        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
01855        t->comp_desc->cd_free = (comp_free_func*)NULL;
01856        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
01857        t->comp_desc->cd_type = ASN_COMPOSITE;
01858        t->comp_desc->cd_type_id = RelativeDistinguishedName;
01859        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
01860     (*bytesDecoded) += totalElmtsLen1;
01861        return LDAP_SUCCESS;
01862 }  /* BDecRelativeDistinguishedNameContent */
01863 
01864 int
01865 GDecComponentRelativeDistinguishedName PARAMS (( mem_op,b, v, bytesDecoded, mode),
01866 void* mem_op _AND_
01867 GenBuf * b _AND_
01868 ComponentRelativeDistinguishedName **v _AND_
01869 AsnLen *bytesDecoded _AND_
01870 int mode)
01871 {
01872        char* peek_head,*peek_head2;
01873        int i, strLen,strLen2, rc, old_mode = mode;
01874        ComponentRelativeDistinguishedName *k,*t, c_temp;
01875 
01876 
01877        int ElmtsLen1;
01878        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01879               memset(&c_temp,0,sizeof(c_temp));
01880                k = &c_temp;
01881        } else
01882                k = t = *v;
01883        mode = DEC_ALLOC_MODE_2;
01884        AsnListInit( &k->comp_list, sizeof( ComponentAttributeTypeAndValue ) );
01885        *bytesDecoded = 0;
01886        if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
01887               Asn1Error("Error during Reading { in encoding");
01888               return LDAP_PROTOCOL_ERROR;
01889        }
01890        if(*peek_head != '{'){
01891               Asn1Error("Missing { in encoded data");
01892               return LDAP_PROTOCOL_ERROR;
01893        }
01894 
01895        for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
01896        {
01897               ComponentAttributeTypeAndValue **tmpVar;
01898               if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
01899                      Asn1Error("Error during Reading{ in encoding");
01900                      return LDAP_PROTOCOL_ERROR;
01901               }
01902               if(*peek_head == '}') break;
01903               if( !(*peek_head == '{' || *peek_head ==',') ) {
01904                      return LDAP_PROTOCOL_ERROR;
01905               }
01906               tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op, &k->comp_list);
01907               if ( tmpVar == NULL ) {
01908                      Asn1Error("Error during Reading{ in encoding");
01909                      return LDAP_PROTOCOL_ERROR;
01910               }
01911               rc =   GDecComponentAttributeTypeAndValue (mem_op, b, tmpVar, bytesDecoded, mode);
01912               if ( rc != LDAP_SUCCESS ) return rc;
01913        } /* end of for */
01914 
01915        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01916        *v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
01917        if ( !t ) return -1;
01918        *t = *k;
01919        }
01920        t->syntax = (Syntax*)NULL;
01921        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01922        if ( !t->comp_desc ) {
01923               free ( t );
01924               return -1;
01925        }
01926        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
01927        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
01928        t->comp_desc->cd_free = (comp_free_func*)NULL;
01929        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
01930        t->comp_desc->cd_type = ASN_COMPOSITE;
01931        t->comp_desc->cd_type_id = RelativeDistinguishedName;
01932        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
01933        return LDAP_SUCCESS;
01934 }  /* GDecRelativeDistinguishedNameContent */
01935 
01936 
01937 int
01938 MatchingComponentRDNSequence ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01939        int rc;
01940        MatchingRule* mr;
01941        void* component1, *component2;
01942        AsnList *v1, *v2, t_list;
01943 
01944 
01945        if ( oid ) {
01946               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01947               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01948        }
01949 
01950        v1 = &((ComponentRDNSequence*)csi_attr)->comp_list;
01951        v2 = &((ComponentRDNSequence*)csi_assert)->comp_list;
01952        FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
01953        {
01954               if( MatchingComponentRelativeDistinguishedName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
01955                      return LDAP_COMPARE_FALSE;
01956               }
01957        } /* end of for */
01958 
01959        AsnListFirst( v1 );
01960        AsnListFirst( v2 );
01961        if( (!component1 && component2) || (component1 && !component2))
01962               return LDAP_COMPARE_FALSE;
01963        else
01964               return LDAP_COMPARE_TRUE;
01965 }  /* BMatchingComponentRDNSequenceContent */
01966 
01967 void*
01968 ExtractingComponentRDNSequence ( void* mem_op, ComponentReference* cr, ComponentRDNSequence *comp )
01969 {
01970        int count = 0;
01971        int total;
01972        AsnList *v = &comp->comp_list;
01973        ComponentInt *k;
01974        ComponentRelativeDistinguishedName *component;
01975 
01976 
01977        switch ( cr->cr_curr->ci_type ) {
01978        case LDAP_COMPREF_FROM_BEGINNING :
01979               count = cr->cr_curr->ci_val.ci_from_beginning;
01980               FOR_EACH_LIST_ELMT( component , v ) {
01981                      if( --count == 0 ) {
01982                             if( cr->cr_curr->ci_next == NULL )
01983                                    return component;
01984                             else {
01985                                    cr->cr_curr = cr->cr_curr->ci_next;
01986                                    return        ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
01987                             }
01988                      }
01989               }
01990               break;
01991        case LDAP_COMPREF_FROM_END :
01992               total = AsnListCount ( v );
01993               count = cr->cr_curr->ci_val.ci_from_end;
01994               count = total + count +1;
01995               FOR_EACH_LIST_ELMT ( component, v ) {
01996                      if( --count == 0 ) {
01997                             if( cr->cr_curr->ci_next == NULL ) 
01998                                    return component;
01999                             else {
02000                                    cr->cr_curr = cr->cr_curr->ci_next;
02001                                    return        ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
02002                             }
02003                      }
02004               }
02005               break;
02006        case LDAP_COMPREF_ALL :
02007               return comp;
02008        case LDAP_COMPREF_COUNT :
02009               k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
02010               k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02011               k->comp_desc->cd_tag = (-1);
02012               k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
02013               k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
02014               k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
02015               k->comp_desc->cd_type = ASN_BASIC;
02016               k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
02017               k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
02018               k->value = AsnListCount(v);
02019               return k;
02020        default :
02021               return NULL;
02022        }
02023 }  /* ExtractingComponentRDNSequence */
02024 
02025 int
02026 BDecComponentRDNSequence PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
02027 void* mem_op _AND_
02028 GenBuf * b _AND_
02029 AsnTag tagId0 _AND_
02030 AsnLen elmtLen0 _AND_
02031 ComponentRDNSequence **v _AND_
02032 AsnLen *bytesDecoded _AND_
02033 int mode)
02034 {
02035        int seqDone = FALSE;
02036        AsnLen totalElmtsLen1 = 0;
02037        AsnLen elmtLen1;
02038        AsnTag tagId1;
02039        int mandatoryElmtCount1 = 0;
02040        int old_mode = mode;
02041        int rc;
02042        ComponentRDNSequence *k, *t, c_temp;
02043 
02044 
02045        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02046               memset(&c_temp,0,sizeof(c_temp));
02047                k = &c_temp;
02048        } else
02049                k = t = *v;
02050        mode = DEC_ALLOC_MODE_2;
02051        AsnListInit(&k->comp_list,sizeof(ComponentRelativeDistinguishedName));
02052     for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
02053     {
02054         ComponentRelativeDistinguishedName **tmpVar;
02055     tagId1 = BDecTag (b, &totalElmtsLen1 );
02056 
02057     if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
02058     {
02059         BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
02060         break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
02061     }
02062     if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
02063     {
02064         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02065     tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op,&k->comp_list);
02066        rc = BDecComponentRelativeDistinguishedName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
02067               if ( rc != LDAP_SUCCESS ) return rc;
02068     }  /* end of tag check if */
02069     else  /* wrong tag */
02070     {
02071          Asn1Error ("Unexpected Tag\n");
02072          return -1;
02073     }
02074     } /* end of for */
02075 
02076        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02077        *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
02078        if ( !t ) return -1;
02079        *t = *k;
02080        }
02081        t->syntax = (Syntax*)NULL;
02082        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02083        if ( !t->comp_desc ) {
02084               free ( t );
02085               return -1;
02086        }
02087 
02088        t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
02089        t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
02090        t->comp_desc->cd_ldap_encoder = (encoder_func*) ConvertRDNSequence2RFC2253;
02091        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
02092        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
02093        t->comp_desc->cd_free = (comp_free_func*)NULL;
02094        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
02095        t->comp_desc->cd_type = ASN_COMPOSITE;
02096        t->comp_desc->cd_type_id = RDNSequence;
02097        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
02098     (*bytesDecoded) += totalElmtsLen1;
02099        return LDAP_SUCCESS;
02100 }  /* BDecRDNSequenceContent */
02101 
02102 int
02103 GDecComponentRDNSequence PARAMS (( mem_op,b, v, bytesDecoded, mode),
02104 void* mem_op _AND_
02105 GenBuf * b _AND_
02106 ComponentRDNSequence **v _AND_
02107 AsnLen *bytesDecoded _AND_
02108 int mode)
02109 {
02110        char* peek_head,*peek_head2;
02111        int i, strLen,strLen2, rc, old_mode = mode;
02112        ComponentRDNSequence *k,*t, c_temp;
02113 
02114 
02115        int ElmtsLen1;
02116        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02117               memset(&c_temp,0,sizeof(c_temp));
02118                k = &c_temp;
02119        } else
02120                k = t = *v;
02121        mode = DEC_ALLOC_MODE_2;
02122        AsnListInit( &k->comp_list, sizeof( ComponentRelativeDistinguishedName ) );
02123        *bytesDecoded = 0;
02124        if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
02125               Asn1Error("Error during Reading { in encoding");
02126               return LDAP_PROTOCOL_ERROR;
02127        }
02128        if(*peek_head != '{'){
02129               Asn1Error("Missing { in encoded data");
02130               return LDAP_PROTOCOL_ERROR;
02131        }
02132 
02133        for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
02134        {
02135               ComponentRelativeDistinguishedName **tmpVar;
02136               if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
02137                      Asn1Error("Error during Reading{ in encoding");
02138                      return LDAP_PROTOCOL_ERROR;
02139               }
02140               if(*peek_head == '}') break;
02141               if( !(*peek_head == '{' || *peek_head ==',') ) {
02142                      return LDAP_PROTOCOL_ERROR;
02143               }
02144               tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op, &k->comp_list);
02145               if ( tmpVar == NULL ) {
02146                      Asn1Error("Error during Reading{ in encoding");
02147                      return LDAP_PROTOCOL_ERROR;
02148               }
02149               rc =   GDecComponentRelativeDistinguishedName (mem_op, b, tmpVar, bytesDecoded, mode);
02150               if ( rc != LDAP_SUCCESS ) return rc;
02151        } /* end of for */
02152 
02153        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02154        *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
02155        if ( !t ) return -1;
02156        *t = *k;
02157        }
02158        t->syntax = (Syntax*)NULL;
02159        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02160        if ( !t->comp_desc ) {
02161               free ( t );
02162               return -1;
02163        }
02164        t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
02165        t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
02166        t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDNSequence2RFC2253;
02167        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
02168        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
02169        t->comp_desc->cd_free = (comp_free_func*)NULL;
02170        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
02171        t->comp_desc->cd_type = ASN_COMPOSITE;
02172        t->comp_desc->cd_type_id = RDNSequence ;
02173        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
02174        return LDAP_SUCCESS;
02175 }  /* GDecRDNSequenceContent */
02176 
02177 
02178 int
02179 MatchingComponentName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
02180        int rc;
02181        MatchingRule* mr;
02182        ComponentName *v1, *v2;
02183 
02184 
02185        v1 = (ComponentName*)csi_attr;
02186        v2 = (ComponentName*)csi_assert;
02187        if ( oid ) {
02188               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
02189               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
02190        }
02191 
02192        if( (v1->choiceId != v2->choiceId ) )
02193               return LDAP_COMPARE_FALSE;
02194        switch( v1->choiceId )
02195        {
02196           case NAME_RDNSEQUENCE :
02197               rc =   MatchingComponentRDNSequence ( oid, (ComponentSyntaxInfo*)(v1->a.rdnSequence), (ComponentSyntaxInfo*)(v2->a.rdnSequence) );
02198               break;
02199        default : 
02200                return LDAP_PROTOCOL_ERROR;
02201        }
02202        return rc;
02203 }  /* BMatchingComponentNameContent */
02204 
02205 void*
02206 ExtractingComponentName ( void* mem_op, ComponentReference* cr, ComponentName *comp )
02207 {
02208 
02209 
02210        if( (comp->choiceId) ==  NAME_RDNSEQUENCE &&
02211                (( comp->a.rdnSequence->identifier.bv_val && strncmp(comp->a.rdnSequence->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
02212                ( strncmp(comp->a.rdnSequence->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
02213               if ( cr->cr_curr->ci_next == NULL )
02214                      return (comp->a.rdnSequence);
02215               else {
02216                      cr->cr_curr = cr->cr_curr->ci_next;
02217                      return        ExtractingComponentRDNSequence ( mem_op, cr, (comp->a.rdnSequence) );
02218               };
02219        }
02220        return NULL;
02221 }  /* ExtractingComponentName */
02222 
02223 int
02224 BDecComponentName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
02225 void* mem_op _AND_
02226 GenBuf * b _AND_
02227 AsnTag tagId0 _AND_
02228 AsnLen elmtLen0 _AND_
02229 ComponentName **v _AND_
02230 AsnLen *bytesDecoded _AND_
02231 int mode)
02232 {
02233        int seqDone = FALSE;
02234        AsnLen totalElmtsLen1 = 0;
02235        AsnLen elmtLen1;
02236        AsnTag tagId1;
02237        int mandatoryElmtCount1 = 0;
02238        int old_mode = mode;
02239        int rc;
02240        ComponentName *k, *t, c_temp;
02241 
02242 
02243        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02244               memset(&c_temp,0,sizeof(c_temp));
02245                k = &c_temp;
02246        } else
02247                k = t = *v;
02248        mode = DEC_ALLOC_MODE_2;
02249     switch (tagId0)
02250     {
02251        case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE):
02252         (k->choiceId) = NAME_RDNSEQUENCE;
02253        rc = BDecComponentRDNSequence (mem_op, b, tagId0, elmtLen0, (&k->a.rdnSequence), &totalElmtsLen1, mode);
02254               if ( rc != LDAP_SUCCESS ) return rc;
02255               (k->a.rdnSequence)->identifier.bv_val = (k->a.rdnSequence)->id_buf;
02256               (k->a.rdnSequence)->identifier.bv_len = strlen("rdnSequence");
02257               strcpy( (k->a.rdnSequence)->identifier.bv_val, "rdnSequence");
02258     break;
02259 
02260     default:
02261         Asn1Error ("ERROR - unexpected tag in CHOICE\n");
02262         return -1;
02263         break;
02264     } /* end switch */
02265        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02266        *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
02267        if ( !t ) return -1;
02268        *t = *k;
02269        }
02270        t->syntax = (Syntax*)NULL;
02271        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02272        if ( !t->comp_desc ) {
02273               free ( t );
02274               return -1;
02275        }
02276        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
02277        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
02278        t->comp_desc->cd_free = (comp_free_func*)NULL;
02279        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
02280        t->comp_desc->cd_type = ASN_COMPOSITE;
02281        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
02282        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
02283     (*bytesDecoded) += totalElmtsLen1;
02284        return LDAP_SUCCESS;
02285 }  /* BDecNameContent */
02286 
02287 int
02288 GDecComponentName PARAMS (( mem_op,b, v, bytesDecoded, mode),
02289 void* mem_op _AND_
02290 GenBuf * b _AND_
02291 ComponentName **v _AND_
02292 AsnLen *bytesDecoded _AND_
02293 int mode)
02294 {
02295        char* peek_head,*peek_head2;
02296        int i, strLen,strLen2, rc, old_mode = mode;
02297        ComponentName *k,*t, c_temp;
02298 
02299 
02300        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02301               memset(&c_temp,0,sizeof(c_temp));
02302                k = &c_temp;
02303        } else
02304                k = t = *v;
02305        mode = DEC_ALLOC_MODE_2;
02306        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02307               Asn1Error("Error during Reading identifier");
02308               return LDAP_PROTOCOL_ERROR;
02309        }
02310        if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
02311               Asn1Error("Error during Reading identifier");
02312               return LDAP_PROTOCOL_ERROR;
02313        }
02314        if(*peek_head2 != ':'){
02315               Asn1Error("Missing : in encoded data");
02316               return LDAP_PROTOCOL_ERROR;
02317        }
02318        if( strncmp("rdnSequence",peek_head, strlen("rdnSequence")) == 0){
02319               (k->choiceId) = NAME_RDNSEQUENCE;
02320               rc =   GDecComponentRDNSequence (mem_op, b, (&k->a.rdnSequence), bytesDecoded, mode);
02321               if ( rc != LDAP_SUCCESS ) return rc;
02322               (k->a.rdnSequence)->identifier.bv_val = peek_head;
02323               (k->a.rdnSequence)->identifier.bv_len = strLen;
02324        }
02325        else {
02326               Asn1Error("Undefined Identifier");
02327               return LDAP_PROTOCOL_ERROR;
02328        }
02329        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02330        *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
02331        if ( !t ) return -1;
02332        *t = *k;
02333        }
02334        t->syntax = (Syntax*)NULL;
02335        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02336        if ( !t->comp_desc ) {
02337               free ( t );
02338               return -1;
02339        }
02340        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
02341        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
02342        t->comp_desc->cd_free = (comp_free_func*)NULL;
02343        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
02344        t->comp_desc->cd_type = ASN_COMPOSITE;
02345        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
02346        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
02347        return LDAP_SUCCESS;
02348 }  /* GDecNameContent */
02349 
02350 
02351 int
02352 MatchingComponentTBSCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
02353        int rc;
02354        MatchingRule* mr;
02355 
02356        if ( oid ) {
02357               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
02358               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
02359        }
02360 
02361        rc = 1;
02362        rc =   MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->version );
02363        if ( rc != LDAP_COMPARE_TRUE )
02364               return rc;
02365        rc =   MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->serialNumber, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->serialNumber );
02366        if ( rc != LDAP_COMPARE_TRUE )
02367               return rc;
02368        rc =   MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->signature );
02369        if ( rc != LDAP_COMPARE_TRUE )
02370               return rc;
02371        rc =   MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->issuer );
02372        if ( rc != LDAP_COMPARE_TRUE )
02373               return rc;
02374        rc =   MatchingComponentValidity ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->validity, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->validity );
02375        if ( rc != LDAP_COMPARE_TRUE )
02376               return rc;
02377        rc =   MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subject, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subject );
02378        if ( rc != LDAP_COMPARE_TRUE )
02379               return rc;
02380        rc =   MatchingComponentSubjectPublicKeyInfo ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subjectPublicKeyInfo, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subjectPublicKeyInfo );
02381        if ( rc != LDAP_COMPARE_TRUE )
02382               return rc;
02383        rc =   MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->issuerUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->issuerUniqueIdentifier );
02384        if ( rc != LDAP_COMPARE_TRUE )
02385               return rc;
02386        rc =   MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->subjectUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->subjectUniqueIdentifier );
02387        if ( rc != LDAP_COMPARE_TRUE )
02388               return rc;
02389        if(COMPONENTNOT_NULL( ((ComponentTBSCertificate*)csi_attr)->extensions ) ) {
02390        rc =   MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->extensions, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->extensions );
02391        if ( rc != LDAP_COMPARE_TRUE )
02392               return rc;
02393        }
02394        return LDAP_COMPARE_TRUE;
02395 }  /* BMatchingComponentTBSCertificate */
02396 
02397 void*
02398 ExtractingComponentTBSCertificate ( void* mem_op, ComponentReference* cr, ComponentTBSCertificate *comp )
02399 {
02400 
02401        if ( ( comp->version->identifier.bv_val && strncmp(comp->version->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->version->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02402               if ( cr->cr_curr->ci_next == NULL )
02403                      return comp->version;
02404               else {
02405                      cr->cr_curr = cr->cr_curr->ci_next;
02406                      return        ExtractingComponentVersion ( mem_op, cr, comp->version );
02407               }
02408        }
02409        if ( ( comp->serialNumber.identifier.bv_val && strncmp(comp->serialNumber.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->serialNumber.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02410               if ( cr->cr_curr->ci_next == NULL )
02411               return &comp->serialNumber;
02412               else
02413               return NULL;
02414        }
02415        if ( ( comp->signature->identifier.bv_val && strncmp(comp->signature->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signature->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02416               if ( cr->cr_curr->ci_next == NULL )
02417                      return comp->signature;
02418               else {
02419                      cr->cr_curr = cr->cr_curr->ci_next;
02420                      return        ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature );
02421               }
02422        }
02423        if ( ( comp->issuer->identifier.bv_val && strncmp(comp->issuer->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->issuer->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02424               if ( cr->cr_curr->ci_next == NULL )
02425                      return comp->issuer;
02426               else {
02427                      cr->cr_curr = cr->cr_curr->ci_next;
02428                      return        ExtractingComponentName ( mem_op, cr, comp->issuer );
02429               }
02430        }
02431        if ( ( comp->validity->identifier.bv_val && strncmp(comp->validity->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->validity->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02432               if ( cr->cr_curr->ci_next == NULL )
02433                      return comp->validity;
02434               else {
02435                      cr->cr_curr = cr->cr_curr->ci_next;
02436                      return        ExtractingComponentValidity ( mem_op, cr, comp->validity );
02437               }
02438        }
02439        if ( ( comp->subject->identifier.bv_val && strncmp(comp->subject->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subject->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02440               if ( cr->cr_curr->ci_next == NULL )
02441                      return comp->subject;
02442               else {
02443                      cr->cr_curr = cr->cr_curr->ci_next;
02444                      return        ExtractingComponentName ( mem_op, cr, comp->subject );
02445               }
02446        }
02447        if ( ( comp->subjectPublicKeyInfo->identifier.bv_val && strncmp(comp->subjectPublicKeyInfo->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectPublicKeyInfo->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02448               if ( cr->cr_curr->ci_next == NULL )
02449                      return comp->subjectPublicKeyInfo;
02450               else {
02451                      cr->cr_curr = cr->cr_curr->ci_next;
02452                      return        ExtractingComponentSubjectPublicKeyInfo ( mem_op, cr, comp->subjectPublicKeyInfo );
02453               }
02454        }
02455        if ( ( comp->issuerUniqueIdentifier.identifier.bv_val && strncmp(comp->issuerUniqueIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->issuerUniqueIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02456               if ( cr->cr_curr->ci_next == NULL )
02457               return &comp->issuerUniqueIdentifier;
02458        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
02459                      cr->cr_curr = cr->cr_curr->ci_next;
02460               return &comp->issuerUniqueIdentifier;
02461         } else {
02462               return NULL;
02463               }
02464        }
02465        if ( ( comp->subjectUniqueIdentifier.identifier.bv_val && strncmp(comp->subjectUniqueIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectUniqueIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02466               if ( cr->cr_curr->ci_next == NULL )
02467               return &comp->subjectUniqueIdentifier;
02468        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
02469                      cr->cr_curr = cr->cr_curr->ci_next;
02470               return &comp->subjectUniqueIdentifier;
02471         } else {
02472               return NULL;
02473               }
02474        }
02475        if ( ( comp->extensions->identifier.bv_val && strncmp(comp->extensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extensions->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
02476               if ( cr->cr_curr->ci_next == NULL )
02477                      return comp->extensions;
02478               else {
02479                      cr->cr_curr = cr->cr_curr->ci_next;
02480                      return        ExtractingComponentExtensions ( mem_op, cr, comp->extensions );
02481               }
02482        }
02483        return NULL;
02484 }  /* ExtractingComponentTBSCertificate */
02485 
02486 int
02487 BDecComponentTBSCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
02488 void* mem_op _AND_
02489 GenBuf * b _AND_
02490 AsnTag tagId0 _AND_
02491 AsnLen elmtLen0 _AND_
02492 ComponentTBSCertificate **v _AND_
02493 AsnLen *bytesDecoded _AND_
02494 int mode)
02495 {
02496        int seqDone = FALSE;
02497        AsnLen totalElmtsLen1 = 0;
02498        AsnLen elmtLen1;
02499        AsnTag tagId1;
02500        int mandatoryElmtCount1 = 0;
02501        AsnLen totalElmtsLen2 = 0;
02502        AsnLen elmtLen2;
02503        AsnTag tagId2;
02504        int old_mode = mode;
02505        int rc;
02506        ComponentTBSCertificate *k, *t, c_temp;
02507 
02508 
02509        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02510               memset(&c_temp,0,sizeof(c_temp));
02511                k = &c_temp;
02512        } else
02513                k = t = *v;
02514        mode = DEC_ALLOC_MODE_2;
02515     tagId1 = BDecTag (b, &totalElmtsLen1 );
02516 
02517     if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
02518     {
02519     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02520         tagId2 = BDecTag (b, &totalElmtsLen1 );
02521 
02522     if (tagId2 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
02523     {
02524          Asn1Error ("Unexpected Tag\n");
02525          return -1;
02526     }
02527 
02528     elmtLen2 = BDecLen (b, &totalElmtsLen1 );
02529        rc = BDecComponentVersion (mem_op, b, tagId2, elmtLen2, (&k->version), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
02530               if ( rc != LDAP_SUCCESS ) return rc;
02531               (k->version)->identifier.bv_val = (k->version)->id_buf;
02532               (k->version)->identifier.bv_len = strlen("version");
02533               strcpy( (k->version)->identifier.bv_val, "version");
02534        if (elmtLen1 == INDEFINITE_LEN)
02535         BDecEoc (b, &totalElmtsLen1 );
02536     tagId1 = BDecTag (b, &totalElmtsLen1);
02537     }
02538 
02539 
02540     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
02541     {
02542     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02543        rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->serialNumber), &totalElmtsLen1, mode);
02544               if ( rc != LDAP_SUCCESS ) return rc;
02545               (&k->serialNumber)->identifier.bv_val = (&k->serialNumber)->id_buf;
02546               (&k->serialNumber)->identifier.bv_len = strlen("serialNumber");
02547               strcpy( (&k->serialNumber)->identifier.bv_val, "serialNumber");
02548     tagId1 = BDecTag (b, &totalElmtsLen1);
02549     }
02550     else
02551         return -1;
02552 
02553 
02554 
02555     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
02556     {
02557     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02558        rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
02559               if ( rc != LDAP_SUCCESS ) return rc;
02560               (k->signature)->identifier.bv_val = (k->signature)->id_buf;
02561               (k->signature)->identifier.bv_len = strlen("signature");
02562               strcpy( (k->signature)->identifier.bv_val, "signature");
02563     tagId1 = BDecTag (b, &totalElmtsLen1);
02564     }
02565     else
02566         return -1;
02567 
02568 
02569 
02570     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
02571     {
02572         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02573        rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->issuer), &totalElmtsLen1, mode);
02574               if ( rc != LDAP_SUCCESS ) return rc;
02575               (k->issuer)->identifier.bv_val = (k->issuer)->id_buf;
02576               (k->issuer)->identifier.bv_len = strlen("issuer");
02577               strcpy( (k->issuer)->identifier.bv_val, "issuer");
02578     tagId1 = BDecTag (b, &totalElmtsLen1);
02579     }
02580     else
02581         return -1;
02582 
02583 
02584 
02585     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
02586     {
02587     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02588        rc = BDecComponentValidity (mem_op, b, tagId1, elmtLen1, (&k->validity), &totalElmtsLen1, mode);
02589               if ( rc != LDAP_SUCCESS ) return rc;
02590               (k->validity)->identifier.bv_val = (k->validity)->id_buf;
02591               (k->validity)->identifier.bv_len = strlen("validity");
02592               strcpy( (k->validity)->identifier.bv_val, "validity");
02593     tagId1 = BDecTag (b, &totalElmtsLen1);
02594     }
02595     else
02596         return -1;
02597 
02598 
02599 
02600     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
02601     {
02602         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02603        rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->subject), &totalElmtsLen1, mode);
02604               if ( rc != LDAP_SUCCESS ) return rc;
02605               (k->subject)->identifier.bv_val = (k->subject)->id_buf;
02606               (k->subject)->identifier.bv_len = strlen("subject");
02607               strcpy( (k->subject)->identifier.bv_val, "subject");
02608     tagId1 = BDecTag (b, &totalElmtsLen1);
02609     }
02610     else
02611         return -1;
02612 
02613 
02614 
02615     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
02616     {
02617     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02618        rc = BDecComponentSubjectPublicKeyInfo (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKeyInfo), &totalElmtsLen1, mode);
02619               if ( rc != LDAP_SUCCESS ) return rc;
02620               (k->subjectPublicKeyInfo)->identifier.bv_val = (k->subjectPublicKeyInfo)->id_buf;
02621               (k->subjectPublicKeyInfo)->identifier.bv_len = strlen("subjectPublicKeyInfo");
02622               strcpy( (k->subjectPublicKeyInfo)->identifier.bv_val, "subjectPublicKeyInfo");
02623     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
02624         seqDone = TRUE;
02625     else
02626     {
02627         tagId1 = BDecTag (b, &totalElmtsLen1 );
02628 
02629          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
02630         {
02631             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
02632             seqDone = TRUE;
02633         }
02634     }
02635     }
02636     else
02637         return -1;
02638 
02639 
02640 
02641     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)) ||
02642 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
02643     {
02644     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02645        rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->issuerUniqueIdentifier), &totalElmtsLen1, mode);
02646               if ( rc != LDAP_SUCCESS ) return rc;
02647               (&k->issuerUniqueIdentifier)->identifier.bv_val = (&k->issuerUniqueIdentifier)->id_buf;
02648               (&k->issuerUniqueIdentifier)->identifier.bv_len = strlen("issuerUniqueIdentifier");
02649               strcpy( (&k->issuerUniqueIdentifier)->identifier.bv_val, "issuerUniqueIdentifier");
02650     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
02651         seqDone = TRUE;
02652     else
02653     {
02654         tagId1 = BDecTag (b, &totalElmtsLen1 );
02655 
02656          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
02657         {
02658             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
02659             seqDone = TRUE;
02660         }
02661     }
02662     }
02663 
02664 
02665     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)) ||
02666 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2))))
02667     {
02668     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02669        rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->subjectUniqueIdentifier), &totalElmtsLen1, mode);
02670               if ( rc != LDAP_SUCCESS ) return rc;
02671               (&k->subjectUniqueIdentifier)->identifier.bv_val = (&k->subjectUniqueIdentifier)->id_buf;
02672               (&k->subjectUniqueIdentifier)->identifier.bv_len = strlen("subjectUniqueIdentifier");
02673               strcpy( (&k->subjectUniqueIdentifier)->identifier.bv_val, "subjectUniqueIdentifier");
02674     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
02675         seqDone = TRUE;
02676     else
02677     {
02678         tagId1 = BDecTag (b, &totalElmtsLen1 );
02679 
02680          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
02681         {
02682             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
02683             seqDone = TRUE;
02684         }
02685     }
02686     }
02687 
02688 
02689     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3))))
02690     {
02691     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
02692         tagId2 = BDecTag (b, &totalElmtsLen1 );
02693 
02694     if (tagId2 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
02695     {
02696          Asn1Error ("Unexpected Tag\n");
02697          return -1;
02698     }
02699 
02700     elmtLen2 = BDecLen (b, &totalElmtsLen1 );
02701        rc = BDecComponentExtensions (mem_op, b, tagId2, elmtLen2, (&k->extensions), &totalElmtsLen1, mode);
02702               if ( rc != LDAP_SUCCESS ) return rc;
02703               (k->extensions)->identifier.bv_val = (k->extensions)->id_buf;
02704               (k->extensions)->identifier.bv_len = strlen("extensions");
02705               strcpy( (k->extensions)->identifier.bv_val, "extensions");
02706        if (elmtLen1 == INDEFINITE_LEN)
02707         BDecEoc (b, &totalElmtsLen1 );
02708         seqDone = TRUE;
02709         if (elmtLen0 == INDEFINITE_LEN)
02710             BDecEoc (b, &totalElmtsLen1 );
02711         else if (totalElmtsLen1 != elmtLen0)
02712         return -1;
02713 
02714     }
02715 
02716 
02717     if (!seqDone)
02718         return -1;
02719 
02720        if(!COMPONENTNOT_NULL ((k->version)))
02721        {
02722 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
02723               (k->version)->identifier.bv_val = (k->version)->id_buf;
02724               (k->version)->identifier.bv_len = strlen("version");
02725               strcpy( (k->version)->identifier.bv_val, "version");
02726        (k->version)->value = 0;
02727        }
02728        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02729        *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
02730        if ( !t ) return -1;
02731        *t = *k;
02732        }
02733        t->syntax = (Syntax*)NULL;
02734        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02735        if ( !t->comp_desc ) {
02736               free ( t );
02737               return -1;
02738        }
02739        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
02740        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
02741        t->comp_desc->cd_free = (comp_free_func*)NULL;
02742        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
02743        t->comp_desc->cd_type = ASN_COMPOSITE;
02744        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
02745        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
02746     (*bytesDecoded) += totalElmtsLen1;
02747        return LDAP_SUCCESS;
02748 }  /* BDecTBSCertificate*/
02749 
02750 int
02751 GDecComponentTBSCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
02752 void* mem_op _AND_
02753 GenBuf * b _AND_
02754 ComponentTBSCertificate **v _AND_
02755 AsnLen *bytesDecoded _AND_
02756 int mode)
02757 {
02758        char* peek_head,*peek_head2;
02759        int i, strLen,strLen2, rc, old_mode = mode;
02760        ComponentTBSCertificate *k,*t, c_temp;
02761 
02762 
02763        if ( !(mode & DEC_ALLOC_MODE_1) ) {
02764               memset(&c_temp,0,sizeof(c_temp));
02765                k = &c_temp;
02766        } else
02767                k = t = *v;
02768        mode = DEC_ALLOC_MODE_2;
02769        *bytesDecoded = 0;
02770        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02771               Asn1Error("Error during Reading { in encoded data");
02772               return LDAP_PROTOCOL_ERROR;
02773        }
02774        if(*peek_head != '{'){
02775               Asn1Error("Missing { in encoded data");
02776               return LDAP_PROTOCOL_ERROR;
02777        }
02778 
02779        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02780               Asn1Error("Error during Reading identifier");
02781               return LDAP_PROTOCOL_ERROR;
02782        }
02783        if ( strncmp( peek_head, "version", strlen("version") ) == 0 ) {
02784               rc =   GDecComponentVersion (mem_op, b, (&k->version), bytesDecoded, DEC_ALLOC_MODE_0 );
02785               if ( rc != LDAP_SUCCESS ) return rc;
02786        ( k->version)->identifier.bv_val = peek_head;
02787        ( k->version)->identifier.bv_len = strLen;
02788        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02789               Asn1Error("Error during Reading , ");
02790               return LDAP_PROTOCOL_ERROR;
02791        }
02792        if(*peek_head != ','){
02793               Asn1Error("Missing , in encoding");
02794               return LDAP_PROTOCOL_ERROR;
02795        }
02796        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02797          Asn1Error("Error during Reading identifier");
02798               return LDAP_PROTOCOL_ERROR;
02799        }
02800        }
02801        else {
02802 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
02803                      (k->version)->value = 0;
02804        }
02805        if ( strncmp( peek_head, "serialNumber", strlen("serialNumber") ) == 0 ) {
02806               rc =   GDecComponentCertificateSerialNumber (mem_op, b, (&k->serialNumber), bytesDecoded, mode);
02807               if ( rc != LDAP_SUCCESS ) return rc;
02808        (&k->serialNumber)->identifier.bv_val = peek_head;
02809        (&k->serialNumber)->identifier.bv_len = strLen;
02810        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02811               Asn1Error("Error during Reading , ");
02812               return LDAP_PROTOCOL_ERROR;
02813        }
02814        if(*peek_head != ','){
02815               Asn1Error("Missing , in encoding");
02816               return LDAP_PROTOCOL_ERROR;
02817        }
02818        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02819          Asn1Error("Error during Reading identifier");
02820               return LDAP_PROTOCOL_ERROR;
02821        }
02822        }
02823        if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
02824               rc =   GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signature), bytesDecoded, mode);
02825               if ( rc != LDAP_SUCCESS ) return rc;
02826        ( k->signature)->identifier.bv_val = peek_head;
02827        ( k->signature)->identifier.bv_len = strLen;
02828        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02829               Asn1Error("Error during Reading , ");
02830               return LDAP_PROTOCOL_ERROR;
02831        }
02832        if(*peek_head != ','){
02833               Asn1Error("Missing , in encoding");
02834               return LDAP_PROTOCOL_ERROR;
02835        }
02836        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02837          Asn1Error("Error during Reading identifier");
02838               return LDAP_PROTOCOL_ERROR;
02839        }
02840        }
02841        if ( strncmp( peek_head, "issuer", strlen("issuer") ) == 0 ) {
02842               rc =   GDecComponentName (mem_op, b, (&k->issuer), bytesDecoded, mode);
02843               if ( rc != LDAP_SUCCESS ) return rc;
02844        ( k->issuer)->identifier.bv_val = peek_head;
02845        ( k->issuer)->identifier.bv_len = strLen;
02846        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02847               Asn1Error("Error during Reading , ");
02848               return LDAP_PROTOCOL_ERROR;
02849        }
02850        if(*peek_head != ','){
02851               Asn1Error("Missing , in encoding");
02852               return LDAP_PROTOCOL_ERROR;
02853        }
02854        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02855          Asn1Error("Error during Reading identifier");
02856               return LDAP_PROTOCOL_ERROR;
02857        }
02858        }
02859        if ( strncmp( peek_head, "validity", strlen("validity") ) == 0 ) {
02860               rc =   GDecComponentValidity (mem_op, b, (&k->validity), bytesDecoded, mode);
02861               if ( rc != LDAP_SUCCESS ) return rc;
02862        ( k->validity)->identifier.bv_val = peek_head;
02863        ( k->validity)->identifier.bv_len = strLen;
02864        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02865               Asn1Error("Error during Reading , ");
02866               return LDAP_PROTOCOL_ERROR;
02867        }
02868        if(*peek_head != ','){
02869               Asn1Error("Missing , in encoding");
02870               return LDAP_PROTOCOL_ERROR;
02871        }
02872        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02873          Asn1Error("Error during Reading identifier");
02874               return LDAP_PROTOCOL_ERROR;
02875        }
02876        }
02877        if ( strncmp( peek_head, "subject", strlen("subject") ) == 0 ) {
02878               rc =   GDecComponentName (mem_op, b, (&k->subject), bytesDecoded, mode);
02879               if ( rc != LDAP_SUCCESS ) return rc;
02880        ( k->subject)->identifier.bv_val = peek_head;
02881        ( k->subject)->identifier.bv_len = strLen;
02882        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02883               Asn1Error("Error during Reading , ");
02884               return LDAP_PROTOCOL_ERROR;
02885        }
02886        if(*peek_head != ','){
02887               Asn1Error("Missing , in encoding");
02888               return LDAP_PROTOCOL_ERROR;
02889        }
02890        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02891          Asn1Error("Error during Reading identifier");
02892               return LDAP_PROTOCOL_ERROR;
02893        }
02894        }
02895        if ( strncmp( peek_head, "subjectPublicKeyInfo", strlen("subjectPublicKeyInfo") ) == 0 ) {
02896               rc =   GDecComponentSubjectPublicKeyInfo (mem_op, b, (&k->subjectPublicKeyInfo), bytesDecoded, mode);
02897               if ( rc != LDAP_SUCCESS ) return rc;
02898        ( k->subjectPublicKeyInfo)->identifier.bv_val = peek_head;
02899        ( k->subjectPublicKeyInfo)->identifier.bv_len = strLen;
02900        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02901               Asn1Error("Error during Reading , ");
02902               return LDAP_PROTOCOL_ERROR;
02903        }
02904        if(*peek_head != ','){
02905               Asn1Error("Missing , in encoding");
02906               return LDAP_PROTOCOL_ERROR;
02907        }
02908        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02909          Asn1Error("Error during Reading identifier");
02910               return LDAP_PROTOCOL_ERROR;
02911        }
02912        }
02913        if ( strncmp( peek_head, "issuerUniqueIdentifier", strlen("issuerUniqueIdentifier") ) == 0 ) {
02914               rc =   GDecComponentUniqueIdentifier (mem_op, b, (&k->issuerUniqueIdentifier), bytesDecoded, mode);
02915               if ( rc != LDAP_SUCCESS ) return rc;
02916        (&k->issuerUniqueIdentifier)->identifier.bv_val = peek_head;
02917        (&k->issuerUniqueIdentifier)->identifier.bv_len = strLen;
02918        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02919               Asn1Error("Error during Reading , ");
02920               return LDAP_PROTOCOL_ERROR;
02921        }
02922        if(*peek_head != ','){
02923               Asn1Error("Missing , in encoding");
02924               return LDAP_PROTOCOL_ERROR;
02925        }
02926        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02927          Asn1Error("Error during Reading identifier");
02928               return LDAP_PROTOCOL_ERROR;
02929        }
02930        }
02931        if ( strncmp( peek_head, "subjectUniqueIdentifier", strlen("subjectUniqueIdentifier") ) == 0 ) {
02932               rc =   GDecComponentUniqueIdentifier (mem_op, b, (&k->subjectUniqueIdentifier), bytesDecoded, mode);
02933               if ( rc != LDAP_SUCCESS ) return rc;
02934        (&k->subjectUniqueIdentifier)->identifier.bv_val = peek_head;
02935        (&k->subjectUniqueIdentifier)->identifier.bv_len = strLen;
02936        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02937               Asn1Error("Error during Reading , ");
02938               return LDAP_PROTOCOL_ERROR;
02939        }
02940        if(*peek_head != ','){
02941               Asn1Error("Missing , in encoding");
02942               return LDAP_PROTOCOL_ERROR;
02943        }
02944        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02945          Asn1Error("Error during Reading identifier");
02946               return LDAP_PROTOCOL_ERROR;
02947        }
02948        }
02949        if ( strncmp( peek_head, "extensions", strlen("extensions") ) == 0 ) {
02950               rc =   GDecComponentExtensions (mem_op, b, (&k->extensions), bytesDecoded, mode);
02951               if ( rc != LDAP_SUCCESS ) return rc;
02952        ( k->extensions)->identifier.bv_val = peek_head;
02953        ( k->extensions)->identifier.bv_len = strLen;
02954        }
02955        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
02956               Asn1Error("Error during Reading } in encoding");
02957               return LDAP_PROTOCOL_ERROR;
02958        }
02959        if(*peek_head != '}'){
02960               Asn1Error("Missing } in encoding");
02961               return LDAP_PROTOCOL_ERROR;
02962        }
02963        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02964        *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
02965        if ( !t ) return -1;
02966        *t = *k;
02967        }
02968        t->syntax = (Syntax*)NULL;
02969        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02970        if ( !t->comp_desc ) {
02971               free ( t );
02972               return -1;
02973        }
02974        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
02975        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
02976        t->comp_desc->cd_free = (comp_free_func*)NULL;
02977        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
02978        t->comp_desc->cd_type = ASN_COMPOSITE;
02979        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
02980        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
02981        return LDAP_SUCCESS;
02982 }  /* GDecTBSCertificate*/
02983 
02984 
02985 int
02986 MatchingComponentCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
02987        int rc;
02988        MatchingRule* mr;
02989 
02990        if ( oid ) {
02991               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
02992               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
02993        }
02994 
02995        rc = 1;
02996        rc =   MatchingComponentTBSCertificate ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->toBeSigned, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->toBeSigned );
02997        if ( rc != LDAP_COMPARE_TRUE )
02998               return rc;
02999        rc =   MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->signatureAlgorithm );
03000        if ( rc != LDAP_COMPARE_TRUE )
03001               return rc;
03002        rc =   MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_assert)->signature );
03003        if ( rc != LDAP_COMPARE_TRUE )
03004               return rc;
03005        return LDAP_COMPARE_TRUE;
03006 }  /* BMatchingComponentCertificate */
03007 
03008 void*
03009 ExtractingComponentCertificate ( void* mem_op, ComponentReference* cr, ComponentCertificate *comp )
03010 {
03011 
03012        if ( ( comp->toBeSigned->identifier.bv_val && strncmp(comp->toBeSigned->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->toBeSigned->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
03013               if ( cr->cr_curr->ci_next == NULL )
03014                      return comp->toBeSigned;
03015               else {
03016                      cr->cr_curr = cr->cr_curr->ci_next;
03017                      return        ExtractingComponentTBSCertificate ( mem_op, cr, comp->toBeSigned );
03018               }
03019        }
03020        if ( ( comp->signatureAlgorithm->identifier.bv_val && strncmp(comp->signatureAlgorithm->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signatureAlgorithm->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
03021               if ( cr->cr_curr->ci_next == NULL )
03022                      return comp->signatureAlgorithm;
03023               else {
03024                      cr->cr_curr = cr->cr_curr->ci_next;
03025                      return        ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm );
03026               }
03027        }
03028        if ( ( comp->signature.identifier.bv_val && strncmp(comp->signature.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signature.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
03029               if ( cr->cr_curr->ci_next == NULL )
03030               return &comp->signature;
03031        else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
03032                      cr->cr_curr = cr->cr_curr->ci_next;
03033               return &comp->signature;
03034         } else {
03035               return NULL;
03036               }
03037        }
03038        return NULL;
03039 }  /* ExtractingComponentCertificate */
03040 
03041 int
03042 BDecComponentCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
03043 void* mem_op _AND_
03044 GenBuf * b _AND_
03045 AsnTag tagId0 _AND_
03046 AsnLen elmtLen0 _AND_
03047 ComponentCertificate **v _AND_
03048 AsnLen *bytesDecoded _AND_
03049 int mode)
03050 {
03051        int seqDone = FALSE;
03052        AsnLen totalElmtsLen1 = 0;
03053        AsnLen elmtLen1;
03054        AsnTag tagId1;
03055        int mandatoryElmtCount1 = 0;
03056        int old_mode = mode;
03057        int rc;
03058        ComponentCertificate *k, *t, c_temp;
03059 
03060 
03061        if ( !(mode & DEC_ALLOC_MODE_1) ) {
03062               memset(&c_temp,0,sizeof(c_temp));
03063                k = &c_temp;
03064        } else
03065                k = t = *v;
03066        mode = DEC_ALLOC_MODE_2;
03067     tagId1 = BDecTag (b, &totalElmtsLen1 );
03068 
03069     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
03070     {
03071     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
03072        rc = BDecComponentTBSCertificate (mem_op, b, tagId1, elmtLen1, (&k->toBeSigned), &totalElmtsLen1, mode);
03073               if ( rc != LDAP_SUCCESS ) return rc;
03074               (k->toBeSigned)->identifier.bv_val = (k->toBeSigned)->id_buf;
03075               (k->toBeSigned)->identifier.bv_len = strlen("toBeSigned");
03076               strcpy( (k->toBeSigned)->identifier.bv_val, "toBeSigned");
03077     tagId1 = BDecTag (b, &totalElmtsLen1);
03078     }
03079     else
03080         return -1;
03081 
03082 
03083 
03084     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
03085     {
03086     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
03087        rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode);
03088               if ( rc != LDAP_SUCCESS ) return rc;
03089               (k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf;
03090               (k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm");
03091               strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm");
03092     tagId1 = BDecTag (b, &totalElmtsLen1);
03093     }
03094     else
03095         return -1;
03096 
03097 
03098 
03099     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
03100 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
03101     {
03102     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
03103        rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
03104               if ( rc != LDAP_SUCCESS ) return rc;
03105               (&k->signature)->identifier.bv_val = (&k->signature)->id_buf;
03106               (&k->signature)->identifier.bv_len = strlen("signature");
03107               strcpy( (&k->signature)->identifier.bv_val, "signature");
03108         seqDone = TRUE;
03109         if (elmtLen0 == INDEFINITE_LEN)
03110             BDecEoc (b, &totalElmtsLen1 );
03111         else if (totalElmtsLen1 != elmtLen0)
03112         return -1;
03113 
03114     }
03115     else
03116         return -1;
03117 
03118 
03119 
03120     if (!seqDone)
03121         return -1;
03122 
03123        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
03124        *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
03125        if ( !t ) return -1;
03126        *t = *k;
03127        }
03128        t->syntax = (Syntax*)NULL;
03129        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
03130        if ( !t->comp_desc ) {
03131               free ( t );
03132               return -1;
03133        }
03134        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
03135        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
03136        t->comp_desc->cd_free = (comp_free_func*)NULL;
03137        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
03138        t->comp_desc->cd_type = ASN_COMPOSITE;
03139        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
03140        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
03141     (*bytesDecoded) += totalElmtsLen1;
03142        return LDAP_SUCCESS;
03143 }  /* BDecCertificate*/
03144 
03145 int
03146 GDecComponentCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
03147 void* mem_op _AND_
03148 GenBuf * b _AND_
03149 ComponentCertificate **v _AND_
03150 AsnLen *bytesDecoded _AND_
03151 int mode)
03152 {
03153        char* peek_head,*peek_head2;
03154        int i, strLen,strLen2, rc, old_mode = mode;
03155        ComponentCertificate *k,*t, c_temp;
03156 
03157 
03158        if ( !(mode & DEC_ALLOC_MODE_1) ) {
03159               memset(&c_temp,0,sizeof(c_temp));
03160                k = &c_temp;
03161        } else
03162                k = t = *v;
03163        mode = DEC_ALLOC_MODE_2;
03164        *bytesDecoded = 0;
03165        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03166               Asn1Error("Error during Reading { in encoded data");
03167               return LDAP_PROTOCOL_ERROR;
03168        }
03169        if(*peek_head != '{'){
03170               Asn1Error("Missing { in encoded data");
03171               return LDAP_PROTOCOL_ERROR;
03172        }
03173 
03174        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03175               Asn1Error("Error during Reading identifier");
03176               return LDAP_PROTOCOL_ERROR;
03177        }
03178        if ( strncmp( peek_head, "toBeSigned", strlen("toBeSigned") ) == 0 ) {
03179               rc =   GDecComponentTBSCertificate (mem_op, b, (&k->toBeSigned), bytesDecoded, mode);
03180               if ( rc != LDAP_SUCCESS ) return rc;
03181        ( k->toBeSigned)->identifier.bv_val = peek_head;
03182        ( k->toBeSigned)->identifier.bv_len = strLen;
03183        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03184               Asn1Error("Error during Reading , ");
03185               return LDAP_PROTOCOL_ERROR;
03186        }
03187        if(*peek_head != ','){
03188               Asn1Error("Missing , in encoding");
03189               return LDAP_PROTOCOL_ERROR;
03190        }
03191        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03192          Asn1Error("Error during Reading identifier");
03193               return LDAP_PROTOCOL_ERROR;
03194        }
03195        }
03196        if ( strncmp( peek_head, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) {
03197               rc =   GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode);
03198               if ( rc != LDAP_SUCCESS ) return rc;
03199        ( k->signatureAlgorithm)->identifier.bv_val = peek_head;
03200        ( k->signatureAlgorithm)->identifier.bv_len = strLen;
03201        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03202               Asn1Error("Error during Reading , ");
03203               return LDAP_PROTOCOL_ERROR;
03204        }
03205        if(*peek_head != ','){
03206               Asn1Error("Missing , in encoding");
03207               return LDAP_PROTOCOL_ERROR;
03208        }
03209        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
03210          Asn1Error("Error during Reading identifier");
03211               return LDAP_PROTOCOL_ERROR;
03212        }
03213        }
03214        if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
03215               rc =   GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode);
03216               if ( rc != LDAP_SUCCESS ) return rc;
03217        (&k->signature)->identifier.bv_val = peek_head;
03218        (&k->signature)->identifier.bv_len = strLen;
03219        }
03220        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
03221               Asn1Error("Error during Reading } in encoding");
03222               return LDAP_PROTOCOL_ERROR;
03223        }
03224        if(*peek_head != '}'){
03225               Asn1Error("Missing } in encoding");
03226               return LDAP_PROTOCOL_ERROR;
03227        }
03228        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
03229        *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
03230        if ( !t ) return -1;
03231        *t = *k;
03232        }
03233        t->syntax = (Syntax*)NULL;
03234        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
03235        if ( !t->comp_desc ) {
03236               free ( t );
03237               return -1;
03238        }
03239        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
03240        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
03241        t->comp_desc->cd_free = (comp_free_func*)NULL;
03242        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
03243        t->comp_desc->cd_type = ASN_COMPOSITE;
03244        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
03245        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
03246        return LDAP_SUCCESS;
03247 }  /* GDecCertificate*/
03248 
03249