📄 crl.c
字号:
if ( mr ) return component_value_match( mr, csi_attr, csi_assert ); } v1 = &((ComponentTBSCertListSeqOf*)csi_attr)->comp_list; v2 = &((ComponentTBSCertListSeqOf*)csi_assert)->comp_list; FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2) { if( MatchingComponentTBSCertListSeqOfSeq(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;} /* BMatchingComponentTBSCertListSeqOfContent */void*ExtractingComponentTBSCertListSeqOf ( void* mem_op, ComponentReference* cr, ComponentTBSCertListSeqOf *comp ){ int count = 0; int total; AsnList *v = &comp->comp_list; ComponentInt *k; ComponentTBSCertListSeqOfSeq *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 ExtractingComponentTBSCertListSeqOfSeq ( 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 ExtractingComponentTBSCertListSeqOfSeq ( 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; }} /* ExtractingComponentTBSCertListSeqOf */intBDecComponentTBSCertListSeqOf PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentTBSCertListSeqOf **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; ComponentTBSCertListSeqOf *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(ComponentTBSCertListSeqOfSeq)); for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);) { ComponentTBSCertListSeqOfSeq **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 = (ComponentTBSCertListSeqOfSeq**) CompAsnListAppend (mem_op,&k->comp_list); rc = BDecComponentTBSCertListSeqOfSeq (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 = (ComponentTBSCertListSeqOf*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOf) ); 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*)GDecComponentTBSCertListSeqOf ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOf ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOf; 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*)MatchingComponentTBSCertListSeqOf; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecTBSCertListSeqOfContent */intGDecComponentTBSCertListSeqOf PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentTBSCertListSeqOf **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentTBSCertListSeqOf *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( ComponentTBSCertListSeqOfSeq ) ); *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++) { ComponentTBSCertListSeqOfSeq **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 = (ComponentTBSCertListSeqOfSeq**) CompAsnListAppend (mem_op, &k->comp_list); if ( tmpVar == NULL ) { Asn1Error("Error during Reading{ in encoding"); return LDAP_PROTOCOL_ERROR; } rc = GDecComponentTBSCertListSeqOfSeq (mem_op, b, tmpVar, bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; } /* end of for */ if( !(old_mode & DEC_ALLOC_MODE_1) ) { *v = t = (ComponentTBSCertListSeqOf*) CompAlloc( mem_op, sizeof(ComponentTBSCertListSeqOf) ); 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*)GDecComponentTBSCertListSeqOf ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertListSeqOf ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertListSeqOf; 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*)MatchingComponentTBSCertListSeqOf; return LDAP_SUCCESS;} /* GDecTBSCertListSeqOfContent */intMatchingComponentTBSCertList ( 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; if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->version ) ) { rc = MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->version ); if ( rc != LDAP_COMPARE_TRUE ) return rc; } rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->signature ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->issuer ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->thisUpdate, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->thisUpdate ); if ( rc != LDAP_COMPARE_TRUE ) return rc; if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->nextUpdate ) ) { rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->nextUpdate, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->nextUpdate ); if ( rc != LDAP_COMPARE_TRUE ) return rc; } rc = MatchingComponentTBSCertListSeqOf ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->revokedCertificates, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->revokedCertificates ); if ( rc != LDAP_COMPARE_TRUE ) return rc; if(COMPONENTNOT_NULL( ((ComponentTBSCertList*)csi_attr)->crlExtensions ) ) { rc = MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_attr)->crlExtensions, (ComponentSyntaxInfo*)((ComponentTBSCertList*)csi_assert)->crlExtensions ); if ( rc != LDAP_COMPARE_TRUE ) return rc; } return LDAP_COMPARE_TRUE;} /* BMatchingComponentTBSCertList */void*ExtractingComponentTBSCertList ( void* mem_op, ComponentReference* cr, ComponentTBSCertList *comp ){ if ( ( comp->version->identifier.bv_val && strncmp(comp->version->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->version->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->version; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentVersion ( mem_op, cr, comp->version ); } } if ( ( comp->signature->identifier.bv_val && strncmp(comp->signature->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signature->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->signature; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature ); } } if ( ( comp->issuer->identifier.bv_val && strncmp(comp->issuer->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->issuer->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->issuer; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentName ( mem_op, cr, comp->issuer ); } } if ( ( comp->thisUpdate->identifier.bv_val && strncmp(comp->thisUpdate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->thisUpdate->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->thisUpdate; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentTime ( mem_op, cr, comp->thisUpdate ); } } if ( ( comp->nextUpdate->identifier.bv_val && strncmp(comp->nextUpdate->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->nextUpdate->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->nextUpdate; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentTime ( mem_op, cr, comp->nextUpdate ); } } if ( ( comp->revokedCertificates->identifier.bv_val && strncmp(comp->revokedCertificates->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->revokedCertificates->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->revokedCertificates; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentTBSCertListSeqOf ( mem_op, cr, comp->revokedCertificates ); } } if ( ( comp->crlExtensions->identifier.bv_val && strncmp(comp->crlExtensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->crlExtensions->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 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -