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

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

?? writeenv.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 "p7obj.h"
#include "idobj.h"
#include "algobj.h"
#include "derhelp.h"
#include "oidlist.h"
#include "errorctx.h"

/* Set up the OpenSSL ASN.1 templates.
 */
ASN1_SEQUENCE (Asn1EncryptedInfo) =
{
  ASN1_SIMPLE (Asn1EncryptedInfo, contentType, Asn1ObjectId),
  ASN1_SIMPLE (Asn1EncryptedInfo, algId, Asn1Encoded),
  ASN1_IMP (Asn1EncryptedInfo, encryptedContent, Asn1EncryptedContent, 0)
} ASN1_SEQUENCE_END (Asn1EncryptedInfo);

IMPLEMENT_ASN1_FUNCTIONS (Asn1EncryptedInfo)

ASN1_SEQUENCE (Asn1EnvelopedData) =
{
  ASN1_SIMPLE (Asn1EnvelopedData, version, ASN1_INTEGER),
  ASN1_SET_OF (Asn1EnvelopedData, recipInfo, Asn1RecipientInfo),
  ASN1_SIMPLE (Asn1EnvelopedData, encryptedInfo, Asn1EncryptedInfo)
} ASN1_SEQUENCE_END (Asn1EnvelopedData);

IMPLEMENT_ASN1_FUNCTIONS (Asn1EnvelopedData)

ASN1_SEQUENCE (Asn1EnvelopedContent) =
{
  ASN1_SIMPLE (Asn1EnvelopedContent, contentType, Asn1ObjectId),
  ASN1_EXP (Asn1EnvelopedContent, envelopedData, Asn1EnvelopedData, 0)
} ASN1_SEQUENCE_END (Asn1EnvelopedContent);

IMPLEMENT_ASN1_FUNCTIONS (Asn1EnvelopedContent)

/* The identity object should contain an encoded ID. Build the
 * identity-based IssuerAndSerialNumber out of it.
 *
 *  IssuerAndSerialNumber ::= SEQUENCE {
 *    issuer Name,
 *    serialNumber CertificateSerialNumber }
 *
 *  CertificateSerialNumber  ::=  INTEGER
 *
 * The serialNumber is always 1 (02 01 01).
 * <p>The Name will contain one Attribute (OID: id-at-name), which is the
 * PrintableString of the Base64 encoded identity string.
 *
 *   Name ::= CHOICE {
 *    RDNSequence }
 *
 *   RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
 *
 *   RelativeDistinguishedName ::=
 *     SET OF AttributeTypeAndValue
 *
 *   AttributeTypeAndValue ::= SEQUENCE {
 *     type     AttributeType,
 *     value    AttributeValue }
 *
 *   AttributeType ::= OBJECT IDENTIFIER
 *
 *   AttributeValue ::= ANY DEFINED BY AttributeType
 *
 * The IssuerAndSerialNumber in this context will then be fixed at
 *
 *   30 len                           SEQ: IssuerAndSerialNumber
 *     30 len                           SEQ OF RDN
 *        31 len                          SET OF Attribute
 *           30 len                         SEQ: Attribute
 *              06 03                         OID
 *                 55 04 29
 *              13 len                        value (ANY, PrintableString)
 *                 <Base64 of encoded ID>
 *     02 01                            INTEGER: serialNumber
 *        01
 *
 * This function will allocate the space necessary to hold the encoding
 * and return the new buffer and its length. It is the responsibility
 * of the caller to free that memory.
 * <p>This function assumes that the identity has been encoded and that
 * it exists in the encoding field of the VoltIdentityObject. The
 * routine will do no argument checking.
 *
 * @param libCtx The library ctx to use.
 * @param idObj The object containing the ID to build into issuer and
 * serial number.
 * @param base64 An object built to encode binary data to Base64.
 * @param issuerSerial The address where the function will deposit the
 * pointer to the newly allocated buffer.
 * @param issuerSerialLen The address where the function will deposit
 * the length of the encoding.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV VoltBuildIssuerSerialAlloc VOLT_PROTO_LIST ((
   VoltLibCtx *libCtx,
   VtIdentityObject idObj,
   VtAlgorithmObject base64,
   unsigned char **issuerSerial,
   unsigned int *issuerSerialLen
));

int VoltP7EnvWriteInit (
   VtPkcs7Object pkcs7Obj,
   VtPolicyCtx policyCtx,
   VtStorageCtx storageCtx,
   VtTransportCtx transportCtx,
   VtRandomObject random
   )
{
  int status;
  unsigned int index, indexC, indexD, idCount, maxIndex, keyLen;
  VoltPkcs7Object *obj = (VoltPkcs7Object *)pkcs7Obj;
  VoltPkcs7WriteEnvCtx *envCtx = (VoltPkcs7WriteEnvCtx *)(obj->localCtx);
  VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
  unsigned char *keyData = (unsigned char *)0;
  VtAlgorithmObject base64 = (VtAlgorithmObject)0;
  VtIdentityObject currentId, compareId;
  VtBase64Info base64Info;
  VtItem keyItem;
  VtItem *getKeyData;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* The state must be VOLT_P7_STATE_ENV_WRITE_SET, if not, we're
     * not allowed to call WriteInit.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_CALL_ORDER;
    if (obj->state != VOLT_P7_STATE_ENV_WRITE_SET)
      break;

    /* This implementation does not work without recipients or a
     * symmetric encryptor. The recipients might be represented as an
     * IdentityList or as a list of RecipientData.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_P7_OBJ;
    if ( (envCtx->recipList == (VtIdentityList)0) &&
         (envCtx->recipients == (VoltRecipientData *)0) )
      break;
    VOLT_SET_FNCT_LINE (fnctLine)
    if (envCtx->symEncryptor == (VtAlgorithmObject)0)
      break;

    /* Build a Base64 object. We'll need it later for each recipient,
     * so rather than build again and again, build one now and pass it
     * around.
     */
    base64Info.base64BlockSize = 76;
    base64Info.newLineCharacter = VT_BASE64_NO_NEW_LINE;
    base64Info.errorCheck = VT_BASE64_NO_ERROR_CHECK;
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtCreateAlgorithmObject (
      (VtLibCtx)libCtx, VtAlgorithmImplBase64, (Pointer)&base64Info,
      &base64);
    if (status != 0)
      break;

    /* If there's no key object yet, build it. If there is one, get the
     * key data.
     */
    if (envCtx->symKey == (VtKeyObject)0)
    {
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_MEMORY;
      keyLen = (envCtx->symKeyBits + 7) / 8;
      keyData = (unsigned char *)Z2Malloc (keyLen, VOLT_MEMORY_SENSITIVE);
      if (keyData == (unsigned char *)0)
        break;

      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGenerateRandomBytes (random, keyData, keyLen);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtCreateKeyObject (
        (VtLibCtx)libCtx, VtKeyImplDefault, (Pointer)0, &(envCtx->symKey));
      if (status != 0)
        break;

      keyItem.data = keyData;
      keyItem.len = keyLen;
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetKeyParam (
        envCtx->symKey, envCtx->SymKeyParam, (Pointer)&keyItem);
      if (status != 0)
        break;

      getKeyData = &keyItem;
    }
    else
    {
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetKeyParam (
        envCtx->symKey, envCtx->SymKeyParam, (Pointer *)&getKeyData);
      if (status != 0)
        break;
    }

    /* If we don't have the RecipientData array built, build it. If it
     * is built, just compute the totalRecipInfoLen and we're done.
     */
    if (envCtx->recipients != (VoltRecipientData *)0)
    {
      envCtx->totalRecipInfoLen = 0;
      for (index = 0; index < envCtx->recipientsCount; ++index)
        envCtx->totalRecipInfoLen += envCtx->recipients[index].recipInfoLen;

      break;
    }

    /* How many recipients are there?
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtGetIdentityListCount (envCtx->recipList, &idCount, &maxIndex);
    if (status != 0)
      break;

    /* Build the array of recipientDatas. Use index as a temp variable.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_MEMORY;
    index = idCount * sizeof (VoltRecipientData);
    envCtx->recipients = (VoltRecipientData *)Z2Malloc (index, 0);
    if (envCtx->recipients == (VoltRecipientData *)0)
      break;
    Z2Memset (envCtx->recipients, 0, index);
    envCtx->recipientsCount = idCount;

    /* Cycle through the identities, creating RecipientData for each.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    indexD = 0;
    for (index = 0; index <= maxIndex; ++index)
    {
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetIdentityListIdentity (
        envCtx->recipList, index, &currentId);
      if (status != 0)
      {
        /* If status is VT_ERROR_NO_ID_AT_INDEX, don't quit, just move
         * on to the next ID in the list.
         */
        if (status != VT_ERROR_NO_ID_AT_INDEX)
          break;
        status = 0;
        continue;
      }

      /* Make sure the identity is encoded. Calling this routine will
       * build the encoded ID internally, which is all we need. Use
       * keyLen as a temp variable. We're expecting the
       * BUFFER_TOO_SMALL error.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtEncodeIdentity (
        currentId, VT_ENCODE_IBCS_2_V_DISTRICT, policyCtx,
        storageCtx, transportCtx, (unsigned char *)0, 0, &keyLen);
      if (status == 0)
        status = VT_ERROR_GENERAL;
      if (status != VT_ERROR_BUFFER_TOO_SMALL)
        break;

      /* If this is a repeat identity, don't bother with it. Set it to
       * be inactive. Compare with all previously encoded ID's.
       * Use keyLen as a temp variable.
       */
      keyLen = 0;
      for (indexC = 0; indexC < index; ++indexC)
      {
        status = VtGetIdentityListIdentity (
          envCtx->recipList, indexC, &compareId);
        if (status != 0)
          continue;

        VoltIsSameIdentity (currentId, compareId, &keyLen);
        if (keyLen != 0)
          break;
      }

      /* If keyLen is not 0, there was a matching ID, ignore this
       * identity.
       */
      if (keyLen != 0)
      {
        VtSetEntryStatusInIdentityList (
          envCtx->recipList, index, VT_RECIPIENT_LIST_ENTRY_INACTIVE);
        continue;
      }

      /* Build the RecipientData struct for this identity.
       */
      envCtx->recipients[indexD].idRef = currentId;
      VOLT_SET_FNCT_LINE (fnctLine)
      status =  VoltBuildRecipientData (
        (VoltObject *)obj, random, base64, VtDerCoderBFType1IBE,
        getKeyData->data, getKeyData->len, &(envCtx->recipients[indexD]));
      if (status != 0)
        break;

      envCtx->totalRecipInfoLen += envCtx->recipients[indexD].recipInfoLen;

      indexD++;
    }
    if (status != 0)
      break;

  } while (0);

  VtDestroyAlgorithmObject (&base64);

  if (keyData != (unsigned char *)0)
    Z2Free (keyData);

  if (status == 0)
    obj->state = VOLT_P7_STATE_ENV_WRITE_INIT;

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, pkcs7Obj, status, 0, errorType,
    (char *)0, "VoltP7EnvWriteInit", fnctLine, (char *)0)

  return (status);
}

int VoltP7EnvWriteUpdate (
   VtPkcs7Object pkcs7Obj,
   VtRandomObject random,
   unsigned char *inputData,
   unsigned int inputDataLen,
   unsigned char *message,
   unsigned int bufferSize,
   unsigned int *messageLen
   )
{
  int status;
  unsigned int index, tempLen, recipOutLen, offset;
#if VT_64_BIT_LENGTH == 64
  VtUInt64 encryptedDataLen, outputLen, encContentInfoLen;
  VtUInt64 seqLen, expLen, totalLen;
#else
  unsigned int encryptedDataLen, outputLen, encContentInfoLen;
  unsigned int seqLen, expLen, totalLen;
#endif
  VoltPkcs7Object *obj = (VoltPkcs7Object *)pkcs7Obj;
  VoltPkcs7WriteEnvCtx *envCtx = (VoltPkcs7WriteEnvCtx *)(obj->localCtx);
  VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
  unsigned char *temp;
  unsigned char envDataOid[VoltP7EnvDataOidBytesLen] =
    { VoltP7EnvDataOidBytes };
  unsigned char dataOid[VoltP7DataOidBytesLen] = { VoltP7DataOidBytes };
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* The state must be INIT or UPDATE.
     */
    if (obj->state == VOLT_P7_STATE_ENV_WRITE_INIT)
    {
      /* Check to see if the inputDataLen exceeds the amount specified
       * by calling SetPkcs7Param with the DataLen param.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_INPUT_LENGTH;
#if VT_64_BIT_LENGTH == 64
      if ((VtUInt64)inputDataLen > obj->dataLen64)
#else
      if (inputDataLen > obj->dataLen)
#endif
        break;

      /* Determine outputLen. It will be the length of the "prefix"
       * plus the length of the input data.
       * The prefix is the following
       *   30 len                                contentInfo
       *      06 len <EnvelopedData OID>         contentType
       *      A0 len                             EXPLICIT content
       *         30 len                          EnvelopeedData
       *            02 01 00                     version
       *            31 len                       RecipientInfos
       *               <recipients>
       *            30 len                       EncryptedContentInfo
       *               06 len <Data OID>         contentType
       *               30 len <rest of algID>    contentEncryptionAlg
       *               80 len                    IMPLICIT encContent
       */
      /* Work up from the bottom. Start with the A0 len. The length of
       * the encryptedContent might not be the same as the length of
       * the input data itself (because of padding, for example).
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtEncryptInit (envCtx->symEncryptor, envCtx->symKey);
      if (status != 0)
        break;

      /* Call EncryptFinal with no output buffer to get length.
       * For the moment, this does not work with NULL input, and it
       * will not work with 64-bit lengths, so compute it explicitly.
       */
/*      status = VtEncryptFinal (
        envCtx->symEncryptor, random, (unsigned char *)0, obj->dataLen,
        (unsigned char *)0, 0, &encryptedDataLen);
      if (status == 0)
        status = VT_ERROR_GENERAL;
      if (status != VT_ERROR_BUFFER_TOO_SMALL)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩和欧美一区二区三区| 国产经典欧美精品| 国产在线精品一区二区三区不卡| a在线播放不卡| 精品剧情在线观看| 亚洲综合一区二区三区| 懂色av一区二区夜夜嗨| 欧美裸体一区二区三区| 亚洲欧美激情插 | 精品国产不卡一区二区三区| 亚洲美女区一区| 国产精品一区二区在线播放 | 亚洲激情自拍视频| 国产成a人亚洲精品| 欧美成人激情免费网| 日韩中文字幕一区二区三区| 91在线视频官网| 欧美国产1区2区| 国产一区二区三区四区在线观看 | 午夜精品123| 在线精品视频免费播放| 成人免费一区二区三区在线观看| 国产精品99久| 久久综合久久鬼色| 激情综合网av| 精品久久久久99| 国产在线播精品第三| 日韩欧美一二三区| 国内欧美视频一区二区| 日韩午夜激情视频| 久久国产三级精品| 久久综合色播五月| 国产999精品久久久久久绿帽| 久久综合狠狠综合久久综合88| 精品中文字幕一区二区| 久久综合九色综合欧美亚洲| 国内精品久久久久影院薰衣草| 久久这里只有精品6| 国产乱码精品一区二区三区五月婷| 精品国产sm最大网站| 国产一区二区不卡| 国产精品家庭影院| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲欧美日韩久久精品| 欧美色成人综合| 久久超碰97中文字幕| 国产偷v国产偷v亚洲高清| 国产精品 日产精品 欧美精品| 国产精品第一页第二页第三页| 91色在线porny| 日本vs亚洲vs韩国一区三区二区| 精品久久久久久最新网址| 国产成人免费在线观看| 一区二区三区久久久| 在线成人av影院| 国产精品一区二区不卡| 亚洲欧美电影院| 在线不卡一区二区| 国产成人啪免费观看软件| 亚洲最新视频在线观看| 日韩精品一区二区三区在线观看| 高清在线观看日韩| 亚洲高清免费一级二级三级| 精品少妇一区二区三区免费观看| 国产 日韩 欧美大片| 亚洲超碰精品一区二区| 国产亚洲视频系列| 欧美性猛交xxxxxx富婆| 国产精品综合一区二区| 亚洲最新视频在线观看| 国产欧美一区视频| 欧美电影一区二区三区| 99在线视频精品| 久久av中文字幕片| 一区二区三区精密机械公司| 26uuu欧美| 一本久久a久久免费精品不卡| 久久国产夜色精品鲁鲁99| 专区另类欧美日韩| 久久网站最新地址| 欧美亚洲另类激情小说| 国产91丝袜在线播放| 久热成人在线视频| 亚洲综合一区二区精品导航| 国产精品美女久久久久久久久| 欧美精品自拍偷拍动漫精品| 91蜜桃在线免费视频| 国产精品一级在线| 美日韩一区二区| 亚洲va欧美va天堂v国产综合| 国产精品网站在线播放| 日韩美女视频一区二区在线观看| 在线国产亚洲欧美| 91蜜桃在线观看| av成人动漫在线观看| 国产精品99久久久久久久女警| 免费观看在线色综合| 污片在线观看一区二区 | 中文字幕乱码久久午夜不卡| 91麻豆精品国产91久久久久久| 91小宝寻花一区二区三区| 成人午夜又粗又硬又大| 国产福利一区二区三区视频在线 | 成人免费毛片片v| 国产一区二区三区四| 久久电影网电视剧免费观看| 日本亚洲免费观看| 日本成人在线不卡视频| 日韩电影在线免费| 午夜国产精品影院在线观看| 午夜精品一区二区三区电影天堂| 亚洲综合免费观看高清完整版在线| 中文字幕日韩欧美一区二区三区| 中文字幕不卡的av| 国产精品成人一区二区三区夜夜夜| 国产亚洲欧美激情| 国产精品视频观看| 一区在线播放视频| 亚洲男人都懂的| 亚洲动漫第一页| 日本中文在线一区| 国产原创一区二区三区| 成人av动漫网站| 在线亚洲精品福利网址导航| 欧美写真视频网站| 日韩欧美在线观看一区二区三区| 精品久久久三级丝袜| 国产色产综合色产在线视频| 国产精品久久久久精k8| 一区二区在线观看免费| 午夜精品123| 国产乱码精品一品二品| 成人美女视频在线观看| 在线精品视频一区二区三四| 欧美一区二区三区系列电影| 精品人在线二区三区| 国产亚洲成aⅴ人片在线观看| 国产精品亲子伦对白| 一级日本不卡的影视| 久久精品99久久久| 91麻豆自制传媒国产之光| 欧美日韩精品欧美日韩精品一 | 中文字幕在线不卡视频| 一区二区三区四区不卡在线| 性做久久久久久免费观看欧美| 久久99热国产| av不卡免费在线观看| 欧美一二三四区在线| 欧美激情在线看| 亚洲成a人在线观看| 国产ts人妖一区二区| 欧美日本视频在线| 国产亚洲欧美日韩俺去了| 亚洲高清在线精品| 成人av资源下载| 精品欧美一区二区久久| 亚洲三级电影全部在线观看高清| 青青草国产成人av片免费| caoporn国产精品| 欧美草草影院在线视频| 亚洲一区二区三区四区在线| 国产一区二区三区观看| 欧美久久久久中文字幕| 国产精品国产a| 九色|91porny| 精品视频1区2区| 国产精品不卡一区二区三区| 精品写真视频在线观看 | 亚洲综合在线第一页| 国产.精品.日韩.另类.中文.在线.播放| 欧美在线三级电影| 中文字幕精品在线不卡| 日本不卡视频一二三区| 在线观看免费亚洲| 国产精品网曝门| 国产成人av电影| 7777女厕盗摄久久久| 亚洲一区在线视频观看| 99精品视频一区二区三区| 26uuu久久综合| 久久国产欧美日韩精品| 欧美精品九九99久久| 艳妇臀荡乳欲伦亚洲一区| 91在线观看成人| 亚洲三级电影全部在线观看高清| 国产成人啪午夜精品网站男同| 久久综合九色综合久久久精品综合| 日本欧美一区二区三区| 欧美日韩精品一区二区| 亚洲成a人片在线不卡一二三区| 色欧美日韩亚洲| 亚洲视频在线观看一区| 99riav久久精品riav| 国产精品久久久久婷婷| 成人一区二区三区视频 | 午夜久久电影网| 欧美日韩久久一区| 午夜精品久久久久影视| 91精品欧美久久久久久动漫| 日韩精品免费视频人成|