📄 saparams.c
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "securearchive.h"
#include "errorctx.h"
#include "vtassert.h"
#define VOLT_SECURE_ARCHIVE_GET_SUPPORTED 1
#define VOLT_SECURE_ARCHIVE_SET_SUPPORTED 2
#define VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED \
(VOLT_SECURE_ARCHIVE_GET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_SUPPORTED)
#define VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED 4
#define VOLT_SECURE_ARCHIVE_SET_INFO_NULL 8
int VoltSecureArchiveParamCommon (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag,
unsigned int paramFlags,
int selector
)
{
int status;
VoltSecureArchiveObject *obj = (VoltSecureArchiveObject *)secureArchiveObj;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
/* Null secure archive object should have already been caught in
* VtSecureArchiveSetParam or VtSecureArchiveGetParam call.
*/
VT_ASSERT(obj != (VoltSecureArchiveObject*)0);
libCtx = obj->voltObject.libraryCtx;
do
{
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
if (flag == VOLT_SECURE_ARCHIVE_SET_TYPE_FLAG)
{
if ((paramFlags & VOLT_SECURE_ARCHIVE_SET_SUPPORTED) == 0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_SET;
break;
}
if ((info == (Pointer)0) &&
((paramFlags & VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED) != 0))
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
break;
}
if ((info != (Pointer)0) &&
((paramFlags & VOLT_SECURE_ARCHIVE_SET_INFO_NULL) != 0))
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
break;
}
if (obj->SetParam == (VSecureArchiveSetParam)0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_IMPL;
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = obj->SetParam(secureArchiveObj, selector, info);
if (status != 0)
break;
}
else if (flag == VOLT_SECURE_ARCHIVE_GET_TYPE_FLAG)
{
if ((paramFlags & VOLT_SECURE_ARCHIVE_GET_SUPPORTED) == 0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_GET;
break;
}
if (info == (Pointer)0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_NULL_ARG;
break;
}
if (obj->GetParam == (VSecureArchiveGetParam)0)
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_IMPL;
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = obj->GetParam(secureArchiveObj, selector, (Pointer*)info);
if (status != 0)
break;
}
else
{
VOLT_SET_FNCT_LINE(fnctLine)
status = VT_ERROR_INVALID_TYPE;
break;
}
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, errorType, fnctLine,
"VoltSecureArchiveParamCommon", (unsigned char*)0)
return status;
}
int VtSecureArchiveParamSignerId (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status = 0;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
do
{
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
if ((flag == VOLT_SECURE_ARCHIVE_SET_TYPE_FLAG) && (info != (Pointer)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(info, VOLT_OBJECT_TYPE_IDENTITY))
{
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_SIGNER_ID);
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, errorType, fnctLine,
"VtSecureArchiveParamSignerId", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamSignerInfo (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status = 0;
VtSecureArchiveSignerInfo* signerInfo;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
do
{
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
if ((flag == VOLT_SECURE_ARCHIVE_SET_TYPE_FLAG) && (info != (Pointer)0))
{
signerInfo = (VtSecureArchiveSignerInfo*)info;
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE(fnctLine)
if ((signerInfo->privateKey != (VtKeyObject)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(signerInfo->privateKey, VOLT_OBJECT_TYPE_KEY))
break;
VOLT_SET_FNCT_LINE(fnctLine)
if ((signerInfo->signerId != (VtIdentityObject)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(signerInfo->signerId, VOLT_OBJECT_TYPE_IDENTITY))
break;
VOLT_SET_FNCT_LINE(fnctLine)
if ((signerInfo->signerCert != (VtCertObject)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(signerInfo->signerCert, VOLT_OBJECT_TYPE_CERT))
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_SIGNER_INFO);
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, errorType, fnctLine,
"VtSecureArchiveParamSignerInfo", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamRecipientList (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status = 0;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
do
{
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
if ((flag == VOLT_SECURE_ARCHIVE_SET_TYPE_FLAG) && (info != (Pointer)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(info, VOLT_OBJECT_TYPE_IDENTITY_LIST))
{
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_RECIPIENT_LIST);
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, errorType, fnctLine,
"VtSecureArchiveParamRecipientList", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamRecipientInfoList (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status = 0;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
VOLT_DECLARE_ERROR_TYPE(errorType)
do
{
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
if ((flag == VOLT_SECURE_ARCHIVE_SET_TYPE_FLAG) && (info != (Pointer)0) &&
VOLT_OBJECT_TYPE_NOT_EQUAL(info, VOLT_OBJECT_TYPE_RECIP_INFO_LIST))
{
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
break;
}
VOLT_SET_FNCT_LINE(fnctLine)
VOLT_SET_ERROR_TYPE(errorType, 0)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_RECIPIENT_INFO_LIST);
}
while (0);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, errorType, fnctLine,
"VtSecureArchiveParamRecipientInfoList", (unsigned char *)0)
return status;
}
int VtSecureArchiveParam3DESCBC (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_NULL,
VOLT_SECURE_ARCHIVE_PARAM_3DESCBC);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParam3DESCBC", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamAES128CBC (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_NULL,
VOLT_SECURE_ARCHIVE_PARAM_AES128CBC);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamAES128CBC", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamCompressionEnabled (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_COMPRESSION_ENABLED);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamCompressionEnabled", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamSigningTime (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_SUPPORTED, VOLT_SECURE_ARCHIVE_PARAM_SIGNING_TIME);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamMessageTime", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamFileName (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_FILE_NAME);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamFileName", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamModDate (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_AND_SET_SUPPORTED | VOLT_SECURE_ARCHIVE_SET_INFO_REQUIRED,
VOLT_SECURE_ARCHIVE_PARAM_MOD_DATE);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamModDate", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamFileSize (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
VOLT_SET_FNCT_LINE(fnctLine)
status = VoltSecureArchiveParamCommon(secureArchiveObj, info, flag,
VOLT_SECURE_ARCHIVE_GET_SUPPORTED, VOLT_SECURE_ARCHIVE_PARAM_FILE_SIZE);
VOLT_LOG_ERROR_COMPARE(status, libCtx, status, 0, fnctLine,
"VtSecureArchiveParamFileSize", (unsigned char *)0)
return status;
}
int VtSecureArchiveParamRecipientIndex (
VtSecureArchiveObject secureArchiveObj,
Pointer info,
unsigned int flag
)
{
int status;
VtLibCtx libCtx = (VtLibCtx)0;
VOLT_DECLARE_FNCT_LINE(fnctLine)
if (secureArchiveObj != (VtSecureArchiveObject)0)
libCtx = secureArchiveObj->voltObject.libraryCtx;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -