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

📄 fipsmodule.h

📁 voltage 公司提供的一个开发Ibe的工具包
💻 H
📖 第 1 页 / 共 2 页
字号:
   VtAlgorithmObject algObj,
   VtRandomObject random,
   unsigned char *dataToDecode,
   unsigned int dataToDecodeLen,
   unsigned char *decodedData,
   unsigned int bufferSize,
   unsigned int *decodedDataLen
));

/* The VtCreateObject definition for the function list. This covers all
 * Create functions (except for CreateLibCtx).
 * <p>The flag indicates what kind of object is to be created,
 * AlgorithmObject, KeyObject, etc. It is one of the OBJECT_TYPE's
 * defined in flags.h.
 * <p>The Impl is the RandomImpl, TransportImpl, or whatever, cast to a
 * generic function pointer.
 */
typedef int VOLT_CALLING_CONV (*VFCreateObject) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int flag,
   VFnctPointer Impl,
   Pointer associatedInfo,
   Pointer *object
));

/* The definition for the "base class" object creator.
 */
typedef int VOLT_CALLING_CONV (*VFVoltCreateObject) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   VoltObject **voltObj,
   unsigned int objectSize,
   unsigned int objectType
));

/* The definition for the "base class" object destructor.
 */
typedef void VOLT_CALLING_CONV (*VFVoltDestroyObject) VOLT_PROTO_LIST ((
   VoltObject **voltObj
));

typedef int VOLT_CALLING_CONV (*VFVoltAddLibCtxInfo) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   unsigned int infoType,
   int maxCount,
   Pointer info,
   VCtxDestroy InfoDestroy
));

/* The definition for the call to get info out of the libCtx.
 */
typedef Pointer VOLT_CALLING_CONV (*VFVoltGetLibCtxInfo) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int infoType
));

/* The definition for the call to get info out of the libCtx.
 */
typedef VoltLibCtxInfo VOLT_CALLING_CONV *(*VFVoltGetLibCtxInfoStruct) VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int infoType
));

/* The definition for the call to get a clone of the mpCtx in the
 * libCtx.
 */
typedef int VOLT_CALLING_CONV (*VFVoltGetMpCtxCloneFromLibCtx) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   Pointer *newCtx
));

/* The definition for the LibCtxParam for IBE caching. This is special
 * because it contains plenty of code inside the crypto library.
 */
typedef int VOLT_CALLING_CONV (*VFVtLibCtxParamIBECache) VOLT_PROTO_LIST ((
   VtLibCtx libraryCtx,
   Pointer info,
   unsigned int flag
));

int VOLT_CALLING_CONV VtLibCtxParamIBECache VOLT_PROTO_LIST ((
   VtLibCtx libraryCtx,
   Pointer info,
   unsigned int flag
));

/* The definition for the call to test a DSA key pair.
 */
typedef int VOLT_CALLING_CONV (*VFVoltTestDsaKeyPair) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   VoltSurrenderCtx *surrCtx,
   VtKeyObject pubKey,
   VtKeyObject priKey,
   VtRandomObject random
));

/* The definition for the call to get the BfCtx.
 */
typedef int VOLT_CALLING_CONV (*VFVoltGetBfCtxFromIBEParams) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   VtMpIntCtx mpCtx,
   VtBFType1IBECurveInfo *curve,
   VtBFType1IBEPoint *pubPointP,
   bf_context_t **bfCtx
));

/* The definition for the call to release the BfCtx.
 */
typedef void VOLT_CALLING_CONV (*VFVoltReleaseBfCtx) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   bf_context_t **bfCtx
));

/* The definition for the call to get params in toolkit form from a
 * bfCtx.
 */
typedef int VOLT_CALLING_CONV (*VFVoltBuildIBEParamsFromBfCtx) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   bf_context_t *bfCtx,
   VtBFType1IBEParamInfo **theParams
));

/* The definition for the call to free up params built by
 * VoltBuildIBEParamsFromBfCtx.
 */
typedef void VOLT_CALLING_CONV (*VFVoltDemolishIBEParams) VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   VtBFType1IBEParamInfo **theParams
));

/* The VtDestroyObject definition for the function list. This covers all
 * Destroy functions (except for DestroyLibCtx).
 */
