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

📄 crl.c

📁 ldap服务器源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* *    crl.c *    "CertificateRevokationList" ASN.1 module encode/decode/extracting/matching/free C src. *    This file was generated by modified eSMACC compiler Fri Jan 21 11:25:24 2005 *    The generated files are supposed to be compiled as a module for OpenLDAP Software */#include "crl.h"BDecComponentCertificateListTop( void* mem_op, GenBuf* b, void *v, AsnLen* bytesDecoded,int mode) {	AsnTag tag;	AsnLen elmtLen;	tag = BDecTag ( b, bytesDecoded );	elmtLen = BDecLen ( b, bytesDecoded );	if ( elmtLen <= 0 ) return (-1);	if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {		return (-1);	}			return BDecComponentCertificateList( mem_op, b, tag, elmtLen, ( ComponentCertificateList**)v, (AsnLen*)bytesDecoded, mode );}void init_module_CertificateRevokationList() {	InstallOidDecoderMapping( "2.5.4.39", NULL,		GDecComponentCertificateList,		BDecComponentCertificateListTop,		ExtractingComponentCertificateList,		MatchingComponentCertificateList);}intMatchingComponentTBSCertListSeqOfSeq ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	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 );	}	rc = 1;	rc =	MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertListSeqOfSeq*)csi_attr)->userCertificate, (ComponentSyntaxInfo*)&((ComponentTBSCertListSeqOfSeq*)csi_assert)->userCertificate );	if ( rc != LDAP_COMPARE_TRUE )		return rc;	rc =	MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_attr)->revocationDate, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_assert)->revocationDate );	if ( rc != LDAP_COMPARE_TRUE )		return rc;	if(COMPONENTNOT_NULL( ((ComponentTBSCertListSeqOfSeq*)csi_attr)->crlEntryExtensions ) ) {	rc =	MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_attr)->crlEntryExtensions, (ComponentSyntaxInfo*)((ComponentTBSCertListSeqOfSeq*)csi_assert)->crlEntryExtensions );	if ( rc != LDAP_COMPARE_TRUE )		return rc;	}	return LDAP_COMPARE_TRUE;}  /* BMatchingComponentTBSCertListSeqOfSeq */void*ExtractingComponentTBSCertListSeqOfSeq ( void* mem_op, ComponentReference* cr, ComponentTBSCertListSeqOfSeq *comp ){	if ( ( comp->userCertificate.identifier.bv_val && strncmp(comp->userCertificate.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->userCertificate.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->userCertificate;		else		return NULL;	}	if ( ( comp->revocationDate->identifier.bv_val && strncmp(comp->revocationDate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->revocationDate->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->revocationDate;		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentTime ( mem_op, cr, comp->revocationDate );		}	}	if ( ( comp->crlEntryExtensions->identifier.bv_val && strncmp(comp->crlEntryExtensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->crlEntryExtensions->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->crlEntryExtensions;		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentExtensions ( mem_op, cr, comp->crlEntryExtensions );		}	}	return NULL;}  /* ExtractingComponentTBSCertListSeqOfSeq */intBDecComponentTBSCertListSeqOfSeq PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentTBSCertListSeqOfSeq **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;	int old_mode = mode;	int rc;	ComponentTBSCertListSeqOfSeq *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;    tagId1 = BDecTag (b, &totalElmtsLen1 );    if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))    {    elmtLen1 = BDecLen (b, &totalElmtsLen1 );	rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->userCertificate), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(&k->userCertificate)->identifier.bv_val = (&k->userCertificate)->id_buf;		(&k->userCertificate)->identifier.bv_len = strlen("userCertificate");		strcpy( (&k->userCertificate)->identifier.bv_val, "userCertificate");    tagId1 = BDecTag (b, &totalElmtsLen1);    }    else        return -1;    if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||(tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||     (tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||    (tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))    {        elmtLen1 = BDecLen (b, &totalElmtsLen1 );	rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->revocationDate), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->revocationDate)->identifier.bv_val = (k->revocationDate)->id_buf;		(k->revocationDate)->identifier.bv_len = strlen("revocationDate");		strcpy( (k->revocationDate)->identifier.bv_val, "revocationDate");    if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))        seqDone = TRUE;    else    {        tagId1 = BDecTag (b, &totalElmtsLen1 );         if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))        {            BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )            seqDone = TRUE;        }    }    }    else        return -1;    if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))    {    elmtLen1 = BDecLen (b, &totalElmtsLen1 );	rc = BDecComponentExtensions (mem_op, b, tagId1, elmtLen1, (&k->crlEntryExtensions), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->crlEntryExtensions)->identifier.bv_val = (k->crlEntryExtensions)->id_buf;		(k->crlEntryExtensions)->identifier.bv_len = strlen("crlEntryExtensions");		strcpy( (k->crlEntryExtensions)->identifier.bv_val, "crlEntryExtensions");        seqDone = TRUE;        if (elmtLen0 == INDEFINITE_LEN)            BDecEoc (b, &totalElmtsLen1 );        else if (totalElmtsLen1 != elmtLen0)        return -1;    }    if (!seqDone)        return -1;	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentTBSCertListSeqOfSeq*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOfSeq) );	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_ldap_encoder = (encoder_func*)NULL;	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOfSeq ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOfSeq ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOfSeq;	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*)MatchingComponentTBSCertListSeqOfSeq;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecTBSCertListSeqOfSeq*/intGDecComponentTBSCertListSeqOfSeq PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentTBSCertListSeqOfSeq **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_head,*peek_head2;	int i, strLen,strLen2, rc, old_mode = mode;	ComponentTBSCertListSeqOfSeq *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;	*bytesDecoded = 0;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading { in encoded data");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != '{'){		Asn1Error("Missing { in encoded data");		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, "userCertificate", strlen("userCertificate") ) == 0 ) {		rc = 	GDecComponentCertificateSerialNumber (mem_op, b, (&k->userCertificate), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	(&k->userCertificate)->identifier.bv_val = peek_head;	(&k->userCertificate)->identifier.bv_len = strLen;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading , ");		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, "revocationDate", strlen("revocationDate") ) == 0 ) {		rc = 	GDecComponentTime (mem_op, b, (&k->revocationDate), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	( k->revocationDate)->identifier.bv_val = peek_head;	( k->revocationDate)->identifier.bv_len = strLen;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading , ");		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, "crlEntryExtensions", strlen("crlEntryExtensions") ) == 0 ) {		rc = 	GDecComponentExtensions (mem_op, b, (&k->crlEntryExtensions), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	( k->crlEntryExtensions)->identifier.bv_val = peek_head;	( k->crlEntryExtensions)->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 = (ComponentTBSCertListSeqOfSeq*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOfSeq) );	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_ldap_encoder = (encoder_func*)NULL;	t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;	t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertListSeqOfSeq ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOfSeq ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOfSeq;	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*)MatchingComponentTBSCertListSeqOfSeq;	return LDAP_SUCCESS;}  /* GDecTBSCertListSeqOfSeq*/intMatchingComponentTBSCertListSeqOf ( 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);

⌨️ 快捷键说明

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