📄 osppkcs7.c
字号:
break; default: errorcode = OSPC_ERR_PKCS7_ENCODING_ERROR; OSPM_DBGERRORLOG(errorcode, "Unknown case encountered encoding PKCS7 SignerInfo"); } if (errorcode == OSPC_ERR_NO_ERROR) { /* Add new object to this object */ if (newObject != OSPC_OSNULL) { errorcode = OSPPASN1ObjectAddChild(signerInfo, newObject, dataRefId); if(newObject != OSPC_OSNULL) { OSPM_FREE(newObject); } } } } if (errorcode == OSPC_ERR_ASN1_PARSE_COMPLETE) { errorcode = OSPC_ERR_NO_ERROR; } if (errorcode == OSPC_ERR_NO_ERROR) { /* Complete the encoding for this object. Update results, elements, etc. */ errorcode = OSPPASN1ObjectDeparse(signerInfo, OSPEPTID_SIGNERINFO, OSPEDRID_SIGNERINFO); } if (errorcode == OSPC_ERR_NO_ERROR) { *ospvSignerInfo = signerInfo; } else { /* Clean up from errors */ OSPPASN1ObjectDelete(&signerInfo); } if(digestInfo != OSPC_OSNULL) { OSPM_FREE(digestInfo); } return errorcode;}intOSPPPKCS7DigestAlgorithmsCreate(OSPTASN1OBJECT **ospvDigestAlgorithms,OSPTASN1OBJECT *ospvDigestAlgorithm){ int errorcode=OSPC_ERR_NO_ERROR; OSPEASN1DATAREFID dataRefId = OSPEDRID_NOTDEFINED; OSPTASN1OBJECT *digestAlgorithms = OSPC_OSNULL; OSPTASN1OBJECT *newObject = OSPC_OSNULL; int i = 0; errorcode = OSPPASN1ObjectNew(&digestAlgorithms, OSPEDRID_SGNDAT_DIGESTALGORITHMS); /* The elements are a contentType OID, and a content element. */ /* Add the content type Element to the result list */ for (i = 0 ;errorcode == OSPC_ERR_NO_ERROR ; i++) { switch(i) { case 0: /* Add DigestAlgorithm */ dataRefId = OSPEDRID_SGNDAT_DIGESTALGORITHM; errorcode = OSPPASN1ObjectCopy(&newObject, ospvDigestAlgorithm); if(newObject != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 1: errorcode = OSPC_ERR_ASN1_PARSE_COMPLETE; break; default: errorcode = OSPC_ERR_PKCS7_ENCODING_ERROR; OSPM_DBGERRORLOG(errorcode, "Unknown case encountered encoding PKCS7 DigestAlgorithms"); } if (errorcode == OSPC_ERR_NO_ERROR) { /* Add new object to this object */ if (newObject != OSPC_OSNULL) { errorcode = OSPPASN1ObjectAddChild(digestAlgorithms, newObject, dataRefId); OSPM_FREE(newObject); } } } if (errorcode == OSPC_ERR_ASN1_PARSE_COMPLETE) { errorcode = OSPC_ERR_NO_ERROR; } if (errorcode == OSPC_ERR_NO_ERROR) { /* Complete the encoding for this object. Update results, elements, etc. */ errorcode = OSPPASN1ObjectDeparse(digestAlgorithms, OSPEPTID_DIGESTALGORITHMS, OSPEDRID_SGNDAT_DIGESTALGORITHMS); } if (errorcode == OSPC_ERR_NO_ERROR) { *ospvDigestAlgorithms = digestAlgorithms; } else { /* Clean up from errors */ OSPPASN1ObjectDelete(&digestAlgorithms); } return errorcode;}intOSPPPKCS7CertificatesCreate( OSPTASN1OBJECT **ospvCertificates, OSPTASN1OBJECT *ospvCertificate){ int errorcode = OSPC_ERR_NO_ERROR; OSPEASN1DATAREFID dataRefId = OSPEDRID_NOTDEFINED; OSPTASN1OBJECT *certificates = OSPC_OSNULL; OSPTASN1OBJECT *newObject = OSPC_OSNULL; int i = 0; errorcode = OSPPASN1ObjectNew(&certificates, OSPEDRID_SGNDAT_CERTIFICATES); /* The elements are a contentType OID, and a content element. */ /* Add the content type Element to the result list */ for (i = 0 ;errorcode == OSPC_ERR_NO_ERROR ; i++) { switch(i) { case 0: /* Add Certificate */ dataRefId = OSPEDRID_SGNDAT_CERTIFICATE; errorcode = OSPPASN1ObjectCopy(&newObject, ospvCertificate); if(newObject->ElementInfo->Element != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 1: errorcode = OSPC_ERR_ASN1_PARSE_COMPLETE; break; default: errorcode = OSPC_ERR_PKCS7_ENCODING_ERROR; OSPM_DBGERRORLOG(errorcode, "Unknown case encountered encoding PKCS7 Certificates"); } if (errorcode == OSPC_ERR_NO_ERROR) { /* Add new object to this object */ if (newObject != OSPC_OSNULL) { errorcode = OSPPASN1ObjectAddChild(certificates, newObject, dataRefId); OSPM_FREE(newObject); } } } if (errorcode == OSPC_ERR_ASN1_PARSE_COMPLETE) { errorcode = OSPC_ERR_NO_ERROR; } if (errorcode == OSPC_ERR_NO_ERROR) { /* Complete the encoding for this object. Update results, elements, etc. */ errorcode = OSPPASN1ObjectDeparse(certificates, OSPEPTID_CERTIFICATES, OSPEDRID_SGNDAT_CERTIFICATES); } if (errorcode == OSPC_ERR_NO_ERROR) { *ospvCertificates = certificates; } else { /* Clean up from errors */ OSPPASN1ObjectDelete(&certificates); } return errorcode;}intOSPPPKCS7SignerInfosCreate( OSPTASN1OBJECT **ospvSignerInfos, OSPTASN1OBJECT *ospvSignerInfo){ int errorcode = OSPC_ERR_NO_ERROR; OSPEASN1DATAREFID dataRefId = OSPEDRID_NOTDEFINED; OSPTASN1OBJECT *signerInfos = OSPC_OSNULL; OSPTASN1OBJECT *newObject = OSPC_OSNULL; int i = 0; errorcode = OSPPASN1ObjectNew(&signerInfos, OSPEDRID_SGNDAT_SIGNERINFOS); /* The elements are a contentType OID, and a content element. */ /* Add the content type Element to the result list */ for (i = 0 ;errorcode == OSPC_ERR_NO_ERROR ; i++) { switch(i) { case 0: /* Add SignerInfo */ dataRefId = OSPEDRID_SGNDAT_SIGNERINFO; errorcode = OSPPASN1ObjectCopy(&newObject, ospvSignerInfo); if(newObject->ElementInfo->Element != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 1: errorcode = OSPC_ERR_ASN1_PARSE_COMPLETE; break; default: errorcode = OSPC_ERR_PKCS7_ENCODING_ERROR; OSPM_DBGERRORLOG(errorcode, "Unknown case encountered encoding PKCS7 SignerInfos"); } if (errorcode == OSPC_ERR_NO_ERROR) { /* Add new object to this object */ if (newObject != OSPC_OSNULL) { errorcode = OSPPASN1ObjectAddChild(signerInfos, newObject, dataRefId); if(newObject != OSPC_OSNULL) { OSPM_FREE(newObject); } } } } if (errorcode == OSPC_ERR_ASN1_PARSE_COMPLETE) { errorcode = OSPC_ERR_NO_ERROR; } if (errorcode == OSPC_ERR_NO_ERROR) { /* Complete the encoding for this object. Update results, elements, etc. */ errorcode = OSPPASN1ObjectDeparse(signerInfos, OSPEPTID_SIGNERINFOS, OSPEDRID_SGNDAT_SIGNERINFOS); } if (errorcode == OSPC_ERR_NO_ERROR) { *ospvSignerInfos = signerInfos; } else { /* Clean up from errors */ OSPPASN1ObjectDelete(&signerInfos); } return errorcode;}intOSPPPKCS7SignedDataCreate( OSPTASN1OBJECT **ospvSignedData, OSPTASN1OBJECT *ospvContentInfo, OSPTASN1OBJECT *ospvDigestAlgorithms, OSPTASN1OBJECT *ospvSignerCertificates, OSPTASN1OBJECT *ospvSignerInfos){ int errorcode = OSPC_ERR_NO_ERROR; unsigned int i = 0; OSPEASN1DATAREFID dataRefId = OSPEDRID_NOTDEFINED; OSPTASN1OBJECT *newObject = OSPC_OSNULL; OSPTASN1OBJECT *signedData = OSPC_OSNULL; errorcode = OSPPASN1ObjectNew(&signedData, OSPEDRID_SIGNEDDATA); for (i = 0 ;errorcode == OSPC_ERR_NO_ERROR ; i++) { switch(i) { case 0: dataRefId = OSPEDRID_SGNDAT_VERSION; errorcode = OSPPASN1SmallIntegerEncode(&newObject, OSPC_PKCS7_SIGNEDDATA_VERSION, dataRefId); break; case 1: dataRefId = OSPEDRID_SGNDAT_DIGESTALGORITHMS; errorcode = OSPPASN1ObjectCopy(&newObject, ospvDigestAlgorithms); if(newObject != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 2: dataRefId = OSPEDRID_SGNDAT_CONTENTINFO; errorcode = OSPPASN1ObjectCopy(&newObject, ospvContentInfo); if(newObject != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 3: dataRefId = OSPEDRID_SGNDAT_CERTIFICATES; errorcode = OSPPASN1ObjectCopy(&newObject, ospvSignerCertificates); if(newObject != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 4: dataRefId = OSPEDRID_SGNDAT_SIGNERINFOS; errorcode = OSPPASN1ObjectCopy(&newObject, ospvSignerInfos); if(newObject != OSPC_OSNULL) { OSPPASN1ElementDelete(&(newObject->ElementInfo), 0); } break; case 5: errorcode = OSPC_ERR_ASN1_PARSE_COMPLETE; break; default: errorcode = OSPC_ERR_PKCS7_ENCODING_ERROR; OSPM_DBGERRORLOG(errorcode, "Unknown case encountered encoding PKCS7 SignedData"); } if (errorcode == OSPC_ERR_NO_ERROR) { /* Add new object to this object */ if (newObject != OSPC_OSNULL) { errorcode = OSPPASN1ObjectAddChild(signedData, newObject, dataRefId); OSPM_FREE(newObject); } } } if (errorcode == OSPC_ERR_ASN1_PARSE_COMPLETE) { errorcode = OSPC_ERR_NO_ERROR; } if (errorcode == OSPC_ERR_NO_ERROR) { errorcode = OSPPASN1ObjectDeparse(signedData, OSPEPTID_SIGNEDDATA, OSPEDRID_SIGNEDDATA); } if (errorcode == OSPC_ERR_NO_ERROR) { *ospvSignedData = signedData; } else { /* Clean up from errors */ OSPPASN1ObjectDelete(&signedData); } if(newObject != OSPC_OSNULL) { OSPPASN1ObjectDelete(&newObject); } return errorcode;} intOSPPPKCS7ContentInfoCreate( OSPTASN1OBJECT **ospvContentInfo, OSPTASN1OBJECT *ospvContent, OSPEASN1ID ospvContentTypeId, int ospvSignatureOnly){ int errorcode = 0; unsigned int i = 0; OSPEASN1DATAREFID dataRefId = OSPEDRID_NOTDEFINED; OSPEASN1PARSETABLEID tableId = OSPEPTID_NOTDEFINED;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -