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