📄 crl.c
字号:
( k->revokedCertificates)->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, "crlExtensions", strlen("crlExtensions") ) == 0 ) { rc = GDecComponentExtensions (mem_op, b, (&k->crlExtensions), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; ( k->crlExtensions)->identifier.bv_val = peek_head; ( k->crlExtensions)->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 = (ComponentTBSCertList*) CompAlloc( mem_op, sizeof(ComponentTBSCertList) ); 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*)GDecComponentTBSCertList ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertList ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertList; 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*)MatchingComponentTBSCertList; return LDAP_SUCCESS;} /* GDecTBSCertList*/intMatchingComponentCertificateList ( 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 = MatchingComponentTBSCertList ( oid, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_attr)->tbsCertList, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_assert)->tbsCertList ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificateList*)csi_assert)->signatureAlgorithm ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificateList*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificateList*)csi_assert)->signature ); if ( rc != LDAP_COMPARE_TRUE ) return rc; return LDAP_COMPARE_TRUE;} /* BMatchingComponentCertificateList */void*ExtractingComponentCertificateList ( void* mem_op, ComponentReference* cr, ComponentCertificateList *comp ){ if ( ( comp->tbsCertList->identifier.bv_val && strncmp(comp->tbsCertList->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->tbsCertList->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->tbsCertList; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentTBSCertList ( mem_op, cr, comp->tbsCertList ); } } if ( ( comp->signatureAlgorithm->identifier.bv_val && strncmp(comp->signatureAlgorithm->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signatureAlgorithm->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->signatureAlgorithm; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm ); } } 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 if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) { cr->cr_curr = cr->cr_curr->ci_next; return &comp->signature; } else { return NULL; } } return NULL;} /* ExtractingComponentCertificateList */intBDecComponentCertificateList PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentCertificateList **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; ComponentCertificateList *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, CONS, SEQ_TAG_CODE)))) { elmtLen1 = BDecLen (b, &totalElmtsLen1 ); rc = BDecComponentTBSCertList (mem_op, b, tagId1, elmtLen1, (&k->tbsCertList), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (k->tbsCertList)->identifier.bv_val = (k->tbsCertList)->id_buf; (k->tbsCertList)->identifier.bv_len = strlen("tbsCertList"); strcpy( (k->tbsCertList)->identifier.bv_val, "tbsCertList"); tagId1 = BDecTag (b, &totalElmtsLen1); } else return -1; if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))) { elmtLen1 = BDecLen (b, &totalElmtsLen1 ); rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf; (k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm"); strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm"); tagId1 = BDecTag (b, &totalElmtsLen1); } else return -1; if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||(tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))) { elmtLen1 = BDecLen (b, &totalElmtsLen1 ); rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (&k->signature)->identifier.bv_val = (&k->signature)->id_buf; (&k->signature)->identifier.bv_len = strlen("signature"); strcpy( (&k->signature)->identifier.bv_val, "signature"); seqDone = TRUE; if (elmtLen0 == INDEFINITE_LEN) BDecEoc (b, &totalElmtsLen1 ); else if (totalElmtsLen1 != elmtLen0) return -1; } else return -1; if (!seqDone) return -1; if( !(old_mode & DEC_ALLOC_MODE_1) ) { *v = t = (ComponentCertificateList*) CompAlloc( mem_op, sizeof(ComponentCertificateList) ); 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*)GDecComponentCertificateList ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificateList ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificateList; 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*)MatchingComponentCertificateList; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecCertificateList*/intGDecComponentCertificateList PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentCertificateList **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentCertificateList *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, "tbsCertList", strlen("tbsCertList") ) == 0 ) { rc = GDecComponentTBSCertList (mem_op, b, (&k->tbsCertList), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; ( k->tbsCertList)->identifier.bv_val = peek_head; ( k->tbsCertList)->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, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) { rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; ( k->signatureAlgorithm)->identifier.bv_val = peek_head; ( k->signatureAlgorithm)->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, "signature", strlen("signature") ) == 0 ) { rc = GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; (&k->signature)->identifier.bv_val = peek_head; (&k->signature)->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 = (ComponentCertificateList*) CompAlloc( mem_op, sizeof(ComponentCertificateList) ); 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*)GDecComponentCertificateList ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificateList ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificateList; 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*)MatchingComponentCertificateList; return LDAP_SUCCESS;} /* GDecCertificateList*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -