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, (ComponentCertificate**)v,(AsnLen*)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, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (ComponentAny*)&((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, (ComponentAny*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (ComponentAny*)&((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 = (-1);
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 = (-1);
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 ) {
1837 t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
1838 t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
1839 t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDN2RFC2253;
1840 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1841 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1842 t->comp_desc->cd_free = (comp_free_func*)NULL;
1843 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1844 t->comp_desc->cd_type = ASN_COMPOSITE;
1845 t->comp_desc->cd_type_id = RelativeDistinguishedName;
1846 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1847 (*bytesDecoded) += totalElmtsLen1;
1848 return LDAP_SUCCESS;
1849 } /* BDecRelativeDistinguishedNameContent */
1852 GDecComponentRelativeDistinguishedName PARAMS (( mem_op,b, v, bytesDecoded, mode),
1855 ComponentRelativeDistinguishedName **v _AND_
1856 AsnLen *bytesDecoded _AND_
1859 char* peek_head,*peek_head2;
1860 int i, strLen,strLen2, rc, old_mode = mode;
1861 ComponentRelativeDistinguishedName *k,*t, c_temp;
1865 if ( !(mode & DEC_ALLOC_MODE_1) ) {
1866 memset(&c_temp,0,sizeof(c_temp));
1870 mode = DEC_ALLOC_MODE_2;
1871 AsnListInit( &k->comp_list, sizeof( ComponentAttributeTypeAndValue ) );
1873 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
1874 Asn1Error("Error during Reading { in encoding");
1875 return LDAP_PROTOCOL_ERROR;
1877 if(*peek_head != '{'){
1878 Asn1Error("Missing { in encoded data");
1879 return LDAP_PROTOCOL_ERROR;
1882 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
1884 ComponentAttributeTypeAndValue **tmpVar;
1885 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
1886 Asn1Error("Error during Reading{ in encoding");
1887 return LDAP_PROTOCOL_ERROR;
1889 if(*peek_head == '}') break;
1890 if( !(*peek_head == '{' || *peek_head ==',') ) {
1891 return LDAP_PROTOCOL_ERROR;
1893 tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op, &k->comp_list);
1894 if ( tmpVar == NULL ) {
1895 Asn1Error("Error during Reading{ in encoding");
1896 return LDAP_PROTOCOL_ERROR;
1898 rc = GDecComponentAttributeTypeAndValue (mem_op, b, tmpVar, bytesDecoded, mode);
1899 if ( rc != LDAP_SUCCESS ) return rc;
1902 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1903 *v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
1904 if ( !t ) return -1;
1907 t->syntax = (Syntax*)NULL;
1908 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1909 if ( !t->comp_desc ) {
1913 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1914 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1915 t->comp_desc->cd_free = (comp_free_func*)NULL;
1916 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1917 t->comp_desc->cd_type = ASN_COMPOSITE;
1918 t->comp_desc->cd_type_id = RelativeDistinguishedName;
1919 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1920 return LDAP_SUCCESS;
1921 } /* GDecRelativeDistinguishedNameContent */
1925 MatchingComponentRDNSequence ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1928 void* component1, *component2;
1929 AsnList *v1, *v2, t_list;
1933 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1934 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1937 v1 = &((ComponentRDNSequence*)csi_attr)->comp_list;
1938 v2 = &((ComponentRDNSequence*)csi_assert)->comp_list;
1939 FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
1941 if( MatchingComponentRelativeDistinguishedName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
1942 return LDAP_COMPARE_FALSE;
1948 if( (!component1 && component2) || (component1 && !component2))
1949 return LDAP_COMPARE_FALSE;
1951 return LDAP_COMPARE_TRUE;
1952 } /* BMatchingComponentRDNSequenceContent */
1955 ExtractingComponentRDNSequence ( void* mem_op, ComponentReference* cr, ComponentRDNSequence *comp )
1959 AsnList *v = &comp->comp_list;
1961 ComponentRelativeDistinguishedName *component;
1964 switch ( cr->cr_curr->ci_type ) {
1965 case LDAP_COMPREF_FROM_BEGINNING :
1966 count = cr->cr_curr->ci_val.ci_from_beginning;
1967 FOR_EACH_LIST_ELMT( component , v ) {
1968 if( --count == 0 ) {
1969 if( cr->cr_curr->ci_next == NULL )
1972 cr->cr_curr = cr->cr_curr->ci_next;
1973 return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
1978 case LDAP_COMPREF_FROM_END :
1979 total = AsnListCount ( v );
1980 count = cr->cr_curr->ci_val.ci_from_end;
1981 count = total + count +1;
1982 FOR_EACH_LIST_ELMT ( component, v ) {
1983 if( --count == 0 ) {
1984 if( cr->cr_curr->ci_next == NULL )
1987 cr->cr_curr = cr->cr_curr->ci_next;
1988 return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
1993 case LDAP_COMPREF_ALL :
1995 case LDAP_COMPREF_COUNT :
1996 k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1997 k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1998 k->comp_desc->cd_tag = (-1);
1999 k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
2000 k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
2001 k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
2002 k->comp_desc->cd_type = ASN_BASIC;
2003 k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
2004 k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
2005 k->value = AsnListCount(v);
2010 } /* ExtractingComponentRDNSequence */
2013 BDecComponentRDNSequence PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2017 AsnLen elmtLen0 _AND_
2018 ComponentRDNSequence **v _AND_
2019 AsnLen *bytesDecoded _AND_
2022 int seqDone = FALSE;
2023 AsnLen totalElmtsLen1 = 0;
2026 int mandatoryElmtCount1 = 0;
2027 int old_mode = mode;
2029 ComponentRDNSequence *k, *t, c_temp;
2032 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2033 memset(&c_temp,0,sizeof(c_temp));
2037 mode = DEC_ALLOC_MODE_2;
2038 AsnListInit(&k->comp_list,sizeof(ComponentRelativeDistinguishedName));
2039 for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
2041 ComponentRelativeDistinguishedName **tmpVar;
2042 tagId1 = BDecTag (b, &totalElmtsLen1 );
2044 if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2046 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2047 break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
2049 if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
2051 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2052 tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op,&k->comp_list);
2053 rc = BDecComponentRelativeDistinguishedName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
2054 if ( rc != LDAP_SUCCESS ) return rc;
2055 } /* end of tag check if */
2056 else /* wrong tag */
2058 Asn1Error ("Unexpected Tag\n");
2063 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2064 *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2065 if ( !t ) return -1;
2068 t->syntax = (Syntax*)NULL;
2069 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2070 if ( !t->comp_desc ) {
2075 t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
2076 t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
2077 t->comp_desc->cd_ldap_encoder = (encoder_func*) ConvertRDNSequence2RFC2253;
2078 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2079 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2080 t->comp_desc->cd_free = (comp_free_func*)NULL;
2081 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2082 t->comp_desc->cd_type = ASN_COMPOSITE;
2083 t->comp_desc->cd_type_id = RDNSequence;
2084 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2085 (*bytesDecoded) += totalElmtsLen1;
2086 return LDAP_SUCCESS;
2087 } /* BDecRDNSequenceContent */
2090 GDecComponentRDNSequence PARAMS (( mem_op,b, v, bytesDecoded, mode),
2093 ComponentRDNSequence **v _AND_
2094 AsnLen *bytesDecoded _AND_
2097 char* peek_head,*peek_head2;
2098 int i, strLen,strLen2, rc, old_mode = mode;
2099 ComponentRDNSequence *k,*t, c_temp;
2103 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2104 memset(&c_temp,0,sizeof(c_temp));
2108 mode = DEC_ALLOC_MODE_2;
2109 AsnListInit( &k->comp_list, sizeof( ComponentRelativeDistinguishedName ) );
2111 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
2112 Asn1Error("Error during Reading { in encoding");
2113 return LDAP_PROTOCOL_ERROR;
2115 if(*peek_head != '{'){
2116 Asn1Error("Missing { in encoded data");
2117 return LDAP_PROTOCOL_ERROR;
2120 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
2122 ComponentRelativeDistinguishedName **tmpVar;
2123 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
2124 Asn1Error("Error during Reading{ in encoding");
2125 return LDAP_PROTOCOL_ERROR;
2127 if(*peek_head == '}') break;
2128 if( !(*peek_head == '{' || *peek_head ==',') ) {
2129 return LDAP_PROTOCOL_ERROR;
2131 tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op, &k->comp_list);
2132 if ( tmpVar == NULL ) {
2133 Asn1Error("Error during Reading{ in encoding");
2134 return LDAP_PROTOCOL_ERROR;
2136 rc = GDecComponentRelativeDistinguishedName (mem_op, b, tmpVar, bytesDecoded, mode);
2137 if ( rc != LDAP_SUCCESS ) return rc;
2140 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2141 *v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2142 if ( !t ) return -1;
2145 t->syntax = (Syntax*)NULL;
2146 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2147 if ( !t->comp_desc ) {
2151 t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
2152 t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
2153 t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDNSequence2RFC2253;
2154 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2155 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2156 t->comp_desc->cd_free = (comp_free_func*)NULL;
2157 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2158 t->comp_desc->cd_type = ASN_COMPOSITE;
2159 t->comp_desc->cd_type_id = RDNSequence ;
2160 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2161 return LDAP_SUCCESS;
2162 } /* GDecRDNSequenceContent */
2166 MatchingComponentName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2169 ComponentName *v1, *v2;
2172 v1 = (ComponentName*)csi_attr;
2173 v2 = (ComponentName*)csi_assert;
2175 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2176 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2179 if( (v1->choiceId != v2->choiceId ) )
2180 return LDAP_COMPARE_FALSE;
2181 switch( v1->choiceId )
2183 case NAME_RDNSEQUENCE :
2184 rc = MatchingComponentRDNSequence ( oid, (ComponentSyntaxInfo*)(v1->a.rdnSequence), (ComponentSyntaxInfo*)(v2->a.rdnSequence) );
2187 return LDAP_PROTOCOL_ERROR;
2190 } /* BMatchingComponentNameContent */
2193 ExtractingComponentName ( void* mem_op, ComponentReference* cr, ComponentName *comp )
2197 if( (comp->choiceId) == NAME_RDNSEQUENCE &&
2198 (( 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) ||
2199 ( 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))) {
2200 if ( cr->cr_curr->ci_next == NULL )
2201 return (comp->a.rdnSequence);
2203 cr->cr_curr = cr->cr_curr->ci_next;
2204 return ExtractingComponentRDNSequence ( mem_op, cr, (comp->a.rdnSequence) );
2208 } /* ExtractingComponentName */
2211 BDecComponentName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2215 AsnLen elmtLen0 _AND_
2216 ComponentName **v _AND_
2217 AsnLen *bytesDecoded _AND_
2220 int seqDone = FALSE;
2221 AsnLen totalElmtsLen1 = 0;
2224 int mandatoryElmtCount1 = 0;
2225 int old_mode = mode;
2227 ComponentName *k, *t, c_temp;
2230 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2231 memset(&c_temp,0,sizeof(c_temp));
2235 mode = DEC_ALLOC_MODE_2;
2238 case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE):
2239 (k->choiceId) = NAME_RDNSEQUENCE;
2240 rc = BDecComponentRDNSequence (mem_op, b, tagId0, elmtLen0, (&k->a.rdnSequence), &totalElmtsLen1, mode);
2241 if ( rc != LDAP_SUCCESS ) return rc;
2242 (k->a.rdnSequence)->identifier.bv_val = (k->a.rdnSequence)->id_buf;
2243 (k->a.rdnSequence)->identifier.bv_len = strlen("rdnSequence");
2244 strcpy( (k->a.rdnSequence)->identifier.bv_val, "rdnSequence");
2248 Asn1Error ("ERROR - unexpected tag in CHOICE\n");
2252 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2253 *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2254 if ( !t ) return -1;
2257 t->syntax = (Syntax*)NULL;
2258 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2259 if ( !t->comp_desc ) {
2263 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2264 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2265 t->comp_desc->cd_free = (comp_free_func*)NULL;
2266 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2267 t->comp_desc->cd_type = ASN_COMPOSITE;
2268 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2269 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2270 (*bytesDecoded) += totalElmtsLen1;
2271 return LDAP_SUCCESS;
2272 } /* BDecNameContent */
2275 GDecComponentName PARAMS (( mem_op,b, v, bytesDecoded, mode),
2278 ComponentName **v _AND_
2279 AsnLen *bytesDecoded _AND_
2282 char* peek_head,*peek_head2;
2283 int i, strLen,strLen2, rc, old_mode = mode;
2284 ComponentName *k,*t, c_temp;
2287 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2288 memset(&c_temp,0,sizeof(c_temp));
2292 mode = DEC_ALLOC_MODE_2;
2293 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2294 Asn1Error("Error during Reading identifier");
2295 return LDAP_PROTOCOL_ERROR;
2297 if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
2298 Asn1Error("Error during Reading identifier");
2299 return LDAP_PROTOCOL_ERROR;
2301 if(*peek_head2 != ':'){
2302 Asn1Error("Missing : in encoded data");
2303 return LDAP_PROTOCOL_ERROR;
2305 if( strncmp("rdnSequence",peek_head, strlen("rdnSequence")) == 0){
2306 (k->choiceId) = NAME_RDNSEQUENCE;
2307 rc = GDecComponentRDNSequence (mem_op, b, (&k->a.rdnSequence), bytesDecoded, mode);
2308 if ( rc != LDAP_SUCCESS ) return rc;
2309 (k->a.rdnSequence)->identifier.bv_val = peek_head;
2310 (k->a.rdnSequence)->identifier.bv_len = strLen;
2313 Asn1Error("Undefined Identifier");
2314 return LDAP_PROTOCOL_ERROR;
2316 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2317 *v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2318 if ( !t ) return -1;
2321 t->syntax = (Syntax*)NULL;
2322 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2323 if ( !t->comp_desc ) {
2327 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2328 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2329 t->comp_desc->cd_free = (comp_free_func*)NULL;
2330 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2331 t->comp_desc->cd_type = ASN_COMPOSITE;
2332 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2333 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2334 return LDAP_SUCCESS;
2335 } /* GDecNameContent */
2339 MatchingComponentTBSCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2344 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2345 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2349 rc = MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->version );
2350 if ( rc != LDAP_COMPARE_TRUE )
2352 rc = MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->serialNumber, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->serialNumber );
2353 if ( rc != LDAP_COMPARE_TRUE )
2355 rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->signature );
2356 if ( rc != LDAP_COMPARE_TRUE )
2358 rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->issuer );
2359 if ( rc != LDAP_COMPARE_TRUE )
2361 rc = MatchingComponentValidity ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->validity, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->validity );
2362 if ( rc != LDAP_COMPARE_TRUE )
2364 rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subject, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subject );
2365 if ( rc != LDAP_COMPARE_TRUE )
2367 rc = MatchingComponentSubjectPublicKeyInfo ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subjectPublicKeyInfo, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subjectPublicKeyInfo );
2368 if ( rc != LDAP_COMPARE_TRUE )
2370 rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->issuerUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->issuerUniqueIdentifier );
2371 if ( rc != LDAP_COMPARE_TRUE )
2373 rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->subjectUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->subjectUniqueIdentifier );
2374 if ( rc != LDAP_COMPARE_TRUE )
2376 if(COMPONENTNOT_NULL( ((ComponentTBSCertificate*)csi_attr)->extensions ) ) {
2377 rc = MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->extensions, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->extensions );
2378 if ( rc != LDAP_COMPARE_TRUE )
2381 return LDAP_COMPARE_TRUE;
2382 } /* BMatchingComponentTBSCertificate */
2385 ExtractingComponentTBSCertificate ( void* mem_op, ComponentReference* cr, ComponentTBSCertificate *comp )
2388 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 ) ) {
2389 if ( cr->cr_curr->ci_next == NULL )
2390 return comp->version;
2392 cr->cr_curr = cr->cr_curr->ci_next;
2393 return ExtractingComponentVersion ( mem_op, cr, comp->version );
2396 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 ) ) {
2397 if ( cr->cr_curr->ci_next == NULL )
2398 return &comp->serialNumber;
2402 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 ) ) {
2403 if ( cr->cr_curr->ci_next == NULL )
2404 return comp->signature;
2406 cr->cr_curr = cr->cr_curr->ci_next;
2407 return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature );
2410 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 ) ) {
2411 if ( cr->cr_curr->ci_next == NULL )
2412 return comp->issuer;
2414 cr->cr_curr = cr->cr_curr->ci_next;
2415 return ExtractingComponentName ( mem_op, cr, comp->issuer );
2418 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 ) ) {
2419 if ( cr->cr_curr->ci_next == NULL )
2420 return comp->validity;
2422 cr->cr_curr = cr->cr_curr->ci_next;
2423 return ExtractingComponentValidity ( mem_op, cr, comp->validity );
2426 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 ) ) {
2427 if ( cr->cr_curr->ci_next == NULL )
2428 return comp->subject;
2430 cr->cr_curr = cr->cr_curr->ci_next;
2431 return ExtractingComponentName ( mem_op, cr, comp->subject );
2434 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 ) ) {
2435 if ( cr->cr_curr->ci_next == NULL )
2436 return comp->subjectPublicKeyInfo;
2438 cr->cr_curr = cr->cr_curr->ci_next;
2439 return ExtractingComponentSubjectPublicKeyInfo ( mem_op, cr, comp->subjectPublicKeyInfo );
2442 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 ) ) {
2443 if ( cr->cr_curr->ci_next == NULL )
2444 return &comp->issuerUniqueIdentifier;
2445 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2446 cr->cr_curr = cr->cr_curr->ci_next;
2447 return &comp->issuerUniqueIdentifier;
2452 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 ) ) {
2453 if ( cr->cr_curr->ci_next == NULL )
2454 return &comp->subjectUniqueIdentifier;
2455 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2456 cr->cr_curr = cr->cr_curr->ci_next;
2457 return &comp->subjectUniqueIdentifier;
2462 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 ) ) {
2463 if ( cr->cr_curr->ci_next == NULL )
2464 return comp->extensions;
2466 cr->cr_curr = cr->cr_curr->ci_next;
2467 return ExtractingComponentExtensions ( mem_op, cr, comp->extensions );
2471 } /* ExtractingComponentTBSCertificate */
2474 BDecComponentTBSCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2478 AsnLen elmtLen0 _AND_
2479 ComponentTBSCertificate **v _AND_
2480 AsnLen *bytesDecoded _AND_
2483 int seqDone = FALSE;
2484 AsnLen totalElmtsLen1 = 0;
2487 int mandatoryElmtCount1 = 0;
2488 AsnLen totalElmtsLen2 = 0;
2491 int old_mode = mode;
2493 ComponentTBSCertificate *k, *t, c_temp;
2496 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2497 memset(&c_temp,0,sizeof(c_temp));
2501 mode = DEC_ALLOC_MODE_2;
2502 tagId1 = BDecTag (b, &totalElmtsLen1 );
2504 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
2506 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2507 tagId2 = BDecTag (b, &totalElmtsLen1 );
2509 if (tagId2 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
2511 Asn1Error ("Unexpected Tag\n");
2515 elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2516 rc = BDecComponentVersion (mem_op, b, tagId2, elmtLen2, (&k->version), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
2517 if ( rc != LDAP_SUCCESS ) return rc;
2518 (k->version)->identifier.bv_val = (k->version)->id_buf;
2519 (k->version)->identifier.bv_len = strlen("version");
2520 strcpy( (k->version)->identifier.bv_val, "version");
2521 if (elmtLen1 == INDEFINITE_LEN)
2522 BDecEoc (b, &totalElmtsLen1 );
2523 tagId1 = BDecTag (b, &totalElmtsLen1);
2527 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
2529 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2530 rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->serialNumber), &totalElmtsLen1, mode);
2531 if ( rc != LDAP_SUCCESS ) return rc;
2532 (&k->serialNumber)->identifier.bv_val = (&k->serialNumber)->id_buf;
2533 (&k->serialNumber)->identifier.bv_len = strlen("serialNumber");
2534 strcpy( (&k->serialNumber)->identifier.bv_val, "serialNumber");
2535 tagId1 = BDecTag (b, &totalElmtsLen1);
2542 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2544 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2545 rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
2546 if ( rc != LDAP_SUCCESS ) return rc;
2547 (k->signature)->identifier.bv_val = (k->signature)->id_buf;
2548 (k->signature)->identifier.bv_len = strlen("signature");
2549 strcpy( (k->signature)->identifier.bv_val, "signature");
2550 tagId1 = BDecTag (b, &totalElmtsLen1);
2557 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2559 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2560 rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->issuer), &totalElmtsLen1, mode);
2561 if ( rc != LDAP_SUCCESS ) return rc;
2562 (k->issuer)->identifier.bv_val = (k->issuer)->id_buf;
2563 (k->issuer)->identifier.bv_len = strlen("issuer");
2564 strcpy( (k->issuer)->identifier.bv_val, "issuer");
2565 tagId1 = BDecTag (b, &totalElmtsLen1);
2572 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2574 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2575 rc = BDecComponentValidity (mem_op, b, tagId1, elmtLen1, (&k->validity), &totalElmtsLen1, mode);
2576 if ( rc != LDAP_SUCCESS ) return rc;
2577 (k->validity)->identifier.bv_val = (k->validity)->id_buf;
2578 (k->validity)->identifier.bv_len = strlen("validity");
2579 strcpy( (k->validity)->identifier.bv_val, "validity");
2580 tagId1 = BDecTag (b, &totalElmtsLen1);
2587 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2589 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2590 rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->subject), &totalElmtsLen1, mode);
2591 if ( rc != LDAP_SUCCESS ) return rc;
2592 (k->subject)->identifier.bv_val = (k->subject)->id_buf;
2593 (k->subject)->identifier.bv_len = strlen("subject");
2594 strcpy( (k->subject)->identifier.bv_val, "subject");
2595 tagId1 = BDecTag (b, &totalElmtsLen1);
2602 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2604 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2605 rc = BDecComponentSubjectPublicKeyInfo (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKeyInfo), &totalElmtsLen1, mode);
2606 if ( rc != LDAP_SUCCESS ) return rc;
2607 (k->subjectPublicKeyInfo)->identifier.bv_val = (k->subjectPublicKeyInfo)->id_buf;
2608 (k->subjectPublicKeyInfo)->identifier.bv_len = strlen("subjectPublicKeyInfo");
2609 strcpy( (k->subjectPublicKeyInfo)->identifier.bv_val, "subjectPublicKeyInfo");
2610 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2614 tagId1 = BDecTag (b, &totalElmtsLen1 );
2616 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2618 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2628 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)) ||
2629 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
2631 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2632 rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->issuerUniqueIdentifier), &totalElmtsLen1, mode);
2633 if ( rc != LDAP_SUCCESS ) return rc;
2634 (&k->issuerUniqueIdentifier)->identifier.bv_val = (&k->issuerUniqueIdentifier)->id_buf;
2635 (&k->issuerUniqueIdentifier)->identifier.bv_len = strlen("issuerUniqueIdentifier");
2636 strcpy( (&k->issuerUniqueIdentifier)->identifier.bv_val, "issuerUniqueIdentifier");
2637 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2641 tagId1 = BDecTag (b, &totalElmtsLen1 );
2643 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2645 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2652 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)) ||
2653 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2))))
2655 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2656 rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->subjectUniqueIdentifier), &totalElmtsLen1, mode);
2657 if ( rc != LDAP_SUCCESS ) return rc;
2658 (&k->subjectUniqueIdentifier)->identifier.bv_val = (&k->subjectUniqueIdentifier)->id_buf;
2659 (&k->subjectUniqueIdentifier)->identifier.bv_len = strlen("subjectUniqueIdentifier");
2660 strcpy( (&k->subjectUniqueIdentifier)->identifier.bv_val, "subjectUniqueIdentifier");
2661 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2665 tagId1 = BDecTag (b, &totalElmtsLen1 );
2667 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2669 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2676 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3))))
2678 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2679 tagId2 = BDecTag (b, &totalElmtsLen1 );
2681 if (tagId2 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2683 Asn1Error ("Unexpected Tag\n");
2687 elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2688 rc = BDecComponentExtensions (mem_op, b, tagId2, elmtLen2, (&k->extensions), &totalElmtsLen1, mode);
2689 if ( rc != LDAP_SUCCESS ) return rc;
2690 (k->extensions)->identifier.bv_val = (k->extensions)->id_buf;
2691 (k->extensions)->identifier.bv_len = strlen("extensions");
2692 strcpy( (k->extensions)->identifier.bv_val, "extensions");
2693 if (elmtLen1 == INDEFINITE_LEN)
2694 BDecEoc (b, &totalElmtsLen1 );
2696 if (elmtLen0 == INDEFINITE_LEN)
2697 BDecEoc (b, &totalElmtsLen1 );
2698 else if (totalElmtsLen1 != elmtLen0)
2707 if(!COMPONENTNOT_NULL ((k->version)))
2709 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2710 (k->version)->identifier.bv_val = (k->version)->id_buf;
2711 (k->version)->identifier.bv_len = strlen("version");
2712 strcpy( (k->version)->identifier.bv_val, "version");
2713 (k->version)->value = 0;
2715 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2716 *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2717 if ( !t ) return -1;
2720 t->syntax = (Syntax*)NULL;
2721 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2722 if ( !t->comp_desc ) {
2726 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2727 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2728 t->comp_desc->cd_free = (comp_free_func*)NULL;
2729 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2730 t->comp_desc->cd_type = ASN_COMPOSITE;
2731 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2732 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2733 (*bytesDecoded) += totalElmtsLen1;
2734 return LDAP_SUCCESS;
2735 } /* BDecTBSCertificate*/
2738 GDecComponentTBSCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
2741 ComponentTBSCertificate **v _AND_
2742 AsnLen *bytesDecoded _AND_
2745 char* peek_head,*peek_head2;
2746 int i, strLen,strLen2, rc, old_mode = mode;
2747 ComponentTBSCertificate *k,*t, c_temp;
2750 if ( !(mode & DEC_ALLOC_MODE_1) ) {
2751 memset(&c_temp,0,sizeof(c_temp));
2755 mode = DEC_ALLOC_MODE_2;
2757 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2758 Asn1Error("Error during Reading { in encoded data");
2759 return LDAP_PROTOCOL_ERROR;
2761 if(*peek_head != '{'){
2762 Asn1Error("Missing { in encoded data");
2763 return LDAP_PROTOCOL_ERROR;
2766 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2767 Asn1Error("Error during Reading identifier");
2768 return LDAP_PROTOCOL_ERROR;
2770 if ( strncmp( peek_head, "version", strlen("version") ) == 0 ) {
2771 rc = GDecComponentVersion (mem_op, b, (&k->version), bytesDecoded, DEC_ALLOC_MODE_0 );
2772 if ( rc != LDAP_SUCCESS ) return rc;
2773 ( k->version)->identifier.bv_val = peek_head;
2774 ( k->version)->identifier.bv_len = strLen;
2775 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2776 Asn1Error("Error during Reading , ");
2777 return LDAP_PROTOCOL_ERROR;
2779 if(*peek_head != ','){
2780 Asn1Error("Missing , in encoding");
2781 return LDAP_PROTOCOL_ERROR;
2783 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2784 Asn1Error("Error during Reading identifier");
2785 return LDAP_PROTOCOL_ERROR;
2789 (k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2790 (k->version)->value = 0;
2792 if ( strncmp( peek_head, "serialNumber", strlen("serialNumber") ) == 0 ) {
2793 rc = GDecComponentCertificateSerialNumber (mem_op, b, (&k->serialNumber), bytesDecoded, mode);
2794 if ( rc != LDAP_SUCCESS ) return rc;
2795 (&k->serialNumber)->identifier.bv_val = peek_head;
2796 (&k->serialNumber)->identifier.bv_len = strLen;
2797 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2798 Asn1Error("Error during Reading , ");
2799 return LDAP_PROTOCOL_ERROR;
2801 if(*peek_head != ','){
2802 Asn1Error("Missing , in encoding");
2803 return LDAP_PROTOCOL_ERROR;
2805 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2806 Asn1Error("Error during Reading identifier");
2807 return LDAP_PROTOCOL_ERROR;
2810 if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
2811 rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signature), bytesDecoded, mode);
2812 if ( rc != LDAP_SUCCESS ) return rc;
2813 ( k->signature)->identifier.bv_val = peek_head;
2814 ( k->signature)->identifier.bv_len = strLen;
2815 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2816 Asn1Error("Error during Reading , ");
2817 return LDAP_PROTOCOL_ERROR;
2819 if(*peek_head != ','){
2820 Asn1Error("Missing , in encoding");
2821 return LDAP_PROTOCOL_ERROR;
2823 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2824 Asn1Error("Error during Reading identifier");
2825 return LDAP_PROTOCOL_ERROR;
2828 if ( strncmp( peek_head, "issuer", strlen("issuer") ) == 0 ) {
2829 rc = GDecComponentName (mem_op, b, (&k->issuer), bytesDecoded, mode);
2830 if ( rc != LDAP_SUCCESS ) return rc;
2831 ( k->issuer)->identifier.bv_val = peek_head;
2832 ( k->issuer)->identifier.bv_len = strLen;
2833 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2834 Asn1Error("Error during Reading , ");
2835 return LDAP_PROTOCOL_ERROR;
2837 if(*peek_head != ','){
2838 Asn1Error("Missing , in encoding");
2839 return LDAP_PROTOCOL_ERROR;
2841 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2842 Asn1Error("Error during Reading identifier");
2843 return LDAP_PROTOCOL_ERROR;
2846 if ( strncmp( peek_head, "validity", strlen("validity") ) == 0 ) {
2847 rc = GDecComponentValidity (mem_op, b, (&k->validity), bytesDecoded, mode);
2848 if ( rc != LDAP_SUCCESS ) return rc;
2849 ( k->validity)->identifier.bv_val = peek_head;
2850 ( k->validity)->identifier.bv_len = strLen;
2851 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2852 Asn1Error("Error during Reading , ");
2853 return LDAP_PROTOCOL_ERROR;
2855 if(*peek_head != ','){
2856 Asn1Error("Missing , in encoding");
2857 return LDAP_PROTOCOL_ERROR;
2859 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2860 Asn1Error("Error during Reading identifier");
2861 return LDAP_PROTOCOL_ERROR;
2864 if ( strncmp( peek_head, "subject", strlen("subject") ) == 0 ) {
2865 rc = GDecComponentName (mem_op, b, (&k->subject), bytesDecoded, mode);
2866 if ( rc != LDAP_SUCCESS ) return rc;
2867 ( k->subject)->identifier.bv_val = peek_head;
2868 ( k->subject)->identifier.bv_len = strLen;
2869 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2870 Asn1Error("Error during Reading , ");
2871 return LDAP_PROTOCOL_ERROR;
2873 if(*peek_head != ','){
2874 Asn1Error("Missing , in encoding");
2875 return LDAP_PROTOCOL_ERROR;
2877 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2878 Asn1Error("Error during Reading identifier");
2879 return LDAP_PROTOCOL_ERROR;
2882 if ( strncmp( peek_head, "subjectPublicKeyInfo", strlen("subjectPublicKeyInfo") ) == 0 ) {
2883 rc = GDecComponentSubjectPublicKeyInfo (mem_op, b, (&k->subjectPublicKeyInfo), bytesDecoded, mode);
2884 if ( rc != LDAP_SUCCESS ) return rc;
2885 ( k->subjectPublicKeyInfo)->identifier.bv_val = peek_head;
2886 ( k->subjectPublicKeyInfo)->identifier.bv_len = strLen;
2887 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2888 Asn1Error("Error during Reading , ");
2889 return LDAP_PROTOCOL_ERROR;
2891 if(*peek_head != ','){
2892 Asn1Error("Missing , in encoding");
2893 return LDAP_PROTOCOL_ERROR;
2895 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2896 Asn1Error("Error during Reading identifier");
2897 return LDAP_PROTOCOL_ERROR;
2900 if ( strncmp( peek_head, "issuerUniqueIdentifier", strlen("issuerUniqueIdentifier") ) == 0 ) {
2901 rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->issuerUniqueIdentifier), bytesDecoded, mode);
2902 if ( rc != LDAP_SUCCESS ) return rc;
2903 (&k->issuerUniqueIdentifier)->identifier.bv_val = peek_head;
2904 (&k->issuerUniqueIdentifier)->identifier.bv_len = strLen;
2905 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2906 Asn1Error("Error during Reading , ");
2907 return LDAP_PROTOCOL_ERROR;
2909 if(*peek_head != ','){
2910 Asn1Error("Missing , in encoding");
2911 return LDAP_PROTOCOL_ERROR;
2913 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2914 Asn1Error("Error during Reading identifier");
2915 return LDAP_PROTOCOL_ERROR;
2918 if ( strncmp( peek_head, "subjectUniqueIdentifier", strlen("subjectUniqueIdentifier") ) == 0 ) {
2919 rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->subjectUniqueIdentifier), bytesDecoded, mode);
2920 if ( rc != LDAP_SUCCESS ) return rc;
2921 (&k->subjectUniqueIdentifier)->identifier.bv_val = peek_head;
2922 (&k->subjectUniqueIdentifier)->identifier.bv_len = strLen;
2923 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2924 Asn1Error("Error during Reading , ");
2925 return LDAP_PROTOCOL_ERROR;
2927 if(*peek_head != ','){
2928 Asn1Error("Missing , in encoding");
2929 return LDAP_PROTOCOL_ERROR;
2931 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2932 Asn1Error("Error during Reading identifier");
2933 return LDAP_PROTOCOL_ERROR;
2936 if ( strncmp( peek_head, "extensions", strlen("extensions") ) == 0 ) {
2937 rc = GDecComponentExtensions (mem_op, b, (&k->extensions), bytesDecoded, mode);
2938 if ( rc != LDAP_SUCCESS ) return rc;
2939 ( k->extensions)->identifier.bv_val = peek_head;
2940 ( k->extensions)->identifier.bv_len = strLen;
2942 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
2943 Asn1Error("Error during Reading } in encoding");
2944 return LDAP_PROTOCOL_ERROR;
2946 if(*peek_head != '}'){
2947 Asn1Error("Missing } in encoding");
2948 return LDAP_PROTOCOL_ERROR;
2950 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2951 *v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2952 if ( !t ) return -1;
2955 t->syntax = (Syntax*)NULL;
2956 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2957 if ( !t->comp_desc ) {
2961 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2962 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2963 t->comp_desc->cd_free = (comp_free_func*)NULL;
2964 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2965 t->comp_desc->cd_type = ASN_COMPOSITE;
2966 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2967 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2968 return LDAP_SUCCESS;
2969 } /* GDecTBSCertificate*/
2973 MatchingComponentCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2978 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2979 if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2983 rc = MatchingComponentTBSCertificate ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->toBeSigned, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->toBeSigned );
2984 if ( rc != LDAP_COMPARE_TRUE )
2986 rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->signatureAlgorithm );
2987 if ( rc != LDAP_COMPARE_TRUE )
2989 rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_assert)->signature );
2990 if ( rc != LDAP_COMPARE_TRUE )
2992 return LDAP_COMPARE_TRUE;
2993 } /* BMatchingComponentCertificate */
2996 ExtractingComponentCertificate ( void* mem_op, ComponentReference* cr, ComponentCertificate *comp )
2999 if ( ( comp->toBeSigned->identifier.bv_val && strncmp(comp->toBeSigned->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->toBeSigned->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
3000 if ( cr->cr_curr->ci_next == NULL )
3001 return comp->toBeSigned;
3003 cr->cr_curr = cr->cr_curr->ci_next;
3004 return ExtractingComponentTBSCertificate ( mem_op, cr, comp->toBeSigned );
3007 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 ) ) {
3008 if ( cr->cr_curr->ci_next == NULL )
3009 return comp->signatureAlgorithm;
3011 cr->cr_curr = cr->cr_curr->ci_next;
3012 return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm );
3015 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 ) ) {
3016 if ( cr->cr_curr->ci_next == NULL )
3017 return &comp->signature;
3018 else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
3019 cr->cr_curr = cr->cr_curr->ci_next;
3020 return &comp->signature;
3026 } /* ExtractingComponentCertificate */
3029 BDecComponentCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
3033 AsnLen elmtLen0 _AND_
3034 ComponentCertificate **v _AND_
3035 AsnLen *bytesDecoded _AND_
3038 int seqDone = FALSE;
3039 AsnLen totalElmtsLen1 = 0;
3042 int mandatoryElmtCount1 = 0;
3043 int old_mode = mode;
3045 ComponentCertificate *k, *t, c_temp;
3048 if ( !(mode & DEC_ALLOC_MODE_1) ) {
3049 memset(&c_temp,0,sizeof(c_temp));
3053 mode = DEC_ALLOC_MODE_2;
3054 tagId1 = BDecTag (b, &totalElmtsLen1 );
3056 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3058 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3059 rc = BDecComponentTBSCertificate (mem_op, b, tagId1, elmtLen1, (&k->toBeSigned), &totalElmtsLen1, mode);
3060 if ( rc != LDAP_SUCCESS ) return rc;
3061 (k->toBeSigned)->identifier.bv_val = (k->toBeSigned)->id_buf;
3062 (k->toBeSigned)->identifier.bv_len = strlen("toBeSigned");
3063 strcpy( (k->toBeSigned)->identifier.bv_val, "toBeSigned");
3064 tagId1 = BDecTag (b, &totalElmtsLen1);
3071 if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3073 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3074 rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode);
3075 if ( rc != LDAP_SUCCESS ) return rc;
3076 (k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf;
3077 (k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm");
3078 strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm");
3079 tagId1 = BDecTag (b, &totalElmtsLen1);
3086 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
3087 (tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
3089 elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3090 rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
3091 if ( rc != LDAP_SUCCESS ) return rc;
3092 (&k->signature)->identifier.bv_val = (&k->signature)->id_buf;
3093 (&k->signature)->identifier.bv_len = strlen("signature");
3094 strcpy( (&k->signature)->identifier.bv_val, "signature");
3096 if (elmtLen0 == INDEFINITE_LEN)
3097 BDecEoc (b, &totalElmtsLen1 );
3098 else if (totalElmtsLen1 != elmtLen0)
3110 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3111 *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3112 if ( !t ) return -1;
3115 t->syntax = (Syntax*)NULL;
3116 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3117 if ( !t->comp_desc ) {
3121 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3122 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3123 t->comp_desc->cd_free = (comp_free_func*)NULL;
3124 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3125 t->comp_desc->cd_type = ASN_COMPOSITE;
3126 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3127 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3128 (*bytesDecoded) += totalElmtsLen1;
3129 return LDAP_SUCCESS;
3130 } /* BDecCertificate*/
3133 GDecComponentCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
3136 ComponentCertificate **v _AND_
3137 AsnLen *bytesDecoded _AND_
3140 char* peek_head,*peek_head2;
3141 int i, strLen,strLen2, rc, old_mode = mode;
3142 ComponentCertificate *k,*t, c_temp;
3145 if ( !(mode & DEC_ALLOC_MODE_1) ) {
3146 memset(&c_temp,0,sizeof(c_temp));
3150 mode = DEC_ALLOC_MODE_2;
3152 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3153 Asn1Error("Error during Reading { in encoded data");
3154 return LDAP_PROTOCOL_ERROR;
3156 if(*peek_head != '{'){
3157 Asn1Error("Missing { in encoded data");
3158 return LDAP_PROTOCOL_ERROR;
3161 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3162 Asn1Error("Error during Reading identifier");
3163 return LDAP_PROTOCOL_ERROR;
3165 if ( strncmp( peek_head, "toBeSigned", strlen("toBeSigned") ) == 0 ) {
3166 rc = GDecComponentTBSCertificate (mem_op, b, (&k->toBeSigned), bytesDecoded, mode);
3167 if ( rc != LDAP_SUCCESS ) return rc;
3168 ( k->toBeSigned)->identifier.bv_val = peek_head;
3169 ( k->toBeSigned)->identifier.bv_len = strLen;
3170 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3171 Asn1Error("Error during Reading , ");
3172 return LDAP_PROTOCOL_ERROR;
3174 if(*peek_head != ','){
3175 Asn1Error("Missing , in encoding");
3176 return LDAP_PROTOCOL_ERROR;
3178 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3179 Asn1Error("Error during Reading identifier");
3180 return LDAP_PROTOCOL_ERROR;
3183 if ( strncmp( peek_head, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) {
3184 rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode);
3185 if ( rc != LDAP_SUCCESS ) return rc;
3186 ( k->signatureAlgorithm)->identifier.bv_val = peek_head;
3187 ( k->signatureAlgorithm)->identifier.bv_len = strLen;
3188 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3189 Asn1Error("Error during Reading , ");
3190 return LDAP_PROTOCOL_ERROR;
3192 if(*peek_head != ','){
3193 Asn1Error("Missing , in encoding");
3194 return LDAP_PROTOCOL_ERROR;
3196 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3197 Asn1Error("Error during Reading identifier");
3198 return LDAP_PROTOCOL_ERROR;
3201 if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
3202 rc = GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode);
3203 if ( rc != LDAP_SUCCESS ) return rc;
3204 (&k->signature)->identifier.bv_val = peek_head;
3205 (&k->signature)->identifier.bv_len = strLen;
3207 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
3208 Asn1Error("Error during Reading } in encoding");
3209 return LDAP_PROTOCOL_ERROR;
3211 if(*peek_head != '}'){
3212 Asn1Error("Missing } in encoding");
3213 return LDAP_PROTOCOL_ERROR;
3215 if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3216 *v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3217 if ( !t ) return -1;
3220 t->syntax = (Syntax*)NULL;
3221 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3222 if ( !t->comp_desc ) {
3226 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3227 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3228 t->comp_desc->cd_free = (comp_free_func*)NULL;
3229 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3230 t->comp_desc->cd_type = ASN_COMPOSITE;
3231 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3232 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3233 return LDAP_SUCCESS;
3234 } /* GDecCertificate*/