亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? opensslbnwrap.c

?? IBE是一種非對稱密碼技術
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
 */
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "mpint.h"
#include "opensslbnwrap.h"
#include "errorctx.h"
#include "openssl/bn.h"
#include "openssl/err.h"

int OpenSSLBnWrapCreateMpInt (
   Pointer mpIntCtx,
   VoltMpInt **newInt
   )
{
  int status;
  unsigned int bufferSize;
  unsigned char *buffer = (unsigned char *)0;
  VoltMpIntCtx *mpCtx = (VoltMpIntCtx *)mpIntCtx;
  VoltLibCtx *libCtx = (VoltLibCtx *)(mpCtx->voltObject.libraryCtx);
  VoltMpInt *mpInt;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* Allocate space for the VoltMpInt.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_MEMORY;
    bufferSize = sizeof (VoltMpInt);
    buffer = (unsigned char *)Z2Malloc (bufferSize, VOLT_MEMORY_SENSITIVE);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);

    /* Position the pointers.
     */
    mpInt = (VoltMpInt *)buffer;
    mpInt->mpCtx = (VtMpIntCtx)mpCtx;

    /* The mpInt field of the VoltMpInt will be a BIGNUM *.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    mpInt->mpInt = (Pointer)BN_new ();
    if (mpInt->mpInt == (Pointer)0)
      break;

    /* Initialize to zero.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (BN_set_word ((BIGNUM *)(mpInt->mpInt), 0) == 0)
      break;

    *newInt = (VoltMpInt *)mpInt;

    status = 0;

  } while (0);

  /* If successful, just return.
   */
  if (status == 0)
    return (0);

  /* If error, free memory.
   */
  if (buffer != (unsigned char *)0)
    Z2Free (buffer);

  VOLT_LOG_ERROR (
    libCtx, status, VT_ERROR_TYPE_PRIMARY, fnctLine,
    "OpenSSLBnWrapCreateMpInt", (char *)0)

  return (status);
}

int OpenSSLBnWrapDestroyMpInt (
   VoltMpInt **theInt
   )
{
  VoltMpIntCtx *mpCtx;
  VoltLibCtx *libCtx;

  /* Call the clear function for the mpz, then free up the MpInt's
   * memory.
   */
  if (theInt == (VoltMpInt **)0)
    return (0);
  if (*theInt == (VoltMpInt *)0)
    return (0);

  /* Destroy the BIGNUM in the mpInt.
   */
  if ((*theInt)->mpInt != (Pointer)0)
    BN_clear_free ((BIGNUM *)((*theInt)->mpInt));

  mpCtx = (VoltMpIntCtx *)((*theInt)->mpCtx);
  libCtx = (VoltLibCtx *)(mpCtx->voltObject.libraryCtx);

  Z2Free (*theInt);

  *theInt = (VoltMpInt *)0;

  return (0);
}

