⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fipsmodule.h

📁 voltage 公司提供的一个开发Ibe的工具包
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Copyright 2003-2004, Voltage Security, all rights reserved.
 */

#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "ictk.h"

#ifndef _FIPS_MODULE_H
#define _FIPS_MODULE_H

#ifdef __cplusplus
extern "C" {
#endif

/* A shared library handle is specific to each platform. For the
 * toolkit, it is an opaque type. Each platform implementation of the
 * shared library functions will know how to cast a VoltLibHandle into
 * the appropriate type.
 */
typedef Pointer VoltLibHandle;

/** This is the MemoryImpl the FIPS module uses. It is the only
 * MemoryImpl available when using the FIPS module. It will load a
 * memory implementation that uses the GlobalAlloc, GlobalFree, etc.,
 * routines offered by the Win32 Operating System. Furthermore, it will
 * keep track of all the Malloc's and Free's so that when destroyed
 * (during VtDestroyLibCtxFips or VtDestroyLibCtx), the Impl can check
 * to see if there were any allocations for which there were no Free's.
 * This implementation will also overwrite all memory before free'ing,
 * there is no option to overwrite only sensitive data.
 * <p>This MemoryImpl is slower and uses more memory than
 * VtMemoryImplWin32.
 * <p>The data associated with VtMemoryImplDebug is a NULL pointer:
 * (Pointer)0.
 */
VtMemoryImpl VtMemoryImplWin32Fips;

/** Use this ThreadImpl when building a FIPS library context, it will
 * load a thread implementation that does no locking. If an application
 * will be run in a single thread, there is no need for the toolkit
 * operations to guard aginst multiple thread access.
 * <p>The FIPS module will always run single threaded.
 * <p>The data associated with VtThreadImplWinFipsSingle is a NULL
 * pointer: (Pointer)0.
 */
VtThreadImpl VtThreadImplWinFipsSingle;

/* The CreateLibCtx definition for FIPS.
 * <p>When creating a FIPS libCtx (shared library, FIPS module),
 * there's no choice on Memory or Thread.
 * <p>Upon return, the localCtx will point to a VoltFipsLibCtx. If the
 * underlying implementation wants more material, then it can create
 * more, however, it must make sure that anyone can cast the localCtx
 * to a pointer to VoltFipsLibCtx and it will find the appropriate
 * material.
 * <p>In addition, the function will allocate space for the libHandle
 * field of the fipsCtx, if the caller requests it. That is, the caller
 * passes in a number. The implementation will make sure the libHandle
 * field points to that much space. If the caller passes in 0 for
 * libHandleSpace, the implementation will leave the libHandle field
 * NULL.
 *
 * @param libHandleSpace How much space the function should allocate
 * for the libHandle field of the fipsCtx. This can be 0.
 */
typedef int VOLT_CALLING_CONV (*VFCreateLibCtxFips) VOLT_PROTO_LIST ((
   unsigned int libHandleSpace,
   VtLibCtx *libCtx
));

/* This is the DestroyLibCtx definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDestroyLibCtxFips) VOLT_PROTO_LIST ((
   VtLibCtx *libCtx
));

/* This is the GetFipsError definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFGetFipsError) VOLT_PROTO_LIST ((
));

/* This definition is for a function that is FIPS only. It is the
 * Command Processing state. All calls except CreateLibCtxFips start
 * here.
 * <p>The implementation will return a zero meaning continue with the
 * operation, or a non-zero value meaining the module is in FIPS error
 * and operations are not allowed to continue.
 * <p>The callFlag indicates what call will be made. If it is
 * VOLT_CALL_FLAG_NORMAL, the function will determine if there is a
 * FIPS error and block execution if there is one. If the callFlag is
 * VOLT_CALL_FLAG_SPECIAL, the function will ignore the FIPS error.
 * This is for function calls that are not FIPS or for function calls
 * that execute even if there is a FIPS error, such as GetFipsError and
 * DestroyLibCtxFips. If the callFlag is VOLT_CALL_FLAG_LOAD, the call
 * is loading the module, so this function does nothing.
 */
typedef int VOLT_CALLING_CONV (*VFCommandProcessing) VOLT_PROTO_LIST ((
   unsigned int callFlag
));

#define VOLT_CALL_FLAG_NORMAL   1
#define VOLT_CALL_FLAG_SPECIAL  2
#define VOLT_CALL_FLAG_LOAD     4

/* The VtMalloc definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMalloc) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int size,
   unsigned int flag,
   Pointer *buffer
));

/* The VtRealloc definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFRealloc) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int size,
   unsigned int flag,
   Pointer *buffer
));

/* The VtFree definition for the function list.
 */
typedef void VOLT_CALLING_CONV (*VFFree) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   Pointer *buffer
));

