📄 certificate.c
字号:
(( comp->a.utcTime->identifier.bv_val && strncmp(comp->a.utcTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || ( strncmp(comp->a.utcTime->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->a.utcTime); else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentUTCTime ( mem_op, cr, (comp->a.utcTime) ); }; } if( (comp->choiceId) == TIME_GENERALIZEDTIME && (( comp->a.generalizedTime->identifier.bv_val && strncmp(comp->a.generalizedTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) || ( strncmp(comp->a.generalizedTime->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->a.generalizedTime); else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentGeneralizedTime ( mem_op, cr, (comp->a.generalizedTime) ); }; } return NULL;} /* ExtractingComponentTime */intBDecComponentTime PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentTime **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; ComponentTime *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; switch (tagId0) { case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE): case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE): (k->choiceId) = TIME_UTCTIME; rc = BDecComponentUTCTime (mem_op, b, tagId0, elmtLen0, (&k->a.utcTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; (k->a.utcTime)->identifier.bv_val = (k->a.utcTime)->id_buf; (k->a.utcTime)->identifier.bv_len = strlen("utcTime"); strcpy( (k->a.utcTime)->identifier.bv_val, "utcTime"); break; case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE): case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE): (k->choiceId) = TIME_GENERALIZEDTIME; rc = BDecComponentGeneralizedTime (mem_op, b, tagId0, elmtLen0, (&k->a.generalizedTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; (k->a.generalizedTime)->identifier.bv_val = (k->a.generalizedTime)->id_buf; (k->a.generalizedTime)->identifier.bv_len = strlen("generalizedTime"); strcpy( (k->a.generalizedTime)->identifier.bv_val, "generalizedTime"); break; default: Asn1Error ("ERROR - unexpected tag in CHOICE\n"); return -1; break; } /* end switch */ if( !(old_mode & DEC_ALLOC_MODE_1) ) { *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) ); 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*)GDecComponentTime ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime; 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*)MatchingComponentTime; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecTimeContent */intGDecComponentTime PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentTime **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentTime *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; if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){ Asn1Error("Error during Reading identifier"); return LDAP_PROTOCOL_ERROR; } if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){ Asn1Error("Error during Reading identifier"); return LDAP_PROTOCOL_ERROR; } if(*peek_head2 != ':'){ Asn1Error("Missing : in encoded data"); return LDAP_PROTOCOL_ERROR; } if( strncmp("utcTime",peek_head, strlen("utcTime")) == 0){ (k->choiceId) = TIME_UTCTIME; rc = GDecComponentUTCTime (mem_op, b, (&k->a.utcTime), bytesDecoded, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; (k->a.utcTime)->identifier.bv_val = peek_head; (k->a.utcTime)->identifier.bv_len = strLen; } else if( strncmp("generalizedTime",peek_head,strlen("generalizedTime")) == 0){ (k->choiceId) = TIME_GENERALIZEDTIME; rc = GDecComponentGeneralizedTime (mem_op, b, (&k->a.generalizedTime), bytesDecoded, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; (k->a.generalizedTime)->identifier.bv_val = peek_head; (k->a.generalizedTime)->identifier.bv_len = strLen; } else { Asn1Error("Undefined Identifier"); return LDAP_PROTOCOL_ERROR; } if( !(old_mode & DEC_ALLOC_MODE_1) ) { *v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) ); 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*)GDecComponentTime ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime; 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*)MatchingComponentTime; return LDAP_SUCCESS;} /* GDecTimeContent */intMatchingComponentExtension ( 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*)&((ComponentExtension*)csi_attr)->extnID, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnID ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentBool ( oid, (ComponentSyntaxInfo*)((ComponentExtension*)csi_attr)->critical, (ComponentSyntaxInfo*)((ComponentExtension*)csi_assert)->critical ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnValue, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnValue ); if ( rc != LDAP_COMPARE_TRUE ) return rc; return LDAP_COMPARE_TRUE;} /* BMatchingComponentExtension */void*ExtractingComponentExtension ( void* mem_op, ComponentReference* cr, ComponentExtension *comp ){ if ( ( comp->extnID.identifier.bv_val && strncmp(comp->extnID.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnID.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->extnID; else return NULL; } if ( ( comp->critical->identifier.bv_val && strncmp(comp->critical->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->critical->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->critical; else { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentBool ( mem_op, cr, comp->critical ); } } if ( ( comp->extnValue.identifier.bv_val && strncmp(comp->extnValue.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnValue.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->extnValue; else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) { cr->cr_curr = cr->cr_curr->ci_next; return &comp->extnValue; } else { return NULL; } } return NULL;} /* ExtractingComponentExtension */intBDecComponentExtension PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentExtension **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; ComponentExtension *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->extnID), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (&k->extnID)->identifier.bv_val = (&k->extnID)->id_buf; (&k->extnID)->identifier.bv_len = strlen("extnID"); strcpy( (&k->extnID)->identifier.bv_val, "extnID"); tagId1 = BDecTag (b, &totalElmtsLen1); } else return -1; if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))) { elmtLen1 = BDecLen (b, &totalElmtsLen1 ); rc = BDecComponentBool (mem_op, b, tagId1, elmtLen1, (&k->critical), &totalElmtsLen1, DEC_ALLOC_MODE_0 ); if ( rc != LDAP_SUCCESS ) return rc; (k->critical)->identifier.bv_val = (k->critical)->id_buf; (k->critical)->identifier.bv_len = strlen("critical"); strcpy( (k->critical)->identifier.bv_val, "critical"); tagId1 = BDecTag (b, &totalElmtsLen1); } if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||(tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))) { elmtLen1 = BDecLen (b, &totalElmtsLen1 ); rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extnValue), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (&k->extnValue)->identifier.bv_val = (&k->extnValue)->id_buf; (&k->extnValue)->identifier.bv_len = strlen("extnValue"); strcpy( (&k->extnValue)->identifier.bv_val, "extnValue"); seqDone = TRUE; if (elmtLen0 == INDEFINITE_LEN) BDecEoc (b, &totalElmtsLen1 ); else if (totalElmtsLen1 != elmtLen0) return -1; } else return -1; if (!seqDone) return -1; if(!COMPONENTNOT_NULL ((k->critical))) {(k->critical) = CompAlloc( mem_op, sizeof(ComponentBool)); (k->critical)->identifier.bv_val = (k->critical)->id_buf; (k->critical)->identifier.bv_len = strlen("critical"); strcpy( (k->critical)->identifier.bv_val, "critical"); (k->critical)->value = 0; } if( !(old_mode & DEC_ALLOC_MODE_1) ) { *v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) ); 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*)GDecComponentExtension ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension; 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*)MatchingComponentExtension; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecExtension*/intGDecComponentExtension PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentExtension **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentExtension *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)) ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -