📄 tdeskey.c
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "keyobj.h"
#include "des.h"
#include "errorctx.h"
/* Implements VCheckKeyLen.
*/
int VOLT_CALLING_CONV TDESCheckKeyLen VOLT_PROTO_LIST ((
VtLibCtx libraryCtx,
unsigned int keyLen
));
int VtKeyParamTripleDES (
VtKeyObject object,
Pointer info,
unsigned int flag
)
{
int status;
VoltKeyObject *obj = (VoltKeyObject *)object;
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
if (flag == VOLT_KEY_GET_TYPE_FLAG)
{
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltGetSymmetricKey (
object, (Pointer *)info, VOLT_KEY_ALG_3_DES);
break;
}
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltSetSymmetricKey (
object, info, flag, TDESCheckKeyLen,
VOLT_KEY_ALG_3_DES | VOLT_KEY_TYPE_DATA);
if (status != 0)
break;
VoltSetDESParity ((VtItem *)(obj->keyData));
/* If successful, set the FIPS bit in the object type, this object
* is a FIPS object.
*/
((VoltObject *)object)->objectType |= VOLT_OBJECT_TYPE_FIPS;
} while (0);
VOLT_LOG_ERROR_COMPARE (
status, ((VoltObject *)object)->libraryCtx, status, 0, fnctLine,
"VtKeyParamTripleDES", (char *)0)
return (status);
}
int TDESCheckKeyLen (
VtLibCtx libraryCtx,
unsigned int keyLen
)
{
VOLT_DECLARE_FNCT_LINE (fnctLine)
/* A Triple DES key can only be 24 bytes long.
*/
VOLT_SET_FNCT_LINE (fnctLine)
if (keyLen == 24)
return (0);
VOLT_LOG_ERROR (
libraryCtx, VT_ERROR_INVALID_KEY_LENGTH, VT_ERROR_TYPE_PRIMARY,
fnctLine, "TDESCheckKeyLen", (char *)0)
return (VT_ERROR_INVALID_KEY_LENGTH);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -