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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dhkeytype.c

?? IBE是一種非對稱密碼技術(shù)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Copyright 2005-2006, Voltage Security, all rights reserved.
 */
#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "keyobj.h"
#include "dh.h"
#include "mpint.h"
#include "errorctx.h"

/* Gets the key data out of a key object.
 *
 * @param object The object from which the data is to be extracted.
 * @param getInfo The address where the function will deposit the
 * pointer to the info.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV VoltKeyGetDHPublic VOLT_PROTO_LIST ((
   VtKeyObject object,
   Pointer *getInfo
));

/* Gets the key data out of a key object.
 *
 * @param object The object from which the data is to be extracted.
 * @param getInfo The address where the function will deposit the
 * pointer to the info.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV VoltKeyGetDHPrivate VOLT_PROTO_LIST ((
   VtKeyObject object,
   Pointer *getInfo
));

/* This routine does the work. It allocates and fills in the contexts.
 *
 * @param obj The key object to set.
 * @param keyInfo The data, params and pub value.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV SetObjectDHPublic VOLT_PROTO_LIST ((
   VoltKeyObject *obj,
   VtDHPubKeyInfo *keyInfo
));

/* This routine does the work. It allocates and fills in the contexts.
 *
 * @param obj The key object to set.
 * @param keyInfo The data, params and pub and pri values.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV SetObjectDHPrivate VOLT_PROTO_LIST ((
   VoltKeyObject *obj,
   VtDHPriKeyInfo *keyInfo
));

/* Fill in the buffer with the public key info as a
 * VtDHPubKeyInfo struct.
 * <p>This routine does no argument checking, it is the responsibility
 * of the caller not to make mistakes. If buffer is NULL, *bufferSize
 * must be 0.
 *
 * @param obj The key object.
 * @param pubKey The VoltDHPublicKey struct with the MpInt version of
 * the key data.
 * @param The buffer to fill.
 * @param bufferSize As input, the current size of the buffer, as
 * output, the size the buffer needs to be or the number of bytes paced
 * into the buffer.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV BuildPubKeyInfo VOLT_PROTO_LIST ((
   VoltKeyObject *obj,
   VoltDHPublicKey *pubKey,
   unsigned char *buffer,
   unsigned int *bufferSize
));

/* Fill in the buffer with the private key info as a
 * VtDHPriKeyInfo struct.
 * <p>This routine does no argument checking, it is the responsibility
 * of the caller not to make mistakes. If buffer is NULL, *bufferSize
 * must be 0.
 *
 * @param obj The key object.
 * @param pubKey The VoltDHPrivateKey struct with the MpInt version of
 * the key data.
 * @param The buffer to fill.
 * @param bufferSize As input, the current size of the buffer, as
 * output, the size the buffer needs to be or the number of bytes paced
 * into the buffer.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV BuildPriKeyInfo VOLT_PROTO_LIST ((
   VoltKeyObject *obj,
   VoltDHPrivateKey *priKey,
   unsigned char *buffer,
   unsigned int *bufferSize
));

int VtKeyParamDHPublic (
   VtKeyObject object,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltKeyObject *obj = (VoltKeyObject *)object;
  VtDHPubKeyInfo *keyInfo = (VtDHPubKeyInfo *)info;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    if (flag == VOLT_KEY_GET_TYPE_FLAG)
    {
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltKeyGetDHPublic (object, (Pointer *)info);
      break;
    }

    /* Check the flag, it should be VOLT_KEY_SET_TYPE_FLAG.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_KEY_SET_TYPE_FLAG)
      break;

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

    /* If using this KeyParam, the key must already have an mpCtx
     * loaded.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_KEY_OBJ;
    if (obj->mpCtx == (VoltMpIntCtx *)0)
      break;

    /* Make sure the key data is there.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if ( (keyInfo->primeP.data == (unsigned char *)0) ||
         (keyInfo->baseG.data == (unsigned char *)0) ||
         (keyInfo->pubValY.data == (unsigned char *)0) )
      break;

#if VOLT_BUILD == VOLT_BUILD_FIPS_SHARED
    /* If this is the FIPS build, there must be a subprimeQ.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if (keyInfo->subprimeQ.data == (unsigned char *)0)
      break;
#endif

    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = SetObjectDHPublic (obj, keyInfo);
    if (status != 0)
      break;

    /* Set the FIPS bit in the object type, this object is a FIPS
     * object.
     */
    obj->voltObject.objectType |= VOLT_OBJECT_TYPE_FIPS;

  } while (0);

  /* If everything worked, return 0.
   */
  if (status == 0)
    return (0);

  /* If something went wrong, indicate that this object is not usable.
   */
  obj->keyType = 0;

  VOLT_LOG_ERROR_INFO (
    0, obj, status, 0, errorType,
    (char *)0, "VtKeyParamDHPublic", fnctLine, (char *)0)

  return (status);
}

