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

📄 certificate.c

📁 ldap服务器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *    certificate.c *    "AuthenticationFramework" ASN.1 module encode/decode/extracting/matching/free C src. *    This file was generated by modified eSMACC compiler Sat Dec 11 11:22:49 2004 *    The generated files are supposed to be compiled as a module for OpenLDAP Software */#include "certificate.h"BDecComponentCertificateTop( 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 BDecComponentCertificate( mem_op, b, tag, elmtLen, (ComponentCertificate**)v,(AsnLen*)bytesDecoded, mode );}void init_module_AuthenticationFramework() {	/* Register Certificate OID and its decoder */	InstallOidDecoderMapping( "2.5.4.36", NULL,				GDecComponentCertificate,				BDecComponentCertificateTop,				ExtractingComponentCertificate,				MatchingComponentCertificate );	InitAnyAuthenticationFramework();}void InitAnyAuthenticationFramework(){    AsnOid oid0 ={ 9, "\52\206\110\206\367\15\1\1\4" };    AsnOid oid1 ={ 9, "\52\206\110\206\367\15\1\1\1" };    AsnOid oid2 ={ 9, "\52\206\110\206\367\15\1\1\5" };    AsnOid oid3 ={ 3, "\125\4\3" };    AsnOid oid4 ={ 3, "\125\4\6" };    AsnOid oid5 ={ 3, "\125\4\7" };    AsnOid oid6 ={ 3, "\125\4\10" };    AsnOid oid7 ={ 3, "\125\4\12" };    AsnOid oid8 ={ 3, "\125\4\13" };    AsnOid oid9 ={ 10, "\11\222\46\211\223\362\54\144\1\3" };    AsnOid oid10 ={ 9, "\52\206\110\206\367\15\1\11\1" };    AsnOid oid11 ={ 3, "\125\35\23" };    AsnOid oid12 ={ 9, "\140\206\110\1\206\370\102\1\15" };    AsnOid oid13 ={ 3, "\125\35\16" };    AsnOid oid14 ={ 3, "\125\35\25" };    AsnOid oid15 ={ 3, "\125\35\24" };    AsnOid oid17 ={ 3, "\125\35\34" };    InstallAnyByComponentOid (nullOid_ANY_ID, &oid0, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);    InstallAnyByComponentOid (nullOid2_ANY_ID, &oid1, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);    InstallAnyByComponentOid (nullOid3_ANY_ID, &oid2, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid_ANY_ID, &oid3, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid2_ANY_ID, &oid4, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid3_ANY_ID, &oid5, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid4_ANY_ID, &oid6, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid5_ANY_ID, &oid7, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid6_ANY_ID, &oid8, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);    InstallAnyByComponentOid (printableStringOid7_ANY_ID, &oid9, sizeof (ComponentTeletexString), (EncodeFcn)BEncTeletexString, (gser_decoder_func*)GDecComponentTeletexString, (ber_tag_decoder_func*)BDecComponentTeletexStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentTeletexString,(FreeFcn)FreeComponentTeletexString, (PrintFcn)NULL);    InstallAnyByComponentOid (iA5StringOid_ANY_ID, &oid10, sizeof (ComponentIA5String), (EncodeFcn)BEncIA5String, (gser_decoder_func*)GDecComponentIA5String, (ber_tag_decoder_func*)BDecComponentIA5StringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentIA5String,(FreeFcn)FreeComponentIA5String, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid_ANY_ID, &oid11, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid2_ANY_ID, &oid12, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid3_ANY_ID, &oid13, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid4_ANY_ID, &oid14, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid5_ANY_ID, &oid15, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);    InstallAnyByComponentOid (octetStringOid7_ANY_ID, &oid17, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);}  /* InitAnyAuthenticationFramework */intMatchingComponentAlgorithmIdentifier ( 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 =	MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_assert)->algorithm );	if ( rc != LDAP_COMPARE_TRUE )		return rc;	rc =	SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm));	rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_assert)->parameters);	if ( rc != LDAP_COMPARE_TRUE )		return rc;	return LDAP_COMPARE_TRUE;}  /* BMatchingComponentAlgorithmIdentifier */void*ExtractingComponentAlgorithmIdentifier ( void* mem_op, ComponentReference* cr, ComponentAlgorithmIdentifier *comp ){	if ( ( comp->algorithm.identifier.bv_val && strncmp(comp->algorithm.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->algorithm.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->algorithm;		else		return NULL;	}	if ( ( comp->parameters.identifier.bv_val && strncmp(comp->parameters.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->parameters.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->parameters;	else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {			cr->cr_curr = cr->cr_curr->ci_next;		return &comp->parameters;	 } else {		return NULL;		}	}	return NULL;}  /* ExtractingComponentAlgorithmIdentifier */intBDecComponentAlgorithmIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentAlgorithmIdentifier **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;	ComponentAlgorithmIdentifier *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, OID_TAG_CODE))))    {    elmtLen1 = BDecLen (b, &totalElmtsLen1 );	rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(&k->algorithm)->identifier.bv_val = (&k->algorithm)->id_buf;		(&k->algorithm)->identifier.bv_len = strlen("algorithm");		strcpy( (&k->algorithm)->identifier.bv_val, "algorithm");    if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))        seqDone = TRUE;    else    {         tagId1 = BufPeekByte (b);         if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))        {            BDecEoc (b, &totalElmtsLen1 );            seqDone = TRUE;        }    }    }    else        return -1;    if (!seqDone)    {	rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm)); 	rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->parameters), &totalElmtsLen1, mode );		if ( rc != LDAP_SUCCESS ) return rc;		(&k->parameters)->identifier.bv_val = (&k->parameters)->id_buf;		(&k->parameters)->identifier.bv_len = strlen("parameters");		strcpy( (&k->parameters)->identifier.bv_val, "parameters");        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 = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );	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*)GDecComponentAlgorithmIdentifier ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;	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*)MatchingComponentAlgorithmIdentifier;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecAlgorithmIdentifier*/intGDecComponentAlgorithmIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentAlgorithmIdentifier **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_head,*peek_head2;	int i, strLen,strLen2, rc, old_mode = mode;	ComponentAlgorithmIdentifier *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, "algorithm", strlen("algorithm") ) == 0 ) {		rc = 	GDecComponentOid (mem_op, b, (&k->algorithm), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	(&k->algorithm)->identifier.bv_val = peek_head;	(&k->algorithm)->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, "parameters", strlen("parameters") ) == 0 ) {		rc = 	rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));	rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->parameters), bytesDecoded, mode );		if ( rc != LDAP_SUCCESS ) return rc;	(&k->parameters)->identifier.bv_val = peek_head;	(&k->parameters)->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 = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );	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*)GDecComponentAlgorithmIdentifier ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;	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*)MatchingComponentAlgorithmIdentifier;	return LDAP_SUCCESS;}  /* GDecAlgorithmIdentifier*/intMatchingComponentTime ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	ComponentTime *v1, *v2;	v1 = (ComponentTime*)csi_attr;	v2 = (ComponentTime*)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 TIME_UTCTIME :		rc = 	MatchingComponentUTCTime ( oid, (ComponentSyntaxInfo*)(v1->a.utcTime), (ComponentSyntaxInfo*)(v2->a.utcTime) );		break;	   case TIME_GENERALIZEDTIME :		rc = 	MatchingComponentGeneralizedTime ( oid, (ComponentSyntaxInfo*)(v1->a.generalizedTime), (ComponentSyntaxInfo*)(v2->a.generalizedTime) );		break;	default : 		 return LDAP_PROTOCOL_ERROR;	}	return rc;}  /* BMatchingComponentTimeContent */void*ExtractingComponentTime ( void* mem_op, ComponentReference* cr, ComponentTime *comp ){	if( (comp->choiceId) ==  TIME_UTCTIME &&

⌨️ 快捷键说明

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