📄 zdm2write.c
字号:
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSecureArchiveWriteUpdate(localCtx->mSecureArchive,
buffer, size, (unsigned char*)0, 0, (unsigned int*)0);
if (status != 0)
break;
}
while (0);
VtDestroyDataNodeObject(&insecureAttributes);
VtDestroyStreamObject(&outputStream);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0,
fnctLine, "VoltZDM2WriteInsecureAttributes", (unsigned char*)0)
return status;
}
static int VoltZDM2SetTemplateVariable(
VtZDMObject zdmObj,
const unsigned char* expression,
const unsigned char* value
)
{
int status = 0;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
VtDataNodeObject dataNode;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VT_ASSERT(zdmObj != (VtZDMObject)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
localCtx = (VoltZDM2WriteLocalCtx*) zdmObj->localCtx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
VT_ASSERT(localCtx->mTemplateVariables != (VtDataNodeObject)0);
do
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VtDataNodeResolveChild(localCtx->mTemplateVariables,
expression, 1, &dataNode);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VtDataNodeSetStringValue(dataNode, value);
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0,
fnctLine, "VoltZDM2SetTemplateVariable", (unsigned char*)0)
return status;
}
static int VoltZDM2DetermineWriteInfo(
VtZDMObject zdmObj,
unsigned char** messageHeader,
unsigned char** zdmLocation
)
{
int status = 0;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
VoltZDM2RecipientInfo* recipientInfo;
int useExternalHeader = 0;
unsigned int i;
VtItem* messageHeaderItem = (VtItem*)0;
VoltPolicyGetType messageHeaderType;
unsigned char* messageHeaderData = (unsigned char*)0;
unsigned int messageHeaderLength = 0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
VT_ASSERT(zdmObj != (VtZDMObject)0);
VT_ASSERT(messageHeader != (unsigned char**)0);
VT_ASSERT(zdmLocation != (unsigned char**)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
localCtx = (VoltZDM2WriteLocalCtx*) zdmObj->localCtx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
*messageHeader = (unsigned char*)0;
*zdmLocation = (unsigned char*)0;
VOLT_SET_ERROR_TYPE(errorType, 0)
do
{
if (localCtx->mPolicyCtx == (VtPolicyCtx)0)
{
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
status = VT_ERROR_INVALID_POLICY_CTX;
break;
}
for (i = 0; i < localCtx->mRecipientInfoList.mCount; i++)
{
recipientInfo = &localCtx->mRecipientInfoList.mInfoArray[i];
if (localCtx->mDesignatedRecipient != (unsigned char*)0)
{
if (Stricmp(localCtx->mDesignatedRecipient,
recipientInfo->mAddress, libCtx) == 0)
{
useExternalHeader = recipientInfo->mExternal;
*zdmLocation = recipientInfo->mZDMLocation;
break;
}
}
if (recipientInfo->mExternal)
useExternalHeader = 1;
}
if (*zdmLocation == (unsigned char*)0)
*zdmLocation = localCtx->mZDMLocation;
messageHeaderType = useExternalHeader ?
VOLT_POLICY_GET_MESSAGE_HEADER_EXTERNAL :
VOLT_POLICY_GET_MESSAGE_HEADER_INTERNAL;
VOLT_SET_FNCT_LINE(fnctLine)
status = localCtx->mPolicyCtx->PolicyGetInfoAlloc (
localCtx->mPolicyCtx, messageHeaderType,
(Pointer)0, (Pointer *)&messageHeaderItem);
if (status != 0)
break;
if (messageHeaderItem != (VtItem*)0)
{
messageHeaderData = messageHeaderItem->data;
messageHeaderLength = messageHeaderItem->len;
}
*messageHeader = (unsigned char*) Z3Malloc(messageHeaderLength + 1);
if (*messageHeader == (unsigned char*)0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_MEMORY;
break;
}
Z2Memcpy(*messageHeader, messageHeaderData, messageHeaderLength);
(*messageHeader)[messageHeaderLength] = 0;
}
while (0);
if (messageHeaderItem != (VtItem *)0)
{
localCtx->mPolicyCtx->PolicyGetInfoFree(localCtx->mPolicyCtx,
(Pointer)messageHeaderItem);
}
if (status != 0)
{
Z2Free(*messageHeader);
*messageHeader = (unsigned char*)0;
VOLT_LOG_ERROR(libCtx, status, 0, fnctLine,
"VoltZDM2DetermineWriteInfo", (unsigned char*)0)
}
return status;
}
static int VoltZDM2UpdateDynamicTemplateVariables(
VtZDMObject zdmObj,
unsigned char* messageHeader,
unsigned char* zdmLocation
)
{
int status = 0;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VT_ASSERT(zdmObj != (VtZDMObject)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
localCtx = (VoltZDM2WriteLocalCtx*) zdmObj->localCtx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
VT_ASSERT(localCtx->mTemplateVariables != (VtDataNodeObject)0);
do
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2HeaderVariableName, messageHeader);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2DesignatedRecipientVariableName,
localCtx->mDesignatedRecipient);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2ZDMLocationVariableName, zdmLocation);
if (status != 0)
break;
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VoltZDM2UpdateDynamicTemplateVariables", (unsigned char*)0)
return status;
}
static int VoltZDM2SetStaticTemplateVariables(
VtZDMObject zdmObj
)
{
int status = 0;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
unsigned char version[64];
unsigned char* messageStartTag = (unsigned char*)0;
unsigned char* messageEndTag = (unsigned char*)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VT_ASSERT(zdmObj != (VtZDMObject)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
localCtx = (VoltZDM2WriteLocalCtx*) zdmObj->localCtx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
VT_ASSERT(localCtx->mTemplateVariables != (VtDataNodeObject)0);
do
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2MessageTypeVariableName, VoltZDM2TypeMessage);
if (status != 0)
break;
status = VoltNumToDecimalString(localCtx->mSupportedVersion,
version, sizeof(version), libCtx);
VT_ASSERT(status == 0);
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2MessageVersionVariableName, version);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2FormatMessageTag(libCtx,
VoltZDM2MessageBlockStartTagPrefix,
VoltZDM2MessageBlockStartTagSuffix,
(const unsigned char*)0, localCtx->mSupportedVersion,
0, &messageStartTag);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2MessageStartTagVariableName, messageStartTag);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2FormatMessageTag(libCtx,
VoltZDM2MessageBlockEndTagPrefix,
VoltZDM2MessageBlockEndTagSuffix,
(const unsigned char*)0, localCtx->mSupportedVersion,
0, &messageEndTag);
if (status != 0)
break;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltZDM2SetTemplateVariable(zdmObj,
VoltZDM2MessageEndTagVariableName, messageEndTag);
if (status != 0)
break;
}
while (0);
Z2Free(messageStartTag);
Z2Free(messageEndTag);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0,
fnctLine, "VoltZDM2UpdateTemplateVariables", (unsigned char*)0)
return status;
}
static void VoltZDM2WriteLocalCtxDestroy(
Pointer obj,
Pointer ctx
)
{
VoltZDMObject* zdmObj = (VoltZDMObject*)obj;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
if ((obj == (Pointer)0) || (ctx == (Pointer)0))
return;
localCtx = (VoltZDM2WriteLocalCtx*)ctx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
VoltZDM2RecipientInfoListDestroy(libCtx,
&localCtx->mRecipientInfoList);
VoltZDM2EmailRecipientListDestroy(libCtx,
&localCtx->mPrimaryEmailRecipientList);
VoltZDM2EmailRecipientListDestroy(libCtx,
&localCtx->mCCEmailRecipientList);
VtDestroySecureArchiveObject(&localCtx->mSecureArchive);
VtDestroyStreamObject(&localCtx->mOutputStream);
VtDestroyStreamObject(&localCtx->mWrapperHeaderStream);
VtDestroyStreamObject(&localCtx->mWrapperTrailerStream);
VtDestroyDataNodeObject(&localCtx->mTemplateVariables);
VtDestroyCompressObject(&localCtx->mMessageBodyDecompress);
VtDestroyAlgorithmObject(&localCtx->mBase64Encoder);
Z2Free(localCtx->mBeginSecureTag);
Z2Free(localCtx->mEndSecureTag);
Z2Free(localCtx->mMessageID);
Z2Free(localCtx->mDesignatedRecipient);
Z2Free(localCtx->mZDMLocation);
Z2Free(localCtx->mPartialLine);
Z2Free(localCtx);
}
static int VoltZDM2WriteSetParam(
VtZDMObject zdmObj,
int paramSelector,
Pointer setInfo
)
{
int status = 0;
VoltZDM2WriteLocalCtx* localCtx;
VtLibCtx libCtx = (VtLibCtx)0;
VtZDMSenderInfo* senderInfo;
VtZDMDataPaddingInfo* dataPaddingInfo;
VtSecureArchiveSignerInfo signerInfo;
VtZDMCurrentEntryInfo* zdmCurrentEntryInfo;
VtSecureArchiveCurrentEntryInfo saCurrentEntryInfo;
VtSecureArchiveAttributeInfo attributeInfo;
VtSecureArchiveParam* attributeParam;
unsigned char* messageID;
unsigned int length;
int outputType;
unsigned int messageFormat;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
VT_ASSERT(zdmObj != (VtZDMObject)0);
libCtx = zdmObj->voltObject.libraryCtx;
VT_ASSERT(libCtx != (VtLibCtx)0);
localCtx = (VoltZDM2WriteLocalCtx*) zdmObj->localCtx;
VT_ASSERT(localCtx != (VoltZDM2WriteLocalCtx*)0);
VOLT_SET_ERROR_TYPE(errorType, 0)
switch (paramSelector)
{
case VT_ZDM_PARAM_SENDER_ID:
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParamSignerId, setInfo);
break;
case VT_ZDM_PARAM_SENDER_INFO:
senderInfo = (VtZDMSenderInfo*) setInfo;
signerInfo.privateKey = senderInfo->privateKey;
signerInfo.signerCert = senderInfo->signerCert;
signerInfo.signerId = senderInfo->senderId;
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParamSignerInfo, (Pointer)&signerInfo);
break;
case VT_ZDM_PARAM_RECIPIENT_LIST:
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParamRecipientList, setInfo);
break;
case VT_ZDM_PARAM_RECIPIENT_INFO_LIST:
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParamRecipientInfoList, setInfo);
break;
case VT_ZDM_PARAM_3DESCBC:
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParam3DESCBC, setInfo);
break;
case VT_ZDM_PARAM_AES128CBC:
VOLT_SET_FNCT_LINE(fnctLine)
status = VtSetSecureArchiveParam(localCtx->mSecureArchive,
VtSecureArchiveParamAES128CBC, setInfo);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -