📄 parambertype.c
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "paramobj.h"
#include "algid.h"
#include "errorctx.h"
int VtParameterParamBer (
VtParameterObject object,
Pointer info,
unsigned int flag
)
{
int status;
unsigned int index, count;
VoltParameterObject *obj = (VoltParameterObject *)object;
VtSetParamBerInfo *berInfo = (VtSetParamBerInfo *)info;
VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
VtDerCoder **ListToUse;
VtDERCoderArray *coderArray;
VoltDerCoderInfo coderInfo;
VOLT_DECLARE_FNCT_LINE (fnctLine)
VOLT_DECLARE_ERROR_TYPE (errorType)
do
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
/* Check the flag, it should be VOLT_PARAM_SET_TYPE_FLAG.
*/
status = VT_ERROR_INVALID_TYPE;
VOLT_SET_FNCT_LINE (fnctLine)
if (flag != VOLT_PARAM_SET_TYPE_FLAG)
break;
/* The associated info should be a pointer to VtSetParamBerInfo.
*/
status = VT_ERROR_INVALID_ASSOCIATED_INFO;
VOLT_SET_FNCT_LINE (fnctLine)
if (info == (Pointer)0)
break;
VOLT_SET_FNCT_LINE (fnctLine)
if ( (berInfo->berEncoding == (unsigned char *)0) ||
(berInfo->maxEncodingLen == 0) )
break;
/* Check the type of the object. It should be 0 (not yet set).
* This SetType is not allowed when an object is already set.
*/
status = VT_ERROR_INVALID_TYPE;
VOLT_SET_FNCT_LINE (fnctLine)
if (obj->paramType != 0)
break;
/* Use the coders passed in, unless none are given, then use the
* coders in the libCtx, unless there are none there, in which
* case, error.
*/
ListToUse = berInfo->derCoders;
count = berInfo->derCoderCount;
if ( (berInfo->derCoders == (VtDerCoder **)0) ||
(berInfo->derCoderCount == 0) )
{
coderArray = (VtDERCoderArray *)VoltGetLibCtxInfo (
obj->voltObject.libraryCtx, VOLT_LIB_CTX_INFO_TYPE_DER_CODERS);
status = VT_ERROR_NO_DER_CODERS;
VOLT_SET_FNCT_LINE (fnctLine)
if (coderArray == (VtDERCoderArray *)0)
break;
ListToUse = coderArray->derCoders;
count = coderArray->derCoderCount;
}
/* Try all the DerCoder's given, see if one of them knows about
* this key.
*/
coderInfo.info.decodeData.type = VOLT_DER_TYPE_PARAM_FLAG;
coderInfo.info.decodeData.asn1Object = (Pointer)0;
coderInfo.info.decodeData.info = info;
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
for (index = 0; index < count; ++index)
{
status = ListToUse[index] (
&coderInfo, (Pointer)obj, VOLT_DER_TYPE_DECODE_FLAG);
/* If status is 0, we found the alg, we're done. Any error other
* than VT_ERROR_UNKNOWN_BER pass on.
*/
if (status != VT_ERROR_UNKNOWN_BER)
break;
}
} while (0);
/* If everything worked, return 0.
*/
if (status == 0)
return (0);
/* If something went wrong, indicate that this object is not usable.
*/
obj->paramType = 0;
VOLT_LOG_ERROR (
(VtLibCtx)libCtx, status, errorType,
fnctLine, "VtParameterParamBer", (char *)0)
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -