📄 riparams.c
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "recipinfo.h"
#include "p7obj.h"
#include "idobj.h"
#include "errorctx.h"
int VtRecipientInfoParam822EmailValidity (
VtRecipientInfoObject recipInfoObj,
Pointer info,
unsigned int flag
)
{
int status;
VoltRecipientInfoObject *obj = (VoltRecipientInfoObject *)recipInfoObj;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
if (flag == VOLT_RECIP_INFO_GET_TYPE_FLAG)
{
/* Get the info out of the local idObj, if it's there.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_GET_INFO_UNAVAILABLE;
if (obj->idObj == (VoltIdentityObject *)0)
break;
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VtGetIdentityParam (
(VtIdentityObject)(obj->idObj), VtIdentityParam822EmailValidity,
(Pointer *)info);
break;
}
/* Check the args.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (flag != VOLT_RECIP_INFO_SET_TYPE_FLAG)
break;
/* If there's already an identity object in this RecipientInfo
* object, error.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_SET;
if (obj->idObj != (VoltIdentityObject *)0)
break;
/* Create and set an id object with the info.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VtCreateIdentityObject (
obj->voltObject.libraryCtx, VtIdentityImplMpCtx,
(Pointer)(obj->mpCtx), (VtIdentityObject *)&(obj->idObj));
if (status != 0)
break;
VOLT_SET_FNCT_LINE (fnctLine)
status = VtSetIdentityParam (
(VtIdentityObject)(obj->idObj), VtIdentityParam822EmailValidity,
info);
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, recipInfoObj, status, 0, errorType,
(char *)0, "VtRecipientInfoParam822EmailValidity", fnctLine, (char *)0)
return (status);
}
int VtRecipientInfoParamIdObject (
VtRecipientInfoObject recipInfoObj,
Pointer info,
unsigned int flag
)
{
int status;
VoltRecipientInfoObject *obj = (VoltRecipientInfoObject *)recipInfoObj;
Pointer *getInfo;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
if (flag == VOLT_RECIP_INFO_GET_TYPE_FLAG)
{
getInfo = (Pointer *)info;
/* Return the value at the idObj field, if there is something
* there.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_GET_INFO_UNAVAILABLE;
if (obj->idObj == (VoltIdentityObject *)0)
break;
*getInfo = (Pointer)(obj->idObj);
status = 0;
break;
}
/* Check the args.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (flag != VOLT_RECIP_INFO_SET_TYPE_FLAG)
break;
/* If there's already an identity object in this RecipientInfo
* object, error.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_SET;
if (obj->idObj != (VoltIdentityObject *)0)
break;
/* The associated info must be an identity object.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
if (info == (Pointer)0)
break;
VOLT_SET_FNCT_LINE (fnctLine)
if (VOLT_OBJECT_TYPE_NOT_EQUAL (info, VOLT_OBJECT_TYPE_IDENTITY))
break;
/* Clone the input.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VtCloneObject (info, (Pointer *)&(obj->idObj));
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, recipInfoObj, status, 0, errorType,
(char *)0, "VtRecipientInfoParamIdObject", fnctLine, (char *)0)
return (status);
}
int VtRecipientInfoParamSymmetricKey (
VtRecipientInfoObject recipInfoObj,
Pointer info,
unsigned int flag
)
{
int status;
VoltRecipientInfoObject *obj = (VoltRecipientInfoObject *)recipInfoObj;
VtItem *keyData;
Pointer *getInfo;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
if (flag == VOLT_RECIP_INFO_GET_TYPE_FLAG)
{
/* Get the info out of the obj, if it's there.
*/
status = 0;
getInfo = (Pointer *)info;
*getInfo = (Pointer)&(obj->symKeyData);
if (obj->symKeyData.data != (unsigned char *)0)
break;
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_GET_INFO_UNAVAILABLE;
break;
}
/* Check the args.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (flag != VOLT_RECIP_INFO_SET_TYPE_FLAG)
break;
/* If there's already a symmetric key in this object, error.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_SET;
if (obj->symKeyData.data != (unsigned char *)0)
break;
/* The associatedInfo must be a VtItem.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
if (info == (Pointer)0)
break;
VOLT_SET_FNCT_LINE (fnctLine)
keyData = (VtItem *)info;
if ( (keyData->data == (unsigned char *)0) || (keyData->len == 0) )
break;
/* Copy the data.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltCopyItemDataAlloc (
obj->voltObject.libraryCtx, VOLT_MEMORY_SENSITIVE, 0, keyData,
&(obj->symKeyData));
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, recipInfoObj, status, 0, errorType,
(char *)0, "VtRecipientInfoParamSymmetricKey", fnctLine, (char *)0)
return (status);
}
int VtRecipientInfoParamIBEAlgorithm (
VtRecipientInfoObject recipInfoObj,
Pointer info,
unsigned int flag
)
{
int status;
unsigned int encodingLen, algorithm;
VoltRecipientInfoObject *obj = (VoltRecipientInfoObject *)recipInfoObj;
VtDerCoderInfo coderInfo;
VtDerCoder *IbeAlg;
VtItem algIDItem;
unsigned char algId[VoltMaxIBEAlgIDLen];
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_GET;
if (flag == VOLT_RECIP_INFO_GET_TYPE_FLAG)
break;
/* Check the args.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (flag != VOLT_RECIP_INFO_SET_TYPE_FLAG)
break;
/* If the ibeAlg is already set in the object, error.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_SET;
if ( (obj->IbeAlg != (VtDerCoder *)0) ||
(obj->ibeAlgID.data != (unsigned char *)0) )
break;
/* Check the associatedInfo.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
if (info == (Pointer)0)
break;
IbeAlg = (VtDerCoder *)info;
/* Make sure the info is a DerCoder and that it is for an IBE
* algorithm.
*/
coderInfo.info.encodeData.libCtx =
(VoltLibCtx *)(obj->voltObject.libraryCtx);
coderInfo.info.encodeData.info = (Pointer)0;
coderInfo.info.encodeData.encoding = algId;
coderInfo.info.encodeData.bufferSize = sizeof (algId);
coderInfo.info.encodeData.encodingLen = &encodingLen;
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = IbeAlg (&coderInfo, (Pointer)0, VOLT_DER_TYPE_ENCODE_FLAG);
if (status != 0)
break;
coderInfo.info.getAlgData.libCtx =
(VoltLibCtx *)(obj->voltObject.libraryCtx);
coderInfo.info.getAlgData.oid = algId + 4;
coderInfo.info.getAlgData.oidLen = (unsigned int)(algId[3]);
coderInfo.info.getAlgData.encodingType = VOLT_ENCODING_TYPE_ALG_ID;
coderInfo.info.getAlgData.algorithm = &algorithm;
coderInfo.info.getAlgData.SymKeyParam = (VtKeyParam *)0;
coderInfo.info.getAlgData.DigestImpl = (VtAlgorithmImpl *)0;
VOLT_SET_FNCT_LINE (fnctLine)
status = IbeAlg (&coderInfo, (Pointer)0, VOLT_DER_TYPE_GET_ALG_FLAG);
if (status != 0)
break;
/* The alg must be an IBE alg.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
if ( (algorithm < VT_ALG_ID_MIN_IBE_CIPHER) ||
(algorithm > VT_ALG_ID_MAX_IBE_CIPHER) )
break;
algIDItem.data = algId;
algIDItem.len = encodingLen;
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltCopyItemDataAlloc (
obj->voltObject.libraryCtx, 0, 0, &algIDItem, &(obj->ibeAlgID));
if (status != 0)
break;
obj->IbeAlg = IbeAlg;
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, recipInfoObj, status, 0, errorType,
(char *)0, "VtRecipientInfoParamIBEAlgorithm", fnctLine, (char *)0)
return (status);
}
int VtRecipientInfoParamIBEAlgId (
VtRecipientInfoObject recipInfoObj,
Pointer info,
unsigned int flag
)
{
int status;
VoltRecipientInfoObject *obj = (VoltRecipientInfoObject *)recipInfoObj;
Pointer *getInfo;
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_SET;
if (flag == VOLT_RECIP_INFO_SET_TYPE_FLAG)
break;
/* Check the args.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (flag != VOLT_RECIP_INFO_GET_TYPE_FLAG)
break;
/* If the ibeAlgID is not set in the object, error.
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_GET_INFO_UNAVAILABLE;
if (obj->ibeAlgID.data == (unsigned char *)0)
break;
getInfo = (Pointer *)info;
*getInfo = (Pointer)&(obj->ibeAlgID);
status = 0;
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, recipInfoObj, status, 0, VT_ERROR_TYPE_PRIMARY,
(char *)0, "VtRecipientInfoParamIBEAlgID", fnctLine, (char *)0)
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -