⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authoritykeyidentifier.c

📁 OpenLdap是LDAP的开源项目
💻 C
📖 第 1 页 / 共 5 页
字号:
	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentEDIPartyName*) CompAlloc( mem_op, sizeof(ComponentEDIPartyName) );	if ( !t ) return -1;	*t = *k;	}	t->syntax = (Syntax*)NULL;	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );	if ( !t->comp_desc ) {		free ( t );		return -1;	}	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEDIPartyName ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEDIPartyName ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentEDIPartyName;	t->comp_desc->cd_type = ASN_COMPOSITE;	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEDIPartyName;	return LDAP_SUCCESS;}  /* GDecEDIPartyName*/intMatchingComponentGeneralName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	ComponentGeneralName *v1, *v2;	v1 = (ComponentGeneralName*)csi_attr;	v2 = (ComponentGeneralName*)csi_assert;	if ( oid ) {		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );	}	if( (v1->choiceId != v2->choiceId ) )		return LDAP_COMPARE_FALSE;	switch( v1->choiceId )	{	   case GENERALNAME_OTHERNAME :		rc = 	MatchingComponentOtherName ( oid, (ComponentSyntaxInfo*)(v1->a.otherName), (ComponentSyntaxInfo*)(v2->a.otherName) );		break;	   case GENERALNAME_RFC822NAME :		rc = 	MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.rfc822Name), (ComponentSyntaxInfo*)(v2->a.rfc822Name) );		break;	   case GENERALNAME_DNSNAME :		rc = 	MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.dNSName), (ComponentSyntaxInfo*)(v2->a.dNSName) );		break;	   case GENERALNAME_X400ADDRESS :		rc = 	MatchingComponentORAddress ( oid, (ComponentSyntaxInfo*)(v1->a.x400Address), (ComponentSyntaxInfo*)(v2->a.x400Address) );		break;	   case GENERALNAME_DIRECTORYNAME :		rc = 	MatchingComponentName ( oid, (ComponentSyntaxInfo*)(v1->a.directoryName), (ComponentSyntaxInfo*)(v2->a.directoryName) );		break;	   case GENERALNAME_EDIPARTYNAME :		rc = 	MatchingComponentEDIPartyName ( oid, (ComponentSyntaxInfo*)(v1->a.ediPartyName), (ComponentSyntaxInfo*)(v2->a.ediPartyName) );		break;	   case GENERALNAME_UNIFORMRESOURCEIDENTIFIER :		rc = 	MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.uniformResourceIdentifier), (ComponentSyntaxInfo*)(v2->a.uniformResourceIdentifier) );		break;	   case GENERALNAME_IPADDRESS :		rc = 	MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)(v1->a.iPAddress), (ComponentSyntaxInfo*)(v2->a.iPAddress) );		break;	   case GENERALNAME_REGISTEREDID :		rc = 	MatchingComponentOid ( oid, (ComponentSyntaxInfo*)(v1->a.registeredID), (ComponentSyntaxInfo*)(v2->a.registeredID) );		break;	default : 		 return LDAP_PROTOCOL_ERROR;	}	return rc;}  /* BMatchingComponentGeneralNameContent */void*ExtractingComponentGeneralName ( void* mem_op, ComponentReference* cr, ComponentGeneralName *comp ){	if( (comp->choiceId) ==  GENERALNAME_OTHERNAME &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.otherName);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentOtherName ( mem_op, cr, (comp->a.otherName) );		};	}	if( (comp->choiceId) ==  GENERALNAME_RFC822NAME &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.rfc822Name);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentIA5String ( mem_op, cr, (comp->a.rfc822Name) );		};	}	if( (comp->choiceId) ==  GENERALNAME_DNSNAME &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.dNSName);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentIA5String ( mem_op, cr, (comp->a.dNSName) );		};	}	if( (comp->choiceId) ==  GENERALNAME_X400ADDRESS &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.x400Address);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentORAddress ( mem_op, cr, (comp->a.x400Address) );		};	}	if( (comp->choiceId) ==  GENERALNAME_DIRECTORYNAME &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.directoryName);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentName ( mem_op, cr, (comp->a.directoryName) );		};	}	if( (comp->choiceId) ==  GENERALNAME_EDIPARTYNAME &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.ediPartyName);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentEDIPartyName ( mem_op, cr, (comp->a.ediPartyName) );		};	}	if( (comp->choiceId) ==  GENERALNAME_UNIFORMRESOURCEIDENTIFIER &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.uniformResourceIdentifier);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentIA5String ( mem_op, cr, (comp->a.uniformResourceIdentifier) );		};	}	if( (comp->choiceId) ==  GENERALNAME_IPADDRESS &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.iPAddress);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentOcts ( mem_op, cr, (comp->a.iPAddress) );		};	}	if( (comp->choiceId) ==  GENERALNAME_REGISTEREDID &&		 (( 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) ||		 ( 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))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.registeredID);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentOid ( mem_op, cr, (comp->a.registeredID) );		};	}	return NULL;}  /* ExtractingComponentGeneralName */intBDecComponentGeneralName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentGeneralName **v _AND_AsnLen *bytesDecoded _AND_int mode){	int seqDone = FALSE;	AsnLen totalElmtsLen1 = 0;	AsnLen elmtLen1;	AsnTag tagId1;	int mandatoryElmtCount1 = 0;	AsnLen totalElmtsLen2 = 0;	AsnLen elmtLen2;	AsnTag tagId2;	AsnLen totalElmtsLen3 = 0;	AsnLen elmtLen3;	AsnTag tagId3;	int old_mode = mode;	int rc;	ComponentGeneralName *k, *t, c_temp;	if ( !(mode & DEC_ALLOC_MODE_1) ) {		memset(&c_temp,0,sizeof(c_temp));		 k = &c_temp;	} else		 k = t = *v;	mode = DEC_ALLOC_MODE_2;    switch (tagId0)    {       case MAKE_TAG_ID (CNTX, CONS, 0):if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_OTHERNAME;		rc = 	BDecComponentOtherName (mem_op, b, tagId1, elmtLen1, (&k->a.otherName), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.otherName)->identifier.bv_val = (k->a.otherName)->id_buf;		(k->a.otherName)->identifier.bv_len = strlen("otherName");		strcpy( (k->a.otherName)->identifier.bv_val, "otherName");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 1):    tagId1 = BDecTag (b, &totalElmtsLen1 );if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&   (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_RFC822NAME;		rc = 	BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.rfc822Name), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.rfc822Name)->identifier.bv_val = (k->a.rfc822Name)->id_buf;		(k->a.rfc822Name)->identifier.bv_len = strlen("rfc822Name");		strcpy( (k->a.rfc822Name)->identifier.bv_val, "rfc822Name");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 2):    tagId1 = BDecTag (b, &totalElmtsLen1 );if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&   (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_DNSNAME;		rc = 	BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.dNSName), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.dNSName)->identifier.bv_val = (k->a.dNSName)->id_buf;		(k->a.dNSName)->identifier.bv_len = strlen("dNSName");		strcpy( (k->a.dNSName)->identifier.bv_val, "dNSName");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 3):if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_X400ADDRESS;		rc = 	BDecComponentORAddress (mem_op, b, tagId1, elmtLen1, (&k->a.x400Address), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.x400Address)->identifier.bv_val = (k->a.x400Address)->id_buf;		(k->a.x400Address)->identifier.bv_len = strlen("x400Address");		strcpy( (k->a.x400Address)->identifier.bv_val, "x400Address");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 4):        (k->choiceId) = GENERALNAME_DIRECTORYNAME;		tagId1 = BDecTag (b, &totalElmtsLen1 );    elmtLen1 = BDecLen (b, &totalElmtsLen1 );	rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->a.directoryName), &totalElmtsLen1, mode);    if (elmtLen0 == INDEFINITE_LEN)        BDecEoc(b, &totalElmtsLen1 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.directoryName)->identifier.bv_val = (k->a.directoryName)->id_buf;		(k->a.directoryName)->identifier.bv_len = strlen("directoryName");		strcpy( (k->a.directoryName)->identifier.bv_val, "directoryName");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 5):if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_EDIPARTYNAME;		rc = 	BDecComponentEDIPartyName (mem_op, b, tagId1, elmtLen1, (&k->a.ediPartyName), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.ediPartyName)->identifier.bv_val = (k->a.ediPartyName)->id_buf;		(k->a.ediPartyName)->identifier.bv_len = strlen("ediPartyName");		strcpy( (k->a.ediPartyName)->identifier.bv_val, "ediPartyName");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 6):    tagId1 = BDecTag (b, &totalElmtsLen1 );if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&   (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER;		rc = 	BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.uniformResourceIdentifier), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.uniformResourceIdentifier)->identifier.bv_val = (k->a.uniformResourceIdentifier)->id_buf;		(k->a.uniformResourceIdentifier)->identifier.bv_len = strlen("uniformResourceIdentifier");		strcpy( (k->a.uniformResourceIdentifier)->identifier.bv_val, "uniformResourceIdentifier");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 7):    tagId1 = BDecTag (b, &totalElmtsLen1 );if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) &&   (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))    {         Asn1Error ("Unexpected Tag\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -