?? aeskey.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 "aes.h"
#include "errorctx.h"
/* Implements VCheckKeyLen.
*/
int VOLT_CALLING_CONV AESCheckKeyLen VOLT_PROTO_LIST ((
VtLibCtx libraryCtx,
unsigned int keyLen
));
int VtKeyParamAES (
VtKeyObject object,
Pointer info,
unsigned int flag
)
{
int status;
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_AES);
break;
}
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltSetSymmetricKey (
object, info, flag, AESCheckKeyLen,
VOLT_KEY_ALG_AES | VOLT_KEY_TYPE_DATA);
if (status != 0)
break;
/* 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,
"VtKeyParamAES", (char *)0)
return (status);
}
int AESCheckKeyLen (
VtLibCtx libraryCtx,
unsigned int keyLen
)
{
VOLT_DECLARE_FNCT_LINE (fnctLine)
/* An AES key can be 16, 24 or 32 bytes long.
*/
VOLT_SET_FNCT_LINE (fnctLine)
if ( (keyLen == 16) || (keyLen == 24) || (keyLen == 32) )
return (0);
VOLT_LOG_ERROR (
libraryCtx, VT_ERROR_INVALID_KEY_LENGTH, VT_ERROR_TYPE_PRIMARY,
fnctLine, "AESCheckKeyLen", (char *)0)
return (VT_ERROR_INVALID_KEY_LENGTH);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -