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

📄 zdmparams.c

📁 IBE是一种非对称密码技术
💻 C
📖 第 1 页 / 共 5 页
字号:
      status = VtSetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamSurrenderCallback, setInfo);
        
      break;
      
    default:
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SET;
  }

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, zdmObj, status, 0, errorType,
    (char *)0, "VoltOldZDMSetParamWrite", fnctLine, (char *)0)

  return (status);
}

int VoltOldZDMGetParamWrite (
   VtZDMObject zdmObj,
   int paramSelector,
   Pointer *getInfo
   )
{
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  VOLT_SET_FNCT_LINE (fnctLine)
  VOLT_LOG_ERROR_INFO (
    0, zdmObj, VT_ERROR_GET_INFO_UNAVAILABLE, 0, VT_ERROR_TYPE_PRIMARY,
    (char *)0, "VoltOldZDMGetParamWrite", fnctLine, (char *)0)

  return (VT_ERROR_GET_INFO_UNAVAILABLE);
}

int VoltOldZDMSetParamRead (
   VtZDMObject zdmObj,
   int paramSelector,
   Pointer setInfo
   )
{
  int status;
  VoltZDMObject *zObj = (VoltZDMObject *)zdmObj;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)(zObj->localCtx);
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  switch (paramSelector)
  {
    case VT_ZDM_PARAM_RECIPIENT_INDEX:
      /* The SecureMail object must be set to read.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_ZDM_OBJ;
      if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
        break;

      /* Set the enveloper with this list.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientIndex, setInfo);

      break;

    case VT_ZDM_PARAM_SURRENDER_CALLBACK:
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltSetObjectSurrender ((VoltObject *)obj, setInfo, 0, 0, 0);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetPkcs7Param (
        obj->p7SignedData, VtPkcs7ParamSurrenderCallback, setInfo);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamSurrenderCallback, setInfo);
        
      break;
      
    default:
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_ZDM_OBJ;
  }

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, zdmObj, status, 0, errorType,
    (char *)0, "VoltOldZDMSetParamRead", fnctLine, (char *)0)

  return (status);
}

int VoltOldZDMGetParamRead (
   VtZDMObject zdmObj,
   int paramSelector,
   Pointer *getInfo
   )
{
  int status;
  unsigned int index, bufferSize, labelLen;
  VoltZDMObject *zObj = (VoltZDMObject *)zdmObj;
  VoltLibCtx *libCtx = (VoltLibCtx *)(zObj->voltObject.libraryCtx);
  VoltSecureMailObject *obj = (VoltSecureMailObject *)(zObj->localCtx);
  VoltSecureMailWriteCtx *writeCtx = (VoltSecureMailWriteCtx *)0;
  VoltSecureMailReadCtx *readCtx = (VoltSecureMailReadCtx *)0;
  VtUtf8StringList *descriptors;
  VoltContentMaterial *currentElement;
  char *labelType = "content-type: ";
  char *labelName = "file-name=";
  char *found;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  if ((obj->state & VOLT_SECURE_MAIL_STATE_WRITE) != 0)
    writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
  else
    readCtx = (VoltSecureMailReadCtx *)(obj->localCtx);

  switch (paramSelector)
  {
    case VT_ZDM_PARAM_RECIPIENT_LIST:
      /* If getting, the SecureMail object must be set to read.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_ZDM_OBJ;
      if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
        break;

      /* Get the list out of the enveloper.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientList, getInfo);

      break;

    case VT_ZDM_PARAM_RECIPIENT_INFO_LIST:
      /* If getting, the SecureMail object must be set to read.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_ZDM_OBJ;
      if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
        break;

      /* Get the list out of the enveloper.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientInfoList, getInfo);

      break;

    case VT_ZDM_PARAM_FILE_NAME:
      /* The ZDM message must be attachment, and there must be a file
       * name captured.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (obj->formatType != VOLT_MESSAGE_FORMAT_ZDM_ATTACHMENT)
        break;

      /* If this is an object to write, the file name is in the
       * writeCtx->fileName.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (writeCtx != (VoltSecureMailWriteCtx *)0)
      {
        if (writeCtx->fileName.data == (unsigned char *)0)
          break;
        *getInfo = (Pointer)(writeCtx->fileName.data);
        status = 0;
        break;
      }

      /* The file name has not yet been found. Find it now.
       * Get all the content descriptors.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetZDMParam (
        zdmObj, VtZDMParamContentDescriptors, (Pointer *)&descriptors);
      if (status != 0)
        break;

      /* Search through the list, find the string that begins
       * "file-name=".
       */
      labelLen = 10;
      found = (char *)0;
      for (index = 0; index < descriptors->count; ++index)
      {
        found = Strstr (
          descriptors->utf8Strings[index], labelName, (VtLibCtx)libCtx);
        if (found != (char *)0)
          break;
      }

      /* If we went through the list and did not find file-name, the
       * info is unavailable.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (found == (char *)0)
        break;

      /* Find the semicolon.
       */
      labelName = found + labelLen;
      labelLen = Z2Strlen (labelName);
      found = Strchr (labelName, ';', (VtLibCtx)libCtx);
      if (found != (char *)0)
        labelLen = (unsigned int)found - (unsigned int)labelName;

      /* Store the name in fileName.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_MEMORY;
      readCtx->fileName.data = (unsigned char *)Z2Realloc (
        readCtx->fileName.data, labelLen + 1);
      if (readCtx->fileName.data == (unsigned char *)0)
        break;

      Z2Memcpy (readCtx->fileName.data, labelName, labelLen);
      readCtx->fileName.data[labelLen] = 0;
      *getInfo = (Pointer)(readCtx->fileName.data);
      status = 0;
      break;

    case VT_ZDM_PARAM_SIGNER_LIST:
      /* The object must be done reading a message.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (obj->state != VOLT_SECURE_MAIL_STATE_READ_COMPLETE)
        break;

      /* Get the info out of the P7 object.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7SignedData, VtPkcs7ParamSignerList, getInfo);

      break;

    case VT_ZDM_PARAM_CONTENT_TYPE:
      /* If this is an object to write, the content-type is in the
       * contentInfo.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (writeCtx != (VoltSecureMailWriteCtx *)0)
      {
        if (obj->contentInfo.data == (unsigned char *)0)
          break;
        *getInfo = (Pointer)(obj->contentInfo.data);
        status = 0;
        break;
      }

      /* Get all the content descriptors.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetZDMParam (
        zdmObj, VtZDMParamContentDescriptors, (Pointer *)&descriptors);
      if (status != 0)
        break;

      /* Search through the list, find the string that begins
       * "content-type:".
       */
      labelLen = 14;
      found = (char *)0;
      for (index = 0; index < descriptors->count; ++index)
      {
        found = Strstr (
          descriptors->utf8Strings[index], labelType, (VtLibCtx)libCtx);
        if (found != (char *)0)
          break;
      }

      /* If we went through the list and did not find file-name, the
       * info is unavailable.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (found == (char *)0)
        break;

      /* Find the semicolon.
       */
      labelType = found + labelLen;
      labelLen = Z2Strlen (labelType);
      found = Strchr (labelType, ';', (VtLibCtx)libCtx);
      if (found != (char *)0)
        labelLen = (unsigned int)found - (unsigned int)labelType;

      /* Store the name in contentInfo.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_MEMORY;
      obj->contentInfo.data = (unsigned char *)Z2Realloc (
        obj->contentInfo.data, labelLen + 1);
      if (obj->contentInfo.data == (unsigned char *)0)
        break;

      Z2Memcpy (obj->contentInfo.data, labelType, labelLen);
      obj->contentInfo.data[labelLen] = 0;
      *getInfo = (Pointer)(obj->contentInfo.data);
      status = 0;
      break;

    case VT_ZDM_PARAM_CONTENT_DESCRIPTORS:
      /* Make sure this object is set to read SecureMail and that the
       * content descriptors have been read.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_ZDM_OBJ;
      if (readCtx->contentMaterialState !=
        VOLT_CONTENT_MATERIAL_STATE_COMPLETE)
        break;

      /* If the list is not yet computed, compute it now.
       */
      if (readCtx->contentDescriptors.count != readCtx->contentMaterialCount)
      {
        /* The buffer size is the size of an array, we'll just fill it
         * with the pointers to the data already copied.
         */
        VOLT_SET_FNCT_LINE (fnctLine)
        status = VT_ERROR_MEMORY;
        bufferSize = readCtx->contentMaterialCount * sizeof (unsigned char *);
        readCtx->contentDescriptors.utf8Strings = (unsigned char **)Z2Realloc (
          readCtx->contentDescriptors.utf8Strings, bufferSize);
        if (readCtx->contentDescriptors.utf8Strings == (unsigned char **)0)
          break;
        Z2Memset (readCtx->contentDescriptors.utf8Strings, 0, bufferSize);
        readCtx->contentDescriptors.count = readCtx->contentMaterialCount;

        /* Load up all the addresses.
         */
        currentElement = readCtx->contentMaterial;
        for (index = 0; index < readCtx->contentMaterialCount; ++index)
        {
          readCtx->contentDescriptors.utf8Strings[index] =
            currentElement->material.data;

          currentElement = (VoltContentMaterial *)(currentElement->nextElement);
        }
      }

      *getInfo = (Pointer)&(readCtx->contentDescriptors);

      status = 0;
      break;

    case VT_ZDM_PARAM_MESSAGE_TIME:
      /* The object must be done reading a message.
       */
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
      if (obj->state != VOLT_SECURE_MAIL_STATE_READ_COMPLETE)
        break;

      /* Get the info out of the P7 object.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7SignedData, VtPkcs7ParamSigningTime, getInfo);

      break;

    case VT_ZDM_PARAM_SUBJECT_LINE:

    default:
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_GET_INFO_UNAVAILABLE;
  }

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, zdmObj, status, 0, errorType,
    (char *)0, "VoltOldZDMGetParamRead", fnctLine, (char *)0)

  return (status);
}

int VoltZDMParamCommon (
   VtZDMObject zdmObj,
   Pointer info,
   unsigned int flag,
   unsigned int paramFlags,
   int selector
   )
{
  int status;
  VoltZDMObject *obj = (VoltZDMObject *)zdmObj;
  VtLibCtx libCtx = (VtLibCtx)(obj->voltObject.libraryCtx);
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    
    if (flag == VOLT_ZDM_SET_TYPE_FLAG)
    {
      /* The caller wants to set, is that allowed?
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SET;
      if ((paramFlags & VT_ZDM_SET_SUPPORTED) == 0)
        break;

      /* If the associated info is supposed to be NULL, make sure the
       * input is NULL. If it's supposed to be non-NULL, make sure of
       * that.
       */
      if ((info == (Pointer)0) &&
          ((paramFlags & VT_ZDM_SET_INFO_REQUIRED) != 0))
      {
        VOLT_SET_FNCT_LINE (fnctLine)
        status = VT_ERROR_INVALID_ASSOCIATED_INFO;
        break;
      }

      if (obj->SetParam == (VZDMSetParam)0)
      {
        VOLT_SET_FNCT_LINE(fnctLine)
        VOLT_SET_ERROR_TYPE(errorType, VT_ERROR_TYPE_PRIMARY)
        status = VT_ERROR_INVALID_IMPL;
        break;
      }
      
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = obj->SetParam (zdmObj, selector, info);
      break;
    }

    /* The flag was not SET, so if it's not GET, error.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_ZDM_GET_TYPE_FLAG)

⌨️ 快捷键说明

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