typedef int VOLT_CALLING_CONV (*VFDestroyObject) VOLT_PROTO_LIST ((
   Pointer *object
));

/* The VtSetObject definition for the function list. This covers all
 * Set functions.
 * <p>The flag indicates what operation is to be performed, Set or Get.
 * It is either VOLT_FIPS_SET_OBJECT or VOLT_FIPS_GET_INFO.
 * <p>The objFlag indicates what kind of object is to be set,
 * AlgorithmObject, KeyObject, etc. It is one of the OBJECT_TYPE's
 * defined in flags.h.
 * <p>The paramFlag is a flag indicating which actual Vt*Param to use.
 * See the list of VOLT_PARAM_* defines. If it is -1, just return an error,
 * invalid set info.
 */
typedef int VOLT_CALLING_CONV (*VFObjectSetGet) VOLT_PROTO_LIST ((
   VoltObject *object,
   unsigned int flag,
   unsigned int objFlag,
   VFnctPointer Param,
   Pointer associatedInfo
));

#define VOLT_FIPS_SET_OBJECT    0
#define VOLT_FIPS_GET_INFO      1
#define VOLT_FIPS_SET_PROVIDER  2

/* This defines a function in the function list. This function sets the
 * derCoder to the requested function pointer, based on the flag.
 */
typedef int VOLT_CALLING_CONV (*VFGetFnctPtr) VOLT_PROTO_LIST ((
   unsigned int flag,
   VFnctPointer *fnctPtr
));

typedef struct
{
  VFGetFipsError                       VtGetFipsError;
  VFDestroyLibCtxFips                  VtDestroyLibCtxFips;
  VFCommandProcessing                  VfCommandProcessing;
  VFMalloc                             VtMalloc;
  VFRealloc                            VtRealloc;
  VFFree                               VtFree;
  VFMemset                             VtMemset;
  VFMemcpy                             VtMemcpy;
  VFMemmove                            VtMemmove;
  VFMemcmp                             VtMemcmp;
  VFCreateObject                       VfCreateObject;
  VFDestroyObject                      VfDestroyObject;
  VFObjectSetGet                       VfObjectSetGet;
  VFGetFnctPtr                         VfGetFnctPtr;
  VFSeedRandom                         VtSeedRandom;
  VFGenerateRandomBytes                VtGenerateRandomBytes;
  VFGenerateParameters                 VtGenerateParameters;
  VFGenerateKeyPair                    VtGenerateKeyPair;
  VFDigestInit                         VtDigestInit;
  VFDigestUpdate                       VtDigestUpdate;
  VFDigestFinal                        VtDigestFinal;
  VFMACInit                            VtMACInit;
  VFMACUpdate                          VtMACUpdate;
  VFMACFinal                           VtMACFinal;
  VFEncryptInit                        VtEncryptInit;
  VFEncryptUpdate                      VtEncryptUpdate;
  VFEncryptFinal                       VtEncryptFinal;
  VFDecryptInit                        VtDecryptInit;
  VFDecryptUpdate                      VtDecryptUpdate;
  VFDecryptFinal                       VtDecryptFinal;
  VFSign                               VtSign;
  VFVerifySignature                    VtVerifySignature;
  VFEncodeInit                         VtEncodeInit;
  VFEncodeUpdate                       VtEncodeUpdate;
  VFEncodeFinal                        VtEncodeFinal;
  VFDecodeInit                         VtDecodeInit;
  VFDecodeUpdate                       VtDecodeUpdate;
  VFDecodeFinal                        VtDecodeFinal;
  VFGetObjectState                     VtGetObjectState;
  VFSetObjectState                     VtSetObjectState;
  VFCloneObject                        VtCloneObject;
  VFVoltCreateObject                   VfVoltCreateObject;
  VFVoltDestroyObject                  VfVoltDestroyObject;
  VFVoltAddLibCtxInfo                  VfVoltAddLibCtxInfo;
  VFVoltGetLibCtxInfo                  VfVoltGetLibCtxInfo;
  VFVoltGetLibCtxInfoStruct            VfVoltGetLibCtxInfoStruct;
  VFVoltGetMpCtxCloneFromLibCtx        VfVoltGetMpCtxCloneFromLibCtx;
  VFVtLibCtxParamIBECache              VtLibCtxParamIBECache;
  VFVoltTestDsaKeyPair                 VfVoltTestDsaKeyPair;
  VFVoltGetBfCtxFromIBEParams          VfVoltGetBfCtxFromIBEParams;
  VFVoltReleaseBfCtx                   VfVoltReleaseBfCtx;
  VFVoltBuildIBEParamsFromBfCtx        VfVoltBuildIBEParamsFromBfCtx;
  VFVoltDemolishIBEParams              VfVoltDemolishIBEParams;
} VoltFipsFunctionList;

