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

📄 certificate.c

📁 ldap服务器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != ','){		Asn1Error("Missing , in encoding");		return LDAP_PROTOCOL_ERROR;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){	  Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	}	if ( strncmp( peek_head, "subjectPublicKey", strlen("subjectPublicKey") ) == 0 ) {		rc = 	GDecComponentBits (mem_op, b, (&k->subjectPublicKey), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	(&k->subjectPublicKey)->identifier.bv_val = peek_head;	(&k->subjectPublicKey)->identifier.bv_len = strLen;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {		Asn1Error("Error during Reading } in encoding");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != '}'){		Asn1Error("Missing } in encoding");		return LDAP_PROTOCOL_ERROR;	}	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );	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*)GDecComponentSubjectPublicKeyInfo ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;	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*)MatchingComponentSubjectPublicKeyInfo;	return LDAP_SUCCESS;}  /* GDecSubjectPublicKeyInfo*/intMatchingComponentExtensions ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	void* component1, *component2;	AsnList *v1, *v2, t_list;	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 );	}	v1 = &((ComponentExtensions*)csi_attr)->comp_list;	v2 = &((ComponentExtensions*)csi_assert)->comp_list;	FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)	{		if( MatchingComponentExtension(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {			return LDAP_COMPARE_FALSE;		}	} /* end of for */	AsnListFirst( v1 );	AsnListFirst( v2 );	if( (!component1 && component2) || (component1 && !component2))		return LDAP_COMPARE_FALSE;	else		return LDAP_COMPARE_TRUE;}  /* BMatchingComponentExtensionsContent */void*ExtractingComponentExtensions ( void* mem_op, ComponentReference* cr, ComponentExtensions *comp ){	int count = 0;	int total;	AsnList *v = &comp->comp_list;	ComponentInt *k;	ComponentExtension *component;	switch ( cr->cr_curr->ci_type ) {	case LDAP_COMPREF_FROM_BEGINNING :		count = cr->cr_curr->ci_val.ci_from_beginning;		FOR_EACH_LIST_ELMT( component , v ) {			if( --count == 0 ) {				if( cr->cr_curr->ci_next == NULL )					return component;				else {					cr->cr_curr = cr->cr_curr->ci_next;					return 	ExtractingComponentExtension ( mem_op, cr, component );				}			}		}		break;	case LDAP_COMPREF_FROM_END :		total = AsnListCount ( v );		count = cr->cr_curr->ci_val.ci_from_end;		count = total + count +1;		FOR_EACH_LIST_ELMT ( component, v ) {			if( --count == 0 ) {				if( cr->cr_curr->ci_next == NULL ) 					return component;				else {					cr->cr_curr = cr->cr_curr->ci_next;					return 	ExtractingComponentExtension ( mem_op, cr, component );				}			}		}		break;	case LDAP_COMPREF_ALL :		return comp;	case LDAP_COMPREF_COUNT :		k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));		k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );		k->comp_desc->cd_tag = (-1);		k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;		k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;		k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;		k->comp_desc->cd_type = ASN_BASIC;		k->comp_desc->cd_type_id = BASICTYPE_INTEGER;		k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;		k->value = AsnListCount(v);		return k;	default :		return NULL;	}}  /* ExtractingComponentExtensions */intBDecComponentExtensions PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentExtensions **v _AND_AsnLen *bytesDecoded _AND_int mode){	int seqDone = FALSE;	AsnLen totalElmtsLen1 = 0;	AsnLen elmtLen1;	AsnTag tagId1;	int mandatoryElmtCount1 = 0;	int old_mode = mode;	int rc;	ComponentExtensions *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;	AsnListInit(&k->comp_list,sizeof(ComponentExtension));    for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)    {        ComponentExtension **tmpVar;    tagId1 = BDecTag (b, &totalElmtsLen1 );    if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))    {        BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )        break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/    }    if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))    {        elmtLen1 = BDecLen (b, &totalElmtsLen1 );    tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op,&k->comp_list);	rc = BDecComponentExtension (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;    }  /* end of tag check if */    else  /* wrong tag */    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    } /* end of for */	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );	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*)GDecComponentExtensions ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;	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*)MatchingComponentExtensions;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecExtensionsContent */intGDecComponentExtensions PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentExtensions **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_head,*peek_head2;	int i, strLen,strLen2, rc, old_mode = mode;	ComponentExtensions *k,*t, c_temp;	int ElmtsLen1;	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;	AsnListInit( &k->comp_list, sizeof( ComponentExtension ) );	*bytesDecoded = 0;	if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){		Asn1Error("Error during Reading { in encoding");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != '{'){		Asn1Error("Missing { in encoded data");		return LDAP_PROTOCOL_ERROR;	}	for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)	{		ComponentExtension **tmpVar;		if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){			Asn1Error("Error during Reading{ in encoding");			return LDAP_PROTOCOL_ERROR;		}		if(*peek_head == '}') break;		if( !(*peek_head == '{' || *peek_head ==',') ) {			return LDAP_PROTOCOL_ERROR;		}		tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op, &k->comp_list);		if ( tmpVar == NULL ) {			Asn1Error("Error during Reading{ in encoding");			return LDAP_PROTOCOL_ERROR;		}		rc = 	GDecComponentExtension (mem_op, b, tmpVar, bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	} /* end of for */	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );	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*)GDecComponentExtensions ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;	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*)MatchingComponentExtensions;	return LDAP_SUCCESS;}  /* GDecExtensionsContent */intMatchingComponentRelativeDistinguishedName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	void* component1, *component2;	AsnList *v1, *v2, t_list;	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 );	}	v1 = &((ComponentRelativeDistinguishedName*)csi_attr)->comp_list;	v2 = &((ComponentRelativeDistinguishedName*)csi_assert)->comp_list;	AsnListInit( &t_list, 0 );	if( AsnListCount( v1 ) != AsnListCount( v2 ) )		return LDAP_COMPARE_FALSE;	FOR_EACH_LIST_ELMT (component1, v1)	{		FOR_EACH_LIST_ELMT(component2, v2)		{			if( MatchingComponentAttributeTypeAndValue(oid, (ComponentSyntaxInfo*)component1,(ComponentSyntaxInfo*)component2) == LDAP_COMPARE_TRUE ) {			AsnElmtMove( v2, &t_list );			   break;			}		} /* end of inner for */	} /* end of outer for */	if( AsnListCount( v2 ) == 0 )		 rc = LDAP_COMPARE_TRUE;	else		 rc = LDAP_COMPARE_FALSE;	AsnListMove( &t_list, v2 );	AsnListFirst( v1 );	AsnListFirst( v2 );	return rc;}  /* BMatchingComponentRelativeDistinguishedNameContent */void*ExtractingComponentRelativeDistinguishedName ( void* mem_op, ComponentReference* cr, ComponentRelativeDistinguishedName *comp ){	int count = 0;	int total;	AsnList *v = &comp->comp_list;	ComponentInt *k;	ComponentAttributeTypeAndValue *component;	switch ( cr->cr_curr->ci_type ) {	case LDAP_COMPREF_FROM_BEGINNING :		count = cr->cr_curr->ci_val.ci_from_beginning;		FOR_EACH_LIST_ELMT( component , v ) {			if( --count == 0 ) {				if( cr->cr_curr->ci_next == NULL )					return component;				else {					cr->cr_curr = cr->cr_curr->ci_next;					return 	ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );				}			}		}		break;	case LDAP_COMPREF_FROM_END :		total = AsnListCount ( v );		count = cr->cr_curr->ci_val.ci_from_end;		count = total + count +1;		FOR_EACH_LIST_ELMT ( component, v ) {			if( --count == 0 ) 

⌨️ 快捷键说明

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