int OpenSSLBnWrapOctetStringToMpInt (
   unsigned int sign,
   unsigned char *sourceOctetString,
   unsigned int sourceOctetStringLen,
   VoltMpInt *destInt
   )
{
  int status;
  BIGNUM *bnTarget, *dummyBn;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* If NULL, we can't log an error, no libCtx.
   */
  if (destInt == (VoltMpInt *)0)
    return (VT_ERROR_NULL_ARG);

  do
  {
    /* Check the arguments.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_NULL_ARG;
    if (sourceOctetString == (unsigned char *)0)
      break;
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_INPUT_LENGTH;
    if (sourceOctetStringLen == 0)
      break;

    bnTarget = (BIGNUM *)(destInt->mpInt);

    /* Call the bn version.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_MEMORY;
    dummyBn = BN_bin2bn (
      sourceOctetString, (int)sourceOctetStringLen, bnTarget);

    /* If it worked, the result is the same as the input.
     * If they are different, there was some error, likely memory.
     */
    if (dummyBn != bnTarget)
      break;

    /* To set the sign, we can't treat the bn as an opaque type. So
     * long as the definition of BIGNUM does not change, this will work.
     * If sign is 0, the number is positive. Otherwise, the number is
     * negative. Inside a BIGNUM, if neg is 0, the number is positive,
     * if neg is 1, the number is negative.
     */
    bnTarget->neg = 1;
    if (sign == 0)
      bnTarget->neg = 0;

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_COMPARE (
    status, destInt->mpCtx->voltObject.libraryCtx, status,
    VT_ERROR_TYPE_PRIMARY, fnctLine, "OpenSSLBnWrapOctetStringToMpInt",
    (char *)0)

  return (status);
}

int OpenSSLBnWrapIntToMpInt (
   int signCheck,
   int sourceValue,
   VoltMpInt *destInt
   )
{
  int status, posVal;
  BIGNUM *bnTarget;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* If NULL, we can't log an error, no libCtx.
   */
  if (destInt == (VoltMpInt *)0)
    return (VT_ERROR_NULL_ARG);

  bnTarget = (BIGNUM *)(destInt->mpInt);

  do
  {
    status = VT_ERROR_MEMORY;

    /* If signCheck is 0, the sourceValue is an unsigned int.
     */
    if (signCheck == 0)
    {
      /* This function returns 0 for failure and presumably 1 for success.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      if (BN_set_word (bnTarget, (BN_ULONG)sourceValue) != 0)
        status = 0;
    }
    else
    {
      /* If signCheck is not 0, the sourceValue is a signed int.
       */
      posVal = -sourceValue;
      if (sourceValue >= 0)
        posVal = sourceValue;

      /* This function returns 0 for failure.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      if (BN_set_word (bnTarget, (BN_ULONG)posVal) == 0)
        break;

      /* To set the sign, we can't treat the bn as an opaque type. So
       * long as the definition of BIGNUM does not change, this will work.
       * If sign is 0, the number is positive. Otherwise, the number is
       * negative. Inside a BIGNUM, if neg is 0, the number is positive,
       * if neg is 1, the number is negative.
       */
      bnTarget->neg = 1;
      if (sourceValue >= 0)
        bnTarget->neg = 0;

      status = 0;
    }

  } while (0);

  VOLT_LOG_ERROR_COMPARE (
    status, destInt->mpCtx->voltObject.libraryCtx, status,
    VT_ERROR_TYPE_PRIMARY, fnctLine, "OpenSSLBnWrapIntToMpInt", (char *)0)

  return (status);
}

int OpenSSLBnWrapMpIntToInt (
   VoltMpInt *sourceInt,
   int signCheck,
   int *destValue
   )
{
  int status, returnValSigned;
  unsigned int returnValUnsigned;
  BN_ULONG result;
  BIGNUM *srcBn;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* If NULL, we can't log an error, no libCtx.
   */
  if (sourceInt == (VoltMpInt *)0)
    return (VT_ERROR_NULL_ARG);

  srcBn = (BIGNUM *)(sourceInt->mpInt);

  do
  {
    /* Check the arguments.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_NULL_ARG;
    if (destValue == (int *)0)
      break;

    *destValue = 0;
    result = BN_get_word (srcBn);

    /* If the return is BN_MASK2, the value was too big to fit into the
     * BN_ULONG. If not, we have an answer.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_MP_INT_RANGE;
    if (result == BN_MASK2)
      break;

    /* We have the answer as a BN_ULONG, get it as an unsigned int.
     */
    returnValUnsigned = (unsigned int)result;

    /* Make sure the conversion from BN_ULONG to unsigned int did not
     * lose any precision.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (result != (BN_ULONG)returnValUnsigned)
      break;

    /* If signCheck is 0, the caller wanted the value as an unsigned
     * int.
     */
    if (signCheck == 0)
    {
      *destValue = (int)returnValUnsigned;
      status = 0;
      break;
    }

    /* The caller wants a signed int.
     * First, check to see if the value fits into a signed int. If
     * the value is negative, it was too big.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    returnValSigned = (int)returnValUnsigned;
    if (returnValSigned < 0)
      break;

    /* To get the sign, we can't treat the bn as an opaque type. So
     * long as the definition of BIGNUM does not change, this will
     * work. Inside a BIGNUM, if neg is 0, the number is positive,
     * if neg is 1, the number is negative.
     */
    *destValue = returnValSigned;
    if (srcBn->neg != 0)
      *destValue = -returnValSigned;

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_COMPARE (
    status, sourceInt->mpCtx->voltObject.libraryCtx, status,
    VT_ERROR_TYPE_PRIMARY, fnctLine, "OpenSSLBnWrapMpIntToInt", (char *)0)

  return (status);
}

int OpenSSLBnWrapMpIntToMpInt (
   VoltMpInt *sourceInt,
   VoltMpInt *destInt
   )
{
  BIGNUM *retVal;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* If NULL, we can't log an error, no libCtx.
   * We could check for one NULL, the other not, but this is the kind
   * of error an app expects not to log.
   */
  if ( (sourceInt == (VoltMpInt *)0) || (destInt == (VoltMpInt *)0) )
    return (VT_ERROR_NULL_ARG);

  /* If successful, this function returns the destination BIGNUM.
   * If the return is NULL, error. Probably the only error possible is
   * memory.
   */
  VOLT_SET_FNCT_LINE (fnctLine)
  retVal = BN_copy ((BIGNUM *)(destInt->mpInt), (BIGNUM *)(sourceInt->mpInt));
  if (retVal != (BIGNUM *)0)
    return (0);

  VOLT_LOG_ERROR (
    sourceInt->mpCtx->voltObject.libraryCtx, VT_ERROR_MEMORY,
    VT_ERROR_TYPE_PRIMARY, fnctLine, "OpenSSLBnWrapMpIntToMpInt", (char *)0)

  return (VT_ERROR_MEMORY);
}

int OpenSSLBnWrapMpIntToOctetString (
   VoltMpInt *sourceInt,
   unsigned int *sign,
   unsigned char *destBuf,
   unsigned int bufferSize,
   unsigned int *destLen
   )
{
  int status;
  unsigned int bitLen, octLen;
  BIGNUM *sourceBn;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* If NULL, we can't log an error, no libCtx.
   */
  if (sourceInt == (VoltMpInt *)0)
    return (VT_ERROR_NULL_ARG);

  sourceBn = (BIGNUM *)(sourceInt->mpInt);

  do
  {
    /* Check the arguments.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_NULL_ARG;
    if ( (sign == (unsigned int *)0) || (destLen == (unsigned int *)0) )
      break;

    if (destBuf == (unsigned char *)0)
      bufferSize = 0;

    /* To get the sign, we can't treat the bn as an opaque type. So long
     * as the definition of BIGNUM does not change, this will work.
     * Inside a BIGNUM, if neg is 0, the number is positive, if neg is 1,
     * the number is negative.
     */
    *sign = 1;
    if (sourceBn->neg == 0)
      *sign = 0;

    /* How big does the buffer need to be?
     */
    bitLen = (unsigned int)BN_num_bits (sourceBn);
    octLen = 1;
    if (bitLen != 0)
      octLen = (bitLen + 7) / 8;

    /* Is the buffer big enough?
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_BUFFER_TOO_SMALL;
    *destLen = octLen;
    if (bufferSize < octLen)
      break;

    /* If bitLen is 0, the value of the BIGNUM is 0. If bitLen is not
     * 0, call the BN function to get the octet string.
     */
    destBuf[0] = 0;
    if (bitLen != 0)
      octLen = BN_bn2bin (sourceBn, destBuf);

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_COMPARE (
    status, sourceInt->mpCtx->voltObject.libraryCtx, status,
    VT_ERROR_TYPE_PRIMARY, fnctLine, "OpenSSLBnWrapMpIntToOctetString",
    (char *)0)

  return (status);
}

int OpenSSLBnWrapCompare (
   VoltMpInt *leftInt,
   VoltMpInt *rightInt,
   int *result
   )
{
  int bnResult;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费毛片嘿嘿连载视频| 久久精品国产秦先生| 久久久久久久久久久久久夜| 精品国产百合女同互慰| 欧美一区二区三区在线观看| 91精品在线免费| 欧美精品一卡二卡| 555www色欧美视频| 日韩亚洲欧美成人一区| 2023国产精品视频| 亚洲国产精品成人久久综合一区| 国产亚洲一区二区三区四区| 亚洲精品一区二区三区蜜桃下载| 2017欧美狠狠色| 国产欧美精品在线观看| 18欧美乱大交hd1984| 亚洲午夜免费福利视频| 日产精品久久久久久久性色| 精品一区二区三区的国产在线播放| 国产在线日韩欧美| 91视频你懂的| 91精品久久久久久蜜臀| 精品国产免费人成在线观看| 欧美激情一区二区三区蜜桃视频| 亚洲欧洲韩国日本视频| 亚洲第一主播视频| 国产一区二区三区观看| 99re热这里只有精品免费视频| 欧美日韩一区二区欧美激情| 精品国产乱码久久久久久牛牛| 欧美国产一区在线| 婷婷久久综合九色国产成人| 极品美女销魂一区二区三区| www.日本不卡| 日韩欧美国产一区二区三区| 亚洲视频免费在线| 久久99九九99精品| 91捆绑美女网站| 精品免费国产二区三区| 亚洲精品久久久久久国产精华液| 日韩电影在线观看网站| 成人精品视频.| 欧美一激情一区二区三区| 中文在线免费一区三区高中清不卡| 一区二区三区小说| 国产成人在线看| 欧美精品v日韩精品v韩国精品v| 国产精品的网站| 激情图区综合网| 欧美精品一二三| 一区二区三区精品视频在线| 国产伦理精品不卡| 欧美一区二区三区白人| 亚洲人一二三区| 盗摄精品av一区二区三区| 日韩一级大片在线| 日日摸夜夜添夜夜添国产精品| 成人av电影免费观看| 久久亚洲综合av| 日本在线不卡视频一二三区| 91美女在线看| 国产精品女人毛片| 成人激情视频网站| 国产精品污www在线观看| 激情综合色综合久久综合| 日韩三级视频在线看| 亚洲h精品动漫在线观看| 欧美亚日韩国产aⅴ精品中极品| 国产精品狼人久久影院观看方式| 国产乱人伦偷精品视频免下载| 日韩网站在线看片你懂的| 午夜欧美视频在线观看 | 欧美一区二区三区系列电影| 亚洲激情图片qvod| 欧洲中文字幕精品| 亚洲一区二区在线免费观看视频| av不卡一区二区三区| 中文字幕免费观看一区| 成人污污视频在线观看| 亚洲国产精品精华液ab| av午夜精品一区二区三区| 亚洲欧洲99久久| 欧美在线不卡一区| 亚洲成人av一区二区三区| 777a∨成人精品桃花网| 人禽交欧美网站| 欧美成人伊人久久综合网| 国产一区二区三区在线观看免费视频 | 成a人片国产精品| 国产日产欧美一区二区视频| 成人小视频免费在线观看| 国产精品久久久久久久久搜平片 | 亚洲精品一线二线三线| 国产91精品久久久久久久网曝门| 国产精品第一页第二页第三页| 91九色最新地址| 日韩影院免费视频| 久久综合久久久久88| 成人高清免费在线播放| 亚洲综合自拍偷拍| 精品国产污网站| 一本一本久久a久久精品综合麻豆| 亚洲国产精品久久不卡毛片| 欧美电影免费观看高清完整版在线观看| 久久99精品久久久久婷婷| 国产精品免费免费| 欧美人伦禁忌dvd放荡欲情| 国产精品一区二区x88av| 亚洲久本草在线中文字幕| 日韩女优电影在线观看| 91麻豆国产香蕉久久精品| 日本不卡一区二区三区高清视频| 欧美高清在线一区二区| 在线电影国产精品| 国产suv精品一区二区6| 亚洲福利视频一区二区| 欧美国产欧美综合| 日韩一区二区三区电影| 91免费看片在线观看| 精品午夜久久福利影院 | 日本欧美一区二区三区| 国产精品国产三级国产aⅴ中文| 欧美高清视频在线高清观看mv色露露十八| 久久av中文字幕片| 香蕉成人伊视频在线观看| 国产精品人人做人人爽人人添| 4438成人网| 欧美中文一区二区三区| 国产91丝袜在线播放| 久久国产精品72免费观看| 亚洲精品ww久久久久久p站| 久久久久久免费毛片精品| 日韩欧美激情一区| 欧美日本精品一区二区三区| 色94色欧美sute亚洲线路一久 | 国产亚洲综合av| 欧美mv和日韩mv的网站| 在线综合视频播放| 在线精品视频免费观看| 99国产一区二区三精品乱码| 国产精品99久久久| 蜜臀99久久精品久久久久久软件| 一区二区三区精品在线| 亚洲猫色日本管| 亚洲精品视频在线观看网站| 中文字幕在线一区免费| 国产精品乱子久久久久| 欧美激情一区三区| 国产精品久久久爽爽爽麻豆色哟哟 | 久久久久久久久久电影| 精品国产亚洲在线| 久久久99久久| 久久精品一区二区三区不卡牛牛 | 亚洲国产va精品久久久不卡综合| 亚洲精品久久久久久国产精华液| 亚洲人成网站色在线观看| ●精品国产综合乱码久久久久| 日韩一区在线免费观看| 亚洲靠逼com| 亚洲成人动漫在线观看| 免费亚洲电影在线| 国产经典欧美精品| jiyouzz国产精品久久| 色拍拍在线精品视频8848| 欧美影院一区二区| 91精品欧美综合在线观看最新| 日韩午夜在线观看| 欧美成人三级在线| 国产色一区二区| 国产精品日产欧美久久久久| 国产精品国产三级国产aⅴ原创| 最新国产の精品合集bt伙计| 18成人在线观看| 日韩精品午夜视频| 国产精品99久久久| 色综合一个色综合亚洲| 欧美精品色综合| 久久午夜电影网| 综合久久国产九一剧情麻豆| 亚洲成人自拍网| 国产一区二区不卡| 91国产福利在线| 精品国产一区二区精华| 最新热久久免费视频| 亚洲第一搞黄网站| 成人永久免费视频| 欧美日本在线播放| 国产人成亚洲第一网站在线播放| 亚洲女性喷水在线观看一区| 免费看日韩精品| 99re亚洲国产精品| 欧美tk—视频vk| 亚洲精品国产无套在线观| 国产麻豆精品在线观看| 91成人在线观看喷潮| 日韩欧美不卡一区| 亚洲中国最大av网站| 国产.欧美.日韩| 91麻豆精品91久久久久同性| 亚洲色图欧美偷拍|