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

📄 sfparams.c

📁 IBE是一种非对称密码技术
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
 */
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "securemail.h"
#include "stringutil.h"
#include "errorctx.h"

int VtSecureFileParamRecipientList (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  VoltSecureMailWriteCtx *writeCtx;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;

    if (flag == VOLT_SECURE_FILE_SET_TYPE_FLAG)
    {
      /* The SecureMail object must be set to write.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SECURE_FILE_OBJ;
      if (obj->state != VOLT_SECURE_MAIL_STATE_WRITE_SET)
        break;

      /* Set the enveloper with this list.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientList, info);
      if (status != 0)
        break;

      /* We need a reference to the recipient list.
       */
      writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientList,
        (Pointer *)&(writeCtx->recipListRef));
    }
    else if (flag == VOLT_SECURE_FILE_GET_TYPE_FLAG)
    {
      /* If getting, the SecureMail object must be set to read.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SECURE_FILE_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, (Pointer *)info);
    }

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureFileObj, status, 0, errorType,
    (char *)0, "VtSecureFileParamRecipientList", fnctLine, (char *)0)

  return (status);
}

int VtSecureFileParamRecipientInfoList (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  VoltSecureMailWriteCtx *writeCtx;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_TYPE;
    if (flag == VOLT_SECURE_FILE_SET_TYPE_FLAG)
    {
      /* The SecureMail object must be set to write.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SECURE_FILE_OBJ;
      if (obj->state != VOLT_SECURE_MAIL_STATE_WRITE_SET)
        break;

      /* Set the enveloper with this list.
       */
      VOLT_SET_ERROR_TYPE (errorType, 0)
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtSetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientInfoList, info);
      if (status != 0)
        break;

      /* We need a reference to the recipient list.
       */
      writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VtGetPkcs7Param (
        obj->p7EnvelopedData, VtPkcs7ParamRecipientList,
        (Pointer *)&(writeCtx->recipListRef));
    }
    else if (flag == VOLT_SECURE_FILE_GET_TYPE_FLAG)
    {
      /* If getting, the SecureMail object must be set to read.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = VT_ERROR_INVALID_SECURE_FILE_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, (Pointer *)info);
    }
  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureFileObj, status, 0, errorType,
    (char *)0, "VtSecureFileParamRecipientInfoList", fnctLine, (char *)0)

  return (status);
}

int VtSecureFileParamRecipientIndex (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This Param cannot Get info.
     */
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_GET;
    if (flag == VOLT_SECURE_FILE_GET_TYPE_FLAG)
      break;

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

    /* The SecureMail object must be set to read.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SECURE_FILE_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, info);

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureFileObj, status, 0, errorType,
    (char *)0, "VtSecureFileParamRecipientIndex", fnctLine, (char *)0)

  return (status);
}

int VtSecureFileParamSignerList (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  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_FILE_SET_TYPE_FLAG)
      break;

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

    /* The object must be built to read.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SECURE_FILE_OBJ;
    if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
      break;

    getInfo = (Pointer *)info;

    /* The object must be done reading a file.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_GET_INFO_UNAVAILABLE;
    if (obj->state != VOLT_SECURE_FILE_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);

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureFileObj, status, 0, errorType,
    (char *)0, "VtSecureFileParamSignerList", fnctLine, (char *)0)

  return (status);
}

int VtSecureFileParamContentDescriptors (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  unsigned int bufferSize, index;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  VoltSecureMailReadCtx *readCtx = (VoltSecureMailReadCtx *)(obj->localCtx);
  VoltLibCtx *libCtx = (VoltLibCtx *)(obj->voltObject.libraryCtx);
  VoltContentMaterial *currentElement;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This param can GetParam only.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SET;
    if (flag == VOLT_SECURE_FILE_SET_TYPE_FLAG)
      break;

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

    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_SECURE_FILE_OBJ;
    if ((obj->state & VOLT_SECURE_MAIL_STATE_READ) == 0)
      break;

    getInfo = (Pointer *)info;

    /* Make sure this object is set to read SecureFile and that the
     * content descriptors have been read.
     */
    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, secureFileObj, status, 0, VT_ERROR_TYPE_PRIMARY,
    (char *)0, "VtSecureFileParamContentDescriptors", fnctLine, (char *)0)

  return (status);
}

int VtSecureFileParamMessageTime (
   VtSecureFileObject secureFileObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  Pointer *getInfo;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureFileObj;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

⌨️ 快捷键说明

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