int VtKeyParamDHPrivate (
   VtKeyObject object,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltKeyObject *obj = (VoltKeyObject *)object;
  VtDHPriKeyInfo *keyInfo = (VtDHPriKeyInfo *)info;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    if (flag == VOLT_KEY_GET_TYPE_FLAG)
    {
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltKeyGetDHPrivate (object, (Pointer *)info);
      break;
    }

    /* Check the flag, it should be VOLT_KEY_SET_TYPE_FLAG.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_KEY_SET_TYPE_FLAG)
      break;

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

    /* If using this KeyParam, the key must already have an mpCtx
     * loaded.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_KEY_OBJ;
    if (obj->mpCtx == (VoltMpIntCtx *)0)
      break;

    /* Make sure the key data is there.
     * This check demands a 1024-bit primeP and a 160-bit subprimeQ.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if ( (keyInfo->primeP.data == (unsigned char *)0) ||
         (keyInfo->baseG.data == (unsigned char *)0) ||
         (keyInfo->pubValY.data == (unsigned char *)0) ||
         (keyInfo->priValX.data == (unsigned char *)0) )
      break;

#if VOLT_BUILD == VOLT_BUILD_FIPS_SHARED
    /* If this is the FIPS build, there must be a subprimeQ.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if (keyInfo->subprimeQ.data == (unsigned char *)0)
      break;
#endif

    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = SetObjectDHPrivate (obj, keyInfo);
    if (status != 0)
      break;

    /* Set the FIPS bit in the object type, this object is a FIPS
     * object.
     */
    obj->voltObject.objectType |= VOLT_OBJECT_TYPE_FIPS;

  } while (0);

  /* If everything worked, return 0.
   */
  if (status == 0)
    return (0);

  /* If something went wrong, indicate that this object is not usable.
   */
  obj->keyType = 0;

  VOLT_LOG_ERROR_INFO (
    0, obj, status, 0, errorType,
    (char *)0, "VtKeyParamDHPrivate", fnctLine, (char *)0)

  return (status);
}

