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

📄 smwritetype.c

📁 IBE是一种非对称密码技术
💻 C
📖 第 1 页 / 共 2 页
字号:
    obj->dataLen64 = *dataLen;

    status = 0;

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, VT_ERROR_TYPE_PRIMARY,
    (char *)0, "VtSecureMailParamDataLen64", fnctLine, (char *)0)

  return (status);
}
#endif

int VtSecureMailParamSenderId (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VoltSecureMailWriteCtx *writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
  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_MAIL_GET_TYPE_FLAG)
      break;

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

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

    /* There can be only one sender.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (writeCtx->senderFlag != 0)
      break;

    /* Send this identity object on to the p7Signer. This will check
     * the validity of the associatedInfo.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtSetPkcs7Param (obj->p7SignedData, VtPkcs7ParamSignerId, info);
    if (status != 0)
      break;

    writeCtx->senderFlag = 1;

    /* Get a reference to the sender ID.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VoltGetSignerIdObjRef (
      obj->p7SignedData, 0, (VtIdentityObject *)&(writeCtx->senderIdRef));
    if (status == VT_ERROR_NO_ID_AT_INDEX)
      status = VT_ERROR_INVALID_ASSOCIATED_INFO;

  } while (0);

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

  return (status);
}

int VtSecureMailParamSenderInfo (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VoltSecureMailWriteCtx *writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
  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_MAIL_GET_TYPE_FLAG)
      break;

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

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

    /* There can be only one sender.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    if (writeCtx->senderFlag != 0)
      break;

    /* Send this sender info on to the p7Signer. This will check
     * the validity of the associatedInfo.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtSetPkcs7Param (obj->p7SignedData, VtPkcs7ParamSignerInfo, info);
    if (status != 0)
      break;

    writeCtx->senderFlag = 1;

    /* Get a reference to the signer's ID object, if there is one,
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VoltGetSignerIdObjRef (
      obj->p7SignedData, 0, (VtIdentityObject *)&(writeCtx->senderIdRef));
    if (status == VT_ERROR_NO_ID_AT_INDEX)
      status = 0;

  } while (0);

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

  return (status);
}

int VtSecureMailParam3DESCBC (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  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_MAIL_GET_TYPE_FLAG)
      break;

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

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

    /* Set the enveloper with Triple-DES.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtSetPkcs7Param (
      obj->p7EnvelopedData, VtPkcs7ParamEnv3DESCBC, info);

  } while (0);

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

  return (status);
}

int VtSecureMailParamAES128CBC (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  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_MAIL_GET_TYPE_FLAG)
      break;

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

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

    /* Set the enveloper with AES.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VtSetPkcs7Param (
      obj->p7EnvelopedData, VtPkcs7ParamEnvAES128CBC, info);

  } while (0);

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

  return (status);
}

int VtSecureMailParamNewLineCharacter (
   VtSecureMailObject secureMailObj,
   Pointer info,
   unsigned int flag
   )
{
  int status;
  VoltSecureMailObject *obj = (VoltSecureMailObject *)secureMailObj;
  VoltSecureMailWriteCtx *writeCtx = (VoltSecureMailWriteCtx *)(obj->localCtx);
  unsigned int newLineFlag;
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  do
  {
    /* This Param cannot get info.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_GET;
    if (flag == VOLT_SECURE_MAIL_GET_TYPE_FLAG)
      break;

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

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

    /* The associated info is a pointer to an unsigned int.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = VT_ERROR_INVALID_ASSOCIATED_INFO;
    if (info == (Pointer)0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    newLineFlag = *((unsigned int *)info);
    if ( (newLineFlag != VT_SECURE_MAIL_NEW_LINE_LF) &&
         (newLineFlag != VT_SECURE_MAIL_NEW_LINE_CR_LF) )
      break;

    /* We initialized the buffer holding the new line chars to be
     * CR_LF. So there's enough space in there to hold whatever is
     * requested.
     */
    status = 0;
    if (newLineFlag == VT_SECURE_MAIL_NEW_LINE_CR_LF)
    {
      writeCtx->itemArray[VOLT_WRITE_SM_ITEM_NEW_LINE].data[0] = 0x0d;
      writeCtx->itemArray[VOLT_WRITE_SM_ITEM_NEW_LINE].data[1] = 0x0a;
      writeCtx->itemArray[VOLT_WRITE_SM_ITEM_NEW_LINE].len = 2;
      break;
    }

    /* The caller wants LF.
     */
    writeCtx->itemArray[VOLT_WRITE_SM_ITEM_NEW_LINE].data[0] = 0x0a;
    writeCtx->itemArray[VOLT_WRITE_SM_ITEM_NEW_LINE].len = 1;

  } while (0);

  VOLT_LOG_ERROR_INFO_COMPARE (
    status, 0, secureMailObj, status, 0, VT_ERROR_TYPE_PRIMARY,
    (char *)0, "VtSecureMailParamNewLineCharacter", fnctLine, (char *)0)

  return (status);
}

⌨️ 快捷键说明

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