/* The CreateLibCtx inside the shared library.
 */
VOLT_SHARED_LIB_EXPORT int VOLT_CALLING_CONV VoltCreateLibCtxFips VOLT_PROTO_LIST ((
   unsigned int libHandleSpace,
   VtLibCtx *libraryCtx
));

/* The DestroyLibCtx inside the shared library.
 */
int VOLT_CALLING_CONV VoltDestroyLibCtxFips VOLT_PROTO_LIST ((
   VtLibCtx *libCtx
));

/* Define VOLT_FIPS_CREATE_LIB_CTX_NAME to be the same as the function
 * that implements VCreateLibCtx.
 */
#define VOLT_CREATE_LIB_CTX_FIPS_NAME   "VoltCreateLibCtxFips"

/** A FIPS libCtx is the local ctx for the base libCtx. It contains
 * info for FIPS, such as an error code, function list, etc.
 */
typedef struct
{
  unsigned int libHandleSpace;
  VoltLibHandle libHandle;
  VoltFipsFunctionList fnctList;
  VFnctPointer reservedFnctPointer;
  Pointer reservedFnctList;
} VoltFipsLibCtx;

/* This is the name of the shared library that is the FIPS module. When
 * porting, this might need to be changed.
 */
#define VOLT_FIPS_SHARED_LIB_NAME      "vibecryptofips.dll"
#define VOLT_FIPS_SHARED_LIB_NAME_LEN  18

/* This is the name of the sig file for the FIPS module. To make
 * programming convenient, make the sign file name and shared file name
 * the same length.
 * The easiest is to share the same base name and have different
 * (although same length) extensions.
 */
#define VOLT_FIPS_SIG_FILE_NAME      "vibecryptofips.sig"
#define VOLT_FIPS_SIG_FILE_NAME_LEN  18

/* Implements VFCommandProcessing.
 */
int VOLT_CALLING_CONV VoltCommandProcessing VOLT_PROTO_LIST ((
   unsigned int callFlag
));

/* This function will be called from within the shared library to
 * set the Fips error to the value given.
 *
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
void VOLT_CALLING_CONV VoltSetFipsError VOLT_PROTO_LIST ((
   int fipsError
));

/* Implements VGetFipsError.
 */
int VOLT_CALLING_CONV VoltGetFipsError VOLT_PROTO_LIST ((
));

/* For routines inside the shared library, call this routine to
 * determine if the FIPS module is active. Some routines will not
 * operate if the module is inactive.
 * <p>Return 0 for active, non-zero for inactive.
 */
int VOLT_CALLING_CONV VoltIsFipsModuleActive VOLT_PROTO_LIST ((
));

/* Implements VFCreateObject.
 */
int VOLT_CALLING_CONV VoltFipsCreateObject VOLT_PROTO_LIST ((
   VtLibCtx libCtx,
   unsigned int flag,
   VFnctPointer Impl,
   Pointer associatedInfo,
   Pointer *object
));

/* Implements VFDestroyObject.
 */
int VOLT_CALLING_CONV VoltFipsDestroyObject VOLT_PROTO_LIST ((
   Pointer *object
));

/* Implements VFObjectSetGet.
 */
int VOLT_CALLING_CONV VoltFipsObjectSetGet VOLT_PROTO_LIST ((
   VoltObject *object,
   unsigned int flag,
   unsigned int objFlag,
   VFnctPointer Param,
   Pointer associatedInfo
));

/* Implements VFGetFnctPtr.
 */
int VOLT_CALLING_CONV VoltFipsGetFnctPtr VOLT_PROTO_LIST ((
   unsigned int flag,
   VFnctPointer *fnctPtr
));

/* The following numbers cannot overlap with toolkit error codes.
 */
#define VOLT_FIPS_FNCT_ARG_BASE                VT_ERROR_FIPS_BASE+1024
#define VOLT_IMPL_NULL                         VOLT_FIPS_FNCT_ARG_BASE+0
#define VOLT_IMPL_ALG_IBE_TYPE1                VOLT_FIPS_FNCT_ARG_BASE+1
#define VOLT_IMPL_ALG_BLS_VERIFY               VOLT_FIPS_FNCT_ARG_BASE+2
#define VOLT_IMPL_ALG_DSA_SIGN                 VOLT_FIPS_FNCT_ARG_BASE+3
#define VOLT_IMPL_ALG_DSA_VERIFY               VOLT_FIPS_FNCT_ARG_BASE+4
#define VOLT_IMPL_ALG_DSA_SIGN_VERIFY          VOLT_FIPS_FNCT_ARG_BASE+5
#define VOLT_IMPL_ALG_SHA1                     VOLT_FIPS_FNCT_ARG_BASE+6
#define VOLT_IMPL_ALG_GENERAL_SHA1             VOLT_FIPS_FNCT_ARG_BASE+7
#define VOLT_IMPL_ALG_SHA224                   VOLT_FIPS_FNCT_ARG_BASE+8
#define VOLT_IMPL_ALG_SHA256                   VOLT_FIPS_FNCT_ARG_BASE+9
#define VOLT_IMPL_ALG_SHA384                   VOLT_FIPS_FNCT_ARG_BASE+10
#define VOLT_IMPL_ALG_SHA512                   VOLT_FIPS_FNCT_ARG_BASE+11
#define VOLT_IMPL_ALG_MD5                      VOLT_FIPS_FNCT_ARG_BASE+12
#define VOLT_IMPL_ALG_HMAC                     VOLT_FIPS_FNCT_ARG_BASE+13
#define VOLT_IMPL_ALG_BASE64                   VOLT_FIPS_FNCT_ARG_BASE+14
#define VOLT_IMPL_ALG_DES                      VOLT_FIPS_FNCT_ARG_BASE+15
#define VOLT_IMPL_ALG_3DES_EDE                 VOLT_FIPS_FNCT_ARG_BASE+16
#define VOLT_IMPL_ALG_AES                      VOLT_FIPS_FNCT_ARG_BASE+17
#define VOLT_IMPL_PARAM_MP_CTX                 VOLT_FIPS_FNCT_ARG_BASE+18
#define VOLT_IMPL_PARAM_DEFAULT                VOLT_FIPS_FNCT_ARG_BASE+19
#define VOLT_IMPL_PARAM_GEN_DSA_PARAMS         VOLT_FIPS_FNCT_ARG_BASE+20
#define VOLT_IMPL_PARAM_GEN_DH_PARAMS          VOLT_FIPS_FNCT_ARG_BASE+21
#define VOLT_IMPL_RANDOM_FIPS186_PRNG          VOLT_FIPS_FNCT_ARG_BASE+22
#define VOLT_IMPL_KEY_DEFAULT                  VOLT_FIPS_FNCT_ARG_BASE+23
#define VOLT_IMPL_KEY_MP_CTX                   VOLT_FIPS_FNCT_ARG_BASE+24
#define VOLT_IMPL_KEY_PAIR_GEN_DSA             VOLT_FIPS_FNCT_ARG_BASE+25
#define VOLT_IMPL_KEY_PAIR_GEN_DSA_AND_PARAMS  VOLT_FIPS_FNCT_ARG_BASE+26
#define VOLT_IMPL_KEY_PAIR_GEN_DH              VOLT_FIPS_FNCT_ARG_BASE+27
#define VOLT_IMPL_SHARED_SECRET_GEN_DH         VOLT_FIPS_FNCT_ARG_BASE+28
#define VOLT_IMPL_KEY_PAIR_GEN_RSA             VOLT_FIPS_FNCT_ARG_BASE+29
#define VOLT_IMPL_MP_INT_FIPS                  VOLT_FIPS_FNCT_ARG_BASE+30

#define VOLT_FEEDBACK_CBC                      VOLT_FIPS_FNCT_ARG_BASE+101
#define VOLT_FEEDBACK_CFB                      VOLT_FIPS_FNCT_ARG_BASE+102
#define VOLT_FEEDBACK_OFB                      VOLT_FIPS_FNCT_ARG_BASE+103

#define VOLT_PADDING_PKCS5                     VOLT_FIPS_FNCT_ARG_BASE+131

#define VOLT_LIB_VERSION_FIPS                  VOLT_FIPS_FNCT_ARG_BASE+151

#define VOLT_PARAM_ALG_SIG_DIGEST_ALG_OBJ      VOLT_FIPS_FNCT_ARG_BASE+161
#define VOLT_PARAM_ALG_DIGEST_STATE            VOLT_FIPS_FNCT_ARG_BASE+162
#define VOLT_PARAM_ALG_SURRENDER               VOLT_FIPS_FNCT_ARG_BASE+163
#define VOLT_PARAM_PARAM_IBE_TYPE1_CURVE       VOLT_FIPS_FNCT_ARG_BASE+171
#define VOLT_PARAM_PARAM_IBE_TYPE1_PARAMS      VOLT_FIPS_FNCT_ARG_BASE+172
#define VOLT_PARAM_PARAM_DSA_PARAMS            VOLT_FIPS_FNCT_ARG_BASE+191
#define VOLT_PARAM_PARAM_DSA_PARAMS_FIPS       VOLT_FIPS_FNCT_ARG_BASE+192
#define VOLT_PARAM_PARAM_DH_PARAMS             VOLT_FIPS_FNCT_ARG_BASE+193
#define VOLT_PARAM_PARAM_SURRENDER             VOLT_FIPS_FNCT_ARG_BASE+196
#define VOLT_PARAM_KEY_IBE_TYPE1_PUBLIC        VOLT_FIPS_FNCT_ARG_BASE+211
#define VOLT_PARAM_KEY_IBE_TYPE1_PRIVATE       VOLT_FIPS_FNCT_ARG_BASE+212
#define VOLT_PARAM_KEY_AES                     VOLT_FIPS_FNCT_ARG_BASE+231
#define VOLT_PARAM_KEY_DES                     VOLT_FIPS_FNCT_ARG_BASE+232
#define VOLT_PARAM_KEY_3DES                    VOLT_FIPS_FNCT_ARG_BASE+233
#define VOLT_PARAM_KEY_MAC                     VOLT_FIPS_FNCT_ARG_BASE+234
#define VOLT_PARAM_KEY_SYMMETRIC               VOLT_FIPS_FNCT_ARG_BASE+235
#define VOLT_PARAM_KEY_DSA_PUBLIC              VOLT_FIPS_FNCT_ARG_BASE+251
#define VOLT_PARAM_KEY_DSA_PRIVATE             VOLT_FIPS_FNCT_ARG_BASE+252
#define VOLT_PARAM_KEY_DH_PUBLIC               VOLT_FIPS_FNCT_ARG_BASE+256
#define VOLT_PARAM_KEY_DH_PRIVATE              VOLT_FIPS_FNCT_ARG_BASE+257
#define VOLT_PARAM_KEY_DH_SHARED_SECRET        VOLT_FIPS_FNCT_ARG_BASE+258
#define VOLT_PARAM_KEY_SURRENDER               VOLT_FIPS_FNCT_ARG_BASE+281

/* These macros expand to check the FIPS error, or to nothing,
 * depending on whether we're building for the shared library or not.
 */
#if VOLT_BUILD == VOLT_BUILD_FIPS_SHARED
#define VOLT_CHECK_FIPS_ERROR_OBJ(_status)                               \
    VOLT_CHECK_FIPS_ERROR (_status)
#define VOLT_CHECK_FIPS_ERROR(_status)                                   \
  status = VoltGetFipsError ();
#else
#define VOLT_CHECK_FOR_FIPS_ERROR(_obj,_status)
#define VOLT_CHECK_FIPS_ERROR_OBJ(_obj,_status)
#define VOLT_CHECK_FIPS_ERROR(_libraryCtx,_status)
#endif  /* VOLT_BUILD == VOLT_BUILD_FIPS_SHARED */

#ifdef __cplusplus
}
#endif

#endif /* _FIPS_MODULE_H */

⌨️ 快捷键说明

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