static int VoltKeyGetDHPublic (
   VtKeyObject object,
   Pointer *getInfo
   )
{
  int status;
  unsigned int bufferSize;
  VoltKeyObject *obj = (VoltKeyObject *)object;
  VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
  unsigned char *buffer = (unsigned char *)0;
  VoltDHPublicKey *pubKey;
  VoltDHKeyPair *theKeyPair;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* Is there data?
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    if (obj->keyData == (Pointer)0)
      break;

    /* Is the algorithm DH?
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if ((obj->keyType & VOLT_KEY_TYPE_MASK_ASYM_ALG) != VOLT_KEY_ALG_DH)
      break;

    /* Check the keyType in the object, if it contains
     * VOLT_KEY_ALG_ASYM_PAIR, the contents are a key pair.
     */
    if ((obj->keyType & VOLT_KEY_TYPE_ASYM_PAIR) != 0)
    {
      VOLT_SET_FNCT_LINE (fnctLine)
      theKeyPair = (VoltDHKeyPair *)(obj->keyData);
      if (theKeyPair->pubKey == (VtKeyObject)0)
        break;

      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetKeyParam (
        theKeyPair->pubKey, VtKeyParamDHPublic, getInfo);
      break;
    }

    /* It's not a key pair.
     * We can get the public key data out of a private key object as well.
     */
    if ((obj->keyType & VOLT_KEY_TYPE_PRIVATE) != 0)
    {
      /* If this is a private key, we want to build the private keyItems
       * struct internally. Externally it looks just like the public.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetKeyParam (
        (VtKeyObject)obj, VtKeyParamDHPrivate, getInfo);
      break;
    }

    /* It's not a pair, it's not private, if it's not public, error.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if ((obj->keyType & VOLT_KEY_TYPE_PUBLIC) == 0)
      break;

    /* Is the key in data form?
     */
    if ((obj->keyType & VOLT_KEY_TYPE_MASK_DATA) != VOLT_KEY_TYPE_DATA)
    {
      /* The data is not available, does the object have a GetData
       * function?
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      *getInfo = (Pointer)0;
      if (obj->GetKeyData == (VGetKeyData)0)
        break;

      /* Call the Get function.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = obj->GetKeyData ((VtKeyObject)obj, getInfo);
      break;
    }

    /* Do we have the data in the appropriate format already?
     */
    status = 0;
    pubKey = (VoltDHPublicKey *)(obj->keyData);
    *getInfo = (Pointer)(pubKey->keyItems);
    if (pubKey->keyItems != (VtDHPubKeyInfo *)0)
      break;

    /* Call the routine that builds the VtDHPubKeyInfo struct.
     * This routine actually will return BufferTooSmall and set
     * bufferSize to the space needed. We'll allocate the space and
     * call it again.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    bufferSize = 0;
    status = BuildPubKeyInfo (obj, pubKey, buffer, &bufferSize);
    if (status == 0)
      status = VT_ERROR_INVALID_KEY_OBJ;
    if (status != VT_ERROR_BUFFER_TOO_SMALL)
      break;

    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_MEMORY;
    buffer = (unsigned char *)Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);

    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = BuildPubKeyInfo (obj, pubKey, buffer, &bufferSize);
    if (status != 0)
      break;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本久道久久综合中文字幕| 婷婷成人综合网| 夜夜嗨av一区二区三区中文字幕 | 精品夜夜嗨av一区二区三区| 青娱乐精品在线视频| 美女网站在线免费欧美精品| 国产中文一区二区三区| 99精品国产99久久久久久白柏| 欧美三级资源在线| 精品国产sm最大网站免费看| 亚洲同性gay激情无套| 亚洲成av人在线观看| 国产精品中文字幕日韩精品| 91看片淫黄大片一级在线观看| 欧美精品一级二级三级| 国产欧美一区视频| 日日嗨av一区二区三区四区| 高清免费成人av| 欧美日韩一区二区三区视频 | 国产69精品久久久久777| 色999日韩国产欧美一区二区| 欧美成人精精品一区二区频| 亚洲精选一二三| 精品无码三级在线观看视频| 色综合久久久久久久久久久| 久久精品亚洲乱码伦伦中文| 洋洋av久久久久久久一区| 国产麻豆视频精品| 欧美另类久久久品| 亚洲色图清纯唯美| 激情图区综合网| 欧美伊人久久久久久久久影院| 久久久精品2019中文字幕之3| 亚洲mv在线观看| 99国产精品久久| 精品国产乱码久久久久久久久| 一区二区三区精品在线| 国产东北露脸精品视频| 欧美一二三区精品| 亚洲一区二区五区| 99麻豆久久久国产精品免费| 久久这里只有精品6| 亚洲国产毛片aaaaa无费看| 成人av网站在线观看免费| 日韩欧美高清在线| 亚洲123区在线观看| 97超碰欧美中文字幕| 久久精品视频网| 久久不见久久见免费视频1| 欧美色倩网站大全免费| 亚洲三级免费观看| 成人av动漫网站| 国产欧美精品一区| 国内外成人在线| 日韩精品一区在线观看| 日本成人在线网站| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲国产另类av| 中文字幕免费不卡| 奇米影视一区二区三区| 激情综合色丁香一区二区| 国产一区二区三区精品视频| 欧美一区三区二区| 午夜电影一区二区| 欧美日韩精品欧美日韩精品 | 国产91精品一区二区| 久久综合久久综合久久| 老色鬼精品视频在线观看播放| 欧美人伦禁忌dvd放荡欲情| 夜夜精品视频一区二区 | 污片在线观看一区二区| 亚洲一区二区av在线| 欧美电视剧免费观看| 综合激情成人伊人| 韩国成人精品a∨在线观看| 精品区一区二区| 精品一区二区三区av| 2021国产精品久久精品| 国产一区二区三区美女| 久久亚洲一区二区三区四区| 国产一区二区91| 中文字幕第一区| 成人app软件下载大全免费| 国产精品视频观看| 91在线视频网址| 亚洲午夜久久久久久久久久久 | 亚洲精品日韩一| 欧美在线视频全部完| 午夜精品一区二区三区三上悠亚| 欧美三级视频在线观看| 日韩国产高清影视| 欧美mv和日韩mv的网站| 国产精品一线二线三线精华| 中文字幕免费不卡| 91浏览器在线视频| 婷婷成人激情在线网| 欧美不卡视频一区| 成人久久久精品乱码一区二区三区| 成人欧美一区二区三区黑人麻豆| 色久综合一二码| 日韩不卡在线观看日韩不卡视频| 欧美成人三级电影在线| 国产99久久久国产精品潘金网站| 国产精品九色蝌蚪自拍| 在线观看日韩精品| 日韩国产一二三区| 国产亚洲自拍一区| 色婷婷av一区二区三区软件| 日韩电影免费在线| 欧美国产一区二区在线观看| 色综合色综合色综合| 日本欧美一区二区三区乱码| 国产清纯美女被跳蛋高潮一区二区久久w| 亚洲不卡一区二区三区| 久久久久久久国产精品影院| 99久久伊人精品| 日韩福利电影在线| 国产欧美精品区一区二区三区 | 亚洲成国产人片在线观看| 精品久久人人做人人爰| 懂色av中文一区二区三区| 亚洲午夜日本在线观看| 久久亚洲综合av| 欧美色图片你懂的| 国产成a人无v码亚洲福利| 一区二区欧美精品| 精品免费视频一区二区| 91免费在线视频观看| 久久国产免费看| 亚洲精品乱码久久久久久久久 | 国模一区二区三区白浆| 亚洲精品免费在线观看| 国产亚洲成aⅴ人片在线观看 | 首页国产丝袜综合| 中文字幕+乱码+中文字幕一区| 欧美日本一道本| 国产成人精品亚洲日本在线桃色| 亚洲一级电影视频| 中文字幕av免费专区久久| 91精品国产全国免费观看| 99re这里只有精品首页| 久久成人免费网| 亚洲综合成人在线| 中文字幕高清一区| 日韩欧美一区在线| 在线观看中文字幕不卡| 成人性生交大片免费看中文 | 久久精品日韩一区二区三区| 欧美日韩国产综合草草| jlzzjlzz欧美大全| 久久99蜜桃精品| 亚洲高清免费观看| 亚洲婷婷综合色高清在线| 国产亚洲欧美日韩日本| 4hu四虎永久在线影院成人| 色猫猫国产区一区二在线视频| 成人久久18免费网站麻豆 | 欧美国产精品中文字幕| 日韩区在线观看| 欧美日韩国产一二三| 色婷婷综合五月| 99久久精品国产导航| 激情另类小说区图片区视频区| 午夜精品一区二区三区电影天堂| 亚洲免费看黄网站| 中文字幕一区二区三区四区不卡 | 国产综合久久久久久鬼色 | 久久综合久久综合久久综合| 欧美一区二区三区视频免费| 在线观看成人免费视频| 99久久精品国产毛片| 99久久久无码国产精品| av不卡在线播放| 99视频精品全部免费在线| 成人一区二区三区视频| 高清不卡一二三区| 成人在线一区二区三区| 国产精品主播直播| 成人午夜私人影院| 成人毛片老司机大片| 成人免费精品视频| eeuss国产一区二区三区| 成人的网站免费观看| 国产mv日韩mv欧美| 丁香一区二区三区| 成人综合在线观看| 成人av资源下载| 色综合天天综合| 欧洲一区二区三区免费视频| 在线精品视频一区二区| 欧洲人成人精品| 欧美高清激情brazzers| 91精品国产色综合久久久蜜香臀| 337p亚洲精品色噜噜噜| 日韩女优毛片在线| 久久久欧美精品sm网站 | 色狠狠色狠狠综合| 欧美中文字幕亚洲一区二区va在线| 在线免费精品视频| 欧美精品久久久久久久多人混战|