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

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

?? dhkeytype.c

?? IBE是一種非對稱密碼技術
?? 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一区二区三区免费野_久草精品视频
国产福利精品一区二区| 国产亚洲欧美激情| 91黄色免费网站| 欧美性猛交xxxxxx富婆| 国产精品久久久久aaaa| 日韩一区二区三区在线视频| 久久久蜜臀国产一区二区| 亚洲欧美一区二区久久| 亚洲激情图片qvod| 美女国产一区二区| 丁香亚洲综合激情啪啪综合| 欧美亚洲动漫精品| 国产视频一区二区三区在线观看| 亚洲日本丝袜连裤袜办公室| 国产主播一区二区三区| 一本色道久久综合亚洲91| 久久久久国产精品人| 亚洲成人你懂的| 成人妖精视频yjsp地址| 日韩午夜中文字幕| 亚洲一区在线观看免费观看电影高清 | 欧美韩日一区二区三区| 亚洲综合免费观看高清完整版在线 | 午夜视频久久久久久| 国产成人在线看| 日韩色在线观看| 日韩精品欧美成人高清一区二区| 不卡高清视频专区| 久久精品日产第一区二区三区高清版| 偷窥国产亚洲免费视频| 一本一本大道香蕉久在线精品 | 26uuu国产电影一区二区| 天天亚洲美女在线视频| 精品久久国产97色综合| 国产丝袜美腿一区二区三区| 国产专区综合网| 2023国产一二三区日本精品2022| 免费看黄色91| 日韩欧美一区二区免费| 老司机免费视频一区二区三区| 欧美蜜桃一区二区三区| 日本欧美在线观看| 日韩一区二区三| 首页国产欧美日韩丝袜| 欧美一区二区三区视频在线观看| 亚洲成年人网站在线观看| 色婷婷久久综合| 亚洲.国产.中文慕字在线| 欧美高清激情brazzers| 天堂一区二区在线| 久久久九九九九| 91美女片黄在线观看| 一区二区理论电影在线观看| 精品国产乱码久久| 亚洲香肠在线观看| 91精品国产欧美日韩| 黄一区二区三区| 国产精品久久久久久亚洲毛片| 一本大道久久a久久精二百| 婷婷综合五月天| 国产欧美日韩激情| 91在线免费视频观看| 日韩国产高清影视| 中文字幕第一区| 7878成人国产在线观看| 国产成人精品综合在线观看| 亚洲乱码精品一二三四区日韩在线| 国产偷v国产偷v亚洲高清| 日韩视频免费观看高清完整版 | 午夜免费久久看| 久久久美女毛片| 国产精品黄色在线观看| 秋霞电影一区二区| 1024成人网| 国产亚洲婷婷免费| 欧美一级日韩一级| 色婷婷精品久久二区二区蜜臂av | 轻轻草成人在线| 国产精品日日摸夜夜摸av| 欧美日本韩国一区| 色综合色狠狠天天综合色| 国产美女精品人人做人人爽| 午夜精品影院在线观看| 亚洲人成小说网站色在线| 久久久久久一二三区| 欧美一区二区播放| 91国在线观看| eeuss鲁一区二区三区| 国产一区二区三区免费播放| 91麻豆文化传媒在线观看| 国产精品福利影院| 久久综合久久综合亚洲| 日韩色在线观看| 日韩一级片在线观看| 欧美放荡的少妇| 777午夜精品视频在线播放| 91理论电影在线观看| 91女人视频在线观看| 99久精品国产| 欧洲一区二区三区免费视频| 色婷婷综合久久久久中文| 欧美性生活久久| 在线播放日韩导航| 欧美一区二区三区男人的天堂| 亚洲午夜电影在线| 日韩成人免费看| 麻豆国产精品一区二区三区 | 天天综合日日夜夜精品| 天天射综合影视| 婷婷一区二区三区| 美女视频黄 久久| 激情综合色播激情啊| 国产ts人妖一区二区| 97aⅴ精品视频一二三区| 欧美午夜精品电影| 正在播放一区二区| 337p日本欧洲亚洲大胆精品| 国产日韩av一区| 国产精品超碰97尤物18| 亚洲国产成人av网| 乱一区二区av| 成人av电影在线播放| 欧美日韩一区成人| 精品国产一区二区亚洲人成毛片| 久久久久久久久伊人| 樱花草国产18久久久久| 麻豆专区一区二区三区四区五区| 国产91在线看| 69久久夜色精品国产69蝌蚪网| 精品国产a毛片| 亚洲综合自拍偷拍| 久久亚洲捆绑美女| 777午夜精品免费视频| 中文字幕一区三区| 精品亚洲国内自在自线福利| 国产在线精品视频| 国产一区二区不卡老阿姨| 毛片基地黄久久久久久天堂| 国产一区二区三区香蕉 | 不卡的av中国片| 欧美中文字幕一区| 国产三级精品视频| 日本sm残虐另类| 色老汉一区二区三区| 2017欧美狠狠色| 天堂蜜桃91精品| 欧美在线一区二区| 国产精品卡一卡二| 久久99最新地址| www.欧美精品一二区| 欧美一区二区性放荡片| 伊人开心综合网| 99视频国产精品| 国产三级精品三级在线专区| 亚洲激情在线播放| 成人一二三区视频| 国产精品欧美精品| 成人久久视频在线观看| 久久久电影一区二区三区| 精品一区二区成人精品| 精品欧美一区二区在线观看| 免费观看成人av| 欧美日韩精品三区| 香港成人在线视频| 欧美日韩一区二区三区不卡| 日日夜夜免费精品| 日韩欧美一二三四区| 国产精品中文欧美| 日韩视频免费直播| 久久精品国产亚洲a| 欧美美女网站色| 日本女优在线视频一区二区| 精品国产欧美一区二区| 国产一区二区不卡| 亚洲欧美日韩在线| 欧美日韩精品一区二区天天拍小说 | 欧美久久一二区| 日本人妖一区二区| 久久久电影一区二区三区| 99在线精品一区二区三区| 亚洲一区中文在线| 精品国产亚洲在线| 成人ar影院免费观看视频| 亚洲18女电影在线观看| 久久久久久99久久久精品网站| 91一区二区在线| 理论电影国产精品| 亚洲综合图片区| 久久久不卡网国产精品二区| 91丨porny丨国产入口| 美国精品在线观看| 亚洲精品中文在线观看| 日韩欧美中文字幕精品| 色八戒一区二区三区| 国产麻豆精品在线观看| 亚洲一级二级三级在线免费观看| 久久久久国产精品厨房| 欧美日韩一区二区三区视频| 成人av高清在线| 国产91色综合久久免费分享|