1/* 2 * authorityKeyIdentifier.c 3 * "AuthorityKeyIdentifierDefinition" ASN.1 module encode/decode/extracting/matching/free C src. 4 * This file was generated by modified eSMACC compiler Wed Dec 8 22:22:49 2004 5 * The generated files are supposed to be compiled as a module for OpenLDAP Software 6 */ 7 8#include "authorityKeyIdentifier.h" 9 10BDecComponentAuthorityKeyIdentifierTop( void* mem_op, GenBuf* b, void *v, AsnLen* bytesDecoded,int mode) { 11 AsnTag tag; 12 AsnLen elmtLen; 13 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) ) { 18 return (-1); 19 } 20 21 return BDecComponentAuthorityKeyIdentifier( mem_op, b, tag, elmtLen, ( ComponentAuthorityKeyIdentifier**)v, (AsnLen*)bytesDecoded, mode ); 22} 23 24 25void init_module_AuthorityKeyIdentifierDefinition() { 26 InstallOidDecoderMapping( "2.5.29.35", NULL, 27 GDecComponentAuthorityKeyIdentifier, 28 BDecComponentAuthorityKeyIdentifierTop, 29 ExtractingComponentAuthorityKeyIdentifier, 30 MatchingComponentAuthorityKeyIdentifier ); 31} 32 33int 34MatchingComponentOtherName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 35 int rc; 36 MatchingRule* mr; 37 38 if ( oid ) { 39 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 40 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 41 } 42 43 rc = 1; 44 rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentOtherName*)csi_attr)->type_id, (ComponentSyntaxInfo*)&((ComponentOtherName*)csi_assert)->type_id ); 45 if ( rc != LDAP_COMPARE_TRUE ) 46 return rc; 47 rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentOtherName*)csi_attr)->value, (&((ComponentOtherName*)csi_attr)->type_id)); 48 rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentOtherName*)csi_attr)->value, (ComponentAny*)&((ComponentOtherName*)csi_assert)->value); 49 if ( rc != LDAP_COMPARE_TRUE ) 50 return rc; 51 return LDAP_COMPARE_TRUE; 52} /* BMatchingComponentOtherName */ 53 54void* 55ExtractingComponentOtherName ( void* mem_op, ComponentReference* cr, ComponentOtherName *comp ) 56{ 57 58 if ( ( comp->type_id.identifier.bv_val && strncmp(comp->type_id.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.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 59 if ( cr->cr_curr->ci_next == NULL ) 60 return &comp->type_id; 61 else 62 return NULL; 63 } 64 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 ) ) { 65 if ( cr->cr_curr->ci_next == NULL ) 66 return &comp->value; 67 else 68 return NULL; 69 } 70 return NULL; 71} /* ExtractingComponentOtherName */ 72 73int 74BDecComponentOtherName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 75void* mem_op _AND_ 76GenBuf * b _AND_ 77AsnTag tagId0 _AND_ 78AsnLen elmtLen0 _AND_ 79ComponentOtherName **v _AND_ 80AsnLen *bytesDecoded _AND_ 81int mode) 82{ 83 int seqDone = FALSE; 84 AsnLen totalElmtsLen1 = 0; 85 AsnLen elmtLen1; 86 AsnTag tagId1; 87 int mandatoryElmtCount1 = 0; 88 AsnLen totalElmtsLen2 = 0; 89 AsnLen elmtLen2; 90 AsnTag tagId2; 91 int old_mode = mode; 92 int rc; 93 ComponentOtherName *k, *t, c_temp; 94 95 96 if ( !(mode & DEC_ALLOC_MODE_1) ) { 97 memset(&c_temp,0,sizeof(c_temp)); 98 k = &c_temp; 99 } else 100 k = t = *v; 101 mode = DEC_ALLOC_MODE_2; 102 tagId1 = BDecTag (b, &totalElmtsLen1 ); 103 104 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) 105 { 106 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 107 rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->type_id), &totalElmtsLen1, mode); 108 if ( rc != LDAP_SUCCESS ) return rc; 109 (&k->type_id)->identifier.bv_val = (&k->type_id)->id_buf; 110 (&k->type_id)->identifier.bv_len = strlen("type_id"); 111 strcpy( (&k->type_id)->identifier.bv_val, "type_id"); 112 tagId1 = BDecTag (b, &totalElmtsLen1); 113 } 114 else 115 return -1; 116 117 118 119 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) 120 { 121 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 122 rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id)); 123 rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode ); 124 if ( rc != LDAP_SUCCESS ) return rc; 125 (&k->value)->identifier.bv_val = (&k->value)->id_buf; 126 (&k->value)->identifier.bv_len = strlen("value"); 127 strcpy( (&k->value)->identifier.bv_val, "value"); 128 if (elmtLen1 == INDEFINITE_LEN) 129 BDecEoc (b, &totalElmtsLen1 ); 130 seqDone = TRUE; 131 if (elmtLen0 == INDEFINITE_LEN) 132 BDecEoc (b, &totalElmtsLen1 ); 133 else if (totalElmtsLen1 != elmtLen0) 134 return -1; 135 136 } 137 else 138 return -1; 139 140 141 142 if (!seqDone) 143 return -1; 144 145 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 146 *v = t = (ComponentOtherName*) CompAlloc( mem_op, sizeof(ComponentOtherName) ); 147 if ( !t ) return -1; 148 *t = *k; 149 } 150 t->syntax = (Syntax*)NULL; 151 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 152 if ( !t->comp_desc ) { 153 free ( t ); 154 return -1; 155 } 156 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentOtherName ; 157 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentOtherName ; 158 t->comp_desc->cd_free = (comp_free_func*)NULL; 159 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentOtherName; 160 t->comp_desc->cd_type = ASN_COMPOSITE; 161 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 162 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentOtherName; 163 (*bytesDecoded) += totalElmtsLen1; 164 return LDAP_SUCCESS; 165} /* BDecOtherName*/ 166 167int 168GDecComponentOtherName PARAMS (( mem_op,b, v, bytesDecoded, mode), 169void* mem_op _AND_ 170GenBuf * b _AND_ 171ComponentOtherName **v _AND_ 172AsnLen *bytesDecoded _AND_ 173int mode) 174{ 175 char* peek_head,*peek_head2; 176 int i, strLen,strLen2, rc, old_mode = mode; 177 ComponentOtherName *k,*t, c_temp; 178 179 180 if ( !(mode & DEC_ALLOC_MODE_1) ) { 181 memset(&c_temp,0,sizeof(c_temp)); 182 k = &c_temp; 183 } else 184 k = t = *v; 185 mode = DEC_ALLOC_MODE_2; 186 *bytesDecoded = 0; 187 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 188 Asn1Error("Error during Reading { in encoded data"); 189 return LDAP_PROTOCOL_ERROR; 190 } 191 if(*peek_head != '{'){ 192 Asn1Error("Missing { in encoded data"); 193 return LDAP_PROTOCOL_ERROR; 194 } 195 196 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 197 Asn1Error("Error during Reading identifier"); 198 return LDAP_PROTOCOL_ERROR; 199 } 200 if ( strncmp( peek_head, "type_id", strlen("type_id") ) == 0 ) { 201 rc = GDecComponentOid (mem_op, b, (&k->type_id), bytesDecoded, mode); 202 if ( rc != LDAP_SUCCESS ) return rc; 203 (&k->type_id)->identifier.bv_val = peek_head; 204 (&k->type_id)->identifier.bv_len = strLen; 205 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 206 Asn1Error("Error during Reading , "); 207 return LDAP_PROTOCOL_ERROR; 208 } 209 if(*peek_head != ','){ 210 Asn1Error("Missing , in encoding"); 211 return LDAP_PROTOCOL_ERROR; 212 } 213 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 214 Asn1Error("Error during Reading identifier"); 215 return LDAP_PROTOCOL_ERROR; 216 } 217 } 218 if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) { 219 rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id)); 220 rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode ); 221 if ( rc != LDAP_SUCCESS ) return rc; 222 (&k->value)->identifier.bv_val = peek_head; 223 (&k->value)->identifier.bv_len = strLen; 224 } 225 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) { 226 Asn1Error("Error during Reading } in encoding"); 227 return LDAP_PROTOCOL_ERROR; 228 } 229 if(*peek_head != '}'){ 230 Asn1Error("Missing } in encoding"); 231 return LDAP_PROTOCOL_ERROR; 232 } 233 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 234 *v = t = (ComponentOtherName*) CompAlloc( mem_op, sizeof(ComponentOtherName) ); 235 if ( !t ) return -1; 236 *t = *k; 237 } 238 t->syntax = (Syntax*)NULL; 239 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 240 if ( !t->comp_desc ) { 241 free ( t ); 242 return -1; 243 } 244 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentOtherName ; 245 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentOtherName ; 246 t->comp_desc->cd_free = (comp_free_func*)NULL; 247 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentOtherName; 248 t->comp_desc->cd_type = ASN_COMPOSITE; 249 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 250 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentOtherName; 251 return LDAP_SUCCESS; 252} /* GDecOtherName*/ 253 254 255int 256MatchingComponentORAddress ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 257 int rc; 258 MatchingRule* mr; 259 260 if ( oid ) { 261 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 262 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 263 } 264 265 rc = 1; 266 rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->type_id, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_assert)->type_id ); 267 if ( rc != LDAP_COMPARE_TRUE ) 268 return rc; 269 rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->value, (&((ComponentORAddress*)csi_attr)->type_id)); 270 rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentORAddress*)csi_attr)->value, (ComponentAny*)&((ComponentORAddress*)csi_assert)->value); 271 if ( rc != LDAP_COMPARE_TRUE ) 272 return rc; 273 rc = MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->extension, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_assert)->extension ); 274 if ( rc != LDAP_COMPARE_TRUE ) 275 return rc; 276 return LDAP_COMPARE_TRUE; 277} /* BMatchingComponentORAddress */ 278 279void* 280ExtractingComponentORAddress ( void* mem_op, ComponentReference* cr, ComponentORAddress *comp ) 281{ 282 283 if ( ( comp->type_id.identifier.bv_val && strncmp(comp->type_id.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.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 284 if ( cr->cr_curr->ci_next == NULL ) 285 return &comp->type_id; 286 else 287 return NULL; 288 } 289 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 ) ) { 290 if ( cr->cr_curr->ci_next == NULL ) 291 return &comp->value; 292 else 293 return NULL; 294 } 295 if ( ( comp->extension.identifier.bv_val && strncmp(comp->extension.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extension.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 296 if ( cr->cr_curr->ci_next == NULL ) 297 return &comp->extension; 298 else 299 return NULL; 300 } 301 return NULL; 302} /* ExtractingComponentORAddress */ 303 304int 305BDecComponentORAddress PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 306void* mem_op _AND_ 307GenBuf * b _AND_ 308AsnTag tagId0 _AND_ 309AsnLen elmtLen0 _AND_ 310ComponentORAddress **v _AND_ 311AsnLen *bytesDecoded _AND_ 312int mode) 313{ 314 int seqDone = FALSE; 315 AsnLen totalElmtsLen1 = 0; 316 AsnLen elmtLen1; 317 AsnTag tagId1; 318 int mandatoryElmtCount1 = 0; 319 int old_mode = mode; 320 int rc; 321 ComponentORAddress *k, *t, c_temp; 322 323 324 if ( !(mode & DEC_ALLOC_MODE_1) ) { 325 memset(&c_temp,0,sizeof(c_temp)); 326 k = &c_temp; 327 } else 328 k = t = *v; 329 mode = DEC_ALLOC_MODE_2; 330 tagId1 = BDecTag (b, &totalElmtsLen1 ); 331 332 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) 333 { 334 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 335 rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->type_id), &totalElmtsLen1, mode); 336 if ( rc != LDAP_SUCCESS ) return rc; 337 (&k->type_id)->identifier.bv_val = (&k->type_id)->id_buf; 338 (&k->type_id)->identifier.bv_len = strlen("type_id"); 339 strcpy( (&k->type_id)->identifier.bv_val, "type_id"); 340 } 341 else 342 return -1; 343 344 345 346 { 347 rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id)); 348 rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode ); 349 if ( rc != LDAP_SUCCESS ) return rc; 350 (&k->value)->identifier.bv_val = (&k->value)->id_buf; 351 (&k->value)->identifier.bv_len = strlen("value"); 352 strcpy( (&k->value)->identifier.bv_val, "value"); 353 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) 354 seqDone = TRUE; 355 else 356 { 357 tagId1 = BDecTag (b, &totalElmtsLen1 ); 358 359 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) 360 { 361 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 ) 362 seqDone = TRUE; 363 } 364 } 365 } 366 367 368 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) || 369(tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))) 370 { 371 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 372 rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extension), &totalElmtsLen1, mode); 373 if ( rc != LDAP_SUCCESS ) return rc; 374 (&k->extension)->identifier.bv_val = (&k->extension)->id_buf; 375 (&k->extension)->identifier.bv_len = strlen("extension"); 376 strcpy( (&k->extension)->identifier.bv_val, "extension"); 377 seqDone = TRUE; 378 if (elmtLen0 == INDEFINITE_LEN) 379 BDecEoc (b, &totalElmtsLen1 ); 380 else if (totalElmtsLen1 != elmtLen0) 381 return -1; 382 383 } 384 385 386 if (!seqDone) 387 return -1; 388 389 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 390 *v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) ); 391 if ( !t ) return -1; 392 *t = *k; 393 } 394 t->syntax = (Syntax*)NULL; 395 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 396 if ( !t->comp_desc ) { 397 free ( t ); 398 return -1; 399 } 400 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentORAddress ; 401 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ; 402 t->comp_desc->cd_free = (comp_free_func*)NULL; 403 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress; 404 t->comp_desc->cd_type = ASN_COMPOSITE; 405 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 406 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentORAddress; 407 (*bytesDecoded) += totalElmtsLen1; 408 return LDAP_SUCCESS; 409} /* BDecORAddress*/ 410 411int 412GDecComponentORAddress PARAMS (( mem_op,b, v, bytesDecoded, mode), 413void* mem_op _AND_ 414GenBuf * b _AND_ 415ComponentORAddress **v _AND_ 416AsnLen *bytesDecoded _AND_ 417int mode) 418{ 419 char* peek_head,*peek_head2; 420 int i, strLen,strLen2, rc, old_mode = mode; 421 ComponentORAddress *k,*t, c_temp; 422 423 424 if ( !(mode & DEC_ALLOC_MODE_1) ) { 425 memset(&c_temp,0,sizeof(c_temp)); 426 k = &c_temp; 427 } else 428 k = t = *v; 429 mode = DEC_ALLOC_MODE_2; 430 *bytesDecoded = 0; 431 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 432 Asn1Error("Error during Reading { in encoded data"); 433 return LDAP_PROTOCOL_ERROR; 434 } 435 if(*peek_head != '{'){ 436 Asn1Error("Missing { in encoded data"); 437 return LDAP_PROTOCOL_ERROR; 438 } 439 440 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 441 Asn1Error("Error during Reading identifier"); 442 return LDAP_PROTOCOL_ERROR; 443 } 444 if ( strncmp( peek_head, "type_id", strlen("type_id") ) == 0 ) { 445 rc = GDecComponentOid (mem_op, b, (&k->type_id), bytesDecoded, mode); 446 if ( rc != LDAP_SUCCESS ) return rc; 447 (&k->type_id)->identifier.bv_val = peek_head; 448 (&k->type_id)->identifier.bv_len = strLen; 449 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 450 Asn1Error("Error during Reading , "); 451 return LDAP_PROTOCOL_ERROR; 452 } 453 if(*peek_head != ','){ 454 Asn1Error("Missing , in encoding"); 455 return LDAP_PROTOCOL_ERROR; 456 } 457 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 458 Asn1Error("Error during Reading identifier"); 459 return LDAP_PROTOCOL_ERROR; 460 } 461 } 462 if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) { 463 rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id)); 464 rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode ); 465 if ( rc != LDAP_SUCCESS ) return rc; 466 (&k->value)->identifier.bv_val = peek_head; 467 (&k->value)->identifier.bv_len = strLen; 468 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 469 Asn1Error("Error during Reading , "); 470 return LDAP_PROTOCOL_ERROR; 471 } 472 if(*peek_head != ','){ 473 Asn1Error("Missing , in encoding"); 474 return LDAP_PROTOCOL_ERROR; 475 } 476 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 477 Asn1Error("Error during Reading identifier"); 478 return LDAP_PROTOCOL_ERROR; 479 } 480 } 481 if ( strncmp( peek_head, "extension", strlen("extension") ) == 0 ) { 482 rc = GDecComponentOcts (mem_op, b, (&k->extension), bytesDecoded, mode); 483 if ( rc != LDAP_SUCCESS ) return rc; 484 (&k->extension)->identifier.bv_val = peek_head; 485 (&k->extension)->identifier.bv_len = strLen; 486 } 487 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) { 488 Asn1Error("Error during Reading } in encoding"); 489 return LDAP_PROTOCOL_ERROR; 490 } 491 if(*peek_head != '}'){ 492 Asn1Error("Missing } in encoding"); 493 return LDAP_PROTOCOL_ERROR; 494 } 495 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 496 *v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) ); 497 if ( !t ) return -1; 498 *t = *k; 499 } 500 t->syntax = (Syntax*)NULL; 501 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 502 if ( !t->comp_desc ) { 503 free ( t ); 504 return -1; 505 } 506 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentORAddress ; 507 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ; 508 t->comp_desc->cd_free = (comp_free_func*)NULL; 509 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress; 510 t->comp_desc->cd_type = ASN_COMPOSITE; 511 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 512 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentORAddress; 513 return LDAP_SUCCESS; 514} /* GDecORAddress*/ 515 516 517int 518MatchingComponentDirectoryString ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 519 int rc; 520 MatchingRule* mr; 521 ComponentDirectoryString *v1, *v2; 522 523 524 v1 = (ComponentDirectoryString*)csi_attr; 525 v2 = (ComponentDirectoryString*)csi_assert; 526 if ( oid ) { 527 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 528 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 529 } 530 531 if( (v1->choiceId != v2->choiceId ) ) 532 return LDAP_COMPARE_FALSE; 533 switch( v1->choiceId ) 534 { 535 case DIRECTORYSTRING_TELETEXSTRING : 536 rc = MatchingComponentTeletexString ( oid, (ComponentSyntaxInfo*)(v1->a.teletexString), (ComponentSyntaxInfo*)(v2->a.teletexString) ); 537 break; 538 case DIRECTORYSTRING_PRINTABLESTRING : 539 rc = MatchingComponentPrintableString ( oid, (ComponentSyntaxInfo*)(v1->a.printableString), (ComponentSyntaxInfo*)(v2->a.printableString) ); 540 break; 541 case DIRECTORYSTRING_UNIVERSALSTRING : 542 rc = MatchingComponentUniversalString ( oid, (ComponentSyntaxInfo*)(v1->a.universalString), (ComponentSyntaxInfo*)(v2->a.universalString) ); 543 break; 544 case DIRECTORYSTRING_UTF8STRING : 545 rc = MatchingComponentUTF8String ( oid, (ComponentSyntaxInfo*)(v1->a.utf8String), (ComponentSyntaxInfo*)(v2->a.utf8String) ); 546 break; 547 case DIRECTORYSTRING_BMPSTRING : 548 rc = MatchingComponentBMPString ( oid, (ComponentSyntaxInfo*)(v1->a.bmpString), (ComponentSyntaxInfo*)(v2->a.bmpString) ); 549 break; 550 default : 551 return LDAP_PROTOCOL_ERROR; 552 } 553 return rc; 554} /* BMatchingComponentDirectoryStringContent */ 555 556void* 557ExtractingComponentDirectoryString ( void* mem_op, ComponentReference* cr, ComponentDirectoryString *comp ) 558{ 559 560 561 if( (comp->choiceId) == DIRECTORYSTRING_TELETEXSTRING && 562 (( comp->a.teletexString->identifier.bv_val && strncmp(comp->a.teletexString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 563 ( strncmp(comp->a.teletexString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 564 if ( cr->cr_curr->ci_next == NULL ) 565 return (comp->a.teletexString); 566 else { 567 cr->cr_curr = cr->cr_curr->ci_next; 568 return ExtractingComponentTeletexString ( mem_op, cr, (comp->a.teletexString) ); 569 }; 570 } 571 if( (comp->choiceId) == DIRECTORYSTRING_PRINTABLESTRING && 572 (( comp->a.printableString->identifier.bv_val && strncmp(comp->a.printableString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 573 ( strncmp(comp->a.printableString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 574 if ( cr->cr_curr->ci_next == NULL ) 575 return (comp->a.printableString); 576 else { 577 cr->cr_curr = cr->cr_curr->ci_next; 578 return ExtractingComponentPrintableString ( mem_op, cr, (comp->a.printableString) ); 579 }; 580 } 581 if( (comp->choiceId) == DIRECTORYSTRING_UNIVERSALSTRING && 582 (( comp->a.universalString->identifier.bv_val && strncmp(comp->a.universalString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 583 ( strncmp(comp->a.universalString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 584 if ( cr->cr_curr->ci_next == NULL ) 585 return (comp->a.universalString); 586 else { 587 cr->cr_curr = cr->cr_curr->ci_next; 588 return ExtractingComponentUniversalString ( mem_op, cr, (comp->a.universalString) ); 589 }; 590 } 591 if( (comp->choiceId) == DIRECTORYSTRING_UTF8STRING && 592 (( comp->a.utf8String->identifier.bv_val && strncmp(comp->a.utf8String->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 593 ( strncmp(comp->a.utf8String->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 594 if ( cr->cr_curr->ci_next == NULL ) 595 return (comp->a.utf8String); 596 else { 597 cr->cr_curr = cr->cr_curr->ci_next; 598 return ExtractingComponentUTF8String ( mem_op, cr, (comp->a.utf8String) ); 599 }; 600 } 601 if( (comp->choiceId) == DIRECTORYSTRING_BMPSTRING && 602 (( comp->a.bmpString->identifier.bv_val && strncmp(comp->a.bmpString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 603 ( strncmp(comp->a.bmpString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 604 if ( cr->cr_curr->ci_next == NULL ) 605 return (comp->a.bmpString); 606 else { 607 cr->cr_curr = cr->cr_curr->ci_next; 608 return ExtractingComponentBMPString ( mem_op, cr, (comp->a.bmpString) ); 609 }; 610 } 611 return NULL; 612} /* ExtractingComponentDirectoryString */ 613 614int 615BDecComponentDirectoryString PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 616void* mem_op _AND_ 617GenBuf * b _AND_ 618AsnTag tagId0 _AND_ 619AsnLen elmtLen0 _AND_ 620ComponentDirectoryString **v _AND_ 621AsnLen *bytesDecoded _AND_ 622int mode) 623{ 624 int seqDone = FALSE; 625 AsnLen totalElmtsLen1 = 0; 626 AsnLen elmtLen1; 627 AsnTag tagId1; 628 int mandatoryElmtCount1 = 0; 629 int old_mode = mode; 630 int rc; 631 ComponentDirectoryString *k, *t, c_temp; 632 633 634 if ( !(mode & DEC_ALLOC_MODE_1) ) { 635 memset(&c_temp,0,sizeof(c_temp)); 636 k = &c_temp; 637 } else 638 k = t = *v; 639 mode = DEC_ALLOC_MODE_2; 640 switch (tagId0) 641 { 642 case MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE): 643 case MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE): 644 (k->choiceId) = DIRECTORYSTRING_TELETEXSTRING; 645 rc = BDecComponentTeletexString (mem_op, b, tagId0, elmtLen0, (&k->a.teletexString), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 646 if ( rc != LDAP_SUCCESS ) return rc; 647 (k->a.teletexString)->identifier.bv_val = (k->a.teletexString)->id_buf; 648 (k->a.teletexString)->identifier.bv_len = strlen("teletexString"); 649 strcpy( (k->a.teletexString)->identifier.bv_val, "teletexString"); 650 break; 651 652 case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE): 653 case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE): 654 (k->choiceId) = DIRECTORYSTRING_PRINTABLESTRING; 655 rc = BDecComponentPrintableString (mem_op, b, tagId0, elmtLen0, (&k->a.printableString), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 656 if ( rc != LDAP_SUCCESS ) return rc; 657 (k->a.printableString)->identifier.bv_val = (k->a.printableString)->id_buf; 658 (k->a.printableString)->identifier.bv_len = strlen("printableString"); 659 strcpy( (k->a.printableString)->identifier.bv_val, "printableString"); 660 break; 661 662 case MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE): 663 case MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE): 664 (k->choiceId) = DIRECTORYSTRING_UNIVERSALSTRING; 665 rc = BDecComponentUniversalString (mem_op, b, tagId0, elmtLen0, (&k->a.universalString), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 666 if ( rc != LDAP_SUCCESS ) return rc; 667 (k->a.universalString)->identifier.bv_val = (k->a.universalString)->id_buf; 668 (k->a.universalString)->identifier.bv_len = strlen("universalString"); 669 strcpy( (k->a.universalString)->identifier.bv_val, "universalString"); 670 break; 671 672 case MAKE_TAG_ID (UNIV, PRIM, UTF8STRING_TAG_CODE): 673 case MAKE_TAG_ID (UNIV, CONS, UTF8STRING_TAG_CODE): 674 (k->choiceId) = DIRECTORYSTRING_UTF8STRING; 675 rc = BDecComponentUTF8String (mem_op, b, tagId0, elmtLen0, (&k->a.utf8String), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 676 if ( rc != LDAP_SUCCESS ) return rc; 677 (k->a.utf8String)->identifier.bv_val = (k->a.utf8String)->id_buf; 678 (k->a.utf8String)->identifier.bv_len = strlen("utf8String"); 679 strcpy( (k->a.utf8String)->identifier.bv_val, "utf8String"); 680 break; 681 682 case MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE): 683 case MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE): 684 (k->choiceId) = DIRECTORYSTRING_BMPSTRING; 685 rc = BDecComponentBMPString (mem_op, b, tagId0, elmtLen0, (&k->a.bmpString), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 686 if ( rc != LDAP_SUCCESS ) return rc; 687 (k->a.bmpString)->identifier.bv_val = (k->a.bmpString)->id_buf; 688 (k->a.bmpString)->identifier.bv_len = strlen("bmpString"); 689 strcpy( (k->a.bmpString)->identifier.bv_val, "bmpString"); 690 break; 691 692 default: 693 Asn1Error ("ERROR - unexpected tag in CHOICE\n"); 694 return -1; 695 break; 696 } /* end switch */ 697 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 698 *v = t = (ComponentDirectoryString*) CompAlloc( mem_op, sizeof(ComponentDirectoryString) ); 699 if ( !t ) return -1; 700 *t = *k; 701 } 702 t->syntax = (Syntax*)NULL; 703 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 704 if ( !t->comp_desc ) { 705 free ( t ); 706 return -1; 707 } 708 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentDirectoryString ; 709 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentDirectoryString ; 710 t->comp_desc->cd_free = (comp_free_func*)NULL; 711 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentDirectoryString; 712 t->comp_desc->cd_type = ASN_COMPOSITE; 713 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 714 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentDirectoryString; 715 (*bytesDecoded) += totalElmtsLen1; 716 return LDAP_SUCCESS; 717} /* BDecDirectoryStringContent */ 718 719int 720GDecComponentDirectoryString PARAMS (( mem_op,b, v, bytesDecoded, mode), 721void* mem_op _AND_ 722GenBuf * b _AND_ 723ComponentDirectoryString **v _AND_ 724AsnLen *bytesDecoded _AND_ 725int mode) 726{ 727 char* peek_head,*peek_head2; 728 int i, strLen,strLen2, rc, old_mode = mode; 729 ComponentDirectoryString *k,*t, c_temp; 730 731 732 if ( !(mode & DEC_ALLOC_MODE_1) ) { 733 memset(&c_temp,0,sizeof(c_temp)); 734 k = &c_temp; 735 } else 736 k = t = *v; 737 mode = DEC_ALLOC_MODE_2; 738 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 739 Asn1Error("Error during Reading identifier"); 740 return LDAP_PROTOCOL_ERROR; 741 } 742 if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){ 743 Asn1Error("Error during Reading identifier"); 744 return LDAP_PROTOCOL_ERROR; 745 } 746 if(*peek_head2 != ':'){ 747 Asn1Error("Missing : in encoded data"); 748 return LDAP_PROTOCOL_ERROR; 749 } 750 if( strncmp("teletexString",peek_head, strlen("teletexString")) == 0){ 751 (k->choiceId) = DIRECTORYSTRING_TELETEXSTRING; 752 rc = GDecComponentTeletexString (mem_op, b, (&k->a.teletexString), bytesDecoded, DEC_ALLOC_MODE_0 ); 753 if ( rc != LDAP_SUCCESS ) return rc; 754 (k->a.teletexString)->identifier.bv_val = peek_head; 755 (k->a.teletexString)->identifier.bv_len = strLen; 756 } 757 else if( strncmp("printableString",peek_head,strlen("printableString")) == 0){ 758 (k->choiceId) = DIRECTORYSTRING_PRINTABLESTRING; 759 rc = GDecComponentPrintableString (mem_op, b, (&k->a.printableString), bytesDecoded, DEC_ALLOC_MODE_0 ); 760 if ( rc != LDAP_SUCCESS ) return rc; 761 (k->a.printableString)->identifier.bv_val = peek_head; 762 (k->a.printableString)->identifier.bv_len = strLen; 763 } 764 else if( strncmp("universalString",peek_head,strlen("universalString")) == 0){ 765 (k->choiceId) = DIRECTORYSTRING_UNIVERSALSTRING; 766 rc = GDecComponentUniversalString (mem_op, b, (&k->a.universalString), bytesDecoded, DEC_ALLOC_MODE_0 ); 767 if ( rc != LDAP_SUCCESS ) return rc; 768 (k->a.universalString)->identifier.bv_val = peek_head; 769 (k->a.universalString)->identifier.bv_len = strLen; 770 } 771 else if( strncmp("utf8String",peek_head,strlen("utf8String")) == 0){ 772 (k->choiceId) = DIRECTORYSTRING_UTF8STRING; 773 rc = GDecComponentUTF8String (mem_op, b, (&k->a.utf8String), bytesDecoded, DEC_ALLOC_MODE_0 ); 774 if ( rc != LDAP_SUCCESS ) return rc; 775 (k->a.utf8String)->identifier.bv_val = peek_head; 776 (k->a.utf8String)->identifier.bv_len = strLen; 777 } 778 else if( strncmp("bmpString",peek_head,strlen("bmpString")) == 0){ 779 (k->choiceId) = DIRECTORYSTRING_BMPSTRING; 780 rc = GDecComponentBMPString (mem_op, b, (&k->a.bmpString), bytesDecoded, DEC_ALLOC_MODE_0 ); 781 if ( rc != LDAP_SUCCESS ) return rc; 782 (k->a.bmpString)->identifier.bv_val = peek_head; 783 (k->a.bmpString)->identifier.bv_len = strLen; 784 } 785 else { 786 Asn1Error("Undefined Identifier"); 787 return LDAP_PROTOCOL_ERROR; 788 } 789 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 790 *v = t = (ComponentDirectoryString*) CompAlloc( mem_op, sizeof(ComponentDirectoryString) ); 791 if ( !t ) return -1; 792 *t = *k; 793 } 794 t->syntax = (Syntax*)NULL; 795 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 796 if ( !t->comp_desc ) { 797 free ( t ); 798 return -1; 799 } 800 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentDirectoryString ; 801 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentDirectoryString ; 802 t->comp_desc->cd_free = (comp_free_func*)NULL; 803 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentDirectoryString; 804 t->comp_desc->cd_type = ASN_COMPOSITE; 805 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 806 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentDirectoryString; 807 return LDAP_SUCCESS; 808} /* GDecDirectoryStringContent */ 809 810 811int 812MatchingComponentEDIPartyName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 813 int rc; 814 MatchingRule* mr; 815 816 if ( oid ) { 817 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 818 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 819 } 820 821 rc = 1; 822 if(COMPONENTNOT_NULL( ((ComponentEDIPartyName*)csi_attr)->nameAssigner ) ) { 823 rc = MatchingComponentDirectoryString ( oid, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_attr)->nameAssigner, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_assert)->nameAssigner ); 824 if ( rc != LDAP_COMPARE_TRUE ) 825 return rc; 826 } 827 rc = MatchingComponentDirectoryString ( oid, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_attr)->partyName, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_assert)->partyName ); 828 if ( rc != LDAP_COMPARE_TRUE ) 829 return rc; 830 return LDAP_COMPARE_TRUE; 831} /* BMatchingComponentEDIPartyName */ 832 833void* 834ExtractingComponentEDIPartyName ( void* mem_op, ComponentReference* cr, ComponentEDIPartyName *comp ) 835{ 836 837 if ( ( comp->nameAssigner->identifier.bv_val && strncmp(comp->nameAssigner->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->nameAssigner->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 838 if ( cr->cr_curr->ci_next == NULL ) 839 return comp->nameAssigner; 840 else { 841 cr->cr_curr = cr->cr_curr->ci_next; 842 return ExtractingComponentDirectoryString ( mem_op, cr, comp->nameAssigner ); 843 } 844 } 845 if ( ( comp->partyName->identifier.bv_val && strncmp(comp->partyName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->partyName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 846 if ( cr->cr_curr->ci_next == NULL ) 847 return comp->partyName; 848 else { 849 cr->cr_curr = cr->cr_curr->ci_next; 850 return ExtractingComponentDirectoryString ( mem_op, cr, comp->partyName ); 851 } 852 } 853 return NULL; 854} /* ExtractingComponentEDIPartyName */ 855 856int 857BDecComponentEDIPartyName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 858void* mem_op _AND_ 859GenBuf * b _AND_ 860AsnTag tagId0 _AND_ 861AsnLen elmtLen0 _AND_ 862ComponentEDIPartyName **v _AND_ 863AsnLen *bytesDecoded _AND_ 864int mode) 865{ 866 int seqDone = FALSE; 867 AsnLen totalElmtsLen1 = 0; 868 AsnLen elmtLen1; 869 AsnTag tagId1; 870 int mandatoryElmtCount1 = 0; 871 AsnLen totalElmtsLen2 = 0; 872 AsnLen elmtLen2; 873 AsnTag tagId2; 874 AsnLen totalElmtsLen3 = 0; 875 AsnLen elmtLen3; 876 AsnTag tagId3; 877 int old_mode = mode; 878 int rc; 879 ComponentEDIPartyName *k, *t, c_temp; 880 881 882 if ( !(mode & DEC_ALLOC_MODE_1) ) { 883 memset(&c_temp,0,sizeof(c_temp)); 884 k = &c_temp; 885 } else 886 k = t = *v; 887 mode = DEC_ALLOC_MODE_2; 888 tagId1 = BDecTag (b, &totalElmtsLen1 ); 889 890 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) 891 { 892 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 893 rc = tagId2 = BDecTag (b, &totalElmtsLen1 ); 894 elmtLen2 = BDecLen (b, &totalElmtsLen1 ); 895 BDecComponentDirectoryString (mem_op, b, tagId2, elmtLen2, (&k->nameAssigner), &totalElmtsLen1, mode); 896 if (elmtLen1 == INDEFINITE_LEN) 897 BDecEoc(b, &totalElmtsLen1 ); 898 if ( rc != LDAP_SUCCESS ) return rc; 899 (k->nameAssigner)->identifier.bv_val = (k->nameAssigner)->id_buf; 900 (k->nameAssigner)->identifier.bv_len = strlen("nameAssigner"); 901 strcpy( (k->nameAssigner)->identifier.bv_val, "nameAssigner"); 902 if (elmtLen1 == INDEFINITE_LEN) 903 BDecEoc (b, &totalElmtsLen1 ); 904 tagId1 = BDecTag (b, &totalElmtsLen1); 905 } 906 907 908 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)))) 909 { 910 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 911 rc = tagId2 = BDecTag (b, &totalElmtsLen1 ); 912 elmtLen2 = BDecLen (b, &totalElmtsLen1 ); 913 BDecComponentDirectoryString (mem_op, b, tagId2, elmtLen2, (&k->partyName), &totalElmtsLen1, mode); 914 if (elmtLen1 == INDEFINITE_LEN) 915 BDecEoc(b, &totalElmtsLen1 ); 916 if ( rc != LDAP_SUCCESS ) return rc; 917 (k->partyName)->identifier.bv_val = (k->partyName)->id_buf; 918 (k->partyName)->identifier.bv_len = strlen("partyName"); 919 strcpy( (k->partyName)->identifier.bv_val, "partyName"); 920 if (elmtLen1 == INDEFINITE_LEN) 921 BDecEoc (b, &totalElmtsLen1 ); 922 seqDone = TRUE; 923 if (elmtLen0 == INDEFINITE_LEN) 924 BDecEoc (b, &totalElmtsLen1 ); 925 else if (totalElmtsLen1 != elmtLen0) 926 return -1; 927 928 } 929 else 930 return -1; 931 932 933 934 if (!seqDone) 935 return -1; 936 937 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 938 *v = t = (ComponentEDIPartyName*) CompAlloc( mem_op, sizeof(ComponentEDIPartyName) ); 939 if ( !t ) return -1; 940 *t = *k; 941 } 942 t->syntax = (Syntax*)NULL; 943 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 944 if ( !t->comp_desc ) { 945 free ( t ); 946 return -1; 947 } 948 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEDIPartyName ; 949 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEDIPartyName ; 950 t->comp_desc->cd_free = (comp_free_func*)NULL; 951 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentEDIPartyName; 952 t->comp_desc->cd_type = ASN_COMPOSITE; 953 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 954 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEDIPartyName; 955 (*bytesDecoded) += totalElmtsLen1; 956 return LDAP_SUCCESS; 957} /* BDecEDIPartyName*/ 958 959int 960GDecComponentEDIPartyName PARAMS (( mem_op,b, v, bytesDecoded, mode), 961void* mem_op _AND_ 962GenBuf * b _AND_ 963ComponentEDIPartyName **v _AND_ 964AsnLen *bytesDecoded _AND_ 965int mode) 966{ 967 char* peek_head,*peek_head2; 968 int i, strLen,strLen2, rc, old_mode = mode; 969 ComponentEDIPartyName *k,*t, c_temp; 970 971 972 if ( !(mode & DEC_ALLOC_MODE_1) ) { 973 memset(&c_temp,0,sizeof(c_temp)); 974 k = &c_temp; 975 } else 976 k = t = *v; 977 mode = DEC_ALLOC_MODE_2; 978 *bytesDecoded = 0; 979 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 980 Asn1Error("Error during Reading { in encoded data"); 981 return LDAP_PROTOCOL_ERROR; 982 } 983 if(*peek_head != '{'){ 984 Asn1Error("Missing { in encoded data"); 985 return LDAP_PROTOCOL_ERROR; 986 } 987 988 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 989 Asn1Error("Error during Reading identifier"); 990 return LDAP_PROTOCOL_ERROR; 991 } 992 if ( strncmp( peek_head, "nameAssigner", strlen("nameAssigner") ) == 0 ) { 993 rc = GDecComponentDirectoryString (mem_op, b, (&k->nameAssigner), bytesDecoded, mode); 994 if ( rc != LDAP_SUCCESS ) return rc; 995 ( k->nameAssigner)->identifier.bv_val = peek_head; 996 ( k->nameAssigner)->identifier.bv_len = strLen; 997 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 998 Asn1Error("Error during Reading , "); 999 return LDAP_PROTOCOL_ERROR; 1000 } 1001 if(*peek_head != ','){ 1002 Asn1Error("Missing , in encoding"); 1003 return LDAP_PROTOCOL_ERROR; 1004 } 1005 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 1006 Asn1Error("Error during Reading identifier"); 1007 return LDAP_PROTOCOL_ERROR; 1008 } 1009 } 1010 if ( strncmp( peek_head, "partyName", strlen("partyName") ) == 0 ) { 1011 rc = GDecComponentDirectoryString (mem_op, b, (&k->partyName), bytesDecoded, mode); 1012 if ( rc != LDAP_SUCCESS ) return rc; 1013 ( k->partyName)->identifier.bv_val = peek_head; 1014 ( k->partyName)->identifier.bv_len = strLen; 1015 } 1016 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) { 1017 Asn1Error("Error during Reading } in encoding"); 1018 return LDAP_PROTOCOL_ERROR; 1019 } 1020 if(*peek_head != '}'){ 1021 Asn1Error("Missing } in encoding"); 1022 return LDAP_PROTOCOL_ERROR; 1023 } 1024 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1025 *v = t = (ComponentEDIPartyName*) CompAlloc( mem_op, sizeof(ComponentEDIPartyName) ); 1026 if ( !t ) return -1; 1027 *t = *k; 1028 } 1029 t->syntax = (Syntax*)NULL; 1030 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1031 if ( !t->comp_desc ) { 1032 free ( t ); 1033 return -1; 1034 } 1035 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEDIPartyName ; 1036 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEDIPartyName ; 1037 t->comp_desc->cd_free = (comp_free_func*)NULL; 1038 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentEDIPartyName; 1039 t->comp_desc->cd_type = ASN_COMPOSITE; 1040 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1041 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEDIPartyName; 1042 return LDAP_SUCCESS; 1043} /* GDecEDIPartyName*/ 1044 1045 1046 1047int 1048MatchingComponentGeneralName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 1049 int rc; 1050 MatchingRule* mr; 1051 ComponentGeneralName *v1, *v2; 1052 1053 1054 v1 = (ComponentGeneralName*)csi_attr; 1055 v2 = (ComponentGeneralName*)csi_assert; 1056 if ( oid ) { 1057 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 1058 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 1059 } 1060 1061 if( (v1->choiceId != v2->choiceId ) ) 1062 return LDAP_COMPARE_FALSE; 1063 switch( v1->choiceId ) 1064 { 1065 case GENERALNAME_OTHERNAME : 1066 rc = MatchingComponentOtherName ( oid, (ComponentSyntaxInfo*)(v1->a.otherName), (ComponentSyntaxInfo*)(v2->a.otherName) ); 1067 break; 1068 case GENERALNAME_RFC822NAME : 1069 rc = MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.rfc822Name), (ComponentSyntaxInfo*)(v2->a.rfc822Name) ); 1070 break; 1071 case GENERALNAME_DNSNAME : 1072 rc = MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.dNSName), (ComponentSyntaxInfo*)(v2->a.dNSName) ); 1073 break; 1074 case GENERALNAME_X400ADDRESS : 1075 rc = MatchingComponentORAddress ( oid, (ComponentSyntaxInfo*)(v1->a.x400Address), (ComponentSyntaxInfo*)(v2->a.x400Address) ); 1076 break; 1077 case GENERALNAME_DIRECTORYNAME : 1078 rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)(v1->a.directoryName), (ComponentSyntaxInfo*)(v2->a.directoryName) ); 1079 break; 1080 case GENERALNAME_EDIPARTYNAME : 1081 rc = MatchingComponentEDIPartyName ( oid, (ComponentSyntaxInfo*)(v1->a.ediPartyName), (ComponentSyntaxInfo*)(v2->a.ediPartyName) ); 1082 break; 1083 case GENERALNAME_UNIFORMRESOURCEIDENTIFIER : 1084 rc = MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.uniformResourceIdentifier), (ComponentSyntaxInfo*)(v2->a.uniformResourceIdentifier) ); 1085 break; 1086 case GENERALNAME_IPADDRESS : 1087 rc = MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)(v1->a.iPAddress), (ComponentSyntaxInfo*)(v2->a.iPAddress) ); 1088 break; 1089 case GENERALNAME_REGISTEREDID : 1090 rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)(v1->a.registeredID), (ComponentSyntaxInfo*)(v2->a.registeredID) ); 1091 break; 1092 default : 1093 return LDAP_PROTOCOL_ERROR; 1094 } 1095 return rc; 1096} /* BMatchingComponentGeneralNameContent */ 1097 1098void* 1099ExtractingComponentGeneralName ( void* mem_op, ComponentReference* cr, ComponentGeneralName *comp ) 1100{ 1101 1102 1103 if( (comp->choiceId) == GENERALNAME_OTHERNAME && 1104 (( comp->a.otherName->identifier.bv_val && strncmp(comp->a.otherName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1105 ( strncmp(comp->a.otherName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1106 if ( cr->cr_curr->ci_next == NULL ) 1107 return (comp->a.otherName); 1108 else { 1109 cr->cr_curr = cr->cr_curr->ci_next; 1110 return ExtractingComponentOtherName ( mem_op, cr, (comp->a.otherName) ); 1111 }; 1112 } 1113 if( (comp->choiceId) == GENERALNAME_RFC822NAME && 1114 (( comp->a.rfc822Name->identifier.bv_val && strncmp(comp->a.rfc822Name->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1115 ( strncmp(comp->a.rfc822Name->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1116 if ( cr->cr_curr->ci_next == NULL ) 1117 return (comp->a.rfc822Name); 1118 else { 1119 cr->cr_curr = cr->cr_curr->ci_next; 1120 return ExtractingComponentIA5String ( mem_op, cr, (comp->a.rfc822Name) ); 1121 }; 1122 } 1123 if( (comp->choiceId) == GENERALNAME_DNSNAME && 1124 (( comp->a.dNSName->identifier.bv_val && strncmp(comp->a.dNSName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1125 ( strncmp(comp->a.dNSName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1126 if ( cr->cr_curr->ci_next == NULL ) 1127 return (comp->a.dNSName); 1128 else { 1129 cr->cr_curr = cr->cr_curr->ci_next; 1130 return ExtractingComponentIA5String ( mem_op, cr, (comp->a.dNSName) ); 1131 }; 1132 } 1133 if( (comp->choiceId) == GENERALNAME_X400ADDRESS && 1134 (( comp->a.x400Address->identifier.bv_val && strncmp(comp->a.x400Address->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1135 ( strncmp(comp->a.x400Address->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1136 if ( cr->cr_curr->ci_next == NULL ) 1137 return (comp->a.x400Address); 1138 else { 1139 cr->cr_curr = cr->cr_curr->ci_next; 1140 return ExtractingComponentORAddress ( mem_op, cr, (comp->a.x400Address) ); 1141 }; 1142 } 1143 if( (comp->choiceId) == GENERALNAME_DIRECTORYNAME && 1144 (( comp->a.directoryName->identifier.bv_val && strncmp(comp->a.directoryName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1145 ( strncmp(comp->a.directoryName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1146 if ( cr->cr_curr->ci_next == NULL ) 1147 return (comp->a.directoryName); 1148 else { 1149 cr->cr_curr = cr->cr_curr->ci_next; 1150 return ExtractingComponentName ( mem_op, cr, (comp->a.directoryName) ); 1151 }; 1152 } 1153 if( (comp->choiceId) == GENERALNAME_EDIPARTYNAME && 1154 (( comp->a.ediPartyName->identifier.bv_val && strncmp(comp->a.ediPartyName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1155 ( strncmp(comp->a.ediPartyName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1156 if ( cr->cr_curr->ci_next == NULL ) 1157 return (comp->a.ediPartyName); 1158 else { 1159 cr->cr_curr = cr->cr_curr->ci_next; 1160 return ExtractingComponentEDIPartyName ( mem_op, cr, (comp->a.ediPartyName) ); 1161 }; 1162 } 1163 if( (comp->choiceId) == GENERALNAME_UNIFORMRESOURCEIDENTIFIER && 1164 (( comp->a.uniformResourceIdentifier->identifier.bv_val && strncmp(comp->a.uniformResourceIdentifier->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1165 ( strncmp(comp->a.uniformResourceIdentifier->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1166 if ( cr->cr_curr->ci_next == NULL ) 1167 return (comp->a.uniformResourceIdentifier); 1168 else { 1169 cr->cr_curr = cr->cr_curr->ci_next; 1170 return ExtractingComponentIA5String ( mem_op, cr, (comp->a.uniformResourceIdentifier) ); 1171 }; 1172 } 1173 if( (comp->choiceId) == GENERALNAME_IPADDRESS && 1174 (( comp->a.iPAddress->identifier.bv_val && strncmp(comp->a.iPAddress->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1175 ( strncmp(comp->a.iPAddress->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1176 if ( cr->cr_curr->ci_next == NULL ) 1177 return (comp->a.iPAddress); 1178 else { 1179 cr->cr_curr = cr->cr_curr->ci_next; 1180 return ExtractingComponentOcts ( mem_op, cr, (comp->a.iPAddress) ); 1181 }; 1182 } 1183 if( (comp->choiceId) == GENERALNAME_REGISTEREDID && 1184 (( comp->a.registeredID->identifier.bv_val && strncmp(comp->a.registeredID->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || 1185 ( strncmp(comp->a.registeredID->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) { 1186 if ( cr->cr_curr->ci_next == NULL ) 1187 return (comp->a.registeredID); 1188 else { 1189 cr->cr_curr = cr->cr_curr->ci_next; 1190 return ExtractingComponentOid ( mem_op, cr, (comp->a.registeredID) ); 1191 }; 1192 } 1193 return NULL; 1194} /* ExtractingComponentGeneralName */ 1195 1196int 1197BDecComponentGeneralName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 1198void* mem_op _AND_ 1199GenBuf * b _AND_ 1200AsnTag tagId0 _AND_ 1201AsnLen elmtLen0 _AND_ 1202ComponentGeneralName **v _AND_ 1203AsnLen *bytesDecoded _AND_ 1204int mode) 1205{ 1206 int seqDone = FALSE; 1207 AsnLen totalElmtsLen1 = 0; 1208 AsnLen elmtLen1; 1209 AsnTag tagId1; 1210 int mandatoryElmtCount1 = 0; 1211 AsnLen totalElmtsLen2 = 0; 1212 AsnLen elmtLen2; 1213 AsnTag tagId2; 1214 AsnLen totalElmtsLen3 = 0; 1215 AsnLen elmtLen3; 1216 AsnTag tagId3; 1217 int old_mode = mode; 1218 int rc; 1219 ComponentGeneralName *k, *t, c_temp; 1220 1221 1222 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1223 memset(&c_temp,0,sizeof(c_temp)); 1224 k = &c_temp; 1225 } else 1226 k = t = *v; 1227 mode = DEC_ALLOC_MODE_2; 1228 switch (tagId0) 1229 { 1230 case MAKE_TAG_ID (CNTX, CONS, 0): 1231if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) 1232 { 1233 Asn1Error ("Unexpected Tag\n"); 1234 return -1; 1235 } 1236 1237 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1238 (k->choiceId) = GENERALNAME_OTHERNAME; 1239 rc = BDecComponentOtherName (mem_op, b, tagId1, elmtLen1, (&k->a.otherName), &totalElmtsLen1, mode); 1240 if ( rc != LDAP_SUCCESS ) return rc; 1241 (k->a.otherName)->identifier.bv_val = (k->a.otherName)->id_buf; 1242 (k->a.otherName)->identifier.bv_len = strlen("otherName"); 1243 strcpy( (k->a.otherName)->identifier.bv_val, "otherName"); 1244 if (elmtLen0 == INDEFINITE_LEN) 1245 BDecEoc (b, &totalElmtsLen1 ); 1246 break; 1247 1248 case MAKE_TAG_ID (CNTX, CONS, 1): 1249 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1250if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) && 1251 (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) 1252 { 1253 Asn1Error ("Unexpected Tag\n"); 1254 return -1; 1255 } 1256 1257 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1258 (k->choiceId) = GENERALNAME_RFC822NAME; 1259 rc = BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.rfc822Name), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 1260 if ( rc != LDAP_SUCCESS ) return rc; 1261 (k->a.rfc822Name)->identifier.bv_val = (k->a.rfc822Name)->id_buf; 1262 (k->a.rfc822Name)->identifier.bv_len = strlen("rfc822Name"); 1263 strcpy( (k->a.rfc822Name)->identifier.bv_val, "rfc822Name"); 1264 if (elmtLen0 == INDEFINITE_LEN) 1265 BDecEoc (b, &totalElmtsLen1 ); 1266 break; 1267 1268 case MAKE_TAG_ID (CNTX, CONS, 2): 1269 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1270if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) && 1271 (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) 1272 { 1273 Asn1Error ("Unexpected Tag\n"); 1274 return -1; 1275 } 1276 1277 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1278 (k->choiceId) = GENERALNAME_DNSNAME; 1279 rc = BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.dNSName), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 1280 if ( rc != LDAP_SUCCESS ) return rc; 1281 (k->a.dNSName)->identifier.bv_val = (k->a.dNSName)->id_buf; 1282 (k->a.dNSName)->identifier.bv_len = strlen("dNSName"); 1283 strcpy( (k->a.dNSName)->identifier.bv_val, "dNSName"); 1284 if (elmtLen0 == INDEFINITE_LEN) 1285 BDecEoc (b, &totalElmtsLen1 ); 1286 break; 1287 1288 case MAKE_TAG_ID (CNTX, CONS, 3): 1289if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) 1290 { 1291 Asn1Error ("Unexpected Tag\n"); 1292 return -1; 1293 } 1294 1295 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1296 (k->choiceId) = GENERALNAME_X400ADDRESS; 1297 rc = BDecComponentORAddress (mem_op, b, tagId1, elmtLen1, (&k->a.x400Address), &totalElmtsLen1, mode); 1298 if ( rc != LDAP_SUCCESS ) return rc; 1299 (k->a.x400Address)->identifier.bv_val = (k->a.x400Address)->id_buf; 1300 (k->a.x400Address)->identifier.bv_len = strlen("x400Address"); 1301 strcpy( (k->a.x400Address)->identifier.bv_val, "x400Address"); 1302 if (elmtLen0 == INDEFINITE_LEN) 1303 BDecEoc (b, &totalElmtsLen1 ); 1304 break; 1305 1306 case MAKE_TAG_ID (CNTX, CONS, 4): 1307 (k->choiceId) = GENERALNAME_DIRECTORYNAME; 1308 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1309 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1310 rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->a.directoryName), &totalElmtsLen1, mode); 1311 if (elmtLen0 == INDEFINITE_LEN) 1312 BDecEoc(b, &totalElmtsLen1 ); 1313 if ( rc != LDAP_SUCCESS ) return rc; 1314 (k->a.directoryName)->identifier.bv_val = (k->a.directoryName)->id_buf; 1315 (k->a.directoryName)->identifier.bv_len = strlen("directoryName"); 1316 strcpy( (k->a.directoryName)->identifier.bv_val, "directoryName"); 1317 if (elmtLen0 == INDEFINITE_LEN) 1318 BDecEoc (b, &totalElmtsLen1 ); 1319 break; 1320 1321 case MAKE_TAG_ID (CNTX, CONS, 5): 1322if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)) 1323 { 1324 Asn1Error ("Unexpected Tag\n"); 1325 return -1; 1326 } 1327 1328 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1329 (k->choiceId) = GENERALNAME_EDIPARTYNAME; 1330 rc = BDecComponentEDIPartyName (mem_op, b, tagId1, elmtLen1, (&k->a.ediPartyName), &totalElmtsLen1, mode); 1331 if ( rc != LDAP_SUCCESS ) return rc; 1332 (k->a.ediPartyName)->identifier.bv_val = (k->a.ediPartyName)->id_buf; 1333 (k->a.ediPartyName)->identifier.bv_len = strlen("ediPartyName"); 1334 strcpy( (k->a.ediPartyName)->identifier.bv_val, "ediPartyName"); 1335 if (elmtLen0 == INDEFINITE_LEN) 1336 BDecEoc (b, &totalElmtsLen1 ); 1337 break; 1338 1339 case MAKE_TAG_ID (CNTX, CONS, 6): 1340 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1341if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) && 1342 (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) 1343 { 1344 Asn1Error ("Unexpected Tag\n"); 1345 return -1; 1346 } 1347 1348 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1349 (k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER; 1350 rc = BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.uniformResourceIdentifier), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 1351 if ( rc != LDAP_SUCCESS ) return rc; 1352 (k->a.uniformResourceIdentifier)->identifier.bv_val = (k->a.uniformResourceIdentifier)->id_buf; 1353 (k->a.uniformResourceIdentifier)->identifier.bv_len = strlen("uniformResourceIdentifier"); 1354 strcpy( (k->a.uniformResourceIdentifier)->identifier.bv_val, "uniformResourceIdentifier"); 1355 if (elmtLen0 == INDEFINITE_LEN) 1356 BDecEoc (b, &totalElmtsLen1 ); 1357 break; 1358 1359 case MAKE_TAG_ID (CNTX, CONS, 7): 1360 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1361if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) && 1362 (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) 1363 { 1364 Asn1Error ("Unexpected Tag\n"); 1365 return -1; 1366 } 1367 1368 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1369 (k->choiceId) = GENERALNAME_IPADDRESS; 1370 rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->a.iPAddress), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 1371 if ( rc != LDAP_SUCCESS ) return rc; 1372 (k->a.iPAddress)->identifier.bv_val = (k->a.iPAddress)->id_buf; 1373 (k->a.iPAddress)->identifier.bv_len = strlen("iPAddress"); 1374 strcpy( (k->a.iPAddress)->identifier.bv_val, "iPAddress"); 1375 if (elmtLen0 == INDEFINITE_LEN) 1376 BDecEoc (b, &totalElmtsLen1 ); 1377 break; 1378 1379 case MAKE_TAG_ID (CNTX, CONS, 8): 1380if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)) 1381 { 1382 Asn1Error ("Unexpected Tag\n"); 1383 return -1; 1384 } 1385 1386 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1387 (k->choiceId) = GENERALNAME_REGISTEREDID; 1388 rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->a.registeredID), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); 1389 if ( rc != LDAP_SUCCESS ) return rc; 1390 (k->a.registeredID)->identifier.bv_val = (k->a.registeredID)->id_buf; 1391 (k->a.registeredID)->identifier.bv_len = strlen("registeredID"); 1392 strcpy( (k->a.registeredID)->identifier.bv_val, "registeredID"); 1393 if (elmtLen0 == INDEFINITE_LEN) 1394 BDecEoc (b, &totalElmtsLen1 ); 1395 break; 1396 1397 default: 1398 Asn1Error ("ERROR - unexpected tag in CHOICE\n"); 1399 return -1; 1400 break; 1401 } /* end switch */ 1402 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1403 *v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) ); 1404 if ( !t ) return -1; 1405 *t = *k; 1406 } 1407 t->syntax = (Syntax*)NULL; 1408 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1409 if ( !t->comp_desc ) { 1410 free ( t ); 1411 return -1; 1412 } 1413 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ; 1414 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ; 1415 t->comp_desc->cd_free = (comp_free_func*)NULL; 1416 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName; 1417 t->comp_desc->cd_type = ASN_COMPOSITE; 1418 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1419 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName; 1420 (*bytesDecoded) += totalElmtsLen1; 1421 return LDAP_SUCCESS; 1422} /* BDecGeneralNameContent */ 1423 1424int 1425GDecComponentGeneralName PARAMS (( mem_op,b, v, bytesDecoded, mode), 1426void* mem_op _AND_ 1427GenBuf * b _AND_ 1428ComponentGeneralName **v _AND_ 1429AsnLen *bytesDecoded _AND_ 1430int mode) 1431{ 1432 char* peek_head,*peek_head2; 1433 int i, strLen,strLen2, rc, old_mode = mode; 1434 ComponentGeneralName *k,*t, c_temp; 1435 1436 1437 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1438 memset(&c_temp,0,sizeof(c_temp)); 1439 k = &c_temp; 1440 } else 1441 k = t = *v; 1442 mode = DEC_ALLOC_MODE_2; 1443 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 1444 Asn1Error("Error during Reading identifier"); 1445 return LDAP_PROTOCOL_ERROR; 1446 } 1447 if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){ 1448 Asn1Error("Error during Reading identifier"); 1449 return LDAP_PROTOCOL_ERROR; 1450 } 1451 if(*peek_head2 != ':'){ 1452 Asn1Error("Missing : in encoded data"); 1453 return LDAP_PROTOCOL_ERROR; 1454 } 1455 if( strncmp("otherName",peek_head, strlen("otherName")) == 0){ 1456 (k->choiceId) = GENERALNAME_OTHERNAME; 1457 rc = GDecComponentOtherName (mem_op, b, (&k->a.otherName), bytesDecoded, mode); 1458 if ( rc != LDAP_SUCCESS ) return rc; 1459 (k->a.otherName)->identifier.bv_val = peek_head; 1460 (k->a.otherName)->identifier.bv_len = strLen; 1461 } 1462 else if( strncmp("rfc822Name",peek_head,strlen("rfc822Name")) == 0){ 1463 (k->choiceId) = GENERALNAME_RFC822NAME; 1464 rc = GDecComponentIA5String (mem_op, b, (&k->a.rfc822Name), bytesDecoded, DEC_ALLOC_MODE_0 ); 1465 if ( rc != LDAP_SUCCESS ) return rc; 1466 (k->a.rfc822Name)->identifier.bv_val = peek_head; 1467 (k->a.rfc822Name)->identifier.bv_len = strLen; 1468 } 1469 else if( strncmp("dNSName",peek_head,strlen("dNSName")) == 0){ 1470 (k->choiceId) = GENERALNAME_DNSNAME; 1471 rc = GDecComponentIA5String (mem_op, b, (&k->a.dNSName), bytesDecoded, DEC_ALLOC_MODE_0 ); 1472 if ( rc != LDAP_SUCCESS ) return rc; 1473 (k->a.dNSName)->identifier.bv_val = peek_head; 1474 (k->a.dNSName)->identifier.bv_len = strLen; 1475 } 1476 else if( strncmp("x400Address",peek_head,strlen("x400Address")) == 0){ 1477 (k->choiceId) = GENERALNAME_X400ADDRESS; 1478 rc = GDecComponentORAddress (mem_op, b, (&k->a.x400Address), bytesDecoded, mode); 1479 if ( rc != LDAP_SUCCESS ) return rc; 1480 (k->a.x400Address)->identifier.bv_val = peek_head; 1481 (k->a.x400Address)->identifier.bv_len = strLen; 1482 } 1483 else if( strncmp("directoryName",peek_head,strlen("directoryName")) == 0){ 1484 (k->choiceId) = GENERALNAME_DIRECTORYNAME; 1485 rc = GDecComponentName (mem_op, b, (&k->a.directoryName), bytesDecoded, mode); 1486 if ( rc != LDAP_SUCCESS ) return rc; 1487 (k->a.directoryName)->identifier.bv_val = peek_head; 1488 (k->a.directoryName)->identifier.bv_len = strLen; 1489 } 1490 else if( strncmp("ediPartyName",peek_head,strlen("ediPartyName")) == 0){ 1491 (k->choiceId) = GENERALNAME_EDIPARTYNAME; 1492 rc = GDecComponentEDIPartyName (mem_op, b, (&k->a.ediPartyName), bytesDecoded, mode); 1493 if ( rc != LDAP_SUCCESS ) return rc; 1494 (k->a.ediPartyName)->identifier.bv_val = peek_head; 1495 (k->a.ediPartyName)->identifier.bv_len = strLen; 1496 } 1497 else if( strncmp("uniformResourceIdentifier",peek_head,strlen("uniformResourceIdentifier")) == 0){ 1498 (k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER; 1499 rc = GDecComponentIA5String (mem_op, b, (&k->a.uniformResourceIdentifier), bytesDecoded, DEC_ALLOC_MODE_0 ); 1500 if ( rc != LDAP_SUCCESS ) return rc; 1501 (k->a.uniformResourceIdentifier)->identifier.bv_val = peek_head; 1502 (k->a.uniformResourceIdentifier)->identifier.bv_len = strLen; 1503 } 1504 else if( strncmp("iPAddress",peek_head,strlen("iPAddress")) == 0){ 1505 (k->choiceId) = GENERALNAME_IPADDRESS; 1506 rc = GDecComponentOcts (mem_op, b, (&k->a.iPAddress), bytesDecoded, DEC_ALLOC_MODE_0 ); 1507 if ( rc != LDAP_SUCCESS ) return rc; 1508 (k->a.iPAddress)->identifier.bv_val = peek_head; 1509 (k->a.iPAddress)->identifier.bv_len = strLen; 1510 } 1511 else if( strncmp("registeredID",peek_head,strlen("registeredID")) == 0){ 1512 (k->choiceId) = GENERALNAME_REGISTEREDID; 1513 rc = GDecComponentOid (mem_op, b, (&k->a.registeredID), bytesDecoded, DEC_ALLOC_MODE_0 ); 1514 if ( rc != LDAP_SUCCESS ) return rc; 1515 (k->a.registeredID)->identifier.bv_val = peek_head; 1516 (k->a.registeredID)->identifier.bv_len = strLen; 1517 } 1518 else { 1519 Asn1Error("Undefined Identifier"); 1520 return LDAP_PROTOCOL_ERROR; 1521 } 1522 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1523 *v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) ); 1524 if ( !t ) return -1; 1525 *t = *k; 1526 } 1527 t->syntax = (Syntax*)NULL; 1528 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1529 if ( !t->comp_desc ) { 1530 free ( t ); 1531 return -1; 1532 } 1533 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ; 1534 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ; 1535 t->comp_desc->cd_free = (comp_free_func*)NULL; 1536 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName; 1537 t->comp_desc->cd_type = ASN_COMPOSITE; 1538 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1539 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName; 1540 return LDAP_SUCCESS; 1541} /* GDecGeneralNameContent */ 1542 1543 1544int 1545MatchingComponentGeneralNames ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 1546 int rc; 1547 MatchingRule* mr; 1548 void* component1, *component2; 1549 AsnList *v1, *v2, t_list; 1550 1551 1552 if ( oid ) { 1553 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 1554 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 1555 } 1556 1557 v1 = &((ComponentGeneralNames*)csi_attr)->comp_list; 1558 v2 = &((ComponentGeneralNames*)csi_assert)->comp_list; 1559 FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2) 1560 { 1561 if( MatchingComponentGeneralName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) { 1562 return LDAP_COMPARE_FALSE; 1563 } 1564 } /* end of for */ 1565 1566 AsnListFirst( v1 ); 1567 AsnListFirst( v2 ); 1568 if( (!component1 && component2) || (component1 && !component2)) 1569 return LDAP_COMPARE_FALSE; 1570 else 1571 return LDAP_COMPARE_TRUE; 1572} /* BMatchingComponentGeneralNamesContent */ 1573 1574void* 1575ExtractingComponentGeneralNames ( void* mem_op, ComponentReference* cr, ComponentGeneralNames *comp ) 1576{ 1577 int count = 0; 1578 int total; 1579 AsnList *v = &comp->comp_list; 1580 ComponentInt *k; 1581 ComponentGeneralName *component; 1582 1583 1584 switch ( cr->cr_curr->ci_type ) { 1585 case LDAP_COMPREF_FROM_BEGINNING : 1586 count = cr->cr_curr->ci_val.ci_from_beginning; 1587 FOR_EACH_LIST_ELMT( component , v ) { 1588 if( --count == 0 ) { 1589 if( cr->cr_curr->ci_next == NULL ) 1590 return component; 1591 else { 1592 cr->cr_curr = cr->cr_curr->ci_next; 1593 return ExtractingComponentGeneralName ( mem_op, cr, component ); 1594 } 1595 } 1596 } 1597 break; 1598 case LDAP_COMPREF_FROM_END : 1599 total = AsnListCount ( v ); 1600 count = cr->cr_curr->ci_val.ci_from_end; 1601 count = total + count +1; 1602 FOR_EACH_LIST_ELMT ( component, v ) { 1603 if( --count == 0 ) { 1604 if( cr->cr_curr->ci_next == NULL ) 1605 return component; 1606 else { 1607 cr->cr_curr = cr->cr_curr->ci_next; 1608 return ExtractingComponentGeneralName ( mem_op, cr, component ); 1609 } 1610 } 1611 } 1612 break; 1613 case LDAP_COMPREF_ALL : 1614 return comp; 1615 case LDAP_COMPREF_COUNT : 1616 k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt)); 1617 k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1618 k->comp_desc->cd_tag = (-1); 1619 k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt; 1620 k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt; 1621 k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL; 1622 k->comp_desc->cd_type = ASN_BASIC; 1623 k->comp_desc->cd_type_id = BASICTYPE_INTEGER; 1624 k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt; 1625 k->value = AsnListCount(v); 1626 return k; 1627 default : 1628 return NULL; 1629 } 1630} /* ExtractingComponentGeneralNames */ 1631 1632int 1633BDecComponentGeneralNames PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 1634void* mem_op _AND_ 1635GenBuf * b _AND_ 1636AsnTag tagId0 _AND_ 1637AsnLen elmtLen0 _AND_ 1638ComponentGeneralNames **v _AND_ 1639AsnLen *bytesDecoded _AND_ 1640int mode) 1641{ 1642 int seqDone = FALSE; 1643 AsnLen totalElmtsLen1 = 0; 1644 AsnLen elmtLen1; 1645 AsnTag tagId1; 1646 int mandatoryElmtCount1 = 0; 1647 int old_mode = mode; 1648 int rc; 1649 ComponentGeneralNames *k, *t, c_temp; 1650 1651 1652 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1653 memset(&c_temp,0,sizeof(c_temp)); 1654 k = &c_temp; 1655 } else 1656 k = t = *v; 1657 mode = DEC_ALLOC_MODE_2; 1658 AsnListInit(&k->comp_list,sizeof(ComponentGeneralName)); 1659 for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) 1660 { 1661 ComponentGeneralName **tmpVar; 1662 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1663 1664 if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN)) 1665 { 1666 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 ) 1667 break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/ 1668 } 1669 elmtLen1 = BDecLen (b, &totalElmtsLen1); 1670 tmpVar = (ComponentGeneralName**) CompAsnListAppend (mem_op,&k->comp_list); 1671 rc = BDecComponentGeneralName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode); 1672 if ( rc != LDAP_SUCCESS ) return rc; 1673 } /* end of for */ 1674 1675 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1676 *v = t = (ComponentGeneralNames*) CompAlloc( mem_op, sizeof(ComponentGeneralNames) ); 1677 if ( !t ) return -1; 1678 *t = *k; 1679 } 1680 t->syntax = (Syntax*)NULL; 1681 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1682 if ( !t->comp_desc ) { 1683 free ( t ); 1684 return -1; 1685 } 1686 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralNames ; 1687 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralNames ; 1688 t->comp_desc->cd_free = (comp_free_func*)NULL; 1689 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralNames; 1690 t->comp_desc->cd_type = ASN_COMPOSITE; 1691 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1692 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralNames; 1693 (*bytesDecoded) += totalElmtsLen1; 1694 return LDAP_SUCCESS; 1695} /* BDecGeneralNamesContent */ 1696 1697int 1698GDecComponentGeneralNames PARAMS (( mem_op,b, v, bytesDecoded, mode), 1699void* mem_op _AND_ 1700GenBuf * b _AND_ 1701ComponentGeneralNames **v _AND_ 1702AsnLen *bytesDecoded _AND_ 1703int mode) 1704{ 1705 char* peek_head,*peek_head2; 1706 int i, strLen,strLen2, rc, old_mode = mode; 1707 ComponentGeneralNames *k,*t, c_temp; 1708 1709 1710 int ElmtsLen1; 1711 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1712 memset(&c_temp,0,sizeof(c_temp)); 1713 k = &c_temp; 1714 } else 1715 k = t = *v; 1716 mode = DEC_ALLOC_MODE_2; 1717 AsnListInit( &k->comp_list, sizeof( ComponentGeneralName ) ); 1718 *bytesDecoded = 0; 1719 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){ 1720 Asn1Error("Error during Reading { in encoding"); 1721 return LDAP_PROTOCOL_ERROR; 1722 } 1723 if(*peek_head != '{'){ 1724 Asn1Error("Missing { in encoded data"); 1725 return LDAP_PROTOCOL_ERROR; 1726 } 1727 1728 for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++) 1729 { 1730 ComponentGeneralName **tmpVar; 1731 if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){ 1732 Asn1Error("Error during Reading{ in encoding"); 1733 return LDAP_PROTOCOL_ERROR; 1734 } 1735 if(*peek_head == '}') break; 1736 if( !(*peek_head == '{' || *peek_head ==',') ) { 1737 return LDAP_PROTOCOL_ERROR; 1738 } 1739 tmpVar = (ComponentGeneralName**) CompAsnListAppend (mem_op, &k->comp_list); 1740 if ( tmpVar == NULL ) { 1741 Asn1Error("Error during Reading{ in encoding"); 1742 return LDAP_PROTOCOL_ERROR; 1743 } 1744 rc = GDecComponentGeneralName (mem_op, b, tmpVar, bytesDecoded, mode); 1745 if ( rc != LDAP_SUCCESS ) return rc; 1746 } /* end of for */ 1747 1748 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1749 *v = t = (ComponentGeneralNames*) CompAlloc( mem_op, sizeof(ComponentGeneralNames) ); 1750 if ( !t ) return -1; 1751 *t = *k; 1752 } 1753 t->syntax = (Syntax*)NULL; 1754 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1755 if ( !t->comp_desc ) { 1756 free ( t ); 1757 return -1; 1758 } 1759 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralNames ; 1760 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralNames ; 1761 t->comp_desc->cd_free = (comp_free_func*)NULL; 1762 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralNames; 1763 t->comp_desc->cd_type = ASN_COMPOSITE; 1764 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1765 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralNames; 1766 return LDAP_SUCCESS; 1767} /* GDecGeneralNamesContent */ 1768 1769 1770int 1771MatchingComponentAuthorityKeyIdentifier ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) { 1772 int rc; 1773 MatchingRule* mr; 1774 1775 if ( oid ) { 1776 mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id); 1777 if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); 1778 } 1779 1780 rc = 1; 1781 rc = MatchingComponentKeyIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentAuthorityKeyIdentifier*)csi_attr)->keyIdentifier, (ComponentSyntaxInfo*)&((ComponentAuthorityKeyIdentifier*)csi_assert)->keyIdentifier ); 1782 if ( rc != LDAP_COMPARE_TRUE ) 1783 return rc; 1784 if(COMPONENTNOT_NULL( ((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertIssuer ) ) { 1785 rc = MatchingComponentGeneralNames ( oid, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertIssuer, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_assert)->authorityCertIssuer ); 1786 if ( rc != LDAP_COMPARE_TRUE ) 1787 return rc; 1788 } 1789 if(COMPONENTNOT_NULL( ((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertSerialNumber ) ) { 1790 rc = MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertSerialNumber, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_assert)->authorityCertSerialNumber ); 1791 if ( rc != LDAP_COMPARE_TRUE ) 1792 return rc; 1793 } 1794 return LDAP_COMPARE_TRUE; 1795} /* BMatchingComponentAuthorityKeyIdentifier */ 1796 1797void* 1798ExtractingComponentAuthorityKeyIdentifier ( void* mem_op, ComponentReference* cr, ComponentAuthorityKeyIdentifier *comp ) 1799{ 1800 1801 if ( ( comp->keyIdentifier.identifier.bv_val && strncmp(comp->keyIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->keyIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 1802 if ( cr->cr_curr->ci_next == NULL ) 1803 return &comp->keyIdentifier; 1804 else 1805 return NULL; 1806 } 1807 if ( ( comp->authorityCertIssuer->identifier.bv_val && strncmp(comp->authorityCertIssuer->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->authorityCertIssuer->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 1808 if ( cr->cr_curr->ci_next == NULL ) 1809 return comp->authorityCertIssuer; 1810 else { 1811 cr->cr_curr = cr->cr_curr->ci_next; 1812 return ExtractingComponentGeneralNames ( mem_op, cr, comp->authorityCertIssuer ); 1813 } 1814 } 1815 if ( ( comp->authorityCertSerialNumber->identifier.bv_val && strncmp(comp->authorityCertSerialNumber->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->authorityCertSerialNumber->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) { 1816 if ( cr->cr_curr->ci_next == NULL ) 1817 return comp->authorityCertSerialNumber; 1818 else { 1819 cr->cr_curr = cr->cr_curr->ci_next; 1820 return ExtractingComponentCertificateSerialNumber ( mem_op, cr, comp->authorityCertSerialNumber ); 1821 } 1822 } 1823 return NULL; 1824} /* ExtractingComponentAuthorityKeyIdentifier */ 1825 1826int 1827BDecComponentAuthorityKeyIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode), 1828void* mem_op _AND_ 1829GenBuf * b _AND_ 1830AsnTag tagId0 _AND_ 1831AsnLen elmtLen0 _AND_ 1832ComponentAuthorityKeyIdentifier **v _AND_ 1833AsnLen *bytesDecoded _AND_ 1834int mode) 1835{ 1836 int seqDone = FALSE; 1837 AsnLen totalElmtsLen1 = 0; 1838 AsnLen elmtLen1; 1839 AsnTag tagId1; 1840 int mandatoryElmtCount1 = 0; 1841 AsnLen totalElmtsLen2 = 0; 1842 AsnLen elmtLen2; 1843 AsnTag tagId2; 1844 int old_mode = mode; 1845 int rc; 1846 ComponentAuthorityKeyIdentifier *k, *t, c_temp; 1847 1848 1849 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1850 memset(&c_temp,0,sizeof(c_temp)); 1851 k = &c_temp; 1852 } else 1853 k = t = *v; 1854 mode = DEC_ALLOC_MODE_2; 1855 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) 1856 seqDone = TRUE; 1857 else 1858 { 1859 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1860 1861 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) 1862 { 1863 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 ) 1864 seqDone = TRUE; 1865 } 1866 } 1867 1868 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) || 1869(tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)))) 1870 { 1871 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1872 rc = BDecComponentKeyIdentifier (mem_op, b, tagId1, elmtLen1, (&k->keyIdentifier), &totalElmtsLen1, mode); 1873 if ( rc != LDAP_SUCCESS ) return rc; 1874 (&k->keyIdentifier)->identifier.bv_val = (&k->keyIdentifier)->id_buf; 1875 (&k->keyIdentifier)->identifier.bv_len = strlen("keyIdentifier"); 1876 strcpy( (&k->keyIdentifier)->identifier.bv_val, "keyIdentifier"); 1877 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) 1878 seqDone = TRUE; 1879 else 1880 { 1881 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1882 1883 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) 1884 { 1885 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 ) 1886 seqDone = TRUE; 1887 } 1888 } 1889 } 1890 1891 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)))) 1892 { 1893 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1894 rc = BDecComponentGeneralNames (mem_op, b, tagId1, elmtLen1, 1895(&k->authorityCertIssuer), &totalElmtsLen1, mode); 1896 if ( rc != LDAP_SUCCESS ) return rc; 1897 (k->authorityCertIssuer)->identifier.bv_val = (k->authorityCertIssuer)->id_buf; 1898 (k->authorityCertIssuer)->identifier.bv_len = strlen("authorityCertIssuer"); 1899 strcpy( (k->authorityCertIssuer)->identifier.bv_val, "authorityCertIssuer"); 1900 if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0)) 1901 seqDone = TRUE; 1902 else 1903 { 1904 tagId1 = BDecTag (b, &totalElmtsLen1 ); 1905 1906 if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID)) 1907 { 1908 BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 ) 1909 seqDone = TRUE; 1910 } 1911 } 1912 } 1913 1914 if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)))) 1915 { 1916 elmtLen1 = BDecLen (b, &totalElmtsLen1 ); 1917 rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->authorityCertSerialNumber), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; 1918 (k->authorityCertSerialNumber)->identifier.bv_val = (k->authorityCertSerialNumber)->id_buf; 1919 (k->authorityCertSerialNumber)->identifier.bv_len = strlen("authorityCertSerialNumber"); 1920 strcpy( (k->authorityCertSerialNumber)->identifier.bv_val, "authorityCertSerialNumber"); 1921 seqDone = TRUE; 1922 if (elmtLen0 == INDEFINITE_LEN) 1923 BDecEoc (b, &totalElmtsLen1 ); 1924 else if (totalElmtsLen1 != elmtLen0) 1925 return -1; 1926 1927 } 1928 1929 if (!seqDone) 1930 return -1; 1931 1932 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 1933 *v = t = (ComponentAuthorityKeyIdentifier*) CompAlloc( mem_op, sizeof(ComponentAuthorityKeyIdentifier) ); 1934 if ( !t ) return -1; 1935 *t = *k; 1936 } 1937 t->syntax = (Syntax*)NULL; 1938 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 1939 if ( !t->comp_desc ) { 1940 free ( t ); 1941 return -1; 1942 } 1943 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAuthorityKeyIdentifier ; 1944 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAuthorityKeyIdentifier ; 1945 t->comp_desc->cd_free = (comp_free_func*)NULL; 1946 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAuthorityKeyIdentifier; 1947 t->comp_desc->cd_type = ASN_COMPOSITE; 1948 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 1949 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAuthorityKeyIdentifier; 1950 (*bytesDecoded) += totalElmtsLen1; 1951 return LDAP_SUCCESS; 1952} /* BDecAuthorityKeyIdentifier*/ 1953 1954int 1955GDecComponentAuthorityKeyIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode), 1956void* mem_op _AND_ 1957GenBuf * b _AND_ 1958ComponentAuthorityKeyIdentifier **v _AND_ 1959AsnLen *bytesDecoded _AND_ 1960int mode) 1961{ 1962 char* peek_head,*peek_head2; 1963 int i, strLen,strLen2, rc, old_mode = mode; 1964 ComponentAuthorityKeyIdentifier *k,*t, c_temp; 1965 1966 1967 if ( !(mode & DEC_ALLOC_MODE_1) ) { 1968 memset(&c_temp,0,sizeof(c_temp)); 1969 k = &c_temp; 1970 } else 1971 k = t = *v; 1972 mode = DEC_ALLOC_MODE_2; 1973 *bytesDecoded = 0; 1974 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 1975 Asn1Error("Error during Reading { in encoded data"); 1976 return LDAP_PROTOCOL_ERROR; 1977 } 1978 if(*peek_head != '{'){ 1979 Asn1Error("Missing { in encoded data"); 1980 return LDAP_PROTOCOL_ERROR; 1981 } 1982 1983 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 1984 Asn1Error("Error during Reading identifier"); 1985 return LDAP_PROTOCOL_ERROR; 1986 } 1987 if ( strncmp( peek_head, "keyIdentifier", strlen("keyIdentifier") ) == 0 ) { 1988 rc = GDecComponentKeyIdentifier (mem_op, b, (&k->keyIdentifier), bytesDecoded, mode); 1989 if ( rc != LDAP_SUCCESS ) return rc; 1990 (&k->keyIdentifier)->identifier.bv_val = peek_head; 1991 (&k->keyIdentifier)->identifier.bv_len = strLen; 1992 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 1993 Asn1Error("Error during Reading , "); 1994 return LDAP_PROTOCOL_ERROR; 1995 } 1996 if(*peek_head != ','){ 1997 Asn1Error("Missing , in encoding"); 1998 return LDAP_PROTOCOL_ERROR; 1999 } 2000 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 2001 Asn1Error("Error during Reading identifier"); 2002 return LDAP_PROTOCOL_ERROR; 2003 } 2004 } 2005 if ( strncmp( peek_head, "authorityCertIssuer", strlen("authorityCertIssuer") ) == 0 ) { 2006 rc = GDecComponentGeneralNames (mem_op, b, (&k->authorityCertIssuer), bytesDecoded, mode); 2007 if ( rc != LDAP_SUCCESS ) return rc; 2008 ( k->authorityCertIssuer)->identifier.bv_val = peek_head; 2009 ( k->authorityCertIssuer)->identifier.bv_len = strLen; 2010 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 2011 Asn1Error("Error during Reading , "); 2012 return LDAP_PROTOCOL_ERROR; 2013 } 2014 if(*peek_head != ','){ 2015 Asn1Error("Missing , in encoding"); 2016 return LDAP_PROTOCOL_ERROR; 2017 } 2018 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ 2019 Asn1Error("Error during Reading identifier"); 2020 return LDAP_PROTOCOL_ERROR; 2021 } 2022 } 2023 if ( strncmp( peek_head, "authorityCertSerialNumber", strlen("authorityCertSerialNumber") ) == 0 ) { 2024 rc = GDecComponentCertificateSerialNumber (mem_op, b, (&k->authorityCertSerialNumber), bytesDecoded, DEC_ALLOC_MODE_0 ); 2025 if ( rc != LDAP_SUCCESS ) return rc; 2026 ( k->authorityCertSerialNumber)->identifier.bv_val = peek_head; 2027 ( k->authorityCertSerialNumber)->identifier.bv_len = strLen; 2028 } 2029 if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) { 2030 Asn1Error("Error during Reading } in encoding"); 2031 return LDAP_PROTOCOL_ERROR; 2032 } 2033 if(*peek_head != '}'){ 2034 Asn1Error("Missing } in encoding"); 2035 return LDAP_PROTOCOL_ERROR; 2036 } 2037 if( !(old_mode & DEC_ALLOC_MODE_1) ) { 2038 *v = t = (ComponentAuthorityKeyIdentifier*) CompAlloc( mem_op, sizeof(ComponentAuthorityKeyIdentifier) ); 2039 if ( !t ) return -1; 2040 *t = *k; 2041 } 2042 t->syntax = (Syntax*)NULL; 2043 t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); 2044 if ( !t->comp_desc ) { 2045 free ( t ); 2046 return -1; 2047 } 2048 t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAuthorityKeyIdentifier ; 2049 t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAuthorityKeyIdentifier ; 2050 t->comp_desc->cd_free = (comp_free_func*)NULL; 2051 t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAuthorityKeyIdentifier; 2052 t->comp_desc->cd_type = ASN_COMPOSITE; 2053 t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE; 2054 t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAuthorityKeyIdentifier; 2055 return LDAP_SUCCESS; 2056} /* GDecAuthorityKeyIdentifier*/ 2057 2058 2059