/* The VtMemset definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMemset) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   Pointer buffer,
   unsigned int value,
   unsigned int count
));

/* The VtMemcpy definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMemcpy) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   Pointer dest,
   Pointer source,
   unsigned int count
));

/* The VtMemmove definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMemmove) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   Pointer dest,
   Pointer source,
   unsigned int count
));

/* The VtMemcmp definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMemcmp) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   Pointer buffer1,
   Pointer buffer2,
   unsigned int count,
   int *cmpResult
));

/* The VtSeedRandom definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFSeedRandom) VOLT_PROTO_LIST ((
   VtRandomObject randObj,
   unsigned char *seedData,
   unsigned int seedLen
));

/* The VtGenerateRandomBytes definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFGenerateRandomBytes) VOLT_PROTO_LIST ((
   VtRandomObject randObj,
   unsigned char *randomBytes,
   unsigned int randomLen
));

/* The VtGenerateParameters definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFGenerateParameters) VOLT_PROTO_LIST ((
   VtParamGenImpl ParamGenImpl,
   Pointer associatedInfo,
   VtRandomObject random,
   VtParameterObject paramObj
));

/* The VtGenerateKeyPair definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFGenerateKeyPair) VOLT_PROTO_LIST ((
   VtKeyPairGenImpl KeyPairGenImpl,
   Pointer associatedInfo,
   VtRandomObject random,
   VtKeyObject pubKey,
   VtKeyObject priKey
));

/* The VtGetObjectState definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFGetObjectState) VOLT_PROTO_LIST ((
   Pointer theObject,
   unsigned char *state,
   unsigned int bufferSize,
   unsigned int *stateLen
));

/* The VtSetObjectState definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFSetObjectState) VOLT_PROTO_LIST ((
   Pointer theObject,
   unsigned char *state,
   unsigned int stateLen
));

/* The VtCloneObject definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFCloneObject) VOLT_PROTO_LIST ((
   Pointer sourceObject,
   Pointer *destObject
));

/* The VtDigestInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDigestInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj
));

/* The VtDigestUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDigestUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   unsigned char *dataToDigest,
   unsigned int dataToDigestLen
));

/* The VtDigestFinal definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDigestFinal) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   unsigned char *dataToDigest,
   unsigned int dataToDigestLen,
   unsigned char *digest,
   unsigned int bufferSize,
   unsigned int *digestLen
));

/* The VtMACInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMACInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtKeyObject keyObj
));

/* The VtMACUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFMACUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   unsigned char *dataToMAC,
   unsigned int dataToMACLen
));

typedef int VOLT_CALLING_CONV (*VFMACFinal) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   unsigned char *dataToMAC,
   unsigned int dataToMACLen,
   unsigned char *mac,
   unsigned int bufferSize,
   unsigned int *macLen
));

/* The VtEncryptInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncryptInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtKeyObject keyObj
));

/* The VtEncryptUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncryptUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToEncrypt,
   unsigned int dataToEncryptLen,
   unsigned char *encryptedData,
   unsigned int bufferSize,
   unsigned int *encryptedDataLen
));

/* The VtEncryptFinal definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncryptFinal) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToEncrypt,
   unsigned int dataToEncryptLen,
   unsigned char *encryptedData,
   unsigned int bufferSize,
   unsigned int *encryptedDataLen
));

/* The VtDecryptInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecryptInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtKeyObject keyObj
));

/* The VtDecryptUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecryptUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToDecrypt,
   unsigned int dataToDecryptLen,
   unsigned char *decryptedData,
   unsigned int bufferSize,
   unsigned int *decryptedDataLen
));

/* The VtDecryptFinal definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecryptFinal) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToDecrypt,
   unsigned int dataToDecryptLen,
   unsigned char *decryptedData,
   unsigned int bufferSize,
   unsigned int *decryptedDataLen
));

/* The VtSign definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFSign) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtKeyObject keyObj,
   VtRandomObject random,
   unsigned int digestAlg,
   unsigned char *digest,
   unsigned int digestLen,
   unsigned char *signature,
   unsigned int bufferSize,
   unsigned int *signatureLen
));

/* The VtVerifySignature definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFVerifySignature) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtKeyObject keyObj,
   VtRandomObject random,
   unsigned int digestAlg,
   unsigned char *digest,
   unsigned int digestLen,
   unsigned char *signature,
   unsigned int signatureLen,
   unsigned int *verifyResult
));

/* The VtEncodeInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncodeInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj
));

/* The VtEncodeUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncodeUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToEncode,
   unsigned int dataToEncodeLen,
   unsigned char *encodedData,
   unsigned int bufferSize,
   unsigned int *encodedDataLen
));

/* The VtEncodeFinal definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFEncodeFinal) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToEncode,
   unsigned int dataToEncodeLen,
   unsigned char *encodedData,
   unsigned int bufferSize,
   unsigned int *encodedDataLen
));

/* The VtDecodeInit definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecodeInit) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj
));

/* The VtDecodeUpdate definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecodeUpdate) VOLT_PROTO_LIST ((
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToDecode,
   unsigned int dataToDecodeLen,
   unsigned char *decodedData,
   unsigned int bufferSize,
   unsigned int *decodedDataLen
));

/* The VtDecodeFinal definition for the function list.
 */
typedef int VOLT_CALLING_CONV (*VFDecodeFinal) VOLT_PROTO_LIST ((

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -