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

📄 smparams.c

📁 IBE是一种非对称密码技术
💻 C
📖 第 1 页 / 共 2 页
字号:
      status = 0;
    }

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, errorType,
    (char *)0, "VtSecureMailParamContentType", fnctLine, (char *)0)

  return (status);
}

int VtSecureMailParamContentDescriptors (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  unsigned int bufferSize, index;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VoltSecureMailReadCtx *readCtx = (VoltSecureMailReadCtx *)(obj->localCtx);
  VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
  VoltContentMaterial *currentElement;
  VtSecureMailObject targetImpl;
  VOLT_DECLARE_FNCT_LINE (fnctLine)
  VOLT_DECLARE_ERROR_TYPE (errorType)

  do
  {
    /* This param can GetParam only.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SET;
    if (flag == VOLT_SECURE_MAIL_SET_TYPE_FLAG)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_SECURE_MAIL_GET_TYPE_FLAG)
      break;

    if (obj->formatType == VOLT_MESSAGE_FORMAT_SECURE_MAIL_GENERIC)
    {
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltGetTargetObjectForGenericSecureMailReader(
        obj, &targetImpl);
      if (status != 0)
        break;
        
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetSecureMailParam(targetImpl,
        VtSecureMailParamContentDescriptors, (Pointer*)info);
      break;
    }
    
    getInfo = (Pointer *)info;

    /* Make sure this object is set to read SecureMail and that the
     * content descriptors have been read.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SECURE_MAIL_OBJ;
    if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    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;

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, errorType, (char *)0,
    "VtSecureMailParamContentDescriptors", fnctLine, (char *)0)

  return (status);
}

int VtSecureMailParamSignerList (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VtSecureMailObject targetImpl;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This param can GetParam only.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SET;
    if (flag == VOLT_SECURE_MAIL_SET_TYPE_FLAG)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_SECURE_MAIL_GET_TYPE_FLAG)
      break;

    getInfo = (Pointer *)info;

    /* The object must be done reading a message.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    if (obj->state != VOLT_SECURE_MAIL_STATE_READ_COMPLETE)
      break;

    VOLT_SET_ERROR_TYPE (errorType, 0)
      
    if (obj->formatType == VOLT_MESSAGE_FORMAT_SECURE_MAIL_GENERIC)
    {
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltGetTargetObjectForGenericSecureMailReader(
        obj, &targetImpl);
      if (status != 0)
        break;
        
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetSecureMailParam(targetImpl,
        VtSecureMailParamSignerList, (Pointer*)info);
    }
    else
    {
      /* Get the info out of the P7 object.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7SignedData, VtPkcs7ParamSignerList, getInfo);
    }
  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, errorType,
    (char *)0, "VtSecureMailParamSignerList", fnctLine, (char *)0)

  return (status);
}

int VtSecureMailParamMessageTime (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VtSecureMailObject targetImpl;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This param can GetParam only.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SET;
    if (flag == VOLT_SECURE_MAIL_SET_TYPE_FLAG)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_SECURE_MAIL_GET_TYPE_FLAG)
      break;

    getInfo = (Pointer *)info;

    /* The object must be done reading a message.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    if (obj->state != VOLT_SECURE_MAIL_STATE_READ_COMPLETE)
      break;

    VOLT_SET_ERROR_TYPE (errorType, 0)
      
    if (obj->formatType == VOLT_MESSAGE_FORMAT_SECURE_MAIL_GENERIC)
    {
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltGetTargetObjectForGenericSecureMailReader(
        obj, &targetImpl);
      if (status != 0)
        break;
        
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetSecureMailParam(targetImpl,
        VtSecureMailParamMessageTime, (Pointer*)info);
    }
    else
    {
      /* Get the info out of the P7 object.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7SignedData, VtPkcs7ParamSigningTime, getInfo);
    }

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, errorType,
    (char *)0, "VtSecureMailParamMessageTime", fnctLine, (char *)0)

  return (status);
}

int VtSecureMailParamVersion (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VtSecureMailObject targetImpl;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This param can GetParam only.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SET;
    if (flag == VOLT_SECURE_MAIL_SET_TYPE_FLAG)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag != VOLT_SECURE_MAIL_GET_TYPE_FLAG)
      break;

    if (obj->formatType == VOLT_MESSAGE_FORMAT_SECURE_MAIL_GENERIC)
    {
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VoltGetTargetObjectForGenericSecureMailReader(
        obj, &targetImpl);
      if (status == VT_ERROR_INVALID_CALL_ORDER)
      {
        VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
        VOLT_SET_FNCT_LINE (fnctLine)
        status = VT_ERROR_UNDETERMINED_VERSION;
        break;
      }
      
      if (status != 0)
        break;
        
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetSecureMailParam(targetImpl,
        VtSecureMailParamVersion, (Pointer*)info);
    }
    else
    {
      VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_UNDETERMINED_VERSION;
      if (obj->version == 0)
        break;
      
      *(unsigned*)info = obj->version;
    }

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, errorType,
    (char *)0, "VtSecureMailParamVersion", fnctLine, (char *)0)

  return (status);
}

#if VT_64_BIT_LENGTH == 64
int VtGetOutputLen64ImplSecureMail (
   VtLibCtx libraryCtx,
   Pointer associatedInfo,
   VtUInt64 *totalOutputLen,
   unsigned int flag
   )
{
  int status;
  unsigned int len;
  VoltSecureMailObject *obj;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This Param must be called by VtGetTotalOutputLen64.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_IMPL;
    if (flag != VOLT_GET_OUTPUT_LEN_64_TYPE_FLAG)
      break;

    /* The associated info is supposed to be a SecureFile object.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if (associatedInfo == (Pointer)0)
      break;

    obj = (VoltSecureMailObject *)associatedInfo;

    /* Paranoid programming check.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (VOLT_OBJECT_TYPE_NOT_EQUAL (obj, VOLT_OBJECT_TYPE_SECURE_MAIL))
      break;

    /* The object should be built to write, and the state must be INIT.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SECURE_MAIL_OBJ;
    if ((obj->state & VOLT_SECURE_MAIL_STATE_WRITE) == 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    if ((obj->state & VOLT_SECURE_MAIL_STATE_INIT) == 0)
      break;

    /* The object must be set with the data length.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (obj->dataLen64 == (VtUInt64)0)
      break;

    /* If the outputLen64 field is not set, call WriteUpdate to set it.
     */
    if (obj->outputLen64 == (VtUInt64)0)
    {
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSecureMailWriteUpdate (
        (VtSecureMailObject)obj, (VtRandomObject)0, (unsigned char *)0, 1,
        (unsigned char *)0, 0, &len);
      if (status == 0)
        status = VT_ERROR_GENERAL;
      if (status != VT_ERROR_BUFFER_TOO_SMALL)
        break;
    }

    *totalOutputLen = obj->outputLen64;

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, libraryCtx, 0, status, 0, errorType,
    (char *)0, "VtGetOutputLen64ImplSecureMail", fnctLine, (char *)0)

  return (status);
}
#endif

⌨️ 快捷键说明

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