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

📄 gmptype.c

📁 IBE是一种非对称密码技术
💻 C
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
 */
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "mpint.h"
#include "gmpwrap.h"
#include "errorctx.h"

int VtMpIntImplGMP (
   VtMpIntCtx *mpCtx,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltMpIntCtx *ctx = (VoltMpIntCtx *)(*mpCtx);
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* Check the flag, it should be VOLT_MP_CTX_SET_TYPE_FLAG.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_MP_CTX_SET_TYPE_FLAG)
      break;

    /* The associated info should be NULL pointer.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if (info != (Pointer)0)
      break;

    /* Set the fields of the mpCtx.
     */
    ctx->MpIntImpl = VtMpIntImplGMP;
    ctx->CreateMpInt = GMPWrapCreateMpInt;
    ctx->DestroyMpInt = GMPWrapDestroyMpInt;
    ctx->OctetStringToMpInt = GMPWrapOctetStringToMpInt;
    ctx->IntToMpInt = GMPWrapIntToMpInt;
    ctx->MpIntToMpInt = GMPWrapMpIntToMpInt;
    ctx->MpIntToOctetString = GMPWrapMpIntToOctetString;
    ctx->MpIntToInt = GMPWrapMpIntToInt;
    ctx->Compare = GMPWrapCompare;
    ctx->EvenOddZeroPositiveNegative = GMPWrapEvenOddZeroPositiveNegative;
    ctx->GetBitLength = GMPWrapGetBitLength;
    ctx->SetBit = GMPWrapSetBit;
    ctx->GetBit = GMPWrapGetBit;
    ctx->ShiftLeftBits = GMPWrapShiftLeftBits;
    ctx->ShiftRightBits = GMPWrapShiftRightBits;
    ctx->Add = GMPWrapAdd;
    ctx->Subtract = GMPWrapSubtract;
    ctx->Multiply = GMPWrapMultiply;
    ctx->Square = GMPWrapSquare;
    ctx->Divide = GMPWrapDivide;
    ctx->GCD = GMPWrapGCD;
    ctx->ModReduce = GMPWrapModReduce;
    ctx->ModInvert = GMPWrapModInvert;
    ctx->ModExp = GMPWrapModExp;
    /* GMP does not supply a CRT function, use the Volt version.
     */
    ctx->ModExpCRT = VoltModExpCRT;
    ctx->GeneratePrime = GMPWrapGeneratePrime;
    /* No need for a SpecialDestroy.
     */

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_COMPARE (
    status, ctx->voltObject.libraryCtx, status, VT_ERROR_TYPE_PRIMARY,
    fnctLine, "VtMpIntImplGMP", (char *)0)

  return (status);
}

⌨️ 快捷键说明

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