📄 certificate.c
字号:
ComponentValidity **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; ComponentValidity *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, 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->notBefore), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (k->notBefore)->identifier.bv_val = (k->notBefore)->id_buf; (k->notBefore)->identifier.bv_len = strlen("notBefore"); strcpy( (k->notBefore)->identifier.bv_val, "notBefore"); 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->notAfter), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (k->notAfter)->identifier.bv_val = (k->notAfter)->id_buf; (k->notAfter)->identifier.bv_len = strlen("notAfter"); strcpy( (k->notAfter)->identifier.bv_val, "notAfter"); 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 = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) ); 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*)GDecComponentValidity ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity; 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*)MatchingComponentValidity; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecValidity*/intGDecComponentValidity PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentValidity **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentValidity *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, "notBefore", strlen("notBefore") ) == 0 ) { rc = GDecComponentTime (mem_op, b, (&k->notBefore), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; ( k->notBefore)->identifier.bv_val = peek_head; ( k->notBefore)->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, "notAfter", strlen("notAfter") ) == 0 ) { rc = GDecComponentTime (mem_op, b, (&k->notAfter), bytesDecoded, mode); if ( rc != LDAP_SUCCESS ) return rc; ( k->notAfter)->identifier.bv_val = peek_head; ( k->notAfter)->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 = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) ); 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*)GDecComponentValidity ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity; 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*)MatchingComponentValidity; return LDAP_SUCCESS;} /* GDecValidity*/intMatchingComponentSubjectPublicKeyInfo ( 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 = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_attr)->algorithm, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_assert)->algorithm ); if ( rc != LDAP_COMPARE_TRUE ) return rc; rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_attr)->subjectPublicKey, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_assert)->subjectPublicKey ); if ( rc != LDAP_COMPARE_TRUE ) return rc; return LDAP_COMPARE_TRUE;} /* BMatchingComponentSubjectPublicKeyInfo */void*ExtractingComponentSubjectPublicKeyInfo ( void* mem_op, ComponentReference* cr, ComponentSubjectPublicKeyInfo *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 { cr->cr_curr = cr->cr_curr->ci_next; return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->algorithm ); } } if ( ( comp->subjectPublicKey.identifier.bv_val && strncmp(comp->subjectPublicKey.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectPublicKey.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->subjectPublicKey; else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) { cr->cr_curr = cr->cr_curr->ci_next; return &comp->subjectPublicKey; } else { return NULL; } } return NULL;} /* ExtractingComponentSubjectPublicKeyInfo */intBDecComponentSubjectPublicKeyInfo PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentSubjectPublicKeyInfo **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; ComponentSubjectPublicKeyInfo *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 = BDecComponentAlgorithmIdentifier (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"); 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->subjectPublicKey), &totalElmtsLen1, mode); if ( rc != LDAP_SUCCESS ) return rc; (&k->subjectPublicKey)->identifier.bv_val = (&k->subjectPublicKey)->id_buf; (&k->subjectPublicKey)->identifier.bv_len = strlen("subjectPublicKey"); strcpy( (&k->subjectPublicKey)->identifier.bv_val, "subjectPublicKey"); 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 = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) ); 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*)GDecComponentSubjectPublicKeyInfo ; t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ; t->comp_desc->cd_free = (comp_free_func*)NULL; t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo; 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*)MatchingComponentSubjectPublicKeyInfo; (*bytesDecoded) += totalElmtsLen1; return LDAP_SUCCESS;} /* BDecSubjectPublicKeyInfo*/intGDecComponentSubjectPublicKeyInfo PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentSubjectPublicKeyInfo **v _AND_AsnLen *bytesDecoded _AND_int mode){ char* peek_head,*peek_head2; int i, strLen,strLen2, rc, old_mode = mode; ComponentSubjectPublicKeyInfo *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 = GDecComponentAlgorithmIdentifier (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 , ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -