1 /*	$NetBSD: crl.c,v 1.1.1.2 2010/03/08 02:14:20 lukem Exp $	*/
2 
3 /*
4  *    crl.c
5  *    "CertificateRevokationList" ASN.1 module encode/decode/extracting/matching/free C src.
6  *    This file was generated by modified eSMACC compiler Fri Jan 21 11:25:24 2005
7  *    The generated files are supposed to be compiled as a module for OpenLDAP Software
8  */
9 
10 #include "crl.h"
11 
12 BDecComponentCertificateListTop( void* mem_op, GenBuf* b, void *v, AsnLen* bytesDecoded,int mode) {
13 	AsnTag tag;
14 	AsnLen elmtLen;
15 
16 	tag = BDecTag ( b, bytesDecoded );
17 	elmtLen = BDecLen ( b, bytesDecoded );
18 	if ( elmtLen <= 0 ) return (-1);
19 	if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {
20 		return (-1);
21 	}
22 
23 	return BDecComponentCertificateList( mem_op, b, tag, elmtLen, ( ComponentCertificateList**)v, (AsnLen*)bytesDecoded, mode );
24 }
25 
26 
27 void init_module_CertificateRevokationList() {
28 	InstallOidDecoderMapping( "2.5.4.39", NULL,
29 		GDecComponentCertificateList,
30 		BDecComponentCertificateListTop,
31 		ExtractingComponentCertificateList,
32 		MatchingComponentCertificateList);
33 }
34 
35 int
36 MatchingComponentTBSCertListSeqOfSeq ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
37 	int rc;
38 	MatchingRule* mr;
39 
40 	if ( oid ) {
41 		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
42 		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
43 	}
44 
45 	rc = 1;
46 	rc =	MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertListSeqOfSeq*)csi_attr)->userCertificate, (ComponentSyntaxInfo*)&((ComponentTBSCertListSeqOfSeq*)csi_assert)->userCertificate );
47 	if ( rc != LDAP_COMPARE_TRUE )
48 		return rc;
49 	rc =	MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_attr)->revocationDate, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_assert)->revocationDate );
50 	if ( rc != LDAP_COMPARE_TRUE )
51 		return rc;
52 	if(COMPONENTNOT_NULL( ((ComponentTBSCertListSeqOfSeq*)csi_attr)->crlEntryExtensions ) ) {
53 	rc =	MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_attr)->crlEntryExtensions, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_assert)->crlEntryExtensions );
54 	if ( rc != LDAP_COMPARE_TRUE )
55 		return rc;
56 	}
57 	return LDAP_COMPARE_TRUE;
58 }  /* BMatchingComponentTBSCertListSeqOfSeq */
59 
60 void*
61 ExtractingComponentTBSCertListSeqOfSeq ( void* mem_op, ComponentReference* cr, ComponentTBSCertListSeqOfSeq *comp )
62 {
63 
64 	if ( ( comp->userCertificate.identifier.bv_val && strncmp(comp->userCertificate.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->userCertificate.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
65 		if ( cr->cr_curr->ci_next == NULL )
66 		return &comp->userCertificate;
67 		else
68 		return NULL;
69 	}
70 	if ( ( comp->revocationDate->identifier.bv_val && strncmp(comp->revocationDate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->revocationDate->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
71 		if ( cr->cr_curr->ci_next == NULL )
72 			return comp->revocationDate;
73 		else {
74 			cr->cr_curr = cr->cr_curr->ci_next;
75 			return 	ExtractingComponentTime ( mem_op, cr, comp->revocationDate );
76 		}
77 	}
78 	if ( ( comp->crlEntryExtensions->identifier.bv_val && strncmp(comp->crlEntryExtensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->crlEntryExtensions->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
79 		if ( cr->cr_curr->ci_next == NULL )
80 			return comp->crlEntryExtensions;
81 		else {
82 			cr->cr_curr = cr->cr_curr->ci_next;
83 			return 	ExtractingComponentExtensions ( mem_op, cr, comp->crlEntryExtensions );
84 		}
85 	}
86 	return NULL;
87 }  /* ExtractingComponentTBSCertListSeqOfSeq */
88 
89 int
90 BDecComponentTBSCertListSeqOfSeq PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
91 void* mem_op _AND_
92 GenBuf * b _AND_
93 AsnTag tagId0 _AND_
94 AsnLen elmtLen0 _AND_
95 ComponentTBSCertListSeqOfSeq **v _AND_
96 AsnLen *bytesDecoded _AND_
97 int mode)
98 {
99 	int seqDone = FALSE;
100 	AsnLen totalElmtsLen1 = 0;
101 	AsnLen elmtLen1;
102 	AsnTag tagId1;
103 	int mandatoryElmtCount1 = 0;
104 	AsnLen totalElmtsLen2 = 0;
105 	AsnLen elmtLen2;
106 	AsnTag tagId2;
107 	int old_mode = mode;
108 	int rc;
109 	ComponentTBSCertListSeqOfSeq *k, *t, c_temp;
110 
111 
112 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
113 		memset(&c_temp,0,sizeof(c_temp));
114 		 k = &c_temp;
115 	} else
116 		 k = t = *v;
117 	mode = DEC_ALLOC_MODE_2;
118     tagId1 = BDecTag (b, &totalElmtsLen1 );
119 
120     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
121     {
122     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
123 	rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->userCertificate), &totalElmtsLen1, mode);
124 		if ( rc != LDAP_SUCCESS ) return rc;
125 		(&k->userCertificate)->identifier.bv_val = (&k->userCertificate)->id_buf;
126 		(&k->userCertificate)->identifier.bv_len = strlen("userCertificate");
127 		strcpy( (&k->userCertificate)->identifier.bv_val, "userCertificate");
128     tagId1 = BDecTag (b, &totalElmtsLen1);
129     }
130     else
131         return -1;
132 
133 
134 
135     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
136 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
137      (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
138     (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
139     {
140         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
141 	rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->revocationDate), &totalElmtsLen1, mode);
142 		if ( rc != LDAP_SUCCESS ) return rc;
143 		(k->revocationDate)->identifier.bv_val = (k->revocationDate)->id_buf;
144 		(k->revocationDate)->identifier.bv_len = strlen("revocationDate");
145 		strcpy( (k->revocationDate)->identifier.bv_val, "revocationDate");
146     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
147         seqDone = TRUE;
148     else
149     {
150         tagId1 = BDecTag (b, &totalElmtsLen1 );
151 
152          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
153         {
154             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
155             seqDone = TRUE;
156         }
157     }
158     }
159     else
160         return -1;
161 
162 
163 
164     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
165     {
166     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
167 	rc = BDecComponentExtensions (mem_op, b, tagId1, elmtLen1, (&k->crlEntryExtensions), &totalElmtsLen1, mode);
168 		if ( rc != LDAP_SUCCESS ) return rc;
169 		(k->crlEntryExtensions)->identifier.bv_val = (k->crlEntryExtensions)->id_buf;
170 		(k->crlEntryExtensions)->identifier.bv_len = strlen("crlEntryExtensions");
171 		strcpy( (k->crlEntryExtensions)->identifier.bv_val, "crlEntryExtensions");
172         seqDone = TRUE;
173         if (elmtLen0 == INDEFINITE_LEN)
174             BDecEoc (b, &totalElmtsLen1 );
175         else if (totalElmtsLen1 != elmtLen0)
176         return -1;
177 
178     }
179 
180 
181     if (!seqDone)
182         return -1;
183 
184 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
185 	*v = t = (ComponentTBSCertListSeqOfSeq*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOfSeq) );
186 	if ( !t ) return -1;
187 	*t = *k;
188 	}
189 	t->syntax = (Syntax*)NULL;
190 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
191 	if ( !t->comp_desc ) {
192 		free ( t );
193 		return -1;
194 	}
195 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
196 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
197 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
198 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOfSeq ;
199 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOfSeq ;
200 	t->comp_desc->cd_free = (comp_free_func*)NULL;
201 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOfSeq;
202 	t->comp_desc->cd_type = ASN_COMPOSITE;
203 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
204 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertListSeqOfSeq;
205     (*bytesDecoded) += totalElmtsLen1;
206 	return LDAP_SUCCESS;
207 }  /* BDecTBSCertListSeqOfSeq*/
208 
209 int
210 GDecComponentTBSCertListSeqOfSeq PARAMS (( mem_op,b, v, bytesDecoded, mode),
211 void* mem_op _AND_
212 GenBuf * b _AND_
213 ComponentTBSCertListSeqOfSeq **v _AND_
214 AsnLen *bytesDecoded _AND_
215 int mode)
216 {
217 	char* peek_head,*peek_head2;
218 	int i, strLen,strLen2, rc, old_mode = mode;
219 	ComponentTBSCertListSeqOfSeq *k,*t, c_temp;
220 
221 
222 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
223 		memset(&c_temp,0,sizeof(c_temp));
224 		 k = &c_temp;
225 	} else
226 		 k = t = *v;
227 	mode = DEC_ALLOC_MODE_2;
228 	*bytesDecoded = 0;
229 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
230 		Asn1Error("Error during Reading { in encoded data");
231 		return LDAP_PROTOCOL_ERROR;
232 	}
233 	if(*peek_head != '{'){
234 		Asn1Error("Missing { in encoded data");
235 		return LDAP_PROTOCOL_ERROR;
236 	}
237 
238 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
239 		Asn1Error("Error during Reading identifier");
240 		return LDAP_PROTOCOL_ERROR;
241 	}
242 	if ( strncmp( peek_head, "userCertificate", strlen("userCertificate") ) == 0 ) {
243 		rc = 	GDecComponentCertificateSerialNumber (mem_op, b, (&k->userCertificate), bytesDecoded, mode);
244 		if ( rc != LDAP_SUCCESS ) return rc;
245 	(&k->userCertificate)->identifier.bv_val = peek_head;
246 	(&k->userCertificate)->identifier.bv_len = strLen;
247 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
248 		Asn1Error("Error during Reading , ");
249 		return LDAP_PROTOCOL_ERROR;
250 	}
251 	if(*peek_head != ','){
252 		Asn1Error("Missing , in encoding");
253 		return LDAP_PROTOCOL_ERROR;
254 	}
255 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
256 	  Asn1Error("Error during Reading identifier");
257 		return LDAP_PROTOCOL_ERROR;
258 	}
259 	}
260 	if ( strncmp( peek_head, "revocationDate", strlen("revocationDate") ) == 0 ) {
261 		rc = 	GDecComponentTime (mem_op, b, (&k->revocationDate), bytesDecoded, mode);
262 		if ( rc != LDAP_SUCCESS ) return rc;
263 	( k->revocationDate)->identifier.bv_val = peek_head;
264 	( k->revocationDate)->identifier.bv_len = strLen;
265 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
266 		Asn1Error("Error during Reading , ");
267 		return LDAP_PROTOCOL_ERROR;
268 	}
269 	if(*peek_head != ','){
270 		Asn1Error("Missing , in encoding");
271 		return LDAP_PROTOCOL_ERROR;
272 	}
273 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
274 	  Asn1Error("Error during Reading identifier");
275 		return LDAP_PROTOCOL_ERROR;
276 	}
277 	}
278 	if ( strncmp( peek_head, "crlEntryExtensions", strlen("crlEntryExtensions") ) == 0 ) {
279 		rc = 	GDecComponentExtensions (mem_op, b, (&k->crlEntryExtensions), bytesDecoded, mode);
280 		if ( rc != LDAP_SUCCESS ) return rc;
281 	( k->crlEntryExtensions)->identifier.bv_val = peek_head;
282 	( k->crlEntryExtensions)->identifier.bv_len = strLen;
283 	}
284 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
285 		Asn1Error("Error during Reading } in encoding");
286 		return LDAP_PROTOCOL_ERROR;
287 	}
288 	if(*peek_head != '}'){
289 		Asn1Error("Missing } in encoding");
290 		return LDAP_PROTOCOL_ERROR;
291 	}
292 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
293 	*v = t = (ComponentTBSCertListSeqOfSeq*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOfSeq) );
294 	if ( !t ) return -1;
295 	*t = *k;
296 	}
297 	t->syntax = (Syntax*)NULL;
298 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
299 	if ( !t->comp_desc ) {
300 		free ( t );
301 		return -1;
302 	}
303 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
304 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
305 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
306 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOfSeq ;
307 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOfSeq ;
308 	t->comp_desc->cd_free = (comp_free_func*)NULL;
309 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOfSeq;
310 	t->comp_desc->cd_type = ASN_COMPOSITE;
311 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
312 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertListSeqOfSeq;
313 	return LDAP_SUCCESS;
314 }  /* GDecTBSCertListSeqOfSeq*/
315 
316 
317 int
318 MatchingComponentTBSCertListSeqOf ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
319 	int rc;
320 	MatchingRule* mr;
321 	void* component1, *component2;
322 	AsnList *v1, *v2, t_list;
323 
324 
325 	if ( oid ) {
326 		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
327 		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
328 	}
329 
330 	v1 = &((ComponentTBSCertListSeqOf*)csi_attr)->comp_list;
331 	v2 = &((ComponentTBSCertListSeqOf*)csi_assert)->comp_list;
332 	FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
333 	{
334 		if( MatchingComponentTBSCertListSeqOfSeq(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
335 			return LDAP_COMPARE_FALSE;
336 		}
337 	} /* end of for */
338 
339 	AsnListFirst( v1 );
340 	AsnListFirst( v2 );
341 	if( (!component1 && component2) || (component1 && !component2))
342 		return LDAP_COMPARE_FALSE;
343 	else
344 		return LDAP_COMPARE_TRUE;
345 }  /* BMatchingComponentTBSCertListSeqOfContent */
346 
347 void*
348 ExtractingComponentTBSCertListSeqOf ( void* mem_op, ComponentReference* cr, ComponentTBSCertListSeqOf *comp )
349 {
350 	int count = 0;
351 	int total;
352 	AsnList *v = &comp->comp_list;
353 	ComponentInt *k;
354 	ComponentTBSCertListSeqOfSeq *component;
355 
356 
357 	switch ( cr->cr_curr->ci_type ) {
358 	case LDAP_COMPREF_FROM_BEGINNING :
359 		count = cr->cr_curr->ci_val.ci_from_beginning;
360 		FOR_EACH_LIST_ELMT( component , v ) {
361 			if( --count == 0 ) {
362 				if( cr->cr_curr->ci_next == NULL )
363 					return component;
364 				else {
365 					cr->cr_curr = cr->cr_curr->ci_next;
366 					return 	ExtractingComponentTBSCertListSeqOfSeq ( mem_op, cr, component );
367 				}
368 			}
369 		}
370 		break;
371 	case LDAP_COMPREF_FROM_END :
372 		total = AsnListCount ( v );
373 		count = cr->cr_curr->ci_val.ci_from_end;
374 		count = total + count +1;
375 		FOR_EACH_LIST_ELMT ( component, v ) {
376 			if( --count == 0 ) {
377 				if( cr->cr_curr->ci_next == NULL )
378 					return component;
379 				else {
380 					cr->cr_curr = cr->cr_curr->ci_next;
381 					return 	ExtractingComponentTBSCertListSeqOfSeq ( mem_op, cr, component );
382 				}
383 			}
384 		}
385 		break;
386 	case LDAP_COMPREF_ALL :
387 		return comp;
388 	case LDAP_COMPREF_COUNT :
389 		k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
390 		k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
391 		k->comp_desc->cd_tag = (-1);
392 		k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
393 		k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
394 		k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
395 		k->comp_desc->cd_type = ASN_BASIC;
396 		k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
397 		k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
398 		k->value = AsnListCount(v);
399 		return k;
400 	default :
401 		return NULL;
402 	}
403 }  /* ExtractingComponentTBSCertListSeqOf */
404 
405 int
406 BDecComponentTBSCertListSeqOf PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
407 void* mem_op _AND_
408 GenBuf * b _AND_
409 AsnTag tagId0 _AND_
410 AsnLen elmtLen0 _AND_
411 ComponentTBSCertListSeqOf **v _AND_
412 AsnLen *bytesDecoded _AND_
413 int mode)
414 {
415 	int seqDone = FALSE;
416 	AsnLen totalElmtsLen1 = 0;
417 	AsnLen elmtLen1;
418 	AsnTag tagId1;
419 	int mandatoryElmtCount1 = 0;
420 	int old_mode = mode;
421 	int rc;
422 	ComponentTBSCertListSeqOf *k, *t, c_temp;
423 
424 
425 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
426 		memset(&c_temp,0,sizeof(c_temp));
427 		 k = &c_temp;
428 	} else
429 		 k = t = *v;
430 	mode = DEC_ALLOC_MODE_2;
431 	AsnListInit(&k->comp_list,sizeof(ComponentTBSCertListSeqOfSeq));
432     for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
433     {
434         ComponentTBSCertListSeqOfSeq **tmpVar;
435     tagId1 = BDecTag (b, &totalElmtsLen1 );
436 
437     if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
438     {
439         BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
440         break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
441     }
442     if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
443     {
444         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
445     tmpVar = (ComponentTBSCertListSeqOfSeq**) CompAsnListAppend (mem_op,&k->comp_list);
446 	rc = BDecComponentTBSCertListSeqOfSeq (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
447 		if ( rc != LDAP_SUCCESS ) return rc;
448     }  /* end of tag check if */
449     else  /* wrong tag */
450     {
451          Asn1Error ("Unexpected Tag\n");
452          return -1;
453     }
454     } /* end of for */
455 
456 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
457 	*v = t = (ComponentTBSCertListSeqOf*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOf) );
458 	if ( !t ) return -1;
459 	*t = *k;
460 	}
461 	t->syntax = (Syntax*)NULL;
462 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
463 	if ( !t->comp_desc ) {
464 		free ( t );
465 		return -1;
466 	}
467 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
468 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
469 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
470 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOf ;
471 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOf ;
472 	t->comp_desc->cd_free = (comp_free_func*)NULL;
473 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOf;
474 	t->comp_desc->cd_type = ASN_COMPOSITE;
475 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
476 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertListSeqOf;
477     (*bytesDecoded) += totalElmtsLen1;
478 	return LDAP_SUCCESS;
479 }  /* BDecTBSCertListSeqOfContent */
480 
481 int
482 GDecComponentTBSCertListSeqOf PARAMS (( mem_op,b, v, bytesDecoded, mode),
483 void* mem_op _AND_
484 GenBuf * b _AND_
485 ComponentTBSCertListSeqOf **v _AND_
486 AsnLen *bytesDecoded _AND_
487 int mode)
488 {
489 	char* peek_head,*peek_head2;
490 	int i, strLen,strLen2, rc, old_mode = mode;
491 	ComponentTBSCertListSeqOf *k,*t, c_temp;
492 
493 
494 	int ElmtsLen1;
495 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
496 		memset(&c_temp,0,sizeof(c_temp));
497 		 k = &c_temp;
498 	} else
499 		 k = t = *v;
500 	mode = DEC_ALLOC_MODE_2;
501 	AsnListInit( &k->comp_list, sizeof( ComponentTBSCertListSeqOfSeq ) );
502 	*bytesDecoded = 0;
503 	if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
504 		Asn1Error("Error during Reading { in encoding");
505 		return LDAP_PROTOCOL_ERROR;
506 	}
507 	if(*peek_head != '{'){
508 		Asn1Error("Missing { in encoded data");
509 		return LDAP_PROTOCOL_ERROR;
510 	}
511 
512 	for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
513 	{
514 		ComponentTBSCertListSeqOfSeq **tmpVar;
515 		if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
516 			Asn1Error("Error during Reading{ in encoding");
517 			return LDAP_PROTOCOL_ERROR;
518 		}
519 		if(*peek_head == '}') break;
520 		if( !(*peek_head == '{' || *peek_head ==',') ) {
521 			return LDAP_PROTOCOL_ERROR;
522 		}
523 		tmpVar = (ComponentTBSCertListSeqOfSeq**) CompAsnListAppend (mem_op, &k->comp_list);
524 		if ( tmpVar == NULL ) {
525 			Asn1Error("Error during Reading{ in encoding");
526 			return LDAP_PROTOCOL_ERROR;
527 		}
528 		rc = 	GDecComponentTBSCertListSeqOfSeq (mem_op, b, tmpVar, bytesDecoded, mode);
529 		if ( rc != LDAP_SUCCESS ) return rc;
530 	} /* end of for */
531 
532 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
533 	*v = t = (ComponentTBSCertListSeqOf*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOf) );
534 	if ( !t ) return -1;
535 	*t = *k;
536 	}
537 	t->syntax = (Syntax*)NULL;
538 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
539 	if ( !t->comp_desc ) {
540 		free ( t );
541 		return -1;
542 	}
543 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
544 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
545 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
546 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOf ;
547 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOf ;
548 	t->comp_desc->cd_free = (comp_free_func*)NULL;
549 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOf;
550 	t->comp_desc->cd_type = ASN_COMPOSITE;
551 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
552 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertListSeqOf;
553 	return LDAP_SUCCESS;
554 }  /* GDecTBSCertListSeqOfContent */
555 
556 int
557 MatchingComponentTBSCertList ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
558 	int rc;
559 	MatchingRule* mr;
560 
561 	if ( oid ) {
562 		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
563 		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
564 	}
565 
566 	rc = 1;
567 	if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->version ) ) {
568 	rc =	MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->version );
569 	if ( rc != LDAP_COMPARE_TRUE )
570 		return rc;
571 	}
572 	rc =	MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->signature );
573 	if ( rc != LDAP_COMPARE_TRUE )
574 		return rc;
575 	rc =	MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->issuer );
576 	if ( rc != LDAP_COMPARE_TRUE )
577 		return rc;
578 	rc =	MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->thisUpdate, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->thisUpdate );
579 	if ( rc != LDAP_COMPARE_TRUE )
580 		return rc;
581 	if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->nextUpdate ) ) {
582 	rc =	MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->nextUpdate, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->nextUpdate );
583 	if ( rc != LDAP_COMPARE_TRUE )
584 		return rc;
585 	}
586 	rc =	MatchingComponentTBSCertListSeqOf ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->revokedCertificates, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->revokedCertificates );
587 	if ( rc != LDAP_COMPARE_TRUE )
588 		return rc;
589 	if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->crlExtensions ) ) {
590 	rc =	MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->crlExtensions, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->crlExtensions );
591 	if ( rc != LDAP_COMPARE_TRUE )
592 		return rc;
593 	}
594 	return LDAP_COMPARE_TRUE;
595 }  /* BMatchingComponentTBSCertList */
596 
597 void*
598 ExtractingComponentTBSCertList ( void* mem_op, ComponentReference* cr, ComponentTBSCertList *comp )
599 {
600 
601 	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 ) ) {
602 		if ( cr->cr_curr->ci_next == NULL )
603 			return comp->version;
604 		else {
605 			cr->cr_curr = cr->cr_curr->ci_next;
606 			return 	ExtractingComponentVersion ( mem_op, cr, comp->version );
607 		}
608 	}
609 	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 ) ) {
610 		if ( cr->cr_curr->ci_next == NULL )
611 			return comp->signature;
612 		else {
613 			cr->cr_curr = cr->cr_curr->ci_next;
614 			return 	ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature );
615 		}
616 	}
617 	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 ) ) {
618 		if ( cr->cr_curr->ci_next == NULL )
619 			return comp->issuer;
620 		else {
621 			cr->cr_curr = cr->cr_curr->ci_next;
622 			return 	ExtractingComponentName ( mem_op, cr, comp->issuer );
623 		}
624 	}
625 	if ( ( comp->thisUpdate->identifier.bv_val && strncmp(comp->thisUpdate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->thisUpdate->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
626 		if ( cr->cr_curr->ci_next == NULL )
627 			return comp->thisUpdate;
628 		else {
629 			cr->cr_curr = cr->cr_curr->ci_next;
630 			return 	ExtractingComponentTime ( mem_op, cr, comp->thisUpdate );
631 		}
632 	}
633 	if ( ( comp->nextUpdate->identifier.bv_val && strncmp(comp->nextUpdate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->nextUpdate->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
634 		if ( cr->cr_curr->ci_next == NULL )
635 			return comp->nextUpdate;
636 		else {
637 			cr->cr_curr = cr->cr_curr->ci_next;
638 			return 	ExtractingComponentTime ( mem_op, cr, comp->nextUpdate );
639 		}
640 	}
641 	if ( ( comp->revokedCertificates->identifier.bv_val && strncmp(comp->revokedCertificates->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->revokedCertificates->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
642 		if ( cr->cr_curr->ci_next == NULL )
643 			return comp->revokedCertificates;
644 		else {
645 			cr->cr_curr = cr->cr_curr->ci_next;
646 			return 	ExtractingComponentTBSCertListSeqOf ( mem_op, cr, comp->revokedCertificates );
647 		}
648 	}
649 	if ( ( comp->crlExtensions->identifier.bv_val && strncmp(comp->crlExtensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->crlExtensions->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
650 		if ( cr->cr_curr->ci_next == NULL )
651 			return comp->crlExtensions;
652 		else {
653 			cr->cr_curr = cr->cr_curr->ci_next;
654 			return 	ExtractingComponentExtensions ( mem_op, cr, comp->crlExtensions );
655 		}
656 	}
657 	return NULL;
658 }  /* ExtractingComponentTBSCertList */
659 
660 int
661 BDecComponentTBSCertList PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
662 void* mem_op _AND_
663 GenBuf * b _AND_
664 AsnTag tagId0 _AND_
665 AsnLen elmtLen0 _AND_
666 ComponentTBSCertList **v _AND_
667 AsnLen *bytesDecoded _AND_
668 int mode)
669 {
670 	int seqDone = FALSE;
671 	AsnLen totalElmtsLen1 = 0;
672 	AsnLen elmtLen1;
673 	AsnTag tagId1;
674 	int mandatoryElmtCount1 = 0;
675 	AsnLen totalElmtsLen2 = 0;
676 	AsnLen elmtLen2;
677 	AsnTag tagId2;
678 	int old_mode = mode;
679 	int rc;
680 	ComponentTBSCertList *k, *t, c_temp;
681 
682 
683 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
684 		memset(&c_temp,0,sizeof(c_temp));
685 		 k = &c_temp;
686 	} else
687 		 k = t = *v;
688 	mode = DEC_ALLOC_MODE_2;
689     tagId1 = BDecTag (b, &totalElmtsLen1 );
690 
691     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
692     {
693     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
694 	rc = BDecComponentVersion (mem_op, b, tagId1, elmtLen1, (&k->version), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
695 		if ( rc != LDAP_SUCCESS ) return rc;
696 		(k->version)->identifier.bv_val = (k->version)->id_buf;
697 		(k->version)->identifier.bv_len = strlen("version");
698 		strcpy( (k->version)->identifier.bv_val, "version");
699     tagId1 = BDecTag (b, &totalElmtsLen1);
700     }
701 
702 
703     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
704     {
705     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
706 	rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
707 		if ( rc != LDAP_SUCCESS ) return rc;
708 		(k->signature)->identifier.bv_val = (k->signature)->id_buf;
709 		(k->signature)->identifier.bv_len = strlen("signature");
710 		strcpy( (k->signature)->identifier.bv_val, "signature");
711     tagId1 = BDecTag (b, &totalElmtsLen1);
712     }
713     else
714         return -1;
715 
716 
717 
718     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
719     {
720         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
721 	rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->issuer), &totalElmtsLen1, mode);
722 		if ( rc != LDAP_SUCCESS ) return rc;
723 		(k->issuer)->identifier.bv_val = (k->issuer)->id_buf;
724 		(k->issuer)->identifier.bv_len = strlen("issuer");
725 		strcpy( (k->issuer)->identifier.bv_val, "issuer");
726     tagId1 = BDecTag (b, &totalElmtsLen1);
727     }
728     else
729         return -1;
730 
731 
732 
733     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
734 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
735      (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
736     (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
737     {
738         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
739 	rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->thisUpdate), &totalElmtsLen1, mode);
740 		if ( rc != LDAP_SUCCESS ) return rc;
741 		(k->thisUpdate)->identifier.bv_val = (k->thisUpdate)->id_buf;
742 		(k->thisUpdate)->identifier.bv_len = strlen("thisUpdate");
743 		strcpy( (k->thisUpdate)->identifier.bv_val, "thisUpdate");
744     tagId1 = BDecTag (b, &totalElmtsLen1);
745     }
746     else
747         return -1;
748 
749 
750 
751     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
752 (tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
753      (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
754     (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
755     {
756         elmtLen1 = BDecLen (b, &totalElmtsLen1 );
757 	rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->nextUpdate), &totalElmtsLen1, mode);
758 		if ( rc != LDAP_SUCCESS ) return rc;
759 		(k->nextUpdate)->identifier.bv_val = (k->nextUpdate)->id_buf;
760 		(k->nextUpdate)->identifier.bv_len = strlen("nextUpdate");
761 		strcpy( (k->nextUpdate)->identifier.bv_val, "nextUpdate");
762     tagId1 = BDecTag (b, &totalElmtsLen1);
763     }
764 
765 
766     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
767     {
768     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
769 	rc = BDecComponentTBSCertListSeqOf (mem_op, b, tagId1, elmtLen1, (&k->revokedCertificates), &totalElmtsLen1, mode);
770 		if ( rc != LDAP_SUCCESS ) return rc;
771 		(k->revokedCertificates)->identifier.bv_val = (k->revokedCertificates)->id_buf;
772 		(k->revokedCertificates)->identifier.bv_len = strlen("revokedCertificates");
773 		strcpy( (k->revokedCertificates)->identifier.bv_val, "revokedCertificates");
774     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
775         seqDone = TRUE;
776     else
777     {
778         tagId1 = BDecTag (b, &totalElmtsLen1 );
779 
780          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
781         {
782             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
783             seqDone = TRUE;
784         }
785     }
786     }
787     else
788         return -1;
789 
790 
791 
792     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
793     {
794     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
795         tagId2 = BDecTag (b, &totalElmtsLen1 );
796 
797     if (tagId2 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
798     {
799          Asn1Error ("Unexpected Tag\n");
800          return -1;
801     }
802 
803     elmtLen2 = BDecLen (b, &totalElmtsLen1 );
804 	rc = BDecComponentExtensions (mem_op, b, tagId2, elmtLen2, (&k->crlExtensions), &totalElmtsLen1, mode);
805 		if ( rc != LDAP_SUCCESS ) return rc;
806 		(k->crlExtensions)->identifier.bv_val = (k->crlExtensions)->id_buf;
807 		(k->crlExtensions)->identifier.bv_len = strlen("crlExtensions");
808 		strcpy( (k->crlExtensions)->identifier.bv_val, "crlExtensions");
809 	if (elmtLen1 == INDEFINITE_LEN)
810         BDecEoc (b, &totalElmtsLen1 );
811         seqDone = TRUE;
812         if (elmtLen0 == INDEFINITE_LEN)
813             BDecEoc (b, &totalElmtsLen1 );
814         else if (totalElmtsLen1 != elmtLen0)
815         return -1;
816 
817     }
818 
819 
820     if (!seqDone)
821         return -1;
822 
823 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
824 	*v = t = (ComponentTBSCertList*) CompAlloc( mem_op, sizeof(ComponentTBSCertList) );
825 	if ( !t ) return -1;
826 	*t = *k;
827 	}
828 	t->syntax = (Syntax*)NULL;
829 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
830 	if ( !t->comp_desc ) {
831 		free ( t );
832 		return -1;
833 	}
834 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
835 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
836 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
837 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertList ;
838 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertList ;
839 	t->comp_desc->cd_free = (comp_free_func*)NULL;
840 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertList;
841 	t->comp_desc->cd_type = ASN_COMPOSITE;
842 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
843 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertList;
844     (*bytesDecoded) += totalElmtsLen1;
845 	return LDAP_SUCCESS;
846 }  /* BDecTBSCertList*/
847 
848 int
849 GDecComponentTBSCertList PARAMS (( mem_op,b, v, bytesDecoded, mode),
850 void* mem_op _AND_
851 GenBuf * b _AND_
852 ComponentTBSCertList **v _AND_
853 AsnLen *bytesDecoded _AND_
854 int mode)
855 {
856 	char* peek_head,*peek_head2;
857 	int i, strLen,strLen2, rc, old_mode = mode;
858 	ComponentTBSCertList *k,*t, c_temp;
859 
860 
861 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
862 		memset(&c_temp,0,sizeof(c_temp));
863 		 k = &c_temp;
864 	} else
865 		 k = t = *v;
866 	mode = DEC_ALLOC_MODE_2;
867 	*bytesDecoded = 0;
868 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
869 		Asn1Error("Error during Reading { in encoded data");
870 		return LDAP_PROTOCOL_ERROR;
871 	}
872 	if(*peek_head != '{'){
873 		Asn1Error("Missing { in encoded data");
874 		return LDAP_PROTOCOL_ERROR;
875 	}
876 
877 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
878 		Asn1Error("Error during Reading identifier");
879 		return LDAP_PROTOCOL_ERROR;
880 	}
881 	if ( strncmp( peek_head, "version", strlen("version") ) == 0 ) {
882 		rc = 	GDecComponentVersion (mem_op, b, (&k->version), bytesDecoded, DEC_ALLOC_MODE_0 );
883 		if ( rc != LDAP_SUCCESS ) return rc;
884 	( k->version)->identifier.bv_val = peek_head;
885 	( k->version)->identifier.bv_len = strLen;
886 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
887 		Asn1Error("Error during Reading , ");
888 		return LDAP_PROTOCOL_ERROR;
889 	}
890 	if(*peek_head != ','){
891 		Asn1Error("Missing , in encoding");
892 		return LDAP_PROTOCOL_ERROR;
893 	}
894 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
895 	  Asn1Error("Error during Reading identifier");
896 		return LDAP_PROTOCOL_ERROR;
897 	}
898 	}
899 	if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
900 		rc = 	GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signature), bytesDecoded, mode);
901 		if ( rc != LDAP_SUCCESS ) return rc;
902 	( k->signature)->identifier.bv_val = peek_head;
903 	( k->signature)->identifier.bv_len = strLen;
904 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
905 		Asn1Error("Error during Reading , ");
906 		return LDAP_PROTOCOL_ERROR;
907 	}
908 	if(*peek_head != ','){
909 		Asn1Error("Missing , in encoding");
910 		return LDAP_PROTOCOL_ERROR;
911 	}
912 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
913 	  Asn1Error("Error during Reading identifier");
914 		return LDAP_PROTOCOL_ERROR;
915 	}
916 	}
917 	if ( strncmp( peek_head, "issuer", strlen("issuer") ) == 0 ) {
918 		rc = 	GDecComponentName (mem_op, b, (&k->issuer), bytesDecoded, mode);
919 		if ( rc != LDAP_SUCCESS ) return rc;
920 	( k->issuer)->identifier.bv_val = peek_head;
921 	( k->issuer)->identifier.bv_len = strLen;
922 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
923 		Asn1Error("Error during Reading , ");
924 		return LDAP_PROTOCOL_ERROR;
925 	}
926 	if(*peek_head != ','){
927 		Asn1Error("Missing , in encoding");
928 		return LDAP_PROTOCOL_ERROR;
929 	}
930 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
931 	  Asn1Error("Error during Reading identifier");
932 		return LDAP_PROTOCOL_ERROR;
933 	}
934 	}
935 	if ( strncmp( peek_head, "thisUpdate", strlen("thisUpdate") ) == 0 ) {
936 		rc = 	GDecComponentTime (mem_op, b, (&k->thisUpdate), bytesDecoded, mode);
937 		if ( rc != LDAP_SUCCESS ) return rc;
938 	( k->thisUpdate)->identifier.bv_val = peek_head;
939 	( k->thisUpdate)->identifier.bv_len = strLen;
940 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
941 		Asn1Error("Error during Reading , ");
942 		return LDAP_PROTOCOL_ERROR;
943 	}
944 	if(*peek_head != ','){
945 		Asn1Error("Missing , in encoding");
946 		return LDAP_PROTOCOL_ERROR;
947 	}
948 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
949 	  Asn1Error("Error during Reading identifier");
950 		return LDAP_PROTOCOL_ERROR;
951 	}
952 	}
953 	if ( strncmp( peek_head, "nextUpdate", strlen("nextUpdate") ) == 0 ) {
954 		rc = 	GDecComponentTime (mem_op, b, (&k->nextUpdate), bytesDecoded, mode);
955 		if ( rc != LDAP_SUCCESS ) return rc;
956 	( k->nextUpdate)->identifier.bv_val = peek_head;
957 	( k->nextUpdate)->identifier.bv_len = strLen;
958 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
959 		Asn1Error("Error during Reading , ");
960 		return LDAP_PROTOCOL_ERROR;
961 	}
962 	if(*peek_head != ','){
963 		Asn1Error("Missing , in encoding");
964 		return LDAP_PROTOCOL_ERROR;
965 	}
966 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
967 	  Asn1Error("Error during Reading identifier");
968 		return LDAP_PROTOCOL_ERROR;
969 	}
970 	}
971 	if ( strncmp( peek_head, "revokedCertificates", strlen("revokedCertificates") ) == 0 ) {
972 		rc = 	GDecComponentTBSCertListSeqOf (mem_op, b, (&k->revokedCertificates), bytesDecoded, mode);
973 		if ( rc != LDAP_SUCCESS ) return rc;
974 	( k->revokedCertificates)->identifier.bv_val = peek_head;
975 	( k->revokedCertificates)->identifier.bv_len = strLen;
976 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
977 		Asn1Error("Error during Reading , ");
978 		return LDAP_PROTOCOL_ERROR;
979 	}
980 	if(*peek_head != ','){
981 		Asn1Error("Missing , in encoding");
982 		return LDAP_PROTOCOL_ERROR;
983 	}
984 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
985 	  Asn1Error("Error during Reading identifier");
986 		return LDAP_PROTOCOL_ERROR;
987 	}
988 	}
989 	if ( strncmp( peek_head, "crlExtensions", strlen("crlExtensions") ) == 0 ) {
990 		rc = 	GDecComponentExtensions (mem_op, b, (&k->crlExtensions), bytesDecoded, mode);
991 		if ( rc != LDAP_SUCCESS ) return rc;
992 	( k->crlExtensions)->identifier.bv_val = peek_head;
993 	( k->crlExtensions)->identifier.bv_len = strLen;
994 	}
995 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
996 		Asn1Error("Error during Reading } in encoding");
997 		return LDAP_PROTOCOL_ERROR;
998 	}
999 	if(*peek_head != '}'){
1000 		Asn1Error("Missing } in encoding");
1001 		return LDAP_PROTOCOL_ERROR;
1002 	}
1003 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1004 	*v = t = (ComponentTBSCertList*) CompAlloc( mem_op, sizeof(ComponentTBSCertList) );
1005 	if ( !t ) return -1;
1006 	*t = *k;
1007 	}
1008 	t->syntax = (Syntax*)NULL;
1009 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1010 	if ( !t->comp_desc ) {
1011 		free ( t );
1012 		return -1;
1013 	}
1014 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
1015 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
1016 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
1017 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertList ;
1018 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertList ;
1019 	t->comp_desc->cd_free = (comp_free_func*)NULL;
1020 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertList;
1021 	t->comp_desc->cd_type = ASN_COMPOSITE;
1022 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1023 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertList;
1024 	return LDAP_SUCCESS;
1025 }  /* GDecTBSCertList*/
1026 
1027 
1028 int
1029 MatchingComponentCertificateList ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1030 	int rc;
1031 	MatchingRule* mr;
1032 
1033 	if ( oid ) {
1034 		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1035 		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1036 	}
1037 
1038 	rc = 1;
1039 	rc =	MatchingComponentTBSCertList ( oid, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_attr)->tbsCertList, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_assert)->tbsCertList );
1040 	if ( rc != LDAP_COMPARE_TRUE )
1041 		return rc;
1042 	rc =	MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_assert)->signatureAlgorithm );
1043 	if ( rc != LDAP_COMPARE_TRUE )
1044 		return rc;
1045 	rc =	MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificateList*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificateList*)csi_assert)->signature );
1046 	if ( rc != LDAP_COMPARE_TRUE )
1047 		return rc;
1048 	return LDAP_COMPARE_TRUE;
1049 }  /* BMatchingComponentCertificateList */
1050 
1051 void*
1052 ExtractingComponentCertificateList ( void* mem_op, ComponentReference* cr, ComponentCertificateList *comp )
1053 {
1054 
1055 	if ( ( comp->tbsCertList->identifier.bv_val && strncmp(comp->tbsCertList->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->tbsCertList->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
1056 		if ( cr->cr_curr->ci_next == NULL )
1057 			return comp->tbsCertList;
1058 		else {
1059 			cr->cr_curr = cr->cr_curr->ci_next;
1060 			return 	ExtractingComponentTBSCertList ( mem_op, cr, comp->tbsCertList );
1061 		}
1062 	}
1063 	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 ) ) {
1064 		if ( cr->cr_curr->ci_next == NULL )
1065 			return comp->signatureAlgorithm;
1066 		else {
1067 			cr->cr_curr = cr->cr_curr->ci_next;
1068 			return 	ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm );
1069 		}
1070 	}
1071 	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 ) ) {
1072 		if ( cr->cr_curr->ci_next == NULL )
1073 		return &comp->signature;
1074 	else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
1075 			cr->cr_curr = cr->cr_curr->ci_next;
1076 		return &comp->signature;
1077 	 } else {
1078 		return NULL;
1079 		}
1080 	}
1081 	return NULL;
1082 }  /* ExtractingComponentCertificateList */
1083 
1084 int
1085 BDecComponentCertificateList PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1086 void* mem_op _AND_
1087 GenBuf * b _AND_
1088 AsnTag tagId0 _AND_
1089 AsnLen elmtLen0 _AND_
1090 ComponentCertificateList **v _AND_
1091 AsnLen *bytesDecoded _AND_
1092 int mode)
1093 {
1094 	int seqDone = FALSE;
1095 	AsnLen totalElmtsLen1 = 0;
1096 	AsnLen elmtLen1;
1097 	AsnTag tagId1;
1098 	int mandatoryElmtCount1 = 0;
1099 	int old_mode = mode;
1100 	int rc;
1101 	ComponentCertificateList *k, *t, c_temp;
1102 
1103 
1104 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
1105 		memset(&c_temp,0,sizeof(c_temp));
1106 		 k = &c_temp;
1107 	} else
1108 		 k = t = *v;
1109 	mode = DEC_ALLOC_MODE_2;
1110     tagId1 = BDecTag (b, &totalElmtsLen1 );
1111 
1112     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
1113     {
1114     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1115 	rc = BDecComponentTBSCertList (mem_op, b, tagId1, elmtLen1, (&k->tbsCertList), &totalElmtsLen1, mode);
1116 		if ( rc != LDAP_SUCCESS ) return rc;
1117 		(k->tbsCertList)->identifier.bv_val = (k->tbsCertList)->id_buf;
1118 		(k->tbsCertList)->identifier.bv_len = strlen("tbsCertList");
1119 		strcpy( (k->tbsCertList)->identifier.bv_val, "tbsCertList");
1120     tagId1 = BDecTag (b, &totalElmtsLen1);
1121     }
1122     else
1123         return -1;
1124 
1125 
1126 
1127     if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
1128     {
1129     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1130 	rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode);
1131 		if ( rc != LDAP_SUCCESS ) return rc;
1132 		(k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf;
1133 		(k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm");
1134 		strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm");
1135     tagId1 = BDecTag (b, &totalElmtsLen1);
1136     }
1137     else
1138         return -1;
1139 
1140 
1141 
1142     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
1143 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
1144     {
1145     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1146 	rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
1147 		if ( rc != LDAP_SUCCESS ) return rc;
1148 		(&k->signature)->identifier.bv_val = (&k->signature)->id_buf;
1149 		(&k->signature)->identifier.bv_len = strlen("signature");
1150 		strcpy( (&k->signature)->identifier.bv_val, "signature");
1151         seqDone = TRUE;
1152         if (elmtLen0 == INDEFINITE_LEN)
1153             BDecEoc (b, &totalElmtsLen1 );
1154         else if (totalElmtsLen1 != elmtLen0)
1155         return -1;
1156 
1157     }
1158     else
1159         return -1;
1160 
1161 
1162 
1163     if (!seqDone)
1164         return -1;
1165 
1166 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1167 	*v = t = (ComponentCertificateList*) CompAlloc( mem_op, sizeof(ComponentCertificateList) );
1168 	if ( !t ) return -1;
1169 	*t = *k;
1170 	}
1171 	t->syntax = (Syntax*)NULL;
1172 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1173 	if ( !t->comp_desc ) {
1174 		free ( t );
1175 		return -1;
1176 	}
1177 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
1178 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
1179 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
1180 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificateList ;
1181 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificateList ;
1182 	t->comp_desc->cd_free = (comp_free_func*)NULL;
1183 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificateList;
1184 	t->comp_desc->cd_type = ASN_COMPOSITE;
1185 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1186 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificateList;
1187     (*bytesDecoded) += totalElmtsLen1;
1188 	return LDAP_SUCCESS;
1189 }  /* BDecCertificateList*/
1190 
1191 int
1192 GDecComponentCertificateList PARAMS (( mem_op,b, v, bytesDecoded, mode),
1193 void* mem_op _AND_
1194 GenBuf * b _AND_
1195 ComponentCertificateList **v _AND_
1196 AsnLen *bytesDecoded _AND_
1197 int mode)
1198 {
1199 	char* peek_head,*peek_head2;
1200 	int i, strLen,strLen2, rc, old_mode = mode;
1201 	ComponentCertificateList *k,*t, c_temp;
1202 
1203 
1204 	if ( !(mode & DEC_ALLOC_MODE_1) ) {
1205 		memset(&c_temp,0,sizeof(c_temp));
1206 		 k = &c_temp;
1207 	} else
1208 		 k = t = *v;
1209 	mode = DEC_ALLOC_MODE_2;
1210 	*bytesDecoded = 0;
1211 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1212 		Asn1Error("Error during Reading { in encoded data");
1213 		return LDAP_PROTOCOL_ERROR;
1214 	}
1215 	if(*peek_head != '{'){
1216 		Asn1Error("Missing { in encoded data");
1217 		return LDAP_PROTOCOL_ERROR;
1218 	}
1219 
1220 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1221 		Asn1Error("Error during Reading identifier");
1222 		return LDAP_PROTOCOL_ERROR;
1223 	}
1224 	if ( strncmp( peek_head, "tbsCertList", strlen("tbsCertList") ) == 0 ) {
1225 		rc = 	GDecComponentTBSCertList (mem_op, b, (&k->tbsCertList), bytesDecoded, mode);
1226 		if ( rc != LDAP_SUCCESS ) return rc;
1227 	( k->tbsCertList)->identifier.bv_val = peek_head;
1228 	( k->tbsCertList)->identifier.bv_len = strLen;
1229 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1230 		Asn1Error("Error during Reading , ");
1231 		return LDAP_PROTOCOL_ERROR;
1232 	}
1233 	if(*peek_head != ','){
1234 		Asn1Error("Missing , in encoding");
1235 		return LDAP_PROTOCOL_ERROR;
1236 	}
1237 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1238 	  Asn1Error("Error during Reading identifier");
1239 		return LDAP_PROTOCOL_ERROR;
1240 	}
1241 	}
1242 	if ( strncmp( peek_head, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) {
1243 		rc = 	GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode);
1244 		if ( rc != LDAP_SUCCESS ) return rc;
1245 	( k->signatureAlgorithm)->identifier.bv_val = peek_head;
1246 	( k->signatureAlgorithm)->identifier.bv_len = strLen;
1247 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1248 		Asn1Error("Error during Reading , ");
1249 		return LDAP_PROTOCOL_ERROR;
1250 	}
1251 	if(*peek_head != ','){
1252 		Asn1Error("Missing , in encoding");
1253 		return LDAP_PROTOCOL_ERROR;
1254 	}
1255 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1256 	  Asn1Error("Error during Reading identifier");
1257 		return LDAP_PROTOCOL_ERROR;
1258 	}
1259 	}
1260 	if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
1261 		rc = 	GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode);
1262 		if ( rc != LDAP_SUCCESS ) return rc;
1263 	(&k->signature)->identifier.bv_val = peek_head;
1264 	(&k->signature)->identifier.bv_len = strLen;
1265 	}
1266 	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
1267 		Asn1Error("Error during Reading } in encoding");
1268 		return LDAP_PROTOCOL_ERROR;
1269 	}
1270 	if(*peek_head != '}'){
1271 		Asn1Error("Missing } in encoding");
1272 		return LDAP_PROTOCOL_ERROR;
1273 	}
1274 	if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1275 	*v = t = (ComponentCertificateList*) CompAlloc( mem_op, sizeof(ComponentCertificateList) );
1276 	if ( !t ) return -1;
1277 	*t = *k;
1278 	}
1279 	t->syntax = (Syntax*)NULL;
1280 	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1281 	if ( !t->comp_desc ) {
1282 		free ( t );
1283 		return -1;
1284 	}
1285 	t->comp_desc->cd_ldap_encoder = (encoder_func*)NULL;
1286 	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
1287 	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
1288 	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificateList ;
1289 	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificateList ;
1290 	t->comp_desc->cd_free = (comp_free_func*)NULL;
1291 	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificateList;
1292 	t->comp_desc->cd_type = ASN_COMPOSITE;
1293 	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1294 	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificateList;
1295 	return LDAP_SUCCESS;
1296 }  /* GDecCertificateList*/
1297