3 * "AuthenticationFramework" ASN.1 module encode/decode/extracting/matching/free C src.
4 * This file was generated by modified eSMACC compiler Sat Dec 11 11:22:49 2004
5 * The generated files are supposed to be compiled as a module for OpenLDAP Software
8 #include "certificate.h"
10 BDecComponentCertificateTop( void* mem_op, GenBuf* b, void **v, AsnLen* bytesDecoded,int mode) {
14 tag = BDecTag ( b, bytesDecoded );
15 elmtLen = BDecLen ( b, bytesDecoded );
16 if ( elmtLen <= 0 ) return (-1);
17 if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {
21 return BDecComponentCertificate( mem_op, b, tag, elmtLen, (ComponentSyntaxInfo*)v,(int*)bytesDecoded, mode );
24 void init_module_AuthenticationFramework() {
25 /* Register Certificate OID and its decoder */
26 InstallOidDecoderMapping( "2.5.4.36", NULL,
27 GDecComponentCertificate,
28 BDecComponentCertificateTop,
29 ExtractingComponentCertificate,
30 MatchingComponentCertificate );
31 InitAnyAuthenticationFramework();
35 void InitAnyAuthenticationFramework()
37 AsnOid oid0 ={ 9, "\52\206\110\206\367\15\1\1\4" };
38 AsnOid oid1 ={ 9, "\52\206\110\206\367\15\1\1\1" };
39 AsnOid oid2 ={ 3, "\125\4\3" };
40 AsnOid oid3 ={ 3, "\125\4\6" };
41 AsnOid oid4 ={ 3, "\125\4\7" };
42 AsnOid oid5 ={ 3, "\125\4\10" };
43 AsnOid oid6 ={ 3, "\125\4\12" };
44 AsnOid oid7 ={ 3, "\125\4\13" };
45 AsnOid oid8 ={ 9, "\52\206\110\206\367\15\1\11\1" };
46 AsnOid oid9 ={ 3, "\125\35\23" };
47 AsnOid oid10 ={ 9, "\140\206\110\1\206\370\102\1\15" };
48 AsnOid oid11 ={ 3, "\125\35\16" };
51 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);
53 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);
55 InstallAnyByComponentOid (printableStringOid_ANY_ID, &oid2, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
57 InstallAnyByComponentOid (printableStringOid2_ANY_ID, &oid3, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
59 InstallAnyByComponentOid (printableStringOid3_ANY_ID, &oid4, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
61 InstallAnyByComponentOid (printableStringOid4_ANY_ID, &oid5, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
63 InstallAnyByComponentOid (printableStringOid5_ANY_ID, &oid6, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
65 InstallAnyByComponentOid (printableStringOid6_ANY_ID, &oid7, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
67 InstallAnyByComponentOid (iA5StringOid_ANY_ID, &oid8, sizeof (ComponentIA5String), (EncodeFcn)BEncIA5String, (gser_decoder_func*)GDecComponentIA5String, (ber_tag_decoder_func*)BDecComponentIA5StringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentIA5String,(FreeFcn)FreeComponentIA5String, (PrintFcn)NULL);
69 InstallAnyByComponentOid (octetStringOid_ANY_ID, &oid9, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
71 InstallAnyByComponentOid (octetStringOid2_ANY_ID, &oid10, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
73 InstallAnyByComponentOid (octetStringOid3_ANY_ID, &oid11, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
75 } /* InitAnyAuthenticationFramework */
79 MatchingComponentAlgorithmIdentifier ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
84 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
85 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
89 rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_assert)->algorithm );
90 if ( rc != LDAP_COMPARE_TRUE )
92 rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm));
93 rc = MatchingComponentAnyDefinedBy ( oid, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_assert)->parameters);
94 if ( rc != LDAP_COMPARE_TRUE )
96 return LDAP_COMPARE_TRUE;
97 } /* BMatchingComponentAlgorithmIdentifier */
100 ExtractingComponentAlgorithmIdentifier ( void* mem_op, ComponentReference* cr, ComponentAlgorithmIdentifier *comp )
103 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 ) ) {
104 if ( cr->cr_curr->ci_next == NULL )
105 return &comp->algorithm;
109 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 ) ) {
110 if ( cr->cr_curr->ci_next == NULL )
111 return &comp->parameters;
112 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
113 cr->cr_curr = cr->cr_curr->ci_next;
114 return &comp->parameters;
120 } /* ExtractingComponentAlgorithmIdentifier */
123 BDecComponentAlgorithmIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
127 AsnLen elmtLen0 _AND_
128 ComponentAlgorithmIdentifier **v _AND_
129 AsnLen *bytesDecoded _AND_
133 AsnLen totalElmtsLen1 = 0;
136 int mandatoryElmtCount1 = 0;
139 ComponentAlgorithmIdentifier *k, *t, c_temp;
142 if ( !(mode & DEC_ALLOC_MODE_1) ) {
143 memset(&c_temp,0,sizeof(c_temp));
147 mode = DEC_ALLOC_MODE_2;
148 tagId1 = BDecTag (b, &totalElmtsLen1 );
150 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
152 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
153 rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
154 if ( rc != LDAP_SUCCESS ) return rc;
155 (&k->algorithm)->identifier.bv_val = (&k->algorithm)->id_buf;
156 (&k->algorithm)->identifier.bv_len = strlen("algorithm");
157 strcpy( (&k->algorithm)->identifier.bv_val, "algorithm");
158 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
162 tagId1 = BufPeekByte (b);
163 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
165 BDecEoc (b, &totalElmtsLen1 );
176 rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
177 rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->parameters), &totalElmtsLen1, mode );
178 if ( rc != LDAP_SUCCESS ) return rc;
179 (&k->parameters)->identifier.bv_val = (&k->parameters)->id_buf;
180 (&k->parameters)->identifier.bv_len = strlen("parameters");
181 strcpy( (&k->parameters)->identifier.bv_val, "parameters");
183 if (elmtLen0 == INDEFINITE_LEN)
184 BDecEoc (b, &totalElmtsLen1 );
185 else if (totalElmtsLen1 != elmtLen0)
194 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
195 *v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
199 t->syntax = (Syntax*)NULL;
200 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
201 if ( !t->comp_desc ) {
205 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
206 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
207 t->comp_desc->cd_free = (comp_free_func*)NULL;
208 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
209 t->comp_desc->cd_type = ASN_COMPOSITE;
210 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
211 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
212 (*bytesDecoded) += totalElmtsLen1;
214 } /* BDecAlgorithmIdentifier*/
217 GDecComponentAlgorithmIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode),
220 ComponentAlgorithmIdentifier **v _AND_
221 AsnLen *bytesDecoded _AND_
224 char* peek_head,*peek_head2;
225 int i, strLen,strLen2, rc, old_mode = mode;
226 ComponentAlgorithmIdentifier *k,*t, c_temp;
229 if ( !(mode & DEC_ALLOC_MODE_1) ) {
230 memset(&c_temp,0,sizeof(c_temp));
234 mode = DEC_ALLOC_MODE_2;
236 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
237 Asn1Error("Error during Reading { in encoded data");
238 return LDAP_PROTOCOL_ERROR;
240 if(*peek_head != '{'){
241 Asn1Error("Missing { in encoded data");
242 return LDAP_PROTOCOL_ERROR;
245 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
246 Asn1Error("Error during Reading identifier");
247 return LDAP_PROTOCOL_ERROR;
249 if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
250 rc = GDecComponentOid (mem_op, b, (&k->algorithm), bytesDecoded, mode);
251 if ( rc != LDAP_SUCCESS ) return rc;
252 (&k->algorithm)->identifier.bv_val = peek_head;
253 (&k->algorithm)->identifier.bv_len = strLen;
254 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
255 Asn1Error("Error during Reading , ");
256 return LDAP_PROTOCOL_ERROR;
258 if(*peek_head != ','){
259 Asn1Error("Missing , in encoding");
260 return LDAP_PROTOCOL_ERROR;
262 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
263 Asn1Error("Error during Reading identifier");
264 return LDAP_PROTOCOL_ERROR;
267 if ( strncmp( peek_head, "parameters", strlen("parameters") ) == 0 ) {
268 rc = rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
269 rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->parameters), bytesDecoded, mode );
270 if ( rc != LDAP_SUCCESS ) return rc;
271 (&k->parameters)->identifier.bv_val = peek_head;
272 (&k->parameters)->identifier.bv_len = strLen;
274 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
275 Asn1Error("Error during Reading } in encoding");
276 return LDAP_PROTOCOL_ERROR;
278 if(*peek_head != '}'){
279 Asn1Error("Missing } in encoding");
280 return LDAP_PROTOCOL_ERROR;
282 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
283 *v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
287 t->syntax = (Syntax*)NULL;
288 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
289 if ( !t->comp_desc ) {
293 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
294 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
295 t->comp_desc->cd_free = (comp_free_func*)NULL;
296 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
297 t->comp_desc->cd_type = ASN_COMPOSITE;
298 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
299 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
301 } /* GDecAlgorithmIdentifier*/
305 MatchingComponentTime ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
308 ComponentTime *v1, *v2;
311 v1 = (ComponentTime*)csi_attr;
312 v2 = (ComponentTime*)csi_assert;
314 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
315 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
318 if( (v1->choiceId != v2->choiceId ) )
319 return LDAP_COMPARE_FALSE;
320 switch( v1->choiceId )
323 rc = MatchingComponentUTCTime ( oid, (ComponentSyntaxInfo*)(v1->a.utcTime), (ComponentSyntaxInfo*)(v2->a.utcTime) );
325 case TIME_GENERALIZEDTIME :
326 rc = MatchingComponentGeneralizedTime ( oid, (ComponentSyntaxInfo*)(v1->a.generalizedTime), (ComponentSyntaxInfo*)(v2->a.generalizedTime) );
329 return LDAP_PROTOCOL_ERROR;
332 } /* BMatchingComponentTimeContent */
335 ExtractingComponentTime ( void* mem_op, ComponentReference* cr, ComponentTime *comp )
339 if( (comp->choiceId) == TIME_UTCTIME &&
340 (( 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) ||
341 ( 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))) {
342 if ( cr->cr_curr->ci_next == NULL )
343 return (comp->a.utcTime);
345 cr->cr_curr = cr->cr_curr->ci_next;
346 return ExtractingComponentUTCTime ( mem_op, cr, (comp->a.utcTime) );
349 if( (comp->choiceId) == TIME_GENERALIZEDTIME &&
350 (( 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) ||
351 ( 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))) {
352 if ( cr->cr_curr->ci_next == NULL )
353 return (comp->a.generalizedTime);
355 cr->cr_curr = cr->cr_curr->ci_next;
356 return ExtractingComponentGeneralizedTime ( mem_op, cr, (comp->a.generalizedTime) );
360 } /* ExtractingComponentTime */
363 BDecComponentTime PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
367 AsnLen elmtLen0 _AND_
368 ComponentTime **v _AND_
369 AsnLen *bytesDecoded _AND_
373 AsnLen totalElmtsLen1 = 0;
376 int mandatoryElmtCount1 = 0;
379 ComponentTime *k, *t, c_temp;
382 if ( !(mode & DEC_ALLOC_MODE_1) ) {
383 memset(&c_temp,0,sizeof(c_temp));
387 mode = DEC_ALLOC_MODE_2;
390 case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE):
391 case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE):
392 (k->choiceId) = TIME_UTCTIME;
393 rc = BDecComponentUTCTime (mem_op, b, tagId0, elmtLen0, (&k->a.utcTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
394 if ( rc != LDAP_SUCCESS ) return rc;
395 (k->a.utcTime)->identifier.bv_val = (k->a.utcTime)->id_buf;
396 (k->a.utcTime)->identifier.bv_len = strlen("utcTime");
397 strcpy( (k->a.utcTime)->identifier.bv_val, "utcTime");
400 case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE):
401 case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE):
402 (k->choiceId) = TIME_GENERALIZEDTIME;
403 rc = BDecComponentGeneralizedTime (mem_op, b, tagId0, elmtLen0, (&k->a.generalizedTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
404 if ( rc != LDAP_SUCCESS ) return rc;
405 (k->a.generalizedTime)->identifier.bv_val = (k->a.generalizedTime)->id_buf;
406 (k->a.generalizedTime)->identifier.bv_len = strlen("generalizedTime");
407 strcpy( (k->a.generalizedTime)->identifier.bv_val, "generalizedTime");
411 Asn1Error ("ERROR - unexpected tag in CHOICE\n");
415 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
416 *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
420 t->syntax = (Syntax*)NULL;
421 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
422 if ( !t->comp_desc ) {
426 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
427 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
428 t->comp_desc->cd_free = (comp_free_func*)NULL;
429 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
430 t->comp_desc->cd_type = ASN_COMPOSITE;
431 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
432 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
433 (*bytesDecoded) += totalElmtsLen1;
435 } /* BDecTimeContent */
438 GDecComponentTime PARAMS (( mem_op,b, v, bytesDecoded, mode),
441 ComponentTime **v _AND_
442 AsnLen *bytesDecoded _AND_
445 char* peek_head,*peek_head2;
446 int i, strLen,strLen2, rc, old_mode = mode;
447 ComponentTime *k,*t, c_temp;
450 if ( !(mode & DEC_ALLOC_MODE_1) ) {
451 memset(&c_temp,0,sizeof(c_temp));
455 mode = DEC_ALLOC_MODE_2;
456 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
457 Asn1Error("Error during Reading identifier");
458 return LDAP_PROTOCOL_ERROR;
460 if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
461 Asn1Error("Error during Reading identifier");
462 return LDAP_PROTOCOL_ERROR;
464 if(*peek_head2 != ':'){
465 Asn1Error("Missing : in encoded data");
466 return LDAP_PROTOCOL_ERROR;
468 if( strncmp("utcTime",peek_head, strlen("utcTime")) == 0){
469 (k->choiceId) = TIME_UTCTIME;
470 rc = GDecComponentUTCTime (mem_op, b, (&k->a.utcTime), bytesDecoded, DEC_ALLOC_MODE_0 );
471 if ( rc != LDAP_SUCCESS ) return rc;
472 (k->a.utcTime)->identifier.bv_val = peek_head;
473 (k->a.utcTime)->identifier.bv_len = strLen;
475 else if( strncmp("generalizedTime",peek_head,strlen("generalizedTime")) == 0){
476 (k->choiceId) = TIME_GENERALIZEDTIME;
477 rc = GDecComponentGeneralizedTime (mem_op, b, (&k->a.generalizedTime), bytesDecoded, DEC_ALLOC_MODE_0 );
478 if ( rc != LDAP_SUCCESS ) return rc;
479 (k->a.generalizedTime)->identifier.bv_val = peek_head;
480 (k->a.generalizedTime)->identifier.bv_len = strLen;
483 Asn1Error("Undefined Identifier");
484 return LDAP_PROTOCOL_ERROR;
486 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
487 *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
491 t->syntax = (Syntax*)NULL;
492 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
493 if ( !t->comp_desc ) {
497 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
498 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
499 t->comp_desc->cd_free = (comp_free_func*)NULL;
500 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
501 t->comp_desc->cd_type = ASN_COMPOSITE;
502 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
503 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
505 } /* GDecTimeContent */
509 MatchingComponentExtension ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
514 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
515 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
519 rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnID, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnID );
520 if ( rc != LDAP_COMPARE_TRUE )
522 rc = MatchingComponentBool ( oid, (ComponentSyntaxInfo*)((ComponentExtension*)csi_attr)->critical, (ComponentSyntaxInfo*)((ComponentExtension*)csi_assert)->critical );
523 if ( rc != LDAP_COMPARE_TRUE )
525 rc = MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnValue, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnValue );
526 if ( rc != LDAP_COMPARE_TRUE )
528 return LDAP_COMPARE_TRUE;
529 } /* BMatchingComponentExtension */
532 ExtractingComponentExtension ( void* mem_op, ComponentReference* cr, ComponentExtension *comp )
535 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 ) ) {
536 if ( cr->cr_curr->ci_next == NULL )
537 return &comp->extnID;
541 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 ) ) {
542 if ( cr->cr_curr->ci_next == NULL )
543 return comp->critical;
545 cr->cr_curr = cr->cr_curr->ci_next;
546 return ExtractingComponentBool ( mem_op, cr, comp->critical );
549 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 ) ) {
550 if ( cr->cr_curr->ci_next == NULL )
551 return &comp->extnValue;
552 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
553 cr->cr_curr = cr->cr_curr->ci_next;
554 return &comp->extnValue;
560 } /* ExtractingComponentExtension */
563 BDecComponentExtension PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
567 AsnLen elmtLen0 _AND_
568 ComponentExtension **v _AND_
569 AsnLen *bytesDecoded _AND_
573 AsnLen totalElmtsLen1 = 0;
576 int mandatoryElmtCount1 = 0;
579 ComponentExtension *k, *t, c_temp;
582 if ( !(mode & DEC_ALLOC_MODE_1) ) {
583 memset(&c_temp,0,sizeof(c_temp));
587 mode = DEC_ALLOC_MODE_2;
588 tagId1 = BDecTag (b, &totalElmtsLen1 );
590 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
592 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
593 rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->extnID), &totalElmtsLen1, mode);
594 if ( rc != LDAP_SUCCESS ) return rc;
595 (&k->extnID)->identifier.bv_val = (&k->extnID)->id_buf;
596 (&k->extnID)->identifier.bv_len = strlen("extnID");
597 strcpy( (&k->extnID)->identifier.bv_val, "extnID");
598 tagId1 = BDecTag (b, &totalElmtsLen1);
605 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))))
607 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
608 rc = BDecComponentBool (mem_op, b, tagId1, elmtLen1, (&k->critical), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
609 if ( rc != LDAP_SUCCESS ) return rc;
610 (k->critical)->identifier.bv_val = (k->critical)->id_buf;
611 (k->critical)->identifier.bv_len = strlen("critical");
612 strcpy( (k->critical)->identifier.bv_val, "critical");
613 tagId1 = BDecTag (b, &totalElmtsLen1);
617 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||
618 (tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))))
620 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
621 rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extnValue), &totalElmtsLen1, mode);
622 if ( rc != LDAP_SUCCESS ) return rc;
623 (&k->extnValue)->identifier.bv_val = (&k->extnValue)->id_buf;
624 (&k->extnValue)->identifier.bv_len = strlen("extnValue");
625 strcpy( (&k->extnValue)->identifier.bv_val, "extnValue");
627 if (elmtLen0 == INDEFINITE_LEN)
628 BDecEoc (b, &totalElmtsLen1 );
629 else if (totalElmtsLen1 != elmtLen0)
641 if(!COMPONENTNOT_NULL ((k->critical)))
643 (k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
644 (k->critical)->identifier.bv_val = (k->critical)->id_buf;
645 (k->critical)->identifier.bv_len = strlen("critical");
646 strcpy( (k->critical)->identifier.bv_val, "critical");
647 (k->critical)->value = 0;
649 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
650 *v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
654 t->syntax = (Syntax*)NULL;
655 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
656 if ( !t->comp_desc ) {
660 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
661 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
662 t->comp_desc->cd_free = (comp_free_func*)NULL;
663 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
664 t->comp_desc->cd_type = ASN_COMPOSITE;
665 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
666 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
667 (*bytesDecoded) += totalElmtsLen1;
672 GDecComponentExtension PARAMS (( mem_op,b, v, bytesDecoded, mode),
675 ComponentExtension **v _AND_
676 AsnLen *bytesDecoded _AND_
679 char* peek_head,*peek_head2;
680 int i, strLen,strLen2, rc, old_mode = mode;
681 ComponentExtension *k,*t, c_temp;
684 if ( !(mode & DEC_ALLOC_MODE_1) ) {
685 memset(&c_temp,0,sizeof(c_temp));
689 mode = DEC_ALLOC_MODE_2;
691 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
692 Asn1Error("Error during Reading { in encoded data");
693 return LDAP_PROTOCOL_ERROR;
695 if(*peek_head != '{'){
696 Asn1Error("Missing { in encoded data");
697 return LDAP_PROTOCOL_ERROR;
700 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
701 Asn1Error("Error during Reading identifier");
702 return LDAP_PROTOCOL_ERROR;
704 if ( strncmp( peek_head, "extnID", strlen("extnID") ) == 0 ) {
705 rc = GDecComponentOid (mem_op, b, (&k->extnID), bytesDecoded, mode);
706 if ( rc != LDAP_SUCCESS ) return rc;
707 (&k->extnID)->identifier.bv_val = peek_head;
708 (&k->extnID)->identifier.bv_len = strLen;
709 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
710 Asn1Error("Error during Reading , ");
711 return LDAP_PROTOCOL_ERROR;
713 if(*peek_head != ','){
714 Asn1Error("Missing , in encoding");
715 return LDAP_PROTOCOL_ERROR;
717 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
718 Asn1Error("Error during Reading identifier");
719 return LDAP_PROTOCOL_ERROR;
722 if ( strncmp( peek_head, "critical", strlen("critical") ) == 0 ) {
723 rc = GDecComponentBool (mem_op, b, (&k->critical), bytesDecoded, DEC_ALLOC_MODE_0 );
724 if ( rc != LDAP_SUCCESS ) return rc;
725 ( k->critical)->identifier.bv_val = peek_head;
726 ( k->critical)->identifier.bv_len = strLen;
727 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
728 Asn1Error("Error during Reading , ");
729 return LDAP_PROTOCOL_ERROR;
731 if(*peek_head != ','){
732 Asn1Error("Missing , in encoding");
733 return LDAP_PROTOCOL_ERROR;
735 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
736 Asn1Error("Error during Reading identifier");
737 return LDAP_PROTOCOL_ERROR;
741 (k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
742 (k->critical)->value = 0;
744 if ( strncmp( peek_head, "extnValue", strlen("extnValue") ) == 0 ) {
745 rc = GDecComponentOcts (mem_op, b, (&k->extnValue), bytesDecoded, mode);
746 if ( rc != LDAP_SUCCESS ) return rc;
747 (&k->extnValue)->identifier.bv_val = peek_head;
748 (&k->extnValue)->identifier.bv_len = strLen;
750 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
751 Asn1Error("Error during Reading } in encoding");
752 return LDAP_PROTOCOL_ERROR;
754 if(*peek_head != '}'){
755 Asn1Error("Missing } in encoding");
756 return LDAP_PROTOCOL_ERROR;
758 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
759 *v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
763 t->syntax = (Syntax*)NULL;
764 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
765 if ( !t->comp_desc ) {
769 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
770 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
771 t->comp_desc->cd_free = (comp_free_func*)NULL;
772 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
773 t->comp_desc->cd_type = ASN_COMPOSITE;
774 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
775 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
781 MatchingComponentAttributeTypeAndValue ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
786 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
787 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
791 rc = MatchingComponentAttributeType ( oid, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->type, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_assert)->type );
792 if ( rc != LDAP_COMPARE_TRUE )
794 rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (&((ComponentAttributeTypeAndValue*)csi_attr)->type));
795 rc = MatchingComponentAnyDefinedBy ( oid, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_assert)->value);
796 if ( rc != LDAP_COMPARE_TRUE )
798 return LDAP_COMPARE_TRUE;
799 } /* BMatchingComponentAttributeTypeAndValue */
802 ExtractingComponentAttributeTypeAndValue ( void* mem_op, ComponentReference* cr, ComponentAttributeTypeAndValue *comp )
805 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 ) ) {
806 if ( cr->cr_curr->ci_next == NULL )
811 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 ) ) {
812 if ( cr->cr_curr->ci_next == NULL )
814 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_SELECT ) {
815 cr->cr_curr = cr->cr_curr->ci_next;
822 } /* ExtractingComponentAttributeTypeAndValue */
825 BDecComponentAttributeTypeAndValue PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
829 AsnLen elmtLen0 _AND_
830 ComponentAttributeTypeAndValue **v _AND_
831 AsnLen *bytesDecoded _AND_
835 AsnLen totalElmtsLen1 = 0;
838 int mandatoryElmtCount1 = 0;
841 ComponentAttributeTypeAndValue *k, *t, c_temp;
844 if ( !(mode & DEC_ALLOC_MODE_1) ) {
845 memset(&c_temp,0,sizeof(c_temp));
849 mode = DEC_ALLOC_MODE_2;
850 tagId1 = BDecTag (b, &totalElmtsLen1 );
852 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
854 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
855 rc = BDecComponentAttributeType (mem_op, b, tagId1, elmtLen1, (&k->type), &totalElmtsLen1, mode);
856 if ( rc != LDAP_SUCCESS ) return rc;
857 (&k->type)->identifier.bv_val = (&k->type)->id_buf;
858 (&k->type)->identifier.bv_len = strlen("type");
859 strcpy( (&k->type)->identifier.bv_val, "type");
867 rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
868 rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );
869 if ( rc != LDAP_SUCCESS ) return rc;
870 (&k->value)->identifier.bv_val = (&k->value)->id_buf;
871 (&k->value)->identifier.bv_len = strlen("value");
872 strcpy( (&k->value)->identifier.bv_val, "value");
874 if (elmtLen0 == INDEFINITE_LEN)
875 BDecEoc (b, &totalElmtsLen1 );
876 else if (totalElmtsLen1 != elmtLen0)
885 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
886 *v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
890 t->syntax = (Syntax*)NULL;
891 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
892 if ( !t->comp_desc ) {
896 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
897 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
898 t->comp_desc->cd_free = (comp_free_func*)NULL;
899 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
900 t->comp_desc->cd_type = ASN_COMPOSITE;
901 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
902 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
903 (*bytesDecoded) += totalElmtsLen1;
905 } /* BDecAttributeTypeAndValue*/
908 GDecComponentAttributeTypeAndValue PARAMS (( mem_op,b, v, bytesDecoded, mode),
911 ComponentAttributeTypeAndValue **v _AND_
912 AsnLen *bytesDecoded _AND_
915 char* peek_head,*peek_head2;
916 int i, strLen,strLen2, rc, old_mode = mode;
917 ComponentAttributeTypeAndValue *k,*t, c_temp;
920 if ( !(mode & DEC_ALLOC_MODE_1) ) {
921 memset(&c_temp,0,sizeof(c_temp));
925 mode = DEC_ALLOC_MODE_2;
927 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
928 Asn1Error("Error during Reading { in encoded data");
929 return LDAP_PROTOCOL_ERROR;
931 if(*peek_head != '{'){
932 Asn1Error("Missing { in encoded data");
933 return LDAP_PROTOCOL_ERROR;
936 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
937 Asn1Error("Error during Reading identifier");
938 return LDAP_PROTOCOL_ERROR;
940 if ( strncmp( peek_head, "type", strlen("type") ) == 0 ) {
941 rc = GDecComponentAttributeType (mem_op, b, (&k->type), bytesDecoded, mode);
942 if ( rc != LDAP_SUCCESS ) return rc;
943 (&k->type)->identifier.bv_val = peek_head;
944 (&k->type)->identifier.bv_len = strLen;
945 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
946 Asn1Error("Error during Reading , ");
947 return LDAP_PROTOCOL_ERROR;
949 if(*peek_head != ','){
950 Asn1Error("Missing , in encoding");
951 return LDAP_PROTOCOL_ERROR;
953 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
954 Asn1Error("Error during Reading identifier");
955 return LDAP_PROTOCOL_ERROR;
958 if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {
959 rc = rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
960 rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );
961 if ( rc != LDAP_SUCCESS ) return rc;
962 (&k->value)->identifier.bv_val = peek_head;
963 (&k->value)->identifier.bv_len = strLen;
965 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
966 Asn1Error("Error during Reading } in encoding");
967 return LDAP_PROTOCOL_ERROR;
969 if(*peek_head != '}'){
970 Asn1Error("Missing } in encoding");
971 return LDAP_PROTOCOL_ERROR;
973 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
974 *v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
978 t->syntax = (Syntax*)NULL;
979 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
980 if ( !t->comp_desc ) {
984 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
985 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
986 t->comp_desc->cd_free = (comp_free_func*)NULL;
987 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
988 t->comp_desc->cd_type = ASN_COMPOSITE;
989 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
990 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
992 } /* GDecAttributeTypeAndValue*/
996 MatchingComponentValidity ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1001 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1002 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1006 rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notBefore, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notBefore );
1007 if ( rc != LDAP_COMPARE_TRUE )
1009 rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notAfter, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notAfter );
1010 if ( rc != LDAP_COMPARE_TRUE )
1012 return LDAP_COMPARE_TRUE;
1013 } /* BMatchingComponentValidity */
1016 ExtractingComponentValidity ( void* mem_op, ComponentReference* cr, ComponentValidity *comp )
1019 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 ) ) {
1020 if ( cr->cr_curr->ci_next == NULL )
1021 return comp->notBefore;
1023 cr->cr_curr = cr->cr_curr->ci_next;
1024 return ExtractingComponentTime ( mem_op, cr, comp->notBefore );
1027 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 ) ) {
1028 if ( cr->cr_curr->ci_next == NULL )
1029 return comp->notAfter;
1031 cr->cr_curr = cr->cr_curr->ci_next;
1032 return ExtractingComponentTime ( mem_op, cr, comp->notAfter );
1036 } /* ExtractingComponentValidity */
1039 BDecComponentValidity PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1043 AsnLen elmtLen0 _AND_
1044 ComponentValidity **v _AND_
1045 AsnLen *bytesDecoded _AND_
1048 int seqDone = FALSE;
1049 AsnLen totalElmtsLen1 = 0;
1052 int mandatoryElmtCount1 = 0;
1053 AsnLen totalElmtsLen2 = 0;
1056 int old_mode = mode;
1058 ComponentValidity *k, *t, c_temp;
1061 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1062 memset(&c_temp,0,sizeof(c_temp));
1066 mode = DEC_ALLOC_MODE_2;
1067 tagId1 = BDecTag (b, &totalElmtsLen1 );
1069 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
1070 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
1071 (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
1072 (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
1074 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1075 rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notBefore), &totalElmtsLen1, mode);
1076 if ( rc != LDAP_SUCCESS ) return rc;
1077 (k->notBefore)->identifier.bv_val = (k->notBefore)->id_buf;
1078 (k->notBefore)->identifier.bv_len = strlen("notBefore");
1079 strcpy( (k->notBefore)->identifier.bv_val, "notBefore");
1080 tagId1 = BDecTag (b, &totalElmtsLen1);
1087 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
1088 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
1089 (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
1090 (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
1092 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1093 rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notAfter), &totalElmtsLen1, mode);
1094 if ( rc != LDAP_SUCCESS ) return rc;
1095 (k->notAfter)->identifier.bv_val = (k->notAfter)->id_buf;
1096 (k->notAfter)->identifier.bv_len = strlen("notAfter");
1097 strcpy( (k->notAfter)->identifier.bv_val, "notAfter");
1099 if (elmtLen0 == INDEFINITE_LEN)
1100 BDecEoc (b, &totalElmtsLen1 );
1101 else if (totalElmtsLen1 != elmtLen0)
1113 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1114 *v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
1115 if ( !t ) return -1;
1118 t->syntax = (Syntax*)NULL;
1119 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1120 if ( !t->comp_desc ) {
1124 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
1125 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
1126 t->comp_desc->cd_free = (comp_free_func*)NULL;
1127 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
1128 t->comp_desc->cd_type = ASN_COMPOSITE;
1129 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1130 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
1131 (*bytesDecoded) += totalElmtsLen1;
1132 return LDAP_SUCCESS;
1136 GDecComponentValidity PARAMS (( mem_op,b, v, bytesDecoded, mode),
1139 ComponentValidity **v _AND_
1140 AsnLen *bytesDecoded _AND_
1143 char* peek_head,*peek_head2;
1144 int i, strLen,strLen2, rc, old_mode = mode;
1145 ComponentValidity *k,*t, c_temp;
1148 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1149 memset(&c_temp,0,sizeof(c_temp));
1153 mode = DEC_ALLOC_MODE_2;
1155 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1156 Asn1Error("Error during Reading { in encoded data");
1157 return LDAP_PROTOCOL_ERROR;
1159 if(*peek_head != '{'){
1160 Asn1Error("Missing { in encoded data");
1161 return LDAP_PROTOCOL_ERROR;
1164 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1165 Asn1Error("Error during Reading identifier");
1166 return LDAP_PROTOCOL_ERROR;
1168 if ( strncmp( peek_head, "notBefore", strlen("notBefore") ) == 0 ) {
1169 rc = GDecComponentTime (mem_op, b, (&k->notBefore), bytesDecoded, mode);
1170 if ( rc != LDAP_SUCCESS ) return rc;
1171 ( k->notBefore)->identifier.bv_val = peek_head;
1172 ( k->notBefore)->identifier.bv_len = strLen;
1173 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1174 Asn1Error("Error during Reading , ");
1175 return LDAP_PROTOCOL_ERROR;
1177 if(*peek_head != ','){
1178 Asn1Error("Missing , in encoding");
1179 return LDAP_PROTOCOL_ERROR;
1181 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1182 Asn1Error("Error during Reading identifier");
1183 return LDAP_PROTOCOL_ERROR;
1186 if ( strncmp( peek_head, "notAfter", strlen("notAfter") ) == 0 ) {
1187 rc = GDecComponentTime (mem_op, b, (&k->notAfter), bytesDecoded, mode);
1188 if ( rc != LDAP_SUCCESS ) return rc;
1189 ( k->notAfter)->identifier.bv_val = peek_head;
1190 ( k->notAfter)->identifier.bv_len = strLen;
1192 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
1193 Asn1Error("Error during Reading } in encoding");
1194 return LDAP_PROTOCOL_ERROR;
1196 if(*peek_head != '}'){
1197 Asn1Error("Missing } in encoding");
1198 return LDAP_PROTOCOL_ERROR;
1200 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1201 *v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
1202 if ( !t ) return -1;
1205 t->syntax = (Syntax*)NULL;
1206 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1207 if ( !t->comp_desc ) {
1211 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
1212 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
1213 t->comp_desc->cd_free = (comp_free_func*)NULL;
1214 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
1215 t->comp_desc->cd_type = ASN_COMPOSITE;
1216 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1217 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
1218 return LDAP_SUCCESS;
1223 MatchingComponentSubjectPublicKeyInfo ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1228 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1229 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1233 rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_attr)->algorithm, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_assert)->algorithm );
1234 if ( rc != LDAP_COMPARE_TRUE )
1236 rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_attr)->subjectPublicKey, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_assert)->subjectPublicKey );
1237 if ( rc != LDAP_COMPARE_TRUE )
1239 return LDAP_COMPARE_TRUE;
1240 } /* BMatchingComponentSubjectPublicKeyInfo */
1243 ExtractingComponentSubjectPublicKeyInfo ( void* mem_op, ComponentReference* cr, ComponentSubjectPublicKeyInfo *comp )
1246 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 ) ) {
1247 if ( cr->cr_curr->ci_next == NULL )
1248 return comp->algorithm;
1250 cr->cr_curr = cr->cr_curr->ci_next;
1251 return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->algorithm );
1254 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 ) ) {
1255 if ( cr->cr_curr->ci_next == NULL )
1256 return &comp->subjectPublicKey;
1257 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
1258 cr->cr_curr = cr->cr_curr->ci_next;
1259 return &comp->subjectPublicKey;
1265 } /* ExtractingComponentSubjectPublicKeyInfo */
1268 BDecComponentSubjectPublicKeyInfo PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1272 AsnLen elmtLen0 _AND_
1273 ComponentSubjectPublicKeyInfo **v _AND_
1274 AsnLen *bytesDecoded _AND_
1277 int seqDone = FALSE;
1278 AsnLen totalElmtsLen1 = 0;
1281 int mandatoryElmtCount1 = 0;
1282 int old_mode = mode;
1284 ComponentSubjectPublicKeyInfo *k, *t, c_temp;
1287 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1288 memset(&c_temp,0,sizeof(c_temp));
1292 mode = DEC_ALLOC_MODE_2;
1293 tagId1 = BDecTag (b, &totalElmtsLen1 );
1295 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
1297 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1298 rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
1299 if ( rc != LDAP_SUCCESS ) return rc;
1300 (k->algorithm)->identifier.bv_val = (k->algorithm)->id_buf;
1301 (k->algorithm)->identifier.bv_len = strlen("algorithm");
1302 strcpy( (k->algorithm)->identifier.bv_val, "algorithm");
1303 tagId1 = BDecTag (b, &totalElmtsLen1);
1310 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
1311 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
1313 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1314 rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKey), &totalElmtsLen1, mode);
1315 if ( rc != LDAP_SUCCESS ) return rc;
1316 (&k->subjectPublicKey)->identifier.bv_val = (&k->subjectPublicKey)->id_buf;
1317 (&k->subjectPublicKey)->identifier.bv_len = strlen("subjectPublicKey");
1318 strcpy( (&k->subjectPublicKey)->identifier.bv_val, "subjectPublicKey");
1320 if (elmtLen0 == INDEFINITE_LEN)
1321 BDecEoc (b, &totalElmtsLen1 );
1322 else if (totalElmtsLen1 != elmtLen0)
1334 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1335 *v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
1336 if ( !t ) return -1;
1339 t->syntax = (Syntax*)NULL;
1340 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1341 if ( !t->comp_desc ) {
1345 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
1346 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
1347 t->comp_desc->cd_free = (comp_free_func*)NULL;
1348 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
1349 t->comp_desc->cd_type = ASN_COMPOSITE;
1350 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1351 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
1352 (*bytesDecoded) += totalElmtsLen1;
1353 return LDAP_SUCCESS;
1354 } /* BDecSubjectPublicKeyInfo*/
1357 GDecComponentSubjectPublicKeyInfo PARAMS (( mem_op,b, v, bytesDecoded, mode),
1360 ComponentSubjectPublicKeyInfo **v _AND_
1361 AsnLen *bytesDecoded _AND_
1364 char* peek_head,*peek_head2;
1365 int i, strLen,strLen2, rc, old_mode = mode;
1366 ComponentSubjectPublicKeyInfo *k,*t, c_temp;
1369 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1370 memset(&c_temp,0,sizeof(c_temp));
1374 mode = DEC_ALLOC_MODE_2;
1376 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1377 Asn1Error("Error during Reading { in encoded data");
1378 return LDAP_PROTOCOL_ERROR;
1380 if(*peek_head != '{'){
1381 Asn1Error("Missing { in encoded data");
1382 return LDAP_PROTOCOL_ERROR;
1385 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1386 Asn1Error("Error during Reading identifier");
1387 return LDAP_PROTOCOL_ERROR;
1389 if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
1390 rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->algorithm), bytesDecoded, mode);
1391 if ( rc != LDAP_SUCCESS ) return rc;
1392 ( k->algorithm)->identifier.bv_val = peek_head;
1393 ( k->algorithm)->identifier.bv_len = strLen;
1394 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1395 Asn1Error("Error during Reading , ");
1396 return LDAP_PROTOCOL_ERROR;
1398 if(*peek_head != ','){
1399 Asn1Error("Missing , in encoding");
1400 return LDAP_PROTOCOL_ERROR;
1402 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1403 Asn1Error("Error during Reading identifier");
1404 return LDAP_PROTOCOL_ERROR;
1407 if ( strncmp( peek_head, "subjectPublicKey", strlen("subjectPublicKey") ) == 0 ) {
1408 rc = GDecComponentBits (mem_op, b, (&k->subjectPublicKey), bytesDecoded, mode);
1409 if ( rc != LDAP_SUCCESS ) return rc;
1410 (&k->subjectPublicKey)->identifier.bv_val = peek_head;
1411 (&k->subjectPublicKey)->identifier.bv_len = strLen;
1413 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
1414 Asn1Error("Error during Reading } in encoding");
1415 return LDAP_PROTOCOL_ERROR;
1417 if(*peek_head != '}'){
1418 Asn1Error("Missing } in encoding");
1419 return LDAP_PROTOCOL_ERROR;
1421 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1422 *v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
1423 if ( !t ) return -1;
1426 t->syntax = (Syntax*)NULL;
1427 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1428 if ( !t->comp_desc ) {
1432 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
1433 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
1434 t->comp_desc->cd_free = (comp_free_func*)NULL;
1435 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
1436 t->comp_desc->cd_type = ASN_COMPOSITE;
1437 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1438 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
1439 return LDAP_SUCCESS;
1440 } /* GDecSubjectPublicKeyInfo*/
1444 MatchingComponentExtensions ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1447 void* component1, *component2;
1448 AsnList *v1, *v2, t_list;
1452 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1453 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1456 v1 = &((ComponentExtensions*)csi_attr)->comp_list;
1457 v2 = &((ComponentExtensions*)csi_assert)->comp_list;
1458 FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
1460 if( MatchingComponentExtension(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
1461 return LDAP_COMPARE_FALSE;
1467 if( (!component1 && component2) || (component1 && !component2))
1468 return LDAP_COMPARE_FALSE;
1470 return LDAP_COMPARE_TRUE;
1471 } /* BMatchingComponentExtensionsContent */
1474 ExtractingComponentExtensions ( void* mem_op, ComponentReference* cr, ComponentExtensions *comp )
1478 AsnList *v = &comp->comp_list;
1480 ComponentExtension *component;
1483 switch ( cr->cr_curr->ci_type ) {
1484 case LDAP_COMPREF_FROM_BEGINNING :
1485 count = cr->cr_curr->ci_val.ci_from_beginning;
1486 FOR_EACH_LIST_ELMT( component , v ) {
1487 if( --count == 0 ) {
1488 if( cr->cr_curr->ci_next == NULL )
1491 cr->cr_curr = cr->cr_curr->ci_next;
1492 return ExtractingComponentExtension ( mem_op, cr, component );
1497 case LDAP_COMPREF_FROM_END :
1498 total = AsnListCount ( v );
1499 count = cr->cr_curr->ci_val.ci_from_end;
1500 count = total + count +1;
1501 FOR_EACH_LIST_ELMT ( component, v ) {
1502 if( --count == 0 ) {
1503 if( cr->cr_curr->ci_next == NULL )
1506 cr->cr_curr = cr->cr_curr->ci_next;
1507 return ExtractingComponentExtension ( mem_op, cr, component );
1512 case LDAP_COMPREF_ALL :
1514 case LDAP_COMPREF_COUNT :
1515 k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1516 k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1517 k->comp_desc->cd_tag = NULL;
1518 k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
1519 k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
1520 k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
1521 k->comp_desc->cd_type = ASN_BASIC;
1522 k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
1523 k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
1524 k->value = AsnListCount(v);
1529 } /* ExtractingComponentExtensions */
1532 BDecComponentExtensions PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1536 AsnLen elmtLen0 _AND_
1537 ComponentExtensions **v _AND_
1538 AsnLen *bytesDecoded _AND_
1541 int seqDone = FALSE;
1542 AsnLen totalElmtsLen1 = 0;
1545 int mandatoryElmtCount1 = 0;
1546 int old_mode = mode;
1548 ComponentExtensions *k, *t, c_temp;
1551 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1552 memset(&c_temp,0,sizeof(c_temp));
1556 mode = DEC_ALLOC_MODE_2;
1557 AsnListInit(&k->comp_list,sizeof(ComponentExtension));
1558 for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
1560 ComponentExtension **tmpVar;
1561 tagId1 = BDecTag (b, &totalElmtsLen1 );
1563 if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1565 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
1566 break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
1568 if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1570 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1571 tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op,&k->comp_list);
1572 rc = BDecComponentExtension (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
1573 if ( rc != LDAP_SUCCESS ) return rc;
1574 } /* end of tag check if */
1575 else /* wrong tag */
1577 Asn1Error ("Unexpected Tag\n");
1582 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1583 *v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
1584 if ( !t ) return -1;
1587 t->syntax = (Syntax*)NULL;
1588 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1589 if ( !t->comp_desc ) {
1593 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
1594 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
1595 t->comp_desc->cd_free = (comp_free_func*)NULL;
1596 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
1597 t->comp_desc->cd_type = ASN_COMPOSITE;
1598 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1599 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
1600 (*bytesDecoded) += totalElmtsLen1;
1601 return LDAP_SUCCESS;
1602 } /* BDecExtensionsContent */
1605 GDecComponentExtensions PARAMS (( mem_op,b, v, bytesDecoded, mode),
1608 ComponentExtensions **v _AND_
1609 AsnLen *bytesDecoded _AND_
1612 char* peek_head,*peek_head2;
1613 int i, strLen,strLen2, rc, old_mode = mode;
1614 ComponentExtensions *k,*t, c_temp;
1618 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1619 memset(&c_temp,0,sizeof(c_temp));
1623 mode = DEC_ALLOC_MODE_2;
1624 AsnListInit( &k->comp_list, sizeof( ComponentExtension ) );
1626 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
1627 Asn1Error("Error during Reading { in encoding");
1628 return LDAP_PROTOCOL_ERROR;
1630 if(*peek_head != '{'){
1631 Asn1Error("Missing { in encoded data");
1632 return LDAP_PROTOCOL_ERROR;
1635 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
1637 ComponentExtension **tmpVar;
1638 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
1639 Asn1Error("Error during Reading{ in encoding");
1640 return LDAP_PROTOCOL_ERROR;
1642 if(*peek_head == '}') break;
1643 if( !(*peek_head == '{' || *peek_head ==',') ) {
1644 return LDAP_PROTOCOL_ERROR;
1646 tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op, &k->comp_list);
1647 if ( tmpVar == NULL ) {
1648 Asn1Error("Error during Reading{ in encoding");
1649 return LDAP_PROTOCOL_ERROR;
1651 rc = GDecComponentExtension (mem_op, b, tmpVar, bytesDecoded, mode);
1652 if ( rc != LDAP_SUCCESS ) return rc;
1655 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1656 *v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
1657 if ( !t ) return -1;
1660 t->syntax = (Syntax*)NULL;
1661 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1662 if ( !t->comp_desc ) {
1666 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
1667 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
1668 t->comp_desc->cd_free = (comp_free_func*)NULL;
1669 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
1670 t->comp_desc->cd_type = ASN_COMPOSITE;
1671 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1672 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
1673 return LDAP_SUCCESS;
1674 } /* GDecExtensionsContent */
1678 MatchingComponentRelativeDistinguishedName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1681 void* component1, *component2;
1682 AsnList *v1, *v2, t_list;
1686 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1687 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1690 v1 = &((ComponentRelativeDistinguishedName*)csi_attr)->comp_list;
1691 v2 = &((ComponentRelativeDistinguishedName*)csi_assert)->comp_list;
1692 AsnListInit( &t_list, 0 );
1693 if( AsnListCount( v1 ) != AsnListCount( v2 ) )
1694 return LDAP_COMPARE_FALSE;
1695 FOR_EACH_LIST_ELMT (component1, v1)
1697 FOR_EACH_LIST_ELMT(component2, v2)
1699 if( MatchingComponentAttributeTypeAndValue(oid, (ComponentSyntaxInfo*)component1,(ComponentSyntaxInfo*)component2) == LDAP_COMPARE_TRUE ) {
1700 AsnElmtMove( v2, &t_list );
1703 } /* end of inner for */
1704 } /* end of outer for */
1706 if( AsnListCount( v2 ) == 0 )
1707 rc = LDAP_COMPARE_TRUE;
1709 rc = LDAP_COMPARE_FALSE;
1710 AsnListMove( &t_list, v2 );
1714 } /* BMatchingComponentRelativeDistinguishedNameContent */
1717 ExtractingComponentRelativeDistinguishedName ( void* mem_op, ComponentReference* cr, ComponentRelativeDistinguishedName *comp )
1721 AsnList *v = &comp->comp_list;
1723 ComponentAttributeTypeAndValue *component;
1726 switch ( cr->cr_curr->ci_type ) {
1727 case LDAP_COMPREF_FROM_BEGINNING :
1728 count = cr->cr_curr->ci_val.ci_from_beginning;
1729 FOR_EACH_LIST_ELMT( component , v ) {
1730 if( --count == 0 ) {
1731 if( cr->cr_curr->ci_next == NULL )
1734 cr->cr_curr = cr->cr_curr->ci_next;
1735 return ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
1740 case LDAP_COMPREF_FROM_END :
1741 total = AsnListCount ( v );
1742 count = cr->cr_curr->ci_val.ci_from_end;
1743 count = total + count +1;
1744 FOR_EACH_LIST_ELMT ( component, v ) {
1745 if( --count == 0 ) {
1746 if( cr->cr_curr->ci_next == NULL )
1749 cr->cr_curr = cr->cr_curr->ci_next;
1750 return ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
1755 case LDAP_COMPREF_ALL :
1757 case LDAP_COMPREF_COUNT :
1758 k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1759 k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1760 k->comp_desc->cd_tag = NULL;
1761 k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
1762 k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
1763 k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
1764 k->comp_desc->cd_type = ASN_BASIC;
1765 k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
1766 k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
1767 k->value = AsnListCount(v);
1772 } /* ExtractingComponentRelativeDistinguishedName */
1775 BDecComponentRelativeDistinguishedName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1779 AsnLen elmtLen0 _AND_
1780 ComponentRelativeDistinguishedName **v _AND_
1781 AsnLen *bytesDecoded _AND_
1784 int seqDone = FALSE;
1785 AsnLen totalElmtsLen1 = 0;
1788 int mandatoryElmtCount1 = 0;
1789 int old_mode = mode;
1791 ComponentRelativeDistinguishedName *k, *t, c_temp;
1794 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1795 memset(&c_temp,0,sizeof(c_temp));
1799 mode = DEC_ALLOC_MODE_2;
1800 AsnListInit(&k->comp_list,sizeof(ComponentAttributeTypeAndValue));
1801 for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
1803 ComponentAttributeTypeAndValue **tmpVar;
1804 tagId1 = BDecTag (b, &totalElmtsLen1 );
1806 if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1808 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
1809 break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
1811 if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1813 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1814 tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op,&k->comp_list);
1815 rc = BDecComponentAttributeTypeAndValue (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
1816 if ( rc != LDAP_SUCCESS ) return rc;
1817 } /* end of tag check if */
1818 else /* wrong tag */
1820 Asn1Error ("Unexpected Tag\n");
1825 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1826 *v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
1827 if ( !t ) return -1;
1830 t->syntax = (Syntax*)NULL;
1831 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1832 if ( !t->comp_desc ) {
1836 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1837 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1838 t->comp_desc->cd_free = (comp_free_func*)NULL;
1839 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1840 t->comp_desc->cd_type = ASN_COMPOSITE;
1841 t->comp_desc->cd_type_id = RelativeDistinguishedName;
1842 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1843 (*bytesDecoded) += totalElmtsLen1;
1844 return LDAP_SUCCESS;
1845 } /* BDecRelativeDistinguishedNameContent */
1848 GDecComponentRelativeDistinguishedName PARAMS (( mem_op,b, v, bytesDecoded, mode),
1851 ComponentRelativeDistinguishedName **v _AND_
1852 AsnLen *bytesDecoded _AND_
1855 char* peek_head,*peek_head2;
1856 int i, strLen,strLen2, rc, old_mode = mode;
1857 ComponentRelativeDistinguishedName *k,*t, c_temp;
1861 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1862 memset(&c_temp,0,sizeof(c_temp));
1866 mode = DEC_ALLOC_MODE_2;
1867 AsnListInit( &k->comp_list, sizeof( ComponentAttributeTypeAndValue ) );
1869 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
1870 Asn1Error("Error during Reading { in encoding");
1871 return LDAP_PROTOCOL_ERROR;
1873 if(*peek_head != '{'){
1874 Asn1Error("Missing { in encoded data");
1875 return LDAP_PROTOCOL_ERROR;
1878 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
1880 ComponentAttributeTypeAndValue **tmpVar;
1881 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
1882 Asn1Error("Error during Reading{ in encoding");
1883 return LDAP_PROTOCOL_ERROR;
1885 if(*peek_head == '}') break;
1886 if( !(*peek_head == '{' || *peek_head ==',') ) {
1887 return LDAP_PROTOCOL_ERROR;
1889 tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op, &k->comp_list);
1890 if ( tmpVar == NULL ) {
1891 Asn1Error("Error during Reading{ in encoding");
1892 return LDAP_PROTOCOL_ERROR;
1894 rc = GDecComponentAttributeTypeAndValue (mem_op, b, tmpVar, bytesDecoded, mode);
1895 if ( rc != LDAP_SUCCESS ) return rc;
1898 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1899 *v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
1900 if ( !t ) return -1;
1903 t->syntax = (Syntax*)NULL;
1904 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1905 if ( !t->comp_desc ) {
1909 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1910 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1911 t->comp_desc->cd_free = (comp_free_func*)NULL;
1912 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1913 t->comp_desc->cd_type = ASN_COMPOSITE;
1914 t->comp_desc->cd_type_id = RelativeDistinguishedName;
1915 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1916 return LDAP_SUCCESS;
1917 } /* GDecRelativeDistinguishedNameContent */
1921 MatchingComponentRDNSequence ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1924 void* component1, *component2;
1925 AsnList *v1, *v2, t_list;
1929 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1930 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1933 v1 = &((ComponentRDNSequence*)csi_attr)->comp_list;
1934 v2 = &((ComponentRDNSequence*)csi_assert)->comp_list;
1935 FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
1937 if( MatchingComponentRelativeDistinguishedName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
1938 return LDAP_COMPARE_FALSE;
1944 if( (!component1 && component2) || (component1 && !component2))
1945 return LDAP_COMPARE_FALSE;
1947 return LDAP_COMPARE_TRUE;
1948 } /* BMatchingComponentRDNSequenceContent */
1951 ExtractingComponentRDNSequence ( void* mem_op, ComponentReference* cr, ComponentRDNSequence *comp )
1955 AsnList *v = &comp->comp_list;
1957 ComponentRelativeDistinguishedName *component;
1960 switch ( cr->cr_curr->ci_type ) {
1961 case LDAP_COMPREF_FROM_BEGINNING :
1962 count = cr->cr_curr->ci_val.ci_from_beginning;
1963 FOR_EACH_LIST_ELMT( component , v ) {
1964 if( --count == 0 ) {
1965 if( cr->cr_curr->ci_next == NULL )
1968 cr->cr_curr = cr->cr_curr->ci_next;
1969 return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
1974 case LDAP_COMPREF_FROM_END :
1975 total = AsnListCount ( v );
1976 count = cr->cr_curr->ci_val.ci_from_end;
1977 count = total + count +1;
1978 FOR_EACH_LIST_ELMT ( component, v ) {
1979 if( --count == 0 ) {
1980 if( cr->cr_curr->ci_next == NULL )
1983 cr->cr_curr = cr->cr_curr->ci_next;
1984 return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
1989 case LDAP_COMPREF_ALL :
1991 case LDAP_COMPREF_COUNT :
1992 k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1993 k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1994 k->comp_desc->cd_tag = NULL;
1995 k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
1996 k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
1997 k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
1998 k->comp_desc->cd_type = ASN_BASIC;
1999 k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
2000 k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
2001 k->value = AsnListCount(v);
2006 } /* ExtractingComponentRDNSequence */
2009 BDecComponentRDNSequence PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2013 AsnLen elmtLen0 _AND_
2014 ComponentRDNSequence **v _AND_
2015 AsnLen *bytesDecoded _AND_
2018 int seqDone = FALSE;
2019 AsnLen totalElmtsLen1 = 0;
2022 int mandatoryElmtCount1 = 0;
2023 int old_mode = mode;
2025 ComponentRDNSequence *k, *t, c_temp;
2028 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2029 memset(&c_temp,0,sizeof(c_temp));
2033 mode = DEC_ALLOC_MODE_2;
2034 AsnListInit(&k->comp_list,sizeof(ComponentRelativeDistinguishedName));
2035 for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
2037 ComponentRelativeDistinguishedName **tmpVar;
2038 tagId1 = BDecTag (b, &totalElmtsLen1 );
2040 if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2042 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2043 break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
2045 if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
2047 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2048 tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op,&k->comp_list);
2049 rc = BDecComponentRelativeDistinguishedName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
2050 if ( rc != LDAP_SUCCESS ) return rc;
2051 } /* end of tag check if */
2052 else /* wrong tag */
2054 Asn1Error ("Unexpected Tag\n");
2059 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2060 *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2061 if ( !t ) return -1;
2064 t->syntax = (Syntax*)NULL;
2065 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2066 if ( !t->comp_desc ) {
2070 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2071 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2072 t->comp_desc->cd_free = (comp_free_func*)NULL;
2073 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2074 t->comp_desc->cd_type = ASN_COMPOSITE;
2075 t->comp_desc->cd_type_id = RDNSequence;
2076 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2077 (*bytesDecoded) += totalElmtsLen1;
2078 return LDAP_SUCCESS;
2079 } /* BDecRDNSequenceContent */
2082 GDecComponentRDNSequence PARAMS (( mem_op,b, v, bytesDecoded, mode),
2085 ComponentRDNSequence **v _AND_
2086 AsnLen *bytesDecoded _AND_
2089 char* peek_head,*peek_head2;
2090 int i, strLen,strLen2, rc, old_mode = mode;
2091 ComponentRDNSequence *k,*t, c_temp;
2095 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2096 memset(&c_temp,0,sizeof(c_temp));
2100 mode = DEC_ALLOC_MODE_2;
2101 AsnListInit( &k->comp_list, sizeof( ComponentRelativeDistinguishedName ) );
2103 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
2104 Asn1Error("Error during Reading { in encoding");
2105 return LDAP_PROTOCOL_ERROR;
2107 if(*peek_head != '{'){
2108 Asn1Error("Missing { in encoded data");
2109 return LDAP_PROTOCOL_ERROR;
2112 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
2114 ComponentRelativeDistinguishedName **tmpVar;
2115 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
2116 Asn1Error("Error during Reading{ in encoding");
2117 return LDAP_PROTOCOL_ERROR;
2119 if(*peek_head == '}') break;
2120 if( !(*peek_head == '{' || *peek_head ==',') ) {
2121 return LDAP_PROTOCOL_ERROR;
2123 tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op, &k->comp_list);
2124 if ( tmpVar == NULL ) {
2125 Asn1Error("Error during Reading{ in encoding");
2126 return LDAP_PROTOCOL_ERROR;
2128 rc = GDecComponentRelativeDistinguishedName (mem_op, b, tmpVar, bytesDecoded, mode);
2129 if ( rc != LDAP_SUCCESS ) return rc;
2132 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2133 *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2134 if ( !t ) return -1;
2137 t->syntax = (Syntax*)NULL;
2138 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2139 if ( !t->comp_desc ) {
2143 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2144 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2145 t->comp_desc->cd_free = (comp_free_func*)NULL;
2146 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2147 t->comp_desc->cd_type = ASN_COMPOSITE;
2148 t->comp_desc->cd_type_id = RDNSequence ;
2149 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2150 return LDAP_SUCCESS;
2151 } /* GDecRDNSequenceContent */
2155 MatchingComponentName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2158 ComponentName *v1, *v2;
2161 v1 = (ComponentName*)csi_attr;
2162 v2 = (ComponentName*)csi_assert;
2164 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2165 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2168 if( (v1->choiceId != v2->choiceId ) )
2169 return LDAP_COMPARE_FALSE;
2170 switch( v1->choiceId )
2172 case NAME_RDNSEQUENCE :
2173 rc = MatchingComponentRDNSequence ( oid, (ComponentSyntaxInfo*)(v1->a.rdnSequence), (ComponentSyntaxInfo*)(v2->a.rdnSequence) );
2176 return LDAP_PROTOCOL_ERROR;
2179 } /* BMatchingComponentNameContent */
2182 ExtractingComponentName ( void* mem_op, ComponentReference* cr, ComponentName *comp )
2186 if( (comp->choiceId) == NAME_RDNSEQUENCE &&
2187 (( 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) ||
2188 ( 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))) {
2189 if ( cr->cr_curr->ci_next == NULL )
2190 return (comp->a.rdnSequence);
2192 cr->cr_curr = cr->cr_curr->ci_next;
2193 return ExtractingComponentRDNSequence ( mem_op, cr, (comp->a.rdnSequence) );
2197 } /* ExtractingComponentName */
2200 BDecComponentName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2204 AsnLen elmtLen0 _AND_
2205 ComponentName **v _AND_
2206 AsnLen *bytesDecoded _AND_
2209 int seqDone = FALSE;
2210 AsnLen totalElmtsLen1 = 0;
2213 int mandatoryElmtCount1 = 0;
2214 int old_mode = mode;
2216 ComponentName *k, *t, c_temp;
2219 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2220 memset(&c_temp,0,sizeof(c_temp));
2224 mode = DEC_ALLOC_MODE_2;
2227 case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE):
2228 (k->choiceId) = NAME_RDNSEQUENCE;
2229 rc = BDecComponentRDNSequence (mem_op, b, tagId0, elmtLen0, (&k->a.rdnSequence), &totalElmtsLen1, mode);
2230 if ( rc != LDAP_SUCCESS ) return rc;
2231 (k->a.rdnSequence)->identifier.bv_val = (k->a.rdnSequence)->id_buf;
2232 (k->a.rdnSequence)->identifier.bv_len = strlen("rdnSequence");
2233 strcpy( (k->a.rdnSequence)->identifier.bv_val, "rdnSequence");
2237 Asn1Error ("ERROR - unexpected tag in CHOICE\n");
2241 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2242 *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2243 if ( !t ) return -1;
2246 t->syntax = (Syntax*)NULL;
2247 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2248 if ( !t->comp_desc ) {
2252 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2253 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2254 t->comp_desc->cd_free = (comp_free_func*)NULL;
2255 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2256 t->comp_desc->cd_type = ASN_COMPOSITE;
2257 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2258 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2259 (*bytesDecoded) += totalElmtsLen1;
2260 return LDAP_SUCCESS;
2261 } /* BDecNameContent */
2264 GDecComponentName PARAMS (( mem_op,b, v, bytesDecoded, mode),
2267 ComponentName **v _AND_
2268 AsnLen *bytesDecoded _AND_
2271 char* peek_head,*peek_head2;
2272 int i, strLen,strLen2, rc, old_mode = mode;
2273 ComponentName *k,*t, c_temp;
2276 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2277 memset(&c_temp,0,sizeof(c_temp));
2281 mode = DEC_ALLOC_MODE_2;
2282 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2283 Asn1Error("Error during Reading identifier");
2284 return LDAP_PROTOCOL_ERROR;
2286 if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
2287 Asn1Error("Error during Reading identifier");
2288 return LDAP_PROTOCOL_ERROR;
2290 if(*peek_head2 != ':'){
2291 Asn1Error("Missing : in encoded data");
2292 return LDAP_PROTOCOL_ERROR;
2294 if( strncmp("rdnSequence",peek_head, strlen("rdnSequence")) == 0){
2295 (k->choiceId) = NAME_RDNSEQUENCE;
2296 rc = GDecComponentRDNSequence (mem_op, b, (&k->a.rdnSequence), bytesDecoded, mode);
2297 if ( rc != LDAP_SUCCESS ) return rc;
2298 (k->a.rdnSequence)->identifier.bv_val = peek_head;
2299 (k->a.rdnSequence)->identifier.bv_len = strLen;
2302 Asn1Error("Undefined Identifier");
2303 return LDAP_PROTOCOL_ERROR;
2305 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2306 *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2307 if ( !t ) return -1;
2310 t->syntax = (Syntax*)NULL;
2311 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2312 if ( !t->comp_desc ) {
2316 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2317 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2318 t->comp_desc->cd_free = (comp_free_func*)NULL;
2319 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2320 t->comp_desc->cd_type = ASN_COMPOSITE;
2321 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2322 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2323 return LDAP_SUCCESS;
2324 } /* GDecNameContent */
2328 MatchingComponentTBSCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2333 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2334 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2338 rc = MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->version );
2339 if ( rc != LDAP_COMPARE_TRUE )
2341 rc = MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->serialNumber, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->serialNumber );
2342 if ( rc != LDAP_COMPARE_TRUE )
2344 rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->signature );
2345 if ( rc != LDAP_COMPARE_TRUE )
2347 rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->issuer );
2348 if ( rc != LDAP_COMPARE_TRUE )
2350 rc = MatchingComponentValidity ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->validity, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->validity );
2351 if ( rc != LDAP_COMPARE_TRUE )
2353 rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subject, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subject );
2354 if ( rc != LDAP_COMPARE_TRUE )
2356 rc = MatchingComponentSubjectPublicKeyInfo ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subjectPublicKeyInfo, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subjectPublicKeyInfo );
2357 if ( rc != LDAP_COMPARE_TRUE )
2359 rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->issuerUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->issuerUniqueIdentifier );
2360 if ( rc != LDAP_COMPARE_TRUE )
2362 rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->subjectUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->subjectUniqueIdentifier );
2363 if ( rc != LDAP_COMPARE_TRUE )
2365 if(COMPONENTNOT_NULL( ((ComponentTBSCertificate*)csi_attr)->extensions ) ) {
2366 rc = MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->extensions, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->extensions );
2367 if ( rc != LDAP_COMPARE_TRUE )
2370 return LDAP_COMPARE_TRUE;
2371 } /* BMatchingComponentTBSCertificate */
2374 ExtractingComponentTBSCertificate ( void* mem_op, ComponentReference* cr, ComponentTBSCertificate *comp )
2377 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 ) ) {
2378 if ( cr->cr_curr->ci_next == NULL )
2379 return comp->version;
2381 cr->cr_curr = cr->cr_curr->ci_next;
2382 return ExtractingComponentVersion ( mem_op, cr, comp->version );
2385 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 ) ) {
2386 if ( cr->cr_curr->ci_next == NULL )
2387 return &comp->serialNumber;
2391 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 ) ) {
2392 if ( cr->cr_curr->ci_next == NULL )
2393 return comp->signature;
2395 cr->cr_curr = cr->cr_curr->ci_next;
2396 return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature );
2399 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 ) ) {
2400 if ( cr->cr_curr->ci_next == NULL )
2401 return comp->issuer;
2403 cr->cr_curr = cr->cr_curr->ci_next;
2404 return ExtractingComponentName ( mem_op, cr, comp->issuer );
2407 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 ) ) {
2408 if ( cr->cr_curr->ci_next == NULL )
2409 return comp->validity;
2411 cr->cr_curr = cr->cr_curr->ci_next;
2412 return ExtractingComponentValidity ( mem_op, cr, comp->validity );
2415 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 ) ) {
2416 if ( cr->cr_curr->ci_next == NULL )
2417 return comp->subject;
2419 cr->cr_curr = cr->cr_curr->ci_next;
2420 return ExtractingComponentName ( mem_op, cr, comp->subject );
2423 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 ) ) {
2424 if ( cr->cr_curr->ci_next == NULL )
2425 return comp->subjectPublicKeyInfo;
2427 cr->cr_curr = cr->cr_curr->ci_next;
2428 return ExtractingComponentSubjectPublicKeyInfo ( mem_op, cr, comp->subjectPublicKeyInfo );
2431 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 ) ) {
2432 if ( cr->cr_curr->ci_next == NULL )
2433 return &comp->issuerUniqueIdentifier;
2434 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2435 cr->cr_curr = cr->cr_curr->ci_next;
2436 return &comp->issuerUniqueIdentifier;
2441 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 ) ) {
2442 if ( cr->cr_curr->ci_next == NULL )
2443 return &comp->subjectUniqueIdentifier;
2444 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2445 cr->cr_curr = cr->cr_curr->ci_next;
2446 return &comp->subjectUniqueIdentifier;
2451 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 ) ) {
2452 if ( cr->cr_curr->ci_next == NULL )
2453 return comp->extensions;
2455 cr->cr_curr = cr->cr_curr->ci_next;
2456 return ExtractingComponentExtensions ( mem_op, cr, comp->extensions );
2460 } /* ExtractingComponentTBSCertificate */
2463 BDecComponentTBSCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2467 AsnLen elmtLen0 _AND_
2468 ComponentTBSCertificate **v _AND_
2469 AsnLen *bytesDecoded _AND_
2472 int seqDone = FALSE;
2473 AsnLen totalElmtsLen1 = 0;
2476 int mandatoryElmtCount1 = 0;
2477 AsnLen totalElmtsLen2 = 0;
2480 int old_mode = mode;
2482 ComponentTBSCertificate *k, *t, c_temp;
2485 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2486 memset(&c_temp,0,sizeof(c_temp));
2490 mode = DEC_ALLOC_MODE_2;
2491 tagId1 = BDecTag (b, &totalElmtsLen1 );
2493 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
2495 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2496 tagId2 = BDecTag (b, &totalElmtsLen1 );
2498 if (tagId2 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
2500 Asn1Error ("Unexpected Tag\n");
2504 elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2505 rc = BDecComponentVersion (mem_op, b, tagId2, elmtLen2, (&k->version), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
2506 if ( rc != LDAP_SUCCESS ) return rc;
2507 (k->version)->identifier.bv_val = (k->version)->id_buf;
2508 (k->version)->identifier.bv_len = strlen("version");
2509 strcpy( (k->version)->identifier.bv_val, "version");
2510 if (elmtLen1 == INDEFINITE_LEN)
2511 BDecEoc (b, &totalElmtsLen1 );
2512 tagId1 = BDecTag (b, &totalElmtsLen1);
2516 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
2518 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2519 rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->serialNumber), &totalElmtsLen1, mode);
2520 if ( rc != LDAP_SUCCESS ) return rc;
2521 (&k->serialNumber)->identifier.bv_val = (&k->serialNumber)->id_buf;
2522 (&k->serialNumber)->identifier.bv_len = strlen("serialNumber");
2523 strcpy( (&k->serialNumber)->identifier.bv_val, "serialNumber");
2524 tagId1 = BDecTag (b, &totalElmtsLen1);
2531 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2533 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2534 rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
2535 if ( rc != LDAP_SUCCESS ) return rc;
2536 (k->signature)->identifier.bv_val = (k->signature)->id_buf;
2537 (k->signature)->identifier.bv_len = strlen("signature");
2538 strcpy( (k->signature)->identifier.bv_val, "signature");
2539 tagId1 = BDecTag (b, &totalElmtsLen1);
2546 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2548 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2549 rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->issuer), &totalElmtsLen1, mode);
2550 if ( rc != LDAP_SUCCESS ) return rc;
2551 (k->issuer)->identifier.bv_val = (k->issuer)->id_buf;
2552 (k->issuer)->identifier.bv_len = strlen("issuer");
2553 strcpy( (k->issuer)->identifier.bv_val, "issuer");
2554 tagId1 = BDecTag (b, &totalElmtsLen1);
2561 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2563 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2564 rc = BDecComponentValidity (mem_op, b, tagId1, elmtLen1, (&k->validity), &totalElmtsLen1, mode);
2565 if ( rc != LDAP_SUCCESS ) return rc;
2566 (k->validity)->identifier.bv_val = (k->validity)->id_buf;
2567 (k->validity)->identifier.bv_len = strlen("validity");
2568 strcpy( (k->validity)->identifier.bv_val, "validity");
2569 tagId1 = BDecTag (b, &totalElmtsLen1);
2576 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2578 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2579 rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->subject), &totalElmtsLen1, mode);
2580 if ( rc != LDAP_SUCCESS ) return rc;
2581 (k->subject)->identifier.bv_val = (k->subject)->id_buf;
2582 (k->subject)->identifier.bv_len = strlen("subject");
2583 strcpy( (k->subject)->identifier.bv_val, "subject");
2584 tagId1 = BDecTag (b, &totalElmtsLen1);
2591 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2593 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2594 rc = BDecComponentSubjectPublicKeyInfo (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKeyInfo), &totalElmtsLen1, mode);
2595 if ( rc != LDAP_SUCCESS ) return rc;
2596 (k->subjectPublicKeyInfo)->identifier.bv_val = (k->subjectPublicKeyInfo)->id_buf;
2597 (k->subjectPublicKeyInfo)->identifier.bv_len = strlen("subjectPublicKeyInfo");
2598 strcpy( (k->subjectPublicKeyInfo)->identifier.bv_val, "subjectPublicKeyInfo");
2599 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2603 tagId1 = BDecTag (b, &totalElmtsLen1 );
2605 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2607 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2617 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)) ||
2618 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
2620 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2621 rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->issuerUniqueIdentifier), &totalElmtsLen1, mode);
2622 if ( rc != LDAP_SUCCESS ) return rc;
2623 (&k->issuerUniqueIdentifier)->identifier.bv_val = (&k->issuerUniqueIdentifier)->id_buf;
2624 (&k->issuerUniqueIdentifier)->identifier.bv_len = strlen("issuerUniqueIdentifier");
2625 strcpy( (&k->issuerUniqueIdentifier)->identifier.bv_val, "issuerUniqueIdentifier");
2626 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2630 tagId1 = BDecTag (b, &totalElmtsLen1 );
2632 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2634 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2641 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)) ||
2642 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2))))
2644 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2645 rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->subjectUniqueIdentifier), &totalElmtsLen1, mode);
2646 if ( rc != LDAP_SUCCESS ) return rc;
2647 (&k->subjectUniqueIdentifier)->identifier.bv_val = (&k->subjectUniqueIdentifier)->id_buf;
2648 (&k->subjectUniqueIdentifier)->identifier.bv_len = strlen("subjectUniqueIdentifier");
2649 strcpy( (&k->subjectUniqueIdentifier)->identifier.bv_val, "subjectUniqueIdentifier");
2650 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2654 tagId1 = BDecTag (b, &totalElmtsLen1 );
2656 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2658 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2665 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3))))
2667 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2668 tagId2 = BDecTag (b, &totalElmtsLen1 );
2670 if (tagId2 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2672 Asn1Error ("Unexpected Tag\n");
2676 elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2677 rc = BDecComponentExtensions (mem_op, b, tagId2, elmtLen2, (&k->extensions), &totalElmtsLen1, mode);
2678 if ( rc != LDAP_SUCCESS ) return rc;
2679 (k->extensions)->identifier.bv_val = (k->extensions)->id_buf;
2680 (k->extensions)->identifier.bv_len = strlen("extensions");
2681 strcpy( (k->extensions)->identifier.bv_val, "extensions");
2682 if (elmtLen1 == INDEFINITE_LEN)
2683 BDecEoc (b, &totalElmtsLen1 );
2685 if (elmtLen0 == INDEFINITE_LEN)
2686 BDecEoc (b, &totalElmtsLen1 );
2687 else if (totalElmtsLen1 != elmtLen0)
2696 if(!COMPONENTNOT_NULL ((k->version)))
2698 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2699 (k->version)->identifier.bv_val = (k->version)->id_buf;
2700 (k->version)->identifier.bv_len = strlen("version");
2701 strcpy( (k->version)->identifier.bv_val, "version");
2702 (k->version)->value = 0;
2704 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2705 *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2706 if ( !t ) return -1;
2709 t->syntax = (Syntax*)NULL;
2710 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2711 if ( !t->comp_desc ) {
2715 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2716 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2717 t->comp_desc->cd_free = (comp_free_func*)NULL;
2718 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2719 t->comp_desc->cd_type = ASN_COMPOSITE;
2720 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2721 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2722 (*bytesDecoded) += totalElmtsLen1;
2723 return LDAP_SUCCESS;
2724 } /* BDecTBSCertificate*/
2727 GDecComponentTBSCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
2730 ComponentTBSCertificate **v _AND_
2731 AsnLen *bytesDecoded _AND_
2734 char* peek_head,*peek_head2;
2735 int i, strLen,strLen2, rc, old_mode = mode;
2736 ComponentTBSCertificate *k,*t, c_temp;
2739 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2740 memset(&c_temp,0,sizeof(c_temp));
2744 mode = DEC_ALLOC_MODE_2;
2746 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2747 Asn1Error("Error during Reading { in encoded data");
2748 return LDAP_PROTOCOL_ERROR;
2750 if(*peek_head != '{'){
2751 Asn1Error("Missing { in encoded data");
2752 return LDAP_PROTOCOL_ERROR;
2755 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2756 Asn1Error("Error during Reading identifier");
2757 return LDAP_PROTOCOL_ERROR;
2759 if ( strncmp( peek_head, "version", strlen("version") ) == 0 ) {
2760 rc = GDecComponentVersion (mem_op, b, (&k->version), bytesDecoded, DEC_ALLOC_MODE_0 );
2761 if ( rc != LDAP_SUCCESS ) return rc;
2762 ( k->version)->identifier.bv_val = peek_head;
2763 ( k->version)->identifier.bv_len = strLen;
2764 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2765 Asn1Error("Error during Reading , ");
2766 return LDAP_PROTOCOL_ERROR;
2768 if(*peek_head != ','){
2769 Asn1Error("Missing , in encoding");
2770 return LDAP_PROTOCOL_ERROR;
2772 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2773 Asn1Error("Error during Reading identifier");
2774 return LDAP_PROTOCOL_ERROR;
2778 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2779 (k->version)->value = 0;
2781 if ( strncmp( peek_head, "serialNumber", strlen("serialNumber") ) == 0 ) {
2782 rc = GDecComponentCertificateSerialNumber (mem_op, b, (&k->serialNumber), bytesDecoded, mode);
2783 if ( rc != LDAP_SUCCESS ) return rc;
2784 (&k->serialNumber)->identifier.bv_val = peek_head;
2785 (&k->serialNumber)->identifier.bv_len = strLen;
2786 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2787 Asn1Error("Error during Reading , ");
2788 return LDAP_PROTOCOL_ERROR;
2790 if(*peek_head != ','){
2791 Asn1Error("Missing , in encoding");
2792 return LDAP_PROTOCOL_ERROR;
2794 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2795 Asn1Error("Error during Reading identifier");
2796 return LDAP_PROTOCOL_ERROR;
2799 if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
2800 rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signature), bytesDecoded, mode);
2801 if ( rc != LDAP_SUCCESS ) return rc;
2802 ( k->signature)->identifier.bv_val = peek_head;
2803 ( k->signature)->identifier.bv_len = strLen;
2804 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2805 Asn1Error("Error during Reading , ");
2806 return LDAP_PROTOCOL_ERROR;
2808 if(*peek_head != ','){
2809 Asn1Error("Missing , in encoding");
2810 return LDAP_PROTOCOL_ERROR;
2812 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2813 Asn1Error("Error during Reading identifier");
2814 return LDAP_PROTOCOL_ERROR;
2817 if ( strncmp( peek_head, "issuer", strlen("issuer") ) == 0 ) {
2818 rc = GDecComponentName (mem_op, b, (&k->issuer), bytesDecoded, mode);
2819 if ( rc != LDAP_SUCCESS ) return rc;
2820 ( k->issuer)->identifier.bv_val = peek_head;
2821 ( k->issuer)->identifier.bv_len = strLen;
2822 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2823 Asn1Error("Error during Reading , ");
2824 return LDAP_PROTOCOL_ERROR;
2826 if(*peek_head != ','){
2827 Asn1Error("Missing , in encoding");
2828 return LDAP_PROTOCOL_ERROR;
2830 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2831 Asn1Error("Error during Reading identifier");
2832 return LDAP_PROTOCOL_ERROR;
2835 if ( strncmp( peek_head, "validity", strlen("validity") ) == 0 ) {
2836 rc = GDecComponentValidity (mem_op, b, (&k->validity), bytesDecoded, mode);
2837 if ( rc != LDAP_SUCCESS ) return rc;
2838 ( k->validity)->identifier.bv_val = peek_head;
2839 ( k->validity)->identifier.bv_len = strLen;
2840 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2841 Asn1Error("Error during Reading , ");
2842 return LDAP_PROTOCOL_ERROR;
2844 if(*peek_head != ','){
2845 Asn1Error("Missing , in encoding");
2846 return LDAP_PROTOCOL_ERROR;
2848 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2849 Asn1Error("Error during Reading identifier");
2850 return LDAP_PROTOCOL_ERROR;
2853 if ( strncmp( peek_head, "subject", strlen("subject") ) == 0 ) {
2854 rc = GDecComponentName (mem_op, b, (&k->subject), bytesDecoded, mode);
2855 if ( rc != LDAP_SUCCESS ) return rc;
2856 ( k->subject)->identifier.bv_val = peek_head;
2857 ( k->subject)->identifier.bv_len = strLen;
2858 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2859 Asn1Error("Error during Reading , ");
2860 return LDAP_PROTOCOL_ERROR;
2862 if(*peek_head != ','){
2863 Asn1Error("Missing , in encoding");
2864 return LDAP_PROTOCOL_ERROR;
2866 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2867 Asn1Error("Error during Reading identifier");
2868 return LDAP_PROTOCOL_ERROR;
2871 if ( strncmp( peek_head, "subjectPublicKeyInfo", strlen("subjectPublicKeyInfo") ) == 0 ) {
2872 rc = GDecComponentSubjectPublicKeyInfo (mem_op, b, (&k->subjectPublicKeyInfo), bytesDecoded, mode);
2873 if ( rc != LDAP_SUCCESS ) return rc;
2874 ( k->subjectPublicKeyInfo)->identifier.bv_val = peek_head;
2875 ( k->subjectPublicKeyInfo)->identifier.bv_len = strLen;
2876 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2877 Asn1Error("Error during Reading , ");
2878 return LDAP_PROTOCOL_ERROR;
2880 if(*peek_head != ','){
2881 Asn1Error("Missing , in encoding");
2882 return LDAP_PROTOCOL_ERROR;
2884 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2885 Asn1Error("Error during Reading identifier");
2886 return LDAP_PROTOCOL_ERROR;
2889 if ( strncmp( peek_head, "issuerUniqueIdentifier", strlen("issuerUniqueIdentifier") ) == 0 ) {
2890 rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->issuerUniqueIdentifier), bytesDecoded, mode);
2891 if ( rc != LDAP_SUCCESS ) return rc;
2892 (&k->issuerUniqueIdentifier)->identifier.bv_val = peek_head;
2893 (&k->issuerUniqueIdentifier)->identifier.bv_len = strLen;
2894 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2895 Asn1Error("Error during Reading , ");
2896 return LDAP_PROTOCOL_ERROR;
2898 if(*peek_head != ','){
2899 Asn1Error("Missing , in encoding");
2900 return LDAP_PROTOCOL_ERROR;
2902 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2903 Asn1Error("Error during Reading identifier");
2904 return LDAP_PROTOCOL_ERROR;
2907 if ( strncmp( peek_head, "subjectUniqueIdentifier", strlen("subjectUniqueIdentifier") ) == 0 ) {
2908 rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->subjectUniqueIdentifier), bytesDecoded, mode);
2909 if ( rc != LDAP_SUCCESS ) return rc;
2910 (&k->subjectUniqueIdentifier)->identifier.bv_val = peek_head;
2911 (&k->subjectUniqueIdentifier)->identifier.bv_len = strLen;
2912 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2913 Asn1Error("Error during Reading , ");
2914 return LDAP_PROTOCOL_ERROR;
2916 if(*peek_head != ','){
2917 Asn1Error("Missing , in encoding");
2918 return LDAP_PROTOCOL_ERROR;
2920 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2921 Asn1Error("Error during Reading identifier");
2922 return LDAP_PROTOCOL_ERROR;
2925 if ( strncmp( peek_head, "extensions", strlen("extensions") ) == 0 ) {
2926 rc = GDecComponentExtensions (mem_op, b, (&k->extensions), bytesDecoded, mode);
2927 if ( rc != LDAP_SUCCESS ) return rc;
2928 ( k->extensions)->identifier.bv_val = peek_head;
2929 ( k->extensions)->identifier.bv_len = strLen;
2931 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
2932 Asn1Error("Error during Reading } in encoding");
2933 return LDAP_PROTOCOL_ERROR;
2935 if(*peek_head != '}'){
2936 Asn1Error("Missing } in encoding");
2937 return LDAP_PROTOCOL_ERROR;
2939 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2940 *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2941 if ( !t ) return -1;
2944 t->syntax = (Syntax*)NULL;
2945 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2946 if ( !t->comp_desc ) {
2950 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2951 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2952 t->comp_desc->cd_free = (comp_free_func*)NULL;
2953 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2954 t->comp_desc->cd_type = ASN_COMPOSITE;
2955 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2956 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2957 return LDAP_SUCCESS;
2958 } /* GDecTBSCertificate*/
2962 MatchingComponentCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2967 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2968 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2972 rc = MatchingComponentTBSCertificate ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->tbsCertificate, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->tbsCertificate );
2973 if ( rc != LDAP_COMPARE_TRUE )
2975 rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->signatureAlgorithm );
2976 if ( rc != LDAP_COMPARE_TRUE )
2978 rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_assert)->signature );
2979 if ( rc != LDAP_COMPARE_TRUE )
2981 return LDAP_COMPARE_TRUE;
2982 } /* BMatchingComponentCertificate */
2985 ExtractingComponentCertificate ( void* mem_op, ComponentReference* cr, ComponentCertificate *comp )
2988 if ( ( comp->tbsCertificate->identifier.bv_val && strncmp(comp->tbsCertificate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->tbsCertificate->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2989 if ( cr->cr_curr->ci_next == NULL )
2990 return comp->tbsCertificate;
2992 cr->cr_curr = cr->cr_curr->ci_next;
2993 return ExtractingComponentTBSCertificate ( mem_op, cr, comp->tbsCertificate );
2996 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 ) ) {
2997 if ( cr->cr_curr->ci_next == NULL )
2998 return comp->signatureAlgorithm;
3000 cr->cr_curr = cr->cr_curr->ci_next;
3001 return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm );
3004 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 ) ) {
3005 if ( cr->cr_curr->ci_next == NULL )
3006 return &comp->signature;
3007 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
3008 cr->cr_curr = cr->cr_curr->ci_next;
3009 return &comp->signature;
3015 } /* ExtractingComponentCertificate */
3018 BDecComponentCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
3022 AsnLen elmtLen0 _AND_
3023 ComponentCertificate **v _AND_
3024 AsnLen *bytesDecoded _AND_
3027 int seqDone = FALSE;
3028 AsnLen totalElmtsLen1 = 0;
3031 int mandatoryElmtCount1 = 0;
3032 int old_mode = mode;
3034 ComponentCertificate *k, *t, c_temp;
3037 if ( !(mode & DEC_ALLOC_MODE_1) ) {
3038 memset(&c_temp,0,sizeof(c_temp));
3042 mode = DEC_ALLOC_MODE_2;
3043 tagId1 = BDecTag (b, &totalElmtsLen1 );
3045 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3047 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3048 rc = BDecComponentTBSCertificate (mem_op, b, tagId1, elmtLen1, (&k->tbsCertificate), &totalElmtsLen1, mode);
3049 if ( rc != LDAP_SUCCESS ) return rc;
3050 (k->tbsCertificate)->identifier.bv_val = (k->tbsCertificate)->id_buf;
3051 (k->tbsCertificate)->identifier.bv_len = strlen("tbsCertificate");
3052 strcpy( (k->tbsCertificate)->identifier.bv_val, "tbsCertificate");
3053 tagId1 = BDecTag (b, &totalElmtsLen1);
3060 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3062 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3063 rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode);
3064 if ( rc != LDAP_SUCCESS ) return rc;
3065 (k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf;
3066 (k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm");
3067 strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm");
3068 tagId1 = BDecTag (b, &totalElmtsLen1);
3075 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
3076 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
3078 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3079 rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
3080 if ( rc != LDAP_SUCCESS ) return rc;
3081 (&k->signature)->identifier.bv_val = (&k->signature)->id_buf;
3082 (&k->signature)->identifier.bv_len = strlen("signature");
3083 strcpy( (&k->signature)->identifier.bv_val, "signature");
3085 if (elmtLen0 == INDEFINITE_LEN)
3086 BDecEoc (b, &totalElmtsLen1 );
3087 else if (totalElmtsLen1 != elmtLen0)
3099 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3100 *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3101 if ( !t ) return -1;
3104 t->syntax = (Syntax*)NULL;
3105 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3106 if ( !t->comp_desc ) {
3110 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3111 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3112 t->comp_desc->cd_free = (comp_free_func*)NULL;
3113 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3114 t->comp_desc->cd_type = ASN_COMPOSITE;
3115 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3116 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3117 (*bytesDecoded) += totalElmtsLen1;
3118 return LDAP_SUCCESS;
3119 } /* BDecCertificate*/
3122 GDecComponentCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
3125 ComponentCertificate **v _AND_
3126 AsnLen *bytesDecoded _AND_
3129 char* peek_head,*peek_head2;
3130 int i, strLen,strLen2, rc, old_mode = mode;
3131 ComponentCertificate *k,*t, c_temp;
3134 if ( !(mode & DEC_ALLOC_MODE_1) ) {
3135 memset(&c_temp,0,sizeof(c_temp));
3139 mode = DEC_ALLOC_MODE_2;
3141 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3142 Asn1Error("Error during Reading { in encoded data");
3143 return LDAP_PROTOCOL_ERROR;
3145 if(*peek_head != '{'){
3146 Asn1Error("Missing { in encoded data");
3147 return LDAP_PROTOCOL_ERROR;
3150 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3151 Asn1Error("Error during Reading identifier");
3152 return LDAP_PROTOCOL_ERROR;
3154 if ( strncmp( peek_head, "tbsCertificate", strlen("tbsCertificate") ) == 0 ) {
3155 rc = GDecComponentTBSCertificate (mem_op, b, (&k->tbsCertificate), bytesDecoded, mode);
3156 if ( rc != LDAP_SUCCESS ) return rc;
3157 ( k->tbsCertificate)->identifier.bv_val = peek_head;
3158 ( k->tbsCertificate)->identifier.bv_len = strLen;
3159 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3160 Asn1Error("Error during Reading , ");
3161 return LDAP_PROTOCOL_ERROR;
3163 if(*peek_head != ','){
3164 Asn1Error("Missing , in encoding");
3165 return LDAP_PROTOCOL_ERROR;
3167 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3168 Asn1Error("Error during Reading identifier");
3169 return LDAP_PROTOCOL_ERROR;
3172 if ( strncmp( peek_head, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) {
3173 rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode);
3174 if ( rc != LDAP_SUCCESS ) return rc;
3175 ( k->signatureAlgorithm)->identifier.bv_val = peek_head;
3176 ( k->signatureAlgorithm)->identifier.bv_len = strLen;
3177 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3178 Asn1Error("Error during Reading , ");
3179 return LDAP_PROTOCOL_ERROR;
3181 if(*peek_head != ','){
3182 Asn1Error("Missing , in encoding");
3183 return LDAP_PROTOCOL_ERROR;
3185 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3186 Asn1Error("Error during Reading identifier");
3187 return LDAP_PROTOCOL_ERROR;
3190 if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
3191 rc = GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode);
3192 if ( rc != LDAP_SUCCESS ) return rc;
3193 (&k->signature)->identifier.bv_val = peek_head;
3194 (&k->signature)->identifier.bv_len = strLen;
3196 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
3197 Asn1Error("Error during Reading } in encoding");
3198 return LDAP_PROTOCOL_ERROR;
3200 if(*peek_head != '}'){
3201 Asn1Error("Missing } in encoding");
3202 return LDAP_PROTOCOL_ERROR;
3204 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3205 *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3206 if ( !t ) return -1;
3209 t->syntax = (Syntax*)NULL;
3210 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3211 if ( !t->comp_desc ) {
3215 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3216 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3217 t->comp_desc->cd_free = (comp_free_func*)NULL;
3218 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3219 t->comp_desc->cd_type = ASN_COMPOSITE;
3220 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3221 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3222 return LDAP_SUCCESS;
3223 } /* GDecCertificate*/