ReactOS  0.4.14-dev-98-gb0d4763
msg.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "snmp.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "crypt32_private.h"
Include dependency graph for msg.c:

Go to the source code of this file.

Classes

struct  _CryptMsgBase
 
struct  _CDataEncodeMsg
 
struct  _CHashEncodeMsg
 
struct  _CMSG_SIGNER_ENCODE_INFO_WITH_CMS
 
struct  _CMSG_SIGNED_ENCODE_INFO_WITH_CMS
 
struct  _CSignerHandles
 
struct  _CSignedMsgData
 
struct  _CSignedEncodeMsg
 
struct  _CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS
 
struct  _CEnvelopedEncodeMsg
 
struct  _CEnvelopedDecodeMsg
 
struct  _CDecodeMsg
 

Macros

#define NONAMELESSUNION
 

Typedefs

typedef void(* CryptMsgCloseFunc) (HCRYPTMSG msg)
 
typedef BOOL(* CryptMsgGetParamFunc) (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
typedef BOOL(* CryptMsgUpdateFunc) (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
typedef BOOL(* CryptMsgControlFunc) (HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
 
typedef enum _CryptMsgState CryptMsgState
 
typedef struct _CryptMsgBase CryptMsgBase
 
typedef struct _CDataEncodeMsg CDataEncodeMsg
 
typedef struct _CHashEncodeMsg CHashEncodeMsg
 
typedef struct _CMSG_SIGNER_ENCODE_INFO_WITH_CMS CMSG_SIGNER_ENCODE_INFO_WITH_CMS
 
typedef struct _CMSG_SIGNED_ENCODE_INFO_WITH_CMS CMSG_SIGNED_ENCODE_INFO_WITH_CMS
 
typedef struct _CSignerHandles CSignerHandles
 
typedef struct _CSignedMsgData CSignedMsgData
 
typedef struct _CSignedEncodeMsg CSignedEncodeMsg
 
typedef struct _CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS
 
typedef struct _CEnvelopedEncodeMsg CEnvelopedEncodeMsg
 
typedef struct _CEnvelopedDecodeMsg CEnvelopedDecodeMsg
 
typedef struct _CDecodeMsg CDecodeMsg
 

Enumerations

enum  _CryptMsgState { MsgStateInit, MsgStateUpdated, MsgStateDataFinalized, MsgStateFinalized }
 
enum  SignOrVerify { Sign, Verify }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static BOOL CRYPT_DefaultMsgControl (HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
 
static void CryptMsgBase_Init (CryptMsgBase *msg, DWORD dwFlags, PCMSG_STREAM_INFO pStreamInfo, CryptMsgCloseFunc close, CryptMsgGetParamFunc get_param, CryptMsgUpdateFunc update, CryptMsgControlFunc control)
 
static void CDataEncodeMsg_Close (HCRYPTMSG hCryptMsg)
 
static BOOL WINAPI CRYPT_EncodeContentLength (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_EncodeDataContentInfoHeader (const CDataEncodeMsg *msg, CRYPT_DATA_BLOB *header)
 
static BOOL CDataEncodeMsg_Update (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
static BOOL CRYPT_CopyParam (void *pvData, DWORD *pcbData, const void *src, DWORD len)
 
static BOOL CDataEncodeMsg_GetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static HCRYPTMSG CDataEncodeMsg_Open (DWORD dwFlags, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
 
static void CHashEncodeMsg_Close (HCRYPTMSG hCryptMsg)
 
static BOOL CRYPT_EncodePKCSDigestedData (CHashEncodeMsg *msg, void *pvData, DWORD *pcbData)
 
static BOOL CHashEncodeMsg_GetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CHashEncodeMsg_Update (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
static HCRYPTMSG CHashEncodeMsg_Open (DWORD dwFlags, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
 
static BOOL CRYPT_IsValidSigner (const CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer)
 
static BOOL CRYPT_ConstructBlob (CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
 
static BOOL CRYPT_ConstructBlobArray (DWORD *outCBlobs, PCRYPT_DATA_BLOB *outPBlobs, DWORD cBlobs, const CRYPT_DATA_BLOB *pBlobs)
 
static void CRYPT_FreeBlobArray (DWORD cBlobs, PCRYPT_DATA_BLOB blobs)
 
static BOOL CRYPT_ConstructAttribute (CRYPT_ATTRIBUTE *out, const CRYPT_ATTRIBUTE *in)
 
static BOOL CRYPT_ConstructAttributes (CRYPT_ATTRIBUTES *out, const CRYPT_ATTRIBUTES *in)
 
static BOOL CSignerInfo_Construct (CMSG_CMS_SIGNER_INFO *info, const CMSG_SIGNER_ENCODE_INFO_WITH_CMS *in)
 
static void CSignerInfo_Free (CMSG_CMS_SIGNER_INFO *info)
 
static BOOL CSignedMsgData_ConstructSignerHandles (CSignedMsgData *msg_data, DWORD signerIndex, HCRYPTPROV *crypt_prov, DWORD *flags)
 
static BOOL CSignedMsgData_AllocateHandles (CSignedMsgData *msg_data)
 
static void CSignedMsgData_CloseHandles (CSignedMsgData *msg_data)
 
static BOOL CSignedMsgData_UpdateHash (CSignedMsgData *msg_data, const BYTE *pbData, DWORD cbData)
 
static BOOL CRYPT_AppendAttribute (CRYPT_ATTRIBUTES *out, const CRYPT_ATTRIBUTE *in)
 
static BOOL CSignedMsgData_AppendMessageDigestAttribute (CSignedMsgData *msg_data, DWORD signerIndex)
 
static BOOL CSignedMsgData_UpdateAuthenticatedAttributes (CSignedMsgData *msg_data, SignOrVerify flag)
 
static void CRYPT_ReverseBytes (CRYPT_HASH_BLOB *hash)
 
static BOOL CSignedMsgData_Sign (CSignedMsgData *msg_data)
 
static BOOL CSignedMsgData_Update (CSignedMsgData *msg_data, const BYTE *pbData, DWORD cbData, BOOL fFinal, SignOrVerify flag)
 
static void CSignedEncodeMsg_Close (HCRYPTMSG hCryptMsg)
 
static BOOL CSignedEncodeMsg_GetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CSignedEncodeMsg_Update (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
static HCRYPTMSG CSignedEncodeMsg_Open (DWORD dwFlags, const void *pvMsgEncodeInfo, LPCSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
 
static BOOL CRYPT_ConstructAlgorithmId (CRYPT_ALGORITHM_IDENTIFIER *out, const CRYPT_ALGORITHM_IDENTIFIER *in)
 
static BOOL CRYPT_ConstructBitBlob (CRYPT_BIT_BLOB *out, const CRYPT_BIT_BLOB *in)
 
static BOOL CRYPT_GenKey (CMSG_CONTENT_ENCRYPT_INFO *info, ALG_ID algID)
 
static BOOL WINAPI CRYPT_ExportKeyTrans (PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo, PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO pKeyTransEncodeInfo, PCMSG_KEY_TRANS_ENCRYPT_INFO pKeyTransEncryptInfo, DWORD dwFlags, void *pvReserved)
 
static BOOL CRYPT_ExportEncryptedKey (CMSG_CONTENT_ENCRYPT_INFO *info, DWORD i, CRYPT_DATA_BLOB *key)
 
static LPVOID WINAPI mem_alloc (size_t size)
 
static VOID WINAPI mem_free (LPVOID pv)
 
static BOOL CContentEncryptInfo_Construct (CMSG_CONTENT_ENCRYPT_INFO *info, const CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS *in, HCRYPTPROV prov)
 
static void CContentEncryptInfo_Free (CMSG_CONTENT_ENCRYPT_INFO *info)
 
static BOOL CRecipientInfo_Construct (CMSG_KEY_TRANS_RECIPIENT_INFO *info, const CERT_INFO *cert, CRYPT_DATA_BLOB *key)
 
static void CRecipientInfo_Free (CMSG_KEY_TRANS_RECIPIENT_INFO *info)
 
static void CEnvelopedEncodeMsg_Close (HCRYPTMSG hCryptMsg)
 
static BOOL CEnvelopedEncodeMsg_GetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CEnvelopedEncodeMsg_Update (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
static HCRYPTMSG CEnvelopedEncodeMsg_Open (DWORD dwFlags, const void *pvMsgEncodeInfo, LPCSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
 
HCRYPTMSG WINAPI CryptMsgOpenToEncode (DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
 
static void CDecodeMsg_Close (HCRYPTMSG hCryptMsg)
 
static BOOL CDecodeMsg_CopyData (CRYPT_DATA_BLOB *blob, const BYTE *pbData, DWORD cbData)
 
static BOOL CDecodeMsg_DecodeDataContent (CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
 
static void CDecodeMsg_SaveAlgorithmID (CDecodeMsg *msg, DWORD param, const CRYPT_ALGORITHM_IDENTIFIER *id)
 
static void CRYPT_FixUpAlgorithmID (CRYPT_ALGORITHM_IDENTIFIER *id)
 
static BOOL CDecodeMsg_DecodeHashedContent (CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_DecodeEnvelopedContent (CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_DecodeSignedContent (CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_DecodeContent (CDecodeMsg *msg, const CRYPT_DER_BLOB *blob, DWORD type)
 
static BOOL CDecodeMsg_FinalizeHashedContent (CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_FinalizeEnvelopedContent (CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_FinalizeSignedContent (CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_FinalizeContent (CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
 
static BOOL CDecodeMsg_Update (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
static BOOL CDecodeHashMsg_GetParam (CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static void CRYPT_CopyBlob (CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in, LPBYTE *nextData)
 
static void CRYPT_CopyAlgorithmId (CRYPT_ALGORITHM_IDENTIFIER *out, const CRYPT_ALGORITHM_IDENTIFIER *in, LPBYTE *nextData)
 
static void CRYPT_CopyAttributes (CRYPT_ATTRIBUTES *out, const CRYPT_ATTRIBUTES *in, LPBYTE *nextData)
 
static DWORD CRYPT_SizeOfAttributes (const CRYPT_ATTRIBUTES *attr)
 
static DWORD CRYPT_SizeOfKeyIdAsIssuerAndSerial (const CRYPT_DATA_BLOB *keyId)
 
static BOOL CRYPT_CopyKeyIdAsIssuerAndSerial (CERT_NAME_BLOB *issuer, CRYPT_INTEGER_BLOB *serialNumber, const CRYPT_DATA_BLOB *keyId, DWORD encodedLen, LPBYTE *nextData)
 
static BOOL CRYPT_CopySignerInfo (void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
 
static BOOL CRYPT_CopyCMSSignerInfo (void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
 
static BOOL CRYPT_CopySignerCertInfo (void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
 
static BOOL CRYPT_CopyRecipientInfo (void *pvData, DWORD *pcbData, const CERT_ISSUER_SERIAL_NUMBER *in)
 
static BOOL CDecodeEnvelopedMsg_GetParam (CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CDecodeSignedMsg_GetParam (CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CDecodeMsg_GetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
static BOOL CDecodeHashMsg_VerifyHash (CDecodeMsg *msg)
 
static BOOL CDecodeSignedMsg_VerifySignatureWithKey (CDecodeMsg *msg, HCRYPTPROV prov, DWORD signerIndex, PCERT_PUBLIC_KEY_INFO keyInfo)
 
static BOOL CDecodeSignedMsg_VerifySignature (CDecodeMsg *msg, PCERT_INFO info)
 
static BOOL CDecodeSignedMsg_VerifySignatureEx (CDecodeMsg *msg, PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA para)
 
static BOOL WINAPI CRYPT_ImportKeyTrans (PCRYPT_ALGORITHM_IDENTIFIER pContentEncryptionAlgorithm, PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA pKeyTransDecryptPara, DWORD dwFlags, void *pvReserved, HCRYPTKEY *phContentEncryptKey)
 
static BOOL CRYPT_ImportEncryptedKey (PCRYPT_ALGORITHM_IDENTIFIER contEncrAlg, PCMSG_CTRL_DECRYPT_PARA para, PCMSG_KEY_TRANS_RECIPIENT_INFO info, HCRYPTKEY *key)
 
static BOOL CDecodeEnvelopedMsg_CrtlDecrypt (CDecodeMsg *msg, PCMSG_CTRL_DECRYPT_PARA para)
 
static BOOL CDecodeMsg_Control (HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
 
HCRYPTMSG WINAPI CryptMsgOpenToDecode (DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
 
HCRYPTMSG WINAPI CryptMsgDuplicate (HCRYPTMSG hCryptMsg)
 
BOOL WINAPI CryptMsgClose (HCRYPTMSG hCryptMsg)
 
BOOL WINAPI CryptMsgUpdate (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
 
BOOL WINAPI CryptMsgGetParam (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
 
BOOL WINAPI CryptMsgControl (HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
 
static CERT_INFOCRYPT_GetSignerCertInfoFromMsg (HCRYPTMSG msg, DWORD dwSignerIndex)
 
BOOL WINAPI CryptMsgGetAndVerifySigner (HCRYPTMSG hCryptMsg, DWORD cSignerStore, HCERTSTORE *rghSignerStore, DWORD dwFlags, PCCERT_CONTEXT *ppSigner, DWORD *pdwSignerIndex)
 
BOOL WINAPI CryptMsgVerifyCountersignatureEncoded (HCRYPTPROV_LEGACY hCryptProv, DWORD dwEncodingType, BYTE *pbSignerInfo, DWORD cbSignerInfo, PBYTE pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature, CERT_INFO *pciCountersigner)
 
BOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx (HCRYPTPROV_LEGACY hCryptProv, DWORD dwEncodingType, PBYTE pbSignerInfo, DWORD cbSignerInfo, PBYTE pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature, DWORD dwSignerType, void *pvSigner, DWORD dwFlags, void *pvReserved)
 
BOOL WINAPI CryptMsgEncodeAndSignCTL (DWORD dwMsgEncodingType, PCTL_INFO pCtlInfo, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CryptMsgSignCTL (DWORD dwMsgEncodingType, BYTE *pbCtlContent, DWORD cbCtlContent, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
 

Variables

static const BYTE empty_data_content [] = { 0x04,0x00 }
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 23 of file msg.c.

Typedef Documentation

◆ CDataEncodeMsg

◆ CDecodeMsg

◆ CEnvelopedDecodeMsg

◆ CEnvelopedEncodeMsg

◆ CHashEncodeMsg

◆ CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS

◆ CMSG_SIGNED_ENCODE_INFO_WITH_CMS

◆ CMSG_SIGNER_ENCODE_INFO_WITH_CMS

◆ CryptMsgBase

◆ CryptMsgCloseFunc

typedef void(* CryptMsgCloseFunc) (HCRYPTMSG msg)

Definition at line 38 of file msg.c.

◆ CryptMsgControlFunc

typedef BOOL(* CryptMsgControlFunc) (HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)

Definition at line 46 of file msg.c.

◆ CryptMsgGetParamFunc

typedef BOOL(* CryptMsgGetParamFunc) (HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)

Definition at line 40 of file msg.c.

◆ CryptMsgState

◆ CryptMsgUpdateFunc

typedef BOOL(* CryptMsgUpdateFunc) (HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)

Definition at line 43 of file msg.c.

◆ CSignedEncodeMsg

◆ CSignedMsgData

◆ CSignerHandles

Enumeration Type Documentation

◆ _CryptMsgState

Enumerator
MsgStateInit 
MsgStateUpdated 
MsgStateDataFinalized 
MsgStateFinalized 

Definition at line 57 of file msg.c.

57  {
enum _CryptMsgState CryptMsgState

◆ SignOrVerify

Enumerator
Sign 
Verify 

Definition at line 1063 of file msg.c.

1063  {
1064  Sign,
1065  Verify
1066 } SignOrVerify;
Definition: msg.c:1065
Definition: msg.c:1064
SignOrVerify
Definition: msg.c:1063

Function Documentation

◆ CContentEncryptInfo_Construct()

static BOOL CContentEncryptInfo_Construct ( CMSG_CONTENT_ENCRYPT_INFO info,
const CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS in,
HCRYPTPROV  prov 
)
static

Definition at line 1682 of file msg.c.

1684 {
1685  BOOL ret;
1686 
1687  info->cbSize = sizeof(CMSG_CONTENT_ENCRYPT_INFO);
1688  info->hCryptProv = prov;
1689  ret = CRYPT_ConstructAlgorithmId(&info->ContentEncryptionAlgorithm,
1690  &in->ContentEncryptionAlgorithm);
1691  info->pvEncryptionAuxInfo = in->pvEncryptionAuxInfo;
1692  info->cRecipients = in->cRecipients;
1693  if (ret)
1694  {
1695  info->rgCmsRecipients = CryptMemAlloc(in->cRecipients *
1696  sizeof(CMSG_RECIPIENT_ENCODE_INFO));
1697  if (info->rgCmsRecipients)
1698  {
1699  DWORD i;
1700 
1701  for (i = 0; ret && i < in->cRecipients; ++i)
1702  {
1704  CERT_INFO *cert = in->rgpRecipientCert[i];
1705 
1706  info->rgCmsRecipients[i].dwRecipientChoice =
1708  encodeInfo = CryptMemAlloc(sizeof(*encodeInfo));
1709  info->rgCmsRecipients[i].u.pKeyTrans = encodeInfo;
1710  if (encodeInfo)
1711  {
1712  encodeInfo->cbSize = sizeof(*encodeInfo);
1714  &encodeInfo->KeyEncryptionAlgorithm,
1715  &cert->SubjectPublicKeyInfo.Algorithm);
1716  encodeInfo->pvKeyEncryptionAuxInfo = NULL;
1717  encodeInfo->hCryptProv = prov;
1718  if (ret)
1720  &encodeInfo->RecipientPublicKey,
1721  &cert->SubjectPublicKeyInfo.PublicKey);
1722  if (ret)
1724  &encodeInfo->RecipientId.u.IssuerSerialNumber.Issuer,
1725  &cert->Issuer);
1726  if (ret)
1729  &cert->SerialNumber);
1730  }
1731  else
1732  ret = FALSE;
1733  }
1734  }
1735  else
1736  ret = FALSE;
1737  }
1738  info->pfnAlloc = mem_alloc;
1739  info->pfnFree = mem_free;
1740  return ret;
1741 }
static LPVOID WINAPI mem_alloc(size_t size)
Definition: msg.c:1671
static VOID WINAPI mem_free(LPVOID pv)
Definition: msg.c:1676
#define CMSG_KEY_TRANS_RECIPIENT
Definition: wincrypt.h:3812
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm
Definition: wincrypt.h:3745
static BOOL CRYPT_ConstructBitBlob(CRYPT_BIT_BLOB *out, const CRYPT_BIT_BLOB *in)
Definition: msg.c:1525
struct _CMSG_CONTENT_ENCRYPT_INFO CMSG_CONTENT_ENCRYPT_INFO
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL CRYPT_ConstructAlgorithmId(CRYPT_ALGORITHM_IDENTIFIER *out, const CRYPT_ALGORITHM_IDENTIFIER *in)
Definition: msg.c:1512
int ret
CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber
Definition: wincrypt.h:3667
GLuint in
Definition: glext.h:9616
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:3660
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:3659

Referenced by CEnvelopedEncodeMsg_Open().

◆ CContentEncryptInfo_Free()

static void CContentEncryptInfo_Free ( CMSG_CONTENT_ENCRYPT_INFO info)
static

Definition at line 1743 of file msg.c.

1744 {
1745  CryptMemFree(info->ContentEncryptionAlgorithm.pszObjId);
1746  CryptMemFree(info->ContentEncryptionAlgorithm.Parameters.pbData);
1747  if (info->rgCmsRecipients)
1748  {
1749  DWORD i;
1750 
1751  for (i = 0; i < info->cRecipients; ++i)
1752  {
1754  info->rgCmsRecipients[i].u.pKeyTrans;
1755 
1758  CryptMemFree(encodeInfo->RecipientPublicKey.pbData);
1759  CryptMemFree(
1761  CryptMemFree(
1763  CryptMemFree(encodeInfo);
1764  }
1765  CryptMemFree(info->rgCmsRecipients);
1766  }
1767 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:127
CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm
Definition: wincrypt.h:3745
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE * pbData
Definition: wincrypt.h:103
CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber
Definition: wincrypt.h:3667
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:3660
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:3659
BYTE * pbData
Definition: wincrypt.h:197

Referenced by CEnvelopedEncodeMsg_Open().

◆ CDataEncodeMsg_Close()

static void CDataEncodeMsg_Close ( HCRYPTMSG  hCryptMsg)
static

Definition at line 110 of file msg.c.

111 {
112  CDataEncodeMsg *msg = hCryptMsg;
113 
114  if (msg->bare_content != empty_data_content)
115  LocalFree(msg->bare_content);
116 }
static const BYTE empty_data_content[]
Definition: msg.c:108
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define msg(x)
Definition: auth_time.c:54

Referenced by CDataEncodeMsg_Open().

◆ CDataEncodeMsg_GetParam()

static BOOL CDataEncodeMsg_GetParam ( HCRYPTMSG  hCryptMsg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 315 of file msg.c.

317 {
318  CDataEncodeMsg *msg = hCryptMsg;
319  BOOL ret = FALSE;
320 
321  switch (dwParamType)
322  {
323  case CMSG_CONTENT_PARAM:
324  if (msg->base.streamed)
326  else
327  {
329  char rsa_data[] = "1.2.840.113549.1.7.1";
330 
331  info.pszObjId = rsa_data;
332  info.Content.cbData = msg->bare_content_len;
333  info.Content.pbData = msg->bare_content;
335  pvData, pcbData);
336  }
337  break;
339  if (msg->base.streamed)
341  else
342  ret = CRYPT_CopyParam(pvData, pcbData, msg->bare_content,
343  msg->bare_content_len);
344  break;
345  default:
347  }
348  return ret;
349 }
struct _test_info info[]
Definition: SetCursorPos.c:19
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3400
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
#define SetLastError(x)
Definition: compat.h:409
int ret
BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4655
#define CMSG_BARE_CONTENT_PARAM
Definition: wincrypt.h:3927
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define msg(x)
Definition: auth_time.c:54
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CDataEncodeMsg_Open().

◆ CDataEncodeMsg_Open()

static HCRYPTMSG CDataEncodeMsg_Open ( DWORD  dwFlags,
const void pvMsgEncodeInfo,
LPSTR  pszInnerContentObjID,
PCMSG_STREAM_INFO  pStreamInfo 
)
static

Definition at line 351 of file msg.c.

353 {
355 
356  if (pvMsgEncodeInfo)
357  {
359  return NULL;
360  }
361  msg = CryptMemAlloc(sizeof(CDataEncodeMsg));
362  if (msg)
363  {
364  CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
367  msg->bare_content_len = sizeof(empty_data_content);
368  msg->bare_content = (LPBYTE)empty_data_content;
369  }
370  return msg;
371 }
static const BYTE empty_data_content[]
Definition: msg.c:108
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static BOOL CRYPT_DefaultMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
Definition: msg.c:49
static void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags, PCMSG_STREAM_INFO pStreamInfo, CryptMsgCloseFunc close, CryptMsgGetParamFunc get_param, CryptMsgUpdateFunc update, CryptMsgControlFunc control)
Definition: msg.c:77
static BOOL CDataEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:315
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define msg(x)
Definition: auth_time.c:54
static BOOL CDataEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:191
static void CDataEncodeMsg_Close(HCRYPTMSG hCryptMsg)
Definition: msg.c:110

Referenced by CryptMsgOpenToEncode().

◆ CDataEncodeMsg_Update()

static BOOL CDataEncodeMsg_Update ( HCRYPTMSG  hCryptMsg,
const BYTE pbData,
DWORD  cbData,
BOOL  fFinal 
)
static

Definition at line 191 of file msg.c.

193 {
194  CDataEncodeMsg *msg = hCryptMsg;
195  BOOL ret = FALSE;
196 
197  if (msg->base.state == MsgStateFinalized)
199  else if (msg->base.streamed)
200  {
201  __TRY
202  {
203  if (msg->base.state != MsgStateUpdated)
204  {
206 
208  if (ret)
209  {
210  ret = msg->base.stream_info.pfnStreamOutput(
211  msg->base.stream_info.pvArg, header.pbData, header.cbData,
212  FALSE);
213  LocalFree(header.pbData);
214  }
215  }
216  /* Curiously, every indefinite-length streamed update appears to
217  * get its own tag and length, regardless of fFinal.
218  */
219  if (msg->base.stream_info.cbContent == 0xffffffff)
220  {
221  BYTE *header;
222  DWORD headerLen;
223 
225  &cbData, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&header,
226  &headerLen);
227  if (ret)
228  {
229  ret = msg->base.stream_info.pfnStreamOutput(
230  msg->base.stream_info.pvArg, header, headerLen,
231  FALSE);
232  LocalFree(header);
233  }
234  }
235  if (!fFinal)
236  {
237  ret = msg->base.stream_info.pfnStreamOutput(
238  msg->base.stream_info.pvArg, (BYTE *)pbData, cbData,
239  FALSE);
240  msg->base.state = MsgStateUpdated;
241  }
242  else
243  {
244  msg->base.state = MsgStateFinalized;
245  if (msg->base.stream_info.cbContent == 0xffffffff)
246  {
247  BYTE indefinite_trailer[6] = { 0 };
248 
249  ret = msg->base.stream_info.pfnStreamOutput(
250  msg->base.stream_info.pvArg, (BYTE *)pbData, cbData,
251  FALSE);
252  if (ret)
253  ret = msg->base.stream_info.pfnStreamOutput(
254  msg->base.stream_info.pvArg, indefinite_trailer,
255  sizeof(indefinite_trailer), TRUE);
256  }
257  else
258  ret = msg->base.stream_info.pfnStreamOutput(
259  msg->base.stream_info.pvArg, (BYTE *)pbData, cbData, TRUE);
260  }
261  }
263  {
265  ret = FALSE;
266  }
267  __ENDTRY;
268  }
269  else
270  {
271  if (!fFinal)
272  {
273  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
275  else
277  }
278  else
279  {
280  CRYPT_DATA_BLOB blob = { cbData, (LPBYTE)pbData };
281 
282  msg->base.state = MsgStateFinalized;
283  /* non-streamed data messages don't allow non-final updates,
284  * don't bother checking whether data already exist, they can't.
285  */
287  &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &msg->bare_content,
288  &msg->bare_content_len);
289  }
290  }
291  return ret;
292 }
#define CRYPT_E_MSG_ERROR
Definition: winerror.h:2985
#define TRUE
Definition: types.h:120
Definition: image.c:133
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define __TRY
Definition: compat.h:70
static BOOL WINAPI CRYPT_EncodeContentLength(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: msg.c:118
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define __ENDTRY
Definition: compat.h:72
int ret
unsigned char BYTE
Definition: mem.h:68
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
#define msg(x)
Definition: auth_time.c:54
#define X509_OCTET_STRING
Definition: wincrypt.h:3391
struct CFHEADER header
Definition: fdi.c:109
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:71
static BOOL CRYPT_EncodeDataContentInfoHeader(const CDataEncodeMsg *msg, CRYPT_DATA_BLOB *header)
Definition: msg.c:148
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CDataEncodeMsg_Open().

◆ CDecodeEnvelopedMsg_CrtlDecrypt()

static BOOL CDecodeEnvelopedMsg_CrtlDecrypt ( CDecodeMsg msg,
PCMSG_CTRL_DECRYPT_PARA  para 
)
static

Definition at line 3456 of file msg.c.

3458 {
3459  BOOL ret = FALSE;
3460  CEnvelopedDecodeMsg *enveloped_data = &msg->u.enveloped_data;
3461  CRYPT_ENVELOPED_DATA *data = enveloped_data->data;
3462 
3463  if (para->cbSize != sizeof(CMSG_CTRL_DECRYPT_PARA))
3465  else if (!data)
3467  else if (para->dwRecipientIndex >= data->cRecipientInfo)
3469  else if (enveloped_data->decrypted)
3471  else if (!para->hCryptProv)
3473  else if (enveloped_data->content.cbData)
3474  {
3475  HCRYPTKEY key;
3476 
3478  &data->encryptedContentInfo.contentEncryptionAlgorithm, para,
3479  data->rgRecipientInfo, &key);
3480  if (ret)
3481  {
3482  ret = CryptDecrypt(key, 0, TRUE, 0, enveloped_data->content.pbData,
3483  &enveloped_data->content.cbData);
3485  }
3486  }
3487  else
3488  ret = TRUE;
3489  if (ret)
3490  enveloped_data->decrypted = TRUE;
3491  return ret;
3492 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
CRYPT_DATA_BLOB content
Definition: msg.c:2080
#define TRUE
Definition: types.h:120
CRYPT_ENVELOPED_DATA * data
Definition: msg.c:2078
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL CRYPT_ImportEncryptedKey(PCRYPT_ALGORITHM_IDENTIFIER contEncrAlg, PCMSG_CTRL_DECRYPT_PARA para, PCMSG_KEY_TRANS_RECIPIENT_INFO info, HCRYPTKEY *key)
Definition: msg.c:3427
#define E_INVALIDARG
Definition: ddrawi.h:101
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:935
BOOL WINAPI CryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
Definition: crypt.c:805
#define CRYPT_E_ALREADY_DECRYPTED
Definition: winerror.h:2993
#define CRYPT_E_INVALID_INDEX
Definition: winerror.h:2992
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
BYTE * pbData
Definition: wincrypt.h:103
HKEY key
Definition: reg.c:42
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
#define msg(x)
Definition: auth_time.c:54
Definition: path.c:42

Referenced by CDecodeMsg_Control().

◆ CDecodeEnvelopedMsg_GetParam()

static BOOL CDecodeEnvelopedMsg_GetParam ( CDecodeMsg msg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 2953 of file msg.c.

2955 {
2956  BOOL ret = FALSE;
2957 
2958  switch (dwParamType)
2959  {
2960  case CMSG_TYPE_PARAM:
2961  ret = CRYPT_CopyParam(pvData, pcbData, &msg->type, sizeof(msg->type));
2962  break;
2963  case CMSG_CONTENT_PARAM:
2964  if (msg->u.enveloped_data.data)
2966  msg->u.enveloped_data.content.pbData,
2967  msg->u.enveloped_data.content.cbData);
2968  else
2970  break;
2972  if (msg->u.enveloped_data.data)
2974  &msg->u.enveloped_data.data->cRecipientInfo, sizeof(DWORD));
2975  else
2977  break;
2979  if (msg->u.enveloped_data.data)
2980  {
2981  if (dwIndex < msg->u.enveloped_data.data->cRecipientInfo)
2982  {
2983  PCMSG_KEY_TRANS_RECIPIENT_INFO recipientInfo =
2984  &msg->u.enveloped_data.data->rgRecipientInfo[dwIndex];
2985 
2987  &recipientInfo->RecipientId.u.IssuerSerialNumber);
2988  }
2989  else
2991  }
2992  else
2994  break;
2995  default:
2996  FIXME("unimplemented for %d\n", dwParamType);
2998  }
2999  return ret;
3000 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static BOOL CRYPT_CopyRecipientInfo(void *pvData, DWORD *pcbData, const CERT_ISSUER_SERIAL_NUMBER *in)
Definition: msg.c:2919
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define CRYPT_E_INVALID_INDEX
Definition: winerror.h:2992
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber
Definition: wincrypt.h:3667
#define CMSG_TYPE_PARAM
Definition: wincrypt.h:3925
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define msg(x)
Definition: auth_time.c:54
#define CMSG_RECIPIENT_COUNT_PARAM
Definition: wincrypt.h:3940
#define CMSG_RECIPIENT_INFO_PARAM
Definition: wincrypt.h:3942
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CDecodeMsg_GetParam().

◆ CDecodeHashMsg_GetParam()

static BOOL CDecodeHashMsg_GetParam ( CDecodeMsg msg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 2555 of file msg.c.

2557 {
2558  BOOL ret = FALSE;
2559 
2560  switch (dwParamType)
2561  {
2562  case CMSG_TYPE_PARAM:
2563  ret = CRYPT_CopyParam(pvData, pcbData, &msg->type, sizeof(msg->type));
2564  break;
2566  {
2568 
2569  ret = ContextPropertyList_FindProperty(msg->properties, dwParamType,
2570  &blob);
2571  if (ret)
2572  {
2573  ret = CRYPT_CopyParam(pvData, pcbData, blob.pbData, blob.cbData);
2574  if (ret && pvData)
2576  }
2577  else
2579  break;
2580  }
2582  ret = CryptGetHashParam(msg->u.hash, HP_HASHVAL, pvData, pcbData, 0);
2583  break;
2584  default:
2585  {
2587 
2588  ret = ContextPropertyList_FindProperty(msg->properties, dwParamType,
2589  &blob);
2590  if (ret)
2591  ret = CRYPT_CopyParam(pvData, pcbData, blob.pbData, blob.cbData);
2592  else
2594  }
2595  }
2596  return ret;
2597 }
#define CMSG_HASH_ALGORITHM_PARAM
Definition: wincrypt.h:3943
Definition: image.c:133
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
static void CRYPT_FixUpAlgorithmID(CRYPT_ALGORITHM_IDENTIFIER *id)
Definition: msg.c:2206
#define CMSG_COMPUTED_HASH_PARAM
Definition: wincrypt.h:3945
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1615
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
#define SetLastError(x)
Definition: compat.h:409
int ret
#define CMSG_TYPE_PARAM
Definition: wincrypt.h:3925
#define msg(x)
Definition: auth_time.c:54
#define HP_HASHVAL
Definition: wincrypt.h:2183
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CDecodeHashMsg_VerifyHash(), and CDecodeMsg_GetParam().

◆ CDecodeHashMsg_VerifyHash()

static BOOL CDecodeHashMsg_VerifyHash ( CDecodeMsg msg)
static

Definition at line 3226 of file msg.c.

3227 {
3228  BOOL ret;
3230 
3233  if (ret)
3234  {
3235  DWORD computedHashSize = 0;
3236 
3238  &computedHashSize);
3239  if (hashBlob.cbData == computedHashSize)
3240  {
3241  LPBYTE computedHash = CryptMemAlloc(computedHashSize);
3242 
3243  if (computedHash)
3244  {
3246  computedHash, &computedHashSize);
3247  if (ret)
3248  {
3249  if (memcmp(hashBlob.pbData, computedHash, hashBlob.cbData))
3250  {
3252  ret = FALSE;
3253  }
3254  }
3255  CryptMemFree(computedHash);
3256  }
3257  else
3258  {
3260  ret = FALSE;
3261  }
3262  }
3263  else
3264  {
3266  ret = FALSE;
3267  }
3268  }
3269  return ret;
3270 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
static const BYTE hashBlob[]
Definition: message.c:644
#define CMSG_COMPUTED_HASH_PARAM
Definition: wincrypt.h:3945
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define CMSG_HASH_DATA_PARAM
Definition: wincrypt.h:3944
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define msg(x)
Definition: auth_time.c:54
static BOOL CDecodeHashMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:2555
#define CRYPT_E_HASH_VALUE
Definition: winerror.h:2991
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by CDecodeMsg_Control().

◆ CDecodeMsg_Close()

static void CDecodeMsg_Close ( HCRYPTMSG  hCryptMsg)
static

Definition at line 2099 of file msg.c.

2100 {
2101  CDecodeMsg *msg = hCryptMsg;
2102 
2103  if (msg->crypt_prov && msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
2104  CryptReleaseContext(msg->crypt_prov, 0);
2105  switch (msg->type)
2106  {
2107  case CMSG_HASHED:
2108  if (msg->u.hash)
2109  CryptDestroyHash(msg->u.hash);
2110  break;
2111  case CMSG_ENVELOPED:
2112  if (msg->u.enveloped_data.crypt_prov)
2113  CryptReleaseContext(msg->u.enveloped_data.crypt_prov, 0);
2114  LocalFree(msg->u.enveloped_data.data);
2115  CryptMemFree(msg->u.enveloped_data.content.pbData);
2116  break;
2117  case CMSG_SIGNED:
2118  if (msg->u.signed_data.info)
2119  {
2120  LocalFree(msg->u.signed_data.info);
2121  CSignedMsgData_CloseHandles(&msg->u.signed_data);
2122  }
2123  break;
2124  }
2125  CryptMemFree(msg->msg_data.pbData);
2126  CryptMemFree(msg->detached_data.pbData);
2127  ContextPropertyList_Free(msg->properties);
2128 }
#define CMSG_SIGNED
Definition: wincrypt.h:3680
void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN
Definition: proplist.c:56
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:895
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define CMSG_HASHED
Definition: wincrypt.h:3683
static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data)
Definition: msg.c:983

Referenced by CryptMsgOpenToDecode().

◆ CDecodeMsg_Control()

static BOOL CDecodeMsg_Control ( HCRYPTMSG  hCryptMsg,
DWORD  dwFlags,
DWORD  dwCtrlType,
const void pvCtrlPara 
)
static

Definition at line 3494 of file msg.c.

3496 {
3497  CDecodeMsg *msg = hCryptMsg;
3498  BOOL ret = FALSE;
3499 
3500  switch (dwCtrlType)
3501  {
3503  switch (msg->type)
3504  {
3505  case CMSG_SIGNED:
3507  break;
3508  default:
3510  }
3511  break;
3512  case CMSG_CTRL_DECRYPT:
3513  switch (msg->type)
3514  {
3515  case CMSG_ENVELOPED:
3517  (PCMSG_CTRL_DECRYPT_PARA)pvCtrlPara);
3519  msg->u.enveloped_data.crypt_prov =
3520  ((PCMSG_CTRL_DECRYPT_PARA)pvCtrlPara)->hCryptProv;
3521  break;
3522  default:
3524  }
3525  break;
3526  case CMSG_CTRL_VERIFY_HASH:
3527  switch (msg->type)
3528  {
3529  case CMSG_HASHED:
3531  break;
3532  default:
3534  }
3535  break;
3537  switch (msg->type)
3538  {
3539  case CMSG_SIGNED:
3542  break;
3543  default:
3545  }
3546  break;
3547  default:
3549  }
3550  return ret;
3551 }
static BOOL CDecodeEnvelopedMsg_CrtlDecrypt(CDecodeMsg *msg, PCMSG_CTRL_DECRYPT_PARA para)
Definition: msg.c:3456
#define CMSG_SIGNED
Definition: wincrypt.h:3680
#define CMSG_CTRL_VERIFY_SIGNATURE_EX
Definition: wincrypt.h:3885
#define CMSG_CTRL_DECRYPT
Definition: wincrypt.h:3870
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _CMSG_CTRL_DECRYPT_PARA * PCMSG_CTRL_DECRYPT_PARA
#define CRYPT_E_CONTROL_TYPE
Definition: winerror.h:2996
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define CMSG_CTRL_VERIFY_SIGNATURE
Definition: wincrypt.h:3869
#define CMSG_CTRL_VERIFY_HASH
Definition: wincrypt.h:3871
static BOOL CDecodeSignedMsg_VerifySignatureEx(CDecodeMsg *msg, PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA para)
Definition: msg.c:3347
#define SetLastError(x)
Definition: compat.h:409
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static BOOL CDecodeSignedMsg_VerifySignature(CDecodeMsg *msg, PCERT_INFO info)
Definition: msg.c:3304
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define CMSG_HASHED
Definition: wincrypt.h:3683
static BOOL CDecodeHashMsg_VerifyHash(CDecodeMsg *msg)
Definition: msg.c:3226

Referenced by CryptMsgOpenToDecode().

◆ CDecodeMsg_CopyData()

static BOOL CDecodeMsg_CopyData ( CRYPT_DATA_BLOB blob,
const BYTE pbData,
DWORD  cbData 
)
static

Definition at line 2130 of file msg.c.

2132 {
2133  BOOL ret = TRUE;
2134 
2135  if (cbData)
2136  {
2137  if (blob->cbData)
2138  blob->pbData = CryptMemRealloc(blob->pbData,
2139  blob->cbData + cbData);
2140  else
2141  blob->pbData = CryptMemAlloc(cbData);
2142  if (blob->pbData)
2143  {
2144  memcpy(blob->pbData + blob->cbData, pbData, cbData);
2145  blob->cbData += cbData;
2146  }
2147  else
2148  ret = FALSE;
2149  }
2150  return ret;
2151 }
#define TRUE
Definition: types.h:120
Definition: image.c:133
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:136
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CDecodeMsg_Update().

◆ CDecodeMsg_DecodeContent()

static BOOL CDecodeMsg_DecodeContent ( CDecodeMsg msg,
const CRYPT_DER_BLOB blob,
DWORD  type 
)
static

Definition at line 2284 of file msg.c.

2286 {
2287  BOOL ret;
2288 
2289  switch (type)
2290  {
2291  case CMSG_DATA:
2293  msg->type = CMSG_DATA;
2294  break;
2295  case CMSG_HASHED:
2297  msg->type = CMSG_HASHED;
2298  break;
2299  case CMSG_ENVELOPED:
2301  msg->type = CMSG_ENVELOPED;
2302  break;
2303  case CMSG_SIGNED:
2305  msg->type = CMSG_SIGNED;
2306  break;
2307  default:
2308  {
2310  DWORD size;
2311 
2313  msg->msg_data.pbData, msg->msg_data.cbData, CRYPT_DECODE_ALLOC_FLAG,
2314  NULL, &info, &size);
2315  if (ret)
2316  {
2317  if (!strcmp(info->pszObjId, szOID_RSA_data))
2319  else if (!strcmp(info->pszObjId, szOID_RSA_digestedData))
2320  ret = CDecodeMsg_DecodeContent(msg, &info->Content,
2321  CMSG_HASHED);
2322  else if (!strcmp(info->pszObjId, szOID_RSA_envelopedData))
2323  ret = CDecodeMsg_DecodeContent(msg, &info->Content,
2324  CMSG_ENVELOPED);
2325  else if (!strcmp(info->pszObjId, szOID_RSA_signedData))
2326  ret = CDecodeMsg_DecodeContent(msg, &info->Content,
2327  CMSG_SIGNED);
2328  else
2329  {
2331  ret = FALSE;
2332  }
2333  LocalFree(info);
2334  }
2335  }
2336  }
2337  return ret;
2338 }
static BOOL CDecodeMsg_DecodeSignedContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
Definition: msg.c:2264
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
Definition: image.c:133
#define CMSG_SIGNED
Definition: wincrypt.h:3680
#define CMSG_DATA
Definition: wincrypt.h:3679
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _test_info info[]
Definition: SetCursorPos.c:19
#define szOID_RSA_data
Definition: wincrypt.h:3028
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3400
smooth NULL
Definition: ftsmooth.c:416
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define szOID_RSA_envelopedData
Definition: wincrypt.h:3030
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static BOOL CDecodeMsg_DecodeHashedContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
Definition: msg.c:2212
int ret
static BOOL CDecodeMsg_DecodeDataContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
Definition: msg.c:2153
#define szOID_RSA_signedData
Definition: wincrypt.h:3029
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static BOOL CDecodeMsg_DecodeEnvelopedContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
Definition: msg.c:2249
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define szOID_RSA_digestedData
Definition: wincrypt.h:3032
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define CMSG_HASHED
Definition: wincrypt.h:3683
static BOOL CDecodeMsg_DecodeContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob, DWORD type)
Definition: msg.c:2284

Referenced by CDecodeMsg_Update().

◆ CDecodeMsg_DecodeDataContent()

static BOOL CDecodeMsg_DecodeDataContent ( CDecodeMsg msg,
const CRYPT_DER_BLOB blob 
)
static

Definition at line 2153 of file msg.c.

2154 {
2155  BOOL ret;
2157  DWORD size;
2158 
2160  blob->pbData, blob->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &data, &size);
2161  if (ret)
2162  {
2163  ret = ContextPropertyList_SetProperty(msg->properties,
2164  CMSG_CONTENT_PARAM, data->pbData, data->cbData);
2165  LocalFree(data);
2166  }
2167  return ret;
2168 }
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
Definition: image.c:133
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
#define X509_OCTET_STRING
Definition: wincrypt.h:3391

Referenced by CDecodeMsg_DecodeContent(), and CDecodeMsg_DecodeHashedContent().

◆ CDecodeMsg_DecodeEnvelopedContent()

static BOOL CDecodeMsg_DecodeEnvelopedContent ( CDecodeMsg msg,
const CRYPT_DER_BLOB blob 
)
static

Definition at line 2249 of file msg.c.

2251 {
2252  BOOL ret;
2253  CRYPT_ENVELOPED_DATA *envelopedData;
2254  DWORD size;
2255 
2256  ret = CRYPT_AsnDecodePKCSEnvelopedData(blob->pbData, blob->cbData,
2258  &size);
2259  if (ret)
2260  msg->u.enveloped_data.data = envelopedData;
2261  return ret;
2262 }
Definition: image.c:133
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, CRYPT_ENVELOPED_DATA *envelopedData, DWORD *pcbEnvelopedData) DECLSPEC_HIDDEN
Definition: decode.c:5951
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454

Referenced by CDecodeMsg_DecodeContent().

◆ CDecodeMsg_DecodeHashedContent()

static BOOL CDecodeMsg_DecodeHashedContent ( CDecodeMsg msg,
const CRYPT_DER_BLOB blob 
)
static

Definition at line 2212 of file msg.c.

2214 {
2215  BOOL ret;
2216  CRYPT_DIGESTED_DATA *digestedData;
2217  DWORD size;
2218 
2219  ret = CRYPT_AsnDecodePKCSDigestedData(blob->pbData, blob->cbData,
2221  &size);
2222  if (ret)
2223  {
2225  (const BYTE *)&digestedData->version, sizeof(digestedData->version));
2227  &digestedData->DigestAlgorithm);
2230  (const BYTE *)digestedData->ContentInfo.pszObjId,
2231  digestedData->ContentInfo.pszObjId ?
2232  strlen(digestedData->ContentInfo.pszObjId) + 1 : 0);
2233  if (!(msg->base.open_flags & CMSG_DETACHED_FLAG))
2234  {
2235  if (digestedData->ContentInfo.Content.cbData)
2237  &digestedData->ContentInfo.Content);
2238  else
2240  CMSG_CONTENT_PARAM, NULL, 0);
2241  }
2243  digestedData->hash.pbData, digestedData->hash.cbData);
2244  LocalFree(digestedData);
2245  }
2246  return ret;
2247 }
#define CMSG_HASH_ALGORITHM_PARAM
Definition: wincrypt.h:3943
Definition: image.c:133
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
CRYPT_DER_BLOB Content
Definition: wincrypt.h:454
#define CMSG_INNER_CONTENT_TYPE_PARAM
Definition: wincrypt.h:3928
CRYPT_HASH_BLOB hash
unsigned int BOOL
Definition: ntddk_ex.h:94
static void CDecodeMsg_SaveAlgorithmID(CDecodeMsg *msg, DWORD param, const CRYPT_ALGORITHM_IDENTIFIER *id)
Definition: msg.c:2170
smooth NULL
Definition: ftsmooth.c:416
CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm
CRYPT_CONTENT_INFO ContentInfo
GLsizeiptr size
Definition: glext.h:5919
#define CMSG_HASH_DATA_PARAM
Definition: wincrypt.h:3944
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BYTE * pbData
Definition: wincrypt.h:103
BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData) DECLSPEC_HIDDEN
Definition: decode.c:3371
unsigned char BYTE
Definition: mem.h:68
static BOOL CDecodeMsg_DecodeDataContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob)
Definition: msg.c:2153
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
#define CMSG_VERSION_PARAM
Definition: wincrypt.h:3950

Referenced by CDecodeMsg_DecodeContent().

◆ CDecodeMsg_DecodeSignedContent()

static BOOL CDecodeMsg_DecodeSignedContent ( CDecodeMsg msg,
const CRYPT_DER_BLOB blob 
)
static

Definition at line 2264 of file msg.c.

2266 {
2267  BOOL ret;
2268  CRYPT_SIGNED_INFO *signedInfo;
2269  DWORD size;
2270 
2271  ret = CRYPT_AsnDecodeCMSSignedInfo(blob->pbData, blob->cbData,
2273  &size);
2274  if (ret)
2275  msg->u.signed_data.info = signedInfo;
2276  return ret;
2277 }
Definition: image.c:133
BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, CRYPT_SIGNED_INFO *signedInfo, DWORD *pcbSignedInfo) DECLSPEC_HIDDEN
Definition: decode.c:5822
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454

Referenced by CDecodeMsg_DecodeContent().

◆ CDecodeMsg_FinalizeContent()

static BOOL CDecodeMsg_FinalizeContent ( CDecodeMsg msg,
CRYPT_DER_BLOB blob 
)
static

Definition at line 2451 of file msg.c.

2452 {
2453  BOOL ret = FALSE;
2454 
2455  switch (msg->type)
2456  {
2457  case CMSG_HASHED:
2459  break;
2460  case CMSG_ENVELOPED:
2462  break;
2463  case CMSG_SIGNED:
2465  break;
2466  default:
2467  ret = TRUE;
2468  }
2469  return ret;
2470 }
#define TRUE
Definition: types.h:120
Definition: image.c:133
#define CMSG_SIGNED
Definition: wincrypt.h:3680
static BOOL CDecodeMsg_FinalizeSignedContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
Definition: msg.c:2399
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
static BOOL CDecodeMsg_FinalizeEnvelopedContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
Definition: msg.c:2385
#define msg(x)
Definition: auth_time.c:54
static BOOL CDecodeMsg_FinalizeHashedContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
Definition: msg.c:2340
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define CMSG_HASHED
Definition: wincrypt.h:3683

Referenced by CDecodeMsg_Update().

◆ CDecodeMsg_FinalizeEnvelopedContent()

static BOOL CDecodeMsg_FinalizeEnvelopedContent ( CDecodeMsg msg,
CRYPT_DER_BLOB blob 
)
static

Definition at line 2385 of file msg.c.

2387 {
2389 
2390  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2391  content = &msg->detached_data;
2392  else
2393  content =
2394  &msg->u.enveloped_data.data->encryptedContentInfo.encryptedContent;
2395 
2396  return CRYPT_ConstructBlob(&msg->u.enveloped_data.content, content);
2397 }
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
content
Definition: atl_ax.c:994
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54

Referenced by CDecodeMsg_FinalizeContent().

◆ CDecodeMsg_FinalizeHashedContent()

static BOOL CDecodeMsg_FinalizeHashedContent ( CDecodeMsg msg,
CRYPT_DER_BLOB blob 
)
static

Definition at line 2340 of file msg.c.

2342 {
2343  CRYPT_ALGORITHM_IDENTIFIER *hashAlgoID = NULL;
2344  DWORD size = 0;
2345  ALG_ID algID = 0;
2346  BOOL ret;
2347 
2349  hashAlgoID = CryptMemAlloc(size);
2351  &size);
2352  if (ret)
2353  algID = CertOIDToAlgId(hashAlgoID->pszObjId);
2354 
2355  if (!msg->crypt_prov)
2356  {
2357  msg->crypt_prov = I_CryptGetDefaultCryptProv(algID);
2358  if (msg->crypt_prov)
2359  msg->base.open_flags &= ~CMSG_CRYPT_RELEASE_CONTEXT_FLAG;
2360  }
2361 
2362  ret = CryptCreateHash(msg->crypt_prov, algID, 0, 0, &msg->u.hash);
2363  if (ret)
2364  {
2366 
2367  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2368  {
2369  /* Unlike for non-detached messages, the data were never stored as
2370  * the content param, but were saved in msg->detached_data instead.
2371  */
2372  content.pbData = msg->detached_data.pbData;
2373  content.cbData = msg->detached_data.cbData;
2374  }
2375  else
2378  if (ret)
2379  ret = CryptHashData(msg->u.hash, content.pbData, content.cbData, 0);
2380  }
2381  CryptMemFree(hashAlgoID);
2382  return ret;
2383 }
#define CMSG_HASH_ALGORITHM_PARAM
Definition: wincrypt.h:3943
unsigned int ALG_ID
Definition: wincrypt.h:45
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
content
Definition: atl_ax.c:994
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID)
Definition: main.c:210
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:745
DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId)
Definition: oid.c:1901
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1776
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867

Referenced by CDecodeMsg_FinalizeContent().

◆ CDecodeMsg_FinalizeSignedContent()

static BOOL CDecodeMsg_FinalizeSignedContent ( CDecodeMsg msg,
CRYPT_DER_BLOB blob 
)
static

Definition at line 2399 of file msg.c.

2401 {
2402  BOOL ret;
2403  DWORD i, size;
2404 
2405  ret = CSignedMsgData_AllocateHandles(&msg->u.signed_data);
2406  for (i = 0; ret && i < msg->u.signed_data.info->cSignerInfo; i++)
2407  ret = CSignedMsgData_ConstructSignerHandles(&msg->u.signed_data, i,
2408  &msg->crypt_prov, &msg->base.open_flags);
2409  if (ret)
2410  {
2412 
2413  /* Now that we have all the content, update the hash handles with
2414  * it. If the message is a detached message, the content is stored
2415  * in msg->detached_data rather than in the signed message's
2416  * content.
2417  */
2418  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2419  content = &msg->detached_data;
2420  else
2421  content = &msg->u.signed_data.info->content.Content;
2422  if (content->cbData)
2423  {
2424  /* If the message is not detached, have to decode the message's
2425  * content if the type is szOID_RSA_data.
2426  */
2427  if (!(msg->base.open_flags & CMSG_DETACHED_FLAG) &&
2428  !strcmp(msg->u.signed_data.info->content.pszObjId,
2429  szOID_RSA_data))
2430  {
2431  CRYPT_DATA_BLOB *rsa_blob;
2432 
2434  X509_OCTET_STRING, content->pbData, content->cbData,
2435  CRYPT_DECODE_ALLOC_FLAG, NULL, &rsa_blob, &size);
2436  if (ret)
2437  {
2438  ret = CSignedMsgData_Update(&msg->u.signed_data,
2439  rsa_blob->pbData, rsa_blob->cbData, TRUE, Verify);
2440  LocalFree(rsa_blob);
2441  }
2442  }
2443  else
2444  ret = CSignedMsgData_Update(&msg->u.signed_data,
2445  content->pbData, content->cbData, TRUE, Verify);
2446  }
2447  }
2448  return ret;
2449 }
#define TRUE
Definition: types.h:120
Definition: msg.c:1065
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
static BOOL CSignedMsgData_AllocateHandles(CSignedMsgData *msg_data)
Definition: msg.c:955
#define szOID_RSA_data
Definition: wincrypt.h:3028
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
content
Definition: atl_ax.c:994
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BYTE * pbData
Definition: wincrypt.h:103
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static BOOL CSignedMsgData_Update(CSignedMsgData *msg_data, const BYTE *pbData, DWORD cbData, BOOL fFinal, SignOrVerify flag)
Definition: msg.c:1172
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static BOOL CSignedMsgData_ConstructSignerHandles(CSignedMsgData *msg_data, DWORD signerIndex, HCRYPTPROV *crypt_prov, DWORD *flags)
Definition: msg.c:928
#define X509_OCTET_STRING
Definition: wincrypt.h:3391

Referenced by CDecodeMsg_FinalizeContent().

◆ CDecodeMsg_GetParam()

static BOOL CDecodeMsg_GetParam ( HCRYPTMSG  hCryptMsg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 3182 of file msg.c.

3184 {
3185  CDecodeMsg *msg = hCryptMsg;
3186  BOOL ret = FALSE;
3187 
3188  switch (msg->type)
3189  {
3190  case CMSG_HASHED:
3191  ret = CDecodeHashMsg_GetParam(msg, dwParamType, dwIndex, pvData,
3192  pcbData);
3193  break;
3194  case CMSG_ENVELOPED:
3195  ret = CDecodeEnvelopedMsg_GetParam(msg, dwParamType, dwIndex, pvData,
3196  pcbData);
3197  break;
3198  case CMSG_SIGNED:
3199  ret = CDecodeSignedMsg_GetParam(msg, dwParamType, dwIndex, pvData,
3200  pcbData);
3201  break;
3202  default:
3203  switch (dwParamType)
3204  {
3205  case CMSG_TYPE_PARAM:
3206  ret = CRYPT_CopyParam(pvData, pcbData, &msg->type,
3207  sizeof(msg->type));
3208  break;
3209  default:
3210  {
3212 
3213  ret = ContextPropertyList_FindProperty(msg->properties, dwParamType,
3214  &blob);
3215  if (ret)
3216  ret = CRYPT_CopyParam(pvData, pcbData, blob.pbData,
3217  blob.cbData);
3218  else
3220  }
3221  }
3222  }
3223  return ret;
3224 }
Definition: image.c:133
#define CMSG_SIGNED
Definition: wincrypt.h:3680
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
static BOOL CDecodeEnvelopedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:2953
static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3002
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
#define SetLastError(x)
Definition: compat.h:409
int ret
#define CMSG_TYPE_PARAM
Definition: wincrypt.h:3925
#define msg(x)
Definition: auth_time.c:54
static BOOL CDecodeHashMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:2555
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define CMSG_HASHED
Definition: wincrypt.h:3683
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CryptMsgOpenToDecode().

◆ CDecodeMsg_SaveAlgorithmID()

static void CDecodeMsg_SaveAlgorithmID ( CDecodeMsg msg,
DWORD  param,
const CRYPT_ALGORITHM_IDENTIFIER id 
)
static

Definition at line 2170 of file msg.c.

2172 {
2173  static const BYTE nullParams[] = { ASN_NULL, 0 };
2176 
2177  /* Linearize algorithm id */
2178  len += strlen(id->pszObjId) + 1;
2179  len += id->Parameters.cbData;
2180  copy = CryptMemAlloc(len);
2181  if (copy)
2182  {
2183  copy->pszObjId =
2184  (LPSTR)((BYTE *)copy + sizeof(CRYPT_ALGORITHM_IDENTIFIER));
2185  strcpy(copy->pszObjId, id->pszObjId);
2186  copy->Parameters.pbData = (BYTE *)copy->pszObjId + strlen(id->pszObjId)
2187  + 1;
2188  /* Trick: omit NULL parameters */
2189  if (id->Parameters.cbData == sizeof(nullParams) &&
2190  !memcmp(id->Parameters.pbData, nullParams, sizeof(nullParams)))
2191  {
2192  copy->Parameters.cbData = 0;
2193  len -= sizeof(nullParams);
2194  }
2195  else
2196  copy->Parameters.cbData = id->Parameters.cbData;
2197  if (copy->Parameters.cbData)
2198  memcpy(copy->Parameters.pbData, id->Parameters.pbData,
2199  id->Parameters.cbData);
2201  len);
2202  CryptMemFree(copy);
2203  }
2204 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
char * LPSTR
Definition: xmlstorage.h:182
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _CRYPT_ALGORITHM_IDENTIFIER CRYPT_ALGORITHM_IDENTIFIER
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define ASN_NULL
Definition: snmp.h:106
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define msg(x)
Definition: auth_time.c:54
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLenum GLuint id
Definition: glext.h:5579

Referenced by CDecodeMsg_DecodeHashedContent().

◆ CDecodeMsg_Update()

static BOOL CDecodeMsg_Update ( HCRYPTMSG  hCryptMsg,
const BYTE pbData,
DWORD  cbData,
BOOL  fFinal 
)
static

Definition at line 2472 of file msg.c.

2474 {
2475  CDecodeMsg *msg = hCryptMsg;
2476  BOOL ret = FALSE;
2477 
2478  TRACE("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal);
2479 
2480  if (msg->base.state == MsgStateFinalized)
2482  else if (msg->base.streamed)
2483  {
2484  FIXME("(%p, %p, %d, %d): streamed update stub\n", hCryptMsg, pbData,
2485  cbData, fFinal);
2486  switch (msg->base.state)
2487  {
2488  case MsgStateInit:
2489  ret = CDecodeMsg_CopyData(&msg->msg_data, pbData, cbData);
2490  if (fFinal)
2491  {
2492  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2493  msg->base.state = MsgStateDataFinalized;
2494  else
2495  msg->base.state = MsgStateFinalized;
2496  }
2497  else
2498  msg->base.state = MsgStateUpdated;
2499  break;
2500  case MsgStateUpdated:
2501  ret = CDecodeMsg_CopyData(&msg->msg_data, pbData, cbData);
2502  if (fFinal)
2503  {
2504  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2505  msg->base.state = MsgStateDataFinalized;
2506  else
2507  msg->base.state = MsgStateFinalized;
2508  }
2509  break;
2510  case MsgStateDataFinalized:
2511  ret = CDecodeMsg_CopyData(&msg->detached_data, pbData, cbData);
2512  if (fFinal)
2513  msg->base.state = MsgStateFinalized;
2514  break;
2515  default:
2517  break;
2518  }
2519  }
2520  else
2521  {
2522  if (!fFinal)
2524  else
2525  {
2526  switch (msg->base.state)
2527  {
2528  case MsgStateInit:
2529  ret = CDecodeMsg_CopyData(&msg->msg_data, pbData, cbData);
2530  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
2531  msg->base.state = MsgStateDataFinalized;
2532  else
2533  msg->base.state = MsgStateFinalized;
2534  break;
2535  case MsgStateDataFinalized:
2536  ret = CDecodeMsg_CopyData(&msg->detached_data, pbData, cbData);
2537  msg->base.state = MsgStateFinalized;
2538  break;
2539  default:
2541  }
2542  }
2543  }
2544  if (ret && fFinal &&
2545  ((msg->base.open_flags & CMSG_DETACHED_FLAG && msg->base.state ==
2547  (!(msg->base.open_flags & CMSG_DETACHED_FLAG) && msg->base.state ==
2549  ret = CDecodeMsg_DecodeContent(msg, &msg->msg_data, msg->type);
2550  if (ret && msg->base.state == MsgStateFinalized)
2551  ret = CDecodeMsg_FinalizeContent(msg, &msg->msg_data);
2552  return ret;
2553 }
#define CRYPT_E_MSG_ERROR
Definition: winerror.h:2985
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL CDecodeMsg_FinalizeContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
Definition: msg.c:2451
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
int ret
static BOOL CDecodeMsg_CopyData(CRYPT_DATA_BLOB *blob, const BYTE *pbData, DWORD cbData)
Definition: msg.c:2130
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201
static BOOL CDecodeMsg_DecodeContent(CDecodeMsg *msg, const CRYPT_DER_BLOB *blob, DWORD type)
Definition: msg.c:2284

Referenced by CryptMsgOpenToDecode().

◆ CDecodeSignedMsg_GetParam()

static BOOL CDecodeSignedMsg_GetParam ( CDecodeMsg msg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 3002 of file msg.c.

3004 {
3005  BOOL ret = FALSE;
3006 
3007  switch (dwParamType)
3008  {
3009  case CMSG_TYPE_PARAM:
3010  ret = CRYPT_CopyParam(pvData, pcbData, &msg->type, sizeof(msg->type));
3011  break;
3012  case CMSG_CONTENT_PARAM:
3013  if (msg->u.signed_data.info)
3014  {
3015  if (!strcmp(msg->u.signed_data.info->content.pszObjId,
3016  szOID_RSA_data))
3017  {
3019  DWORD size;
3020 
3022  msg->u.signed_data.info->content.Content.pbData,
3023  msg->u.signed_data.info->content.Content.cbData,
3025  if (ret)
3026  {
3027  ret = CRYPT_CopyParam(pvData, pcbData, blob->pbData,
3028  blob->cbData);
3029  LocalFree(blob);
3030  }
3031  }
3032  else
3034  msg->u.signed_data.info->content.Content.pbData,
3035  msg->u.signed_data.info->content.Content.cbData);
3036  }
3037  else
3039  break;
3041  if (msg->u.signed_data.info)
3043  msg->u.signed_data.info->content.pszObjId,
3044  strlen(msg->u.signed_data.info->content.pszObjId) + 1);
3045  else
3047  break;
3049  if (msg->u.signed_data.info)
3051  &msg->u.signed_data.info->cSignerInfo, sizeof(DWORD));
3052  else
3054  break;
3056  if (msg->u.signed_data.info)
3057  {
3058  if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
3060  else
3062  &msg->u.signed_data.info->rgSignerInfo[dwIndex]);
3063  }
3064  else
3066  break;
3068  if (msg->u.signed_data.info)
3069  {
3070  if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
3072  else
3074  &msg->u.signed_data.info->rgSignerInfo[dwIndex]);
3075  }
3076  else
3078  break;
3079  case CMSG_CERT_COUNT_PARAM:
3080  if (msg->u.signed_data.info)
3082  &msg->u.signed_data.info->cCertEncoded, sizeof(DWORD));
3083  else
3085  break;
3086  case CMSG_CERT_PARAM:
3087  if (msg->u.signed_data.info)
3088  {
3089  if (dwIndex >= msg->u.signed_data.info->cCertEncoded)
3091  else
3093  msg->u.signed_data.info->rgCertEncoded[dwIndex].pbData,
3094  msg->u.signed_data.info->rgCertEncoded[dwIndex].cbData);
3095  }
3096  else
3098  break;
3099  case CMSG_CRL_COUNT_PARAM:
3100  if (msg->u.signed_data.info)
3102  &msg->u.signed_data.info->cCrlEncoded, sizeof(DWORD));
3103  else
3105  break;
3106  case CMSG_CRL_PARAM:
3107  if (msg->u.signed_data.info)
3108  {
3109  if (dwIndex >= msg->u.signed_data.info->cCrlEncoded)
3111  else
3113  msg->u.signed_data.info->rgCrlEncoded[dwIndex].pbData,
3114  msg->u.signed_data.info->rgCrlEncoded[dwIndex].cbData);
3115  }
3116  else
3118  break;
3120  if (msg->u.signed_data.info)
3121  {
3122  if (dwIndex >= msg->u.signed_data.cSignerHandle)
3124  else
3126  msg->u.signed_data.signerHandles[dwIndex].contentHash,
3127  HP_HASHVAL, pvData, pcbData, 0);
3128  }
3129  else
3131  break;
3132  case CMSG_ENCODED_SIGNER:
3133  if (msg->u.signed_data.info)
3134  {
3135  if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
3137  else
3140  &msg->u.signed_data.info->rgSignerInfo[dwIndex], 0, NULL,
3141  pvData, pcbData);
3142  }
3143  else
3145  break;
3147  if (msg->u.signed_data.info)
3148  {
3149  DWORD attrCertCount = 0;
3150 
3152  &attrCertCount, sizeof(DWORD));
3153  }
3154  else
3156  break;
3157  case CMSG_ATTR_CERT_PARAM:
3158  if (msg->u.signed_data.info)
3160  else
3162  break;
3164  if (msg->u.signed_data.info)
3165  {
3166  if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
3168  else
3170  &msg->u.signed_data.info->rgSignerInfo[dwIndex]);
3171  }
3172  else
3174  break;
3175  default:
3176  FIXME("unimplemented for %d\n", dwParamType);
3178  }
3179  return ret;
3180 }
#define CMSG_ATTR_CERT_COUNT_PARAM
Definition: wincrypt.h:3951
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
#define CMSG_CRL_PARAM
Definition: wincrypt.h:3938
Definition: image.c:133
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CMSG_CERT_PARAM
Definition: wincrypt.h:3936
#define CMSG_CMS_SIGNER_INFO_PARAM
Definition: wincrypt.h:3959
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
#define CMSG_ATTR_CERT_PARAM
Definition: wincrypt.h:3952
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
Definition: msg.c:2729
#define CMSG_COMPUTED_HASH_PARAM
Definition: wincrypt.h:3945
#define CMSG_INNER_CONTENT_TYPE_PARAM
Definition: wincrypt.h:3928
#define CMS_SIGNER_INFO
Definition: wincrypt.h:3437
#define szOID_RSA_data
Definition: wincrypt.h:3028
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define CMSG_CRL_COUNT_PARAM
Definition: wincrypt.h:3937
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1615
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL CRYPT_CopySignerCertInfo(void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
Definition: msg.c:2868
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
smooth NULL
Definition: ftsmooth.c:416
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define CRYPT_E_INVALID_INDEX
Definition: winerror.h:2992
GLsizeiptr size
Definition: glext.h:5919
#define CMSG_ENCODED_SIGNER
Definition: wincrypt.h:3948
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define CMSG_CERT_COUNT_PARAM
Definition: wincrypt.h:3935
int ret
static BOOL CRYPT_CopyCMSSignerInfo(void *pvData, DWORD *pcbData, const CMSG_CMS_SIGNER_INFO *in)
Definition: msg.c:2801
#define CMSG_TYPE_PARAM
Definition: wincrypt.h:3925
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define CMSG_SIGNER_CERT_INFO_PARAM
Definition: wincrypt.h:3931
#define CMSG_SIGNER_INFO_PARAM
Definition: wincrypt.h:3930
#define HP_HASHVAL
Definition: wincrypt.h:2183
#define X509_OCTET_STRING
Definition: wincrypt.h:3391
#define CMSG_SIGNER_COUNT_PARAM
Definition: wincrypt.h:3929
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CDecodeMsg_GetParam().

◆ CDecodeSignedMsg_VerifySignature()

static BOOL CDecodeSignedMsg_VerifySignature ( CDecodeMsg msg,
PCERT_INFO  info 
)
static

Definition at line 3304 of file msg.c.

3305 {
3306  BOOL ret = FALSE;
3307  DWORD i;
3308 
3309  if (!msg->u.signed_data.signerHandles)
3310  {
3312  return FALSE;
3313  }
3314  for (i = 0; !ret && i < msg->u.signed_data.info->cSignerInfo; i++)
3315  {
3316  PCMSG_CMS_SIGNER_INFO signerInfo =
3317  &msg->u.signed_data.info->rgSignerInfo[i];
3318 
3320  {
3322  &signerInfo->SignerId.u.IssuerSerialNumber.Issuer,
3323  &info->Issuer);
3324  if (ret)
3325  {
3327  &signerInfo->SignerId.u.IssuerSerialNumber.SerialNumber,
3328  &info->SerialNumber);
3329  if (ret)
3330  break;
3331  }
3332  }
3333  else
3334  {
3335  FIXME("signer %d: unimplemented for key id\n", i);
3336  }
3337  }
3338  if (ret)
3340  &info->SubjectPublicKeyInfo);
3341  else
3343 
3344  return ret;
3345 }
#define NTE_BAD_SIGNATURE
Definition: winerror.h:2874
static BOOL CDecodeSignedMsg_VerifySignatureWithKey(CDecodeMsg *msg, HCRYPTPROV prov, DWORD signerIndex, PCERT_PUBLIC_KEY_INFO keyInfo)
Definition: msg.c:3272
BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType, PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2)
Definition: cert.c:1180
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1, PCRYPT_INTEGER_BLOB pInt2)
Definition: cert.c:1221
DWORD dwIdChoice
Definition: wincrypt.h:3665
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber
Definition: wincrypt.h:3667
#define CERT_ID_ISSUER_SERIAL_NUMBER
Definition: wincrypt.h:3673
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:3660
#define msg(x)
Definition: auth_time.c:54
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:3659
#define CRYPT_E_SIGNER_NOT_FOUND
Definition: winerror.h:2998

Referenced by CDecodeMsg_Control().

◆ CDecodeSignedMsg_VerifySignatureEx()

static BOOL CDecodeSignedMsg_VerifySignatureEx ( CDecodeMsg msg,
PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA  para 
)
static

Definition at line 3347 of file msg.c.

3349 {
3350  BOOL ret = FALSE;
3351 
3352  if (para->cbSize != sizeof(CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA))
3354  else if (para->dwSignerIndex >= msg->u.signed_data.info->cSignerInfo)
3356  else if (!msg->u.signed_data.signerHandles)
3358  else
3359  {
3360  switch (para->dwSignerType)
3361  {
3364  para->hCryptProv, para->dwSignerIndex, para->pvSigner);
3365  break;
3367  {
3368  PCCERT_CONTEXT cert = para->pvSigner;
3369 
3371  para->dwSignerIndex, &cert->pCertInfo->SubjectPublicKeyInfo);
3372  break;
3373  }
3374  default:
3375  FIXME("unimplemented for signer type %d\n", para->dwSignerType);
3377  }
3378  }
3379  return ret;
3380 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define NTE_BAD_SIGNATURE
Definition: winerror.h:2874
static BOOL CDecodeSignedMsg_VerifySignatureWithKey(CDecodeMsg *msg, HCRYPTPROV prov, DWORD signerIndex, PCERT_PUBLIC_KEY_INFO keyInfo)
Definition: msg.c:3272
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define CMSG_VERIFY_SIGNER_CERT
Definition: wincrypt.h:3921
static BYTE cert[]
Definition: msg.c:1437
#define CMSG_VERIFY_SIGNER_PUBKEY
Definition: wincrypt.h:3920
#define SetLastError(x)
Definition: compat.h:409
int ret
#define msg(x)
Definition: auth_time.c:54
#define CRYPT_E_SIGNER_NOT_FOUND
Definition: winerror.h:2998

Referenced by CDecodeMsg_Control().

◆ CDecodeSignedMsg_VerifySignatureWithKey()

static BOOL CDecodeSignedMsg_VerifySignatureWithKey ( CDecodeMsg msg,
HCRYPTPROV  prov,
DWORD  signerIndex,
PCERT_PUBLIC_KEY_INFO  keyInfo 
)
static

Definition at line 3272 of file msg.c.

3274 {
3275  HCRYPTKEY key;
3276  BOOL ret;
3277 
3278  if (!prov)
3279  prov = msg->crypt_prov;
3280  ret = CryptImportPublicKeyInfo(prov, X509_ASN_ENCODING, keyInfo, &key);
3281  if (ret)
3282  {
3283  HCRYPTHASH hash;
3284  CRYPT_HASH_BLOB reversedHash;
3285 
3286  if (msg->u.signed_data.info->rgSignerInfo[signerIndex].AuthAttrs.cAttr)
3287  hash = msg->u.signed_data.signerHandles[signerIndex].authAttrHash;
3288  else
3289  hash = msg->u.signed_data.signerHandles[signerIndex].contentHash;
3290  ret = CRYPT_ConstructBlob(&reversedHash,
3291  &msg->u.signed_data.info->rgSignerInfo[signerIndex].EncryptedHash);
3292  if (ret)
3293  {
3294  CRYPT_ReverseBytes(&reversedHash);
3295  ret = CryptVerifySignatureW(hash, reversedHash.pbData,
3296  reversedHash.cbData, key, NULL, 0);
3297  CryptMemFree(reversedHash.pbData);
3298  }
3300  }
3301  return ret;
3302 }
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
int hash
Definition: main.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey)
Definition: encode.c:4970
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:935
BOOL WINAPI CryptVerifySignatureW(HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
Definition: crypt.c:2243
int ret
BYTE * pbData
Definition: wincrypt.h:103
HKEY key
Definition: reg.c:42
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:50
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define msg(x)
Definition: auth_time.c:54
static void CRYPT_ReverseBytes(CRYPT_HASH_BLOB *hash)
Definition: msg.c:1118
Definition: _hash_fun.h:40
Definition: path.c:42

Referenced by CDecodeSignedMsg_VerifySignature(), and CDecodeSignedMsg_VerifySignatureEx().

◆ CEnvelopedEncodeMsg_Close()

static void CEnvelopedEncodeMsg_Close ( HCRYPTMSG  hCryptMsg)
static

Definition at line 1799 of file msg.c.

1800 {
1801  CEnvelopedEncodeMsg *msg = hCryptMsg;
1802 
1803  CryptMemFree(msg->algo.pszObjId);
1804  CryptMemFree(msg->algo.Parameters.pbData);
1805  if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
1806  CryptReleaseContext(msg->prov, 0);
1807  CryptDestroyKey(msg->key);
1808  if (msg->recipientInfo)
1809  {
1810  DWORD i;
1811 
1812  for (i = 0; i < msg->cRecipientInfo; ++i)
1813  CRecipientInfo_Free(&msg->recipientInfo[i]);
1814  CryptMemFree(msg->recipientInfo);
1815  }
1816  CryptMemFree(msg->data.pbData);
1817 }
static void CRecipientInfo_Free(CMSG_KEY_TRANS_RECIPIENT_INFO *info)
Definition: msg.c:1790
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:935
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867

Referenced by CEnvelopedEncodeMsg_Open().

◆ CEnvelopedEncodeMsg_GetParam()

static BOOL CEnvelopedEncodeMsg_GetParam ( HCRYPTMSG  hCryptMsg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 1819 of file msg.c.

1821 {
1822  CEnvelopedEncodeMsg *msg = hCryptMsg;
1823  BOOL ret = FALSE;
1824 
1825  switch (dwParamType)
1826  {
1828  if (msg->base.streamed)
1830  else
1831  {
1832  char oid_rsa_data[] = szOID_RSA_data;
1833  CRYPT_ENVELOPED_DATA envelopedData = {
1834  CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION, msg->cRecipientInfo,
1835  msg->recipientInfo, { oid_rsa_data, {
1836  msg->algo.pszObjId,
1837  { msg->algo.Parameters.cbData, msg->algo.Parameters.pbData }
1838  },
1839  { msg->data.cbData, msg->data.pbData }
1840  }
1841  };
1842 
1843  ret = CRYPT_AsnEncodePKCSEnvelopedData(&envelopedData, pvData,
1844  pcbData);
1845  }
1846  break;
1847  case CMSG_CONTENT_PARAM:
1848  {
1850 
1852  &info.Content.cbData);
1853  if (ret)
1854  {
1855  info.Content.pbData = CryptMemAlloc(info.Content.cbData);
1856  if (info.Content.pbData)
1857  {
1859  info.Content.pbData, &info.Content.cbData);
1860  if (ret)
1861  {
1862  char oid_rsa_enveloped[] = szOID_RSA_envelopedData;
1863 
1864  info.pszObjId = oid_rsa_enveloped;
1867  }
1868  CryptMemFree(info.Content.pbData);
1869  }
1870  else
1871  ret = FALSE;
1872  }
1873  break;
1874  }
1875  default:
1877  }
1878  return ret;
1879 }
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
struct _test_info info[]
Definition: SetCursorPos.c:19
#define szOID_RSA_data
Definition: wincrypt.h:3028
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3400
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
smooth NULL
Definition: ftsmooth.c:416
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define szOID_RSA_envelopedData
Definition: wincrypt.h:3030
BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData, void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN
Definition: encode.c:4418
#define SetLastError(x)
Definition: compat.h:409
int ret
#define CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION
Definition: wincrypt.h:3990
#define CMSG_BARE_CONTENT_PARAM
Definition: wincrypt.h:3927
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CEnvelopedEncodeMsg_Open().

◆ CEnvelopedEncodeMsg_Open()

static HCRYPTMSG CEnvelopedEncodeMsg_Open ( DWORD  dwFlags,
const void pvMsgEncodeInfo,
LPCSTR  pszInnerContentObjID,
PCMSG_STREAM_INFO  pStreamInfo 
)
static

Definition at line 1950 of file msg.c.

1953 {
1955  const CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS *info = pvMsgEncodeInfo;
1956  HCRYPTPROV prov;
1957  ALG_ID algID;
1958 
1959  if (info->cbSize != sizeof(CMSG_ENVELOPED_ENCODE_INFO) &&
1960  info->cbSize != sizeof(CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS))
1961  {
1963  return NULL;
1964  }
1965  if (info->cbSize == sizeof(CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS))
1966  FIXME("CMS fields unsupported\n");
1967  if (!(algID = CertOIDToAlgId(info->ContentEncryptionAlgorithm.pszObjId)))
1968  {
1970  return NULL;
1971  }
1972  if (info->cRecipients && !info->rgpRecipientCert)
1973  {
1975  return NULL;
1976  }
1977  if (info->hCryptProv)
1978  prov = info->hCryptProv;
1979  else
1980  {
1981  prov = I_CryptGetDefaultCryptProv(0);
1983  }
1985  if (msg)
1986  {
1987  CRYPT_DATA_BLOB encryptedKey = { 0, NULL };
1988  CMSG_CONTENT_ENCRYPT_INFO encryptInfo;
1989  BOOL ret;
1990  DWORD i;
1991 
1992  CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
1996  &info->ContentEncryptionAlgorithm);
1997  msg->prov = prov;
1998  msg->data.cbData = 0;
1999  msg->data.pbData = NULL;
2000  msg->cRecipientInfo = info->cRecipients;
2001  msg->recipientInfo = CryptMemAlloc(info->cRecipients *
2003  if (!msg->recipientInfo)
2004  ret = FALSE;
2005  memset(&encryptInfo, 0, sizeof(encryptInfo));
2006  if (ret)
2007  {
2008  ret = CContentEncryptInfo_Construct(&encryptInfo, info, prov);
2009  if (ret)
2010  {
2011  ret = CRYPT_GenKey(&encryptInfo, algID);
2012  if (ret)
2013  msg->key = encryptInfo.hContentEncryptKey;
2014  }
2015  }
2016  for (i = 0; ret && i < msg->cRecipientInfo; ++i)
2017  {
2018  ret = CRYPT_ExportEncryptedKey(&encryptInfo, i, &encryptedKey);
2019  if (ret)
2020  ret = CRecipientInfo_Construct(&msg->recipientInfo[i],
2021  info->rgpRecipientCert[i], &encryptedKey);
2022  }
2023  CContentEncryptInfo_Free(&encryptInfo);
2024  if (!ret)
2025  {
2026  CryptMsgClose(msg);
2027  msg = NULL;
2028  }
2029  }
2031  CryptReleaseContext(prov, 0);
2032  return msg;
2033 }
unsigned int ALG_ID
Definition: wincrypt.h:45
static void CContentEncryptInfo_Free(CMSG_CONTENT_ENCRYPT_INFO *info)
Definition: msg.c:1743
static BOOL CContentEncryptInfo_Construct(CMSG_CONTENT_ENCRYPT_INFO *info, const CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS *in, HCRYPTPROV prov)
Definition: msg.c:1682
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
static BOOL CRYPT_ExportEncryptedKey(CMSG_CONTENT_ENCRYPT_INFO *info, DWORD i, CRYPT_DATA_BLOB *key)
Definition: msg.c:1630
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static BOOL CRYPT_DefaultMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
Definition: msg.c:49
static BOOL CEnvelopedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:1881
static void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags, PCMSG_STREAM_INFO pStreamInfo, CryptMsgCloseFunc close, CryptMsgGetParamFunc get_param, CryptMsgUpdateFunc update, CryptMsgControlFunc control)
Definition: msg.c:77
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID)
Definition: main.c:210
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static void CEnvelopedEncodeMsg_Close(HCRYPTMSG hCryptMsg)
Definition: msg.c:1799
static BOOL CRYPT_ConstructAlgorithmId(CRYPT_ALGORITHM_IDENTIFIER *out, const CRYPT_ALGORITHM_IDENTIFIER *in)
Definition: msg.c:1512
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CRYPT_E_UNKNOWN_ALGO
Definition: winerror.h:2986
DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId)
Definition: oid.c:1901
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
static BOOL CRYPT_GenKey(CMSG_CONTENT_ENCRYPT_INFO *info, ALG_ID algID)
Definition: msg.c:1542
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867
#define memset(x, y, z)
Definition: compat.h:39
static BOOL CEnvelopedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:1819
static BOOL CRecipientInfo_Construct(CMSG_KEY_TRANS_RECIPIENT_INFO *info, const CERT_INFO *cert, CRYPT_DATA_BLOB *key)
Definition: msg.c:1769

Referenced by CryptMsgOpenToEncode().

◆ CEnvelopedEncodeMsg_Update()

static BOOL CEnvelopedEncodeMsg_Update ( HCRYPTMSG  hCryptMsg,
const BYTE pbData,
DWORD  cbData,
BOOL  fFinal 
)
static

Definition at line 1881 of file msg.c.

1883 {
1884  CEnvelopedEncodeMsg *msg = hCryptMsg;
1885  BOOL ret = FALSE;
1886 
1887  if (msg->base.state == MsgStateFinalized)
1889  else if (msg->base.streamed)
1890  {
1891  FIXME("streamed stub\n");
1892  msg->base.state = fFinal ? MsgStateFinalized : MsgStateUpdated;
1893  ret = TRUE;
1894  }
1895  else
1896  {
1897  if (!fFinal)
1898  {
1899  if (msg->base.open_flags & CMSG_DETACHED_FLAG)
1901  else
1903  }
1904  else
1905  {
1906  if (cbData)
1907  {
1908  DWORD dataLen = cbData;
1909 
1910  msg->data.cbData = cbData;
1911  msg->data.pbData = CryptMemAlloc(cbData);
1912  if (msg->data.pbData)
1913  {
1914  memcpy(msg->data.pbData, pbData, cbData);
1915  ret = CryptEncrypt(msg->key, 0, TRUE, 0, msg->data.pbData,
1916  &dataLen, msg->data.cbData);
1917  msg->data.cbData = dataLen;
1918  if (dataLen > cbData)
1919  {
1920  msg->data.pbData = CryptMemRealloc(msg->data.pbData,
1921  dataLen);
1922  if (msg->data.pbData)
1923  {
1924  dataLen = cbData;
1925  ret = CryptEncrypt(msg->key, 0, TRUE, 0,
1926  msg->data.pbData, &dataLen, msg->data.cbData);
1927  }
1928  else
1929  ret = FALSE;
1930  }
1931  if (!ret)
1932  CryptMemFree(msg->data.pbData);
1933  }
1934  else
1935  ret = FALSE;
1936  if (!ret)
1937  {
1938  msg->data.cbData = 0;
1939  msg->data.pbData = NULL;
1940  }
1941  }
1942  else
1943  ret = TRUE;
1944  msg->base.state = MsgStateFinalized;
1945  }
1946  }
1947  return ret;
1948 }
#define CRYPT_E_MSG_ERROR
Definition: winerror.h:2985
#define TRUE
Definition: types.h:120
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CryptEncrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen)
Definition: crypt.c:1098
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:136
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CEnvelopedEncodeMsg_Open().

◆ CHashEncodeMsg_Close()

static void CHashEncodeMsg_Close ( HCRYPTMSG  hCryptMsg)
static

Definition at line 381 of file msg.c.

382 {
383  CHashEncodeMsg *msg = hCryptMsg;
384 
385  CryptMemFree(msg->data.pbData);
386  CryptDestroyHash(msg->hash);
387  if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
388  CryptReleaseContext(msg->prov, 0);
389 }
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:895
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867

Referenced by CHashEncodeMsg_Open().

◆ CHashEncodeMsg_GetParam()

static BOOL CHashEncodeMsg_GetParam ( HCRYPTMSG  hCryptMsg,
DWORD  dwParamType,
DWORD  dwIndex,
void pvData,
DWORD pcbData 
)
static

Definition at line 439 of file msg.c.

441 {
442  CHashEncodeMsg *msg = hCryptMsg;
443  BOOL ret = FALSE;
444 
445  TRACE("(%p, %d, %d, %p, %p)\n", hCryptMsg, dwParamType, dwIndex,
446  pvData, pcbData);
447 
448  switch (dwParamType)
449  {
451  if (msg->base.streamed)
453  else
455  break;
456  case CMSG_CONTENT_PARAM:
457  {
459 
461  &info.Content.cbData);
462  if (ret)
463  {
464  info.Content.pbData = CryptMemAlloc(info.Content.cbData);
465  if (info.Content.pbData)
466  {
468  info.Content.pbData, &info.Content.cbData);
469  if (ret)
470  {
471  char oid_rsa_hashed[] = szOID_RSA_hashedData;
472 
473  info.pszObjId = oid_rsa_hashed;
476  }
477  CryptMemFree(info.Content.pbData);
478  }
479  else
480  ret = FALSE;
481  }
482  break;
483  }
486  break;
487  case CMSG_VERSION_PARAM:
488  if (msg->base.state != MsgStateFinalized)
490  else
491  {
493 
494  /* Since the data are always encoded as octets, the version is
495  * always 0 (see rfc3852, section 7)
496  */
498  }
499  break;
500  default:
502  }
503  return ret;
504 }
#define CRYPT_E_MSG_ERROR
Definition: winerror.h:2985
#define CMSG_HASHED_DATA_PKCS_1_5_VERSION
Definition: wincrypt.h:3985
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
#define CMSG_COMPUTED_HASH_PARAM
Definition: wincrypt.h:3945
static BOOL CRYPT_EncodePKCSDigestedData(CHashEncodeMsg *msg, void *pvData, DWORD *pcbData)
Definition: msg.c:391
#define szOID_RSA_hashedData
Definition: wincrypt.h:3033
struct _test_info info[]
Definition: SetCursorPos.c:19
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1615
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3400
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:2988
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL CRYPT_CopyParam(void *pvData, DWORD *pcbData, const void *src, DWORD len)
Definition: msg.c:294
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define CMSG_BARE_CONTENT_PARAM
Definition: wincrypt.h:3927
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
#define HP_HASHVAL
Definition: wincrypt.h:2183
#define CMSG_VERSION_PARAM
Definition: wincrypt.h:3950
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CHashEncodeMsg_Open().

◆ CHashEncodeMsg_Open()

static HCRYPTMSG CHashEncodeMsg_Open ( DWORD  dwFlags,
const void pvMsgEncodeInfo,
LPSTR  pszInnerContentObjID,
PCMSG_STREAM_INFO  pStreamInfo 
)
static

Definition at line 548 of file msg.c.

550 {
552  const CMSG_HASHED_ENCODE_INFO *info = pvMsgEncodeInfo;
553  HCRYPTPROV prov;
554  ALG_ID algID;
555 
556  if (info->cbSize != sizeof(CMSG_HASHED_ENCODE_INFO))
557  {
559  return NULL;
560  }
561  if (!(algID = CertOIDToAlgId(info->HashAlgorithm.pszObjId)))
562  {
564  return NULL;
565  }
566  if (info->hCryptProv)
567  prov = info->hCryptProv;
568  else
569  {
570  prov = I_CryptGetDefaultCryptProv(algID);
571  if (!prov)
572  {
574  return NULL;
575  }
577  }
578  msg = CryptMemAlloc(sizeof(CHashEncodeMsg));
579  if (msg)
580  {
581  CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
584  msg->prov = prov;
585  msg->data.cbData = 0;
586  msg->data.pbData = NULL;
587  if (!CryptCreateHash(prov, algID, 0, 0, &msg->hash))
588  {
590  msg = NULL;
591  }
592  }
593  return msg;
594 }
unsigned int ALG_ID
Definition: wincrypt.h:45
static BOOL CHashEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:506
static BOOL CHashEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:439
static void CHashEncodeMsg_Close(HCRYPTMSG hCryptMsg)
Definition: msg.c:381
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static BOOL CRYPT_DefaultMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
Definition: msg.c:49
static void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags, PCMSG_STREAM_INFO pStreamInfo, CryptMsgCloseFunc close, CryptMsgGetParamFunc get_param, CryptMsgUpdateFunc update, CryptMsgControlFunc control)
Definition: msg.c:77
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID)
Definition: main.c:210
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:745
#define CRYPT_E_UNKNOWN_ALGO
Definition: winerror.h:2986
DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId)
Definition: oid.c:1901
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
#define msg(x)
Definition: auth_time.c:54
#define CMSG_CRYPT_RELEASE_CONTEXT_FLAG
Definition: wincrypt.h:3867

Referenced by CryptMsgOpenToEncode().

◆ CHashEncodeMsg_Update()

static BOOL CHashEncodeMsg_Update ( HCRYPTMSG  hCryptMsg,
const BYTE pbData,
DWORD  cbData,
BOOL  fFinal 
)
static

Definition at line 506 of file msg.c.

508 {
509  CHashEncodeMsg *msg = hCryptMsg;
510  BOOL ret = FALSE;
511 
512  TRACE("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal);
513 
514  if (msg->base.state == MsgStateFinalized)
516  else if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG))
517  {
518  /* Doesn't do much, as stream output is never called, and you
519  * can't get the content.
520  */
521  ret = CryptHashData(msg->hash, pbData, cbData, 0);
522  msg->base.state = fFinal ? MsgStateFinalized : MsgStateUpdated;
523  }
524  else
525  {
526  if (!fFinal)
528  else
529  {
530  ret = CryptHashData(msg->hash, pbData, cbData, 0);
531  if (ret)
532  {
533  msg->data.pbData = CryptMemAlloc(cbData);
534  if (msg->data.pbData)
535  {
536  memcpy(msg->data.pbData + msg->data.cbData, pbData, cbData);
537  msg->data.cbData += cbData;
538  }
539  else
540  ret = FALSE;
541  }
542  msg->base.state = MsgStateFinalized;
543  }
544  }
545  return ret;
546 }
#define CRYPT_E_MSG_ERROR
Definition: winerror.h:2985
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1776
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862
#define msg(x)
Definition: auth_time.c:54
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CHashEncodeMsg_Open().

◆ CRecipientInfo_Construct()

static BOOL CRecipientInfo_Construct ( CMSG_KEY_TRANS_RECIPIENT_INFO info,
const CERT_INFO cert,
CRYPT_DATA_BLOB key 
)
static

Definition at line 1769 of file msg.c.

1771 {
1772  BOOL ret;
1773 
1775  info->RecipientId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
1776  ret = CRYPT_ConstructBlob(&info->RecipientId.u.IssuerSerialNumber.Issuer,
1777  &cert->Issuer);
1778  if (ret)
1780  &info->RecipientId.u.IssuerSerialNumber.SerialNumber,
1781  &cert->SerialNumber);
1782  if (ret)
1783  ret = CRYPT_ConstructAlgorithmId(&info->KeyEncryptionAlgorithm,
1784  &cert->SubjectPublicKeyInfo.Algorithm);
1785  info->EncryptedKey.cbData = key->cbData;
1786  info->EncryptedKey.pbData = key->pbData;
1787  return ret;
1788 }
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
#define CMSG_KEY_TRANS_PKCS_1_5_VERSION
Definition: wincrypt.h:4043
unsigned int BOOL
Definition: ntddk_ex.h:94
static BYTE cert[]
Definition: msg.c:1437
static BOOL CRYPT_ConstructAlgorithmId(CRYPT_ALGORITHM_IDENTIFIER *out, const CRYPT_ALGORITHM_IDENTIFIER *in)
Definition: msg.c:1512
int ret
#define CERT_ID_ISSUER_SERIAL_NUMBER
Definition: wincrypt.h:3673
Definition: path.c:42

Referenced by CEnvelopedEncodeMsg_Open().

◆ CRecipientInfo_Free()

static void CRecipientInfo_Free ( CMSG_KEY_TRANS_RECIPIENT_INFO info)
static

Definition at line 1790 of file msg.c.

1791 {
1792  CryptMemFree(info->RecipientId.u.IssuerSerialNumber.Issuer.pbData);
1793  CryptMemFree(info->RecipientId.u.IssuerSerialNumber.SerialNumber.pbData);
1794  CryptMemFree(info->KeyEncryptionAlgorithm.pszObjId);
1795  CryptMemFree(info->KeyEncryptionAlgorithm.Parameters.pbData);
1796  CryptMemFree(info->EncryptedKey.pbData);
1797 }
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

Referenced by CEnvelopedEncodeMsg_Close().

◆ CRYPT_AppendAttribute()

static BOOL CRYPT_AppendAttribute ( CRYPT_ATTRIBUTES out,
const CRYPT_ATTRIBUTE in 
)
static

Definition at line 1011 of file msg.c.

1013 {
1014  BOOL ret = FALSE;
1015 
1016  out->rgAttr = CryptMemRealloc(out->rgAttr,
1017  (out->cAttr + 1) * sizeof(CRYPT_ATTRIBUTE));
1018  if (out->rgAttr)
1019  {
1020  ret = CRYPT_ConstructAttribute(&out->rgAttr[out->cAttr], in);
1021  if (ret)
1022  out->cAttr++;
1023  }
1024  return ret;
1025 }
static BOOL CRYPT_ConstructAttribute(CRYPT_ATTRIBUTE *out, const CRYPT_ATTRIBUTE *in)
Definition: msg.c:754
unsigned int BOOL
Definition: ntddk_ex.h:94
static FILE * out
Definition: regtests2xml.c:44
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:136
int ret
GLuint in
Definition: glext.h:9616

Referenced by CSignedMsgData_AppendMessageDigestAttribute(), and CSignedMsgData_UpdateAuthenticatedAttributes().

◆ CRYPT_ConstructAlgorithmId()

static BOOL CRYPT_ConstructAlgorithmId ( CRYPT_ALGORITHM_IDENTIFIER out,
const CRYPT_ALGORITHM_IDENTIFIER in 
)
static

Definition at line 1512 of file msg.c.

1514 {
1515  out->pszObjId = CryptMemAlloc(strlen(in->pszObjId) + 1);
1516  if (out->pszObjId)
1517  {
1518  strcpy(out->pszObjId, in->pszObjId);
1519  return CRYPT_ConstructBlob(&out->Parameters, &in->Parameters);
1520  }
1521  else
1522  return FALSE;
1523 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by CContentEncryptInfo_Construct(), CEnvelopedEncodeMsg_Open(), CRecipientInfo_Construct(), CRYPT_ExportEncryptedKey(), and CRYPT_ExportKeyTrans().

◆ CRYPT_ConstructAttribute()

static BOOL CRYPT_ConstructAttribute ( CRYPT_ATTRIBUTE out,
const CRYPT_ATTRIBUTE in 
)
static

Definition at line 754 of file msg.c.

756 {
757  BOOL ret;
758 
759  out->pszObjId = CryptMemAlloc(strlen(in->pszObjId) + 1);
760  if (out->pszObjId)
761  {
762  strcpy(out->pszObjId, in->pszObjId);
763  ret = CRYPT_ConstructBlobArray(&out->cValue, &out->rgValue,
764  in->cValue, in->rgValue);
765  }
766  else
767  ret = FALSE;
768  return ret;
769 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL CRYPT_ConstructBlobArray(DWORD *outCBlobs, PCRYPT_DATA_BLOB *outPBlobs, DWORD cBlobs, const CRYPT_DATA_BLOB *pBlobs)
Definition: msg.c:722
static FILE * out
Definition: regtests2xml.c:44
int ret
GLuint in
Definition: glext.h:9616
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by CRYPT_AppendAttribute(), and CRYPT_ConstructAttributes().

◆ CRYPT_ConstructAttributes()

static BOOL CRYPT_ConstructAttributes ( CRYPT_ATTRIBUTES out,
const CRYPT_ATTRIBUTES in 
)
static

Definition at line 771 of file msg.c.

773 {
774  BOOL ret = TRUE;
775 
776  out->cAttr = in->cAttr;
777  if (out->cAttr)
778  {
779  out->rgAttr = CryptMemAlloc(out->cAttr * sizeof(CRYPT_ATTRIBUTE));
780  if (out->rgAttr)
781  {
782  DWORD i;
783 
784  memset(out->rgAttr, 0, out->cAttr * sizeof(CRYPT_ATTRIBUTE));
785  for (i = 0; ret && i < out->cAttr; i++)
786  ret = CRYPT_ConstructAttribute(&out->rgAttr[i], &in->rgAttr[i]);
787  }
788  else
789  ret = FALSE;
790  }
791  else
792  out->rgAttr = NULL;
793  return ret;
794 }
#define TRUE
Definition: types.h:120
static BOOL CRYPT_ConstructAttribute(CRYPT_ATTRIBUTE *out, const CRYPT_ATTRIBUTE *in)
Definition: msg.c:754
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLuint in
Definition: glext.h:9616
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CSignerInfo_Construct().

◆ CRYPT_ConstructBitBlob()

static BOOL CRYPT_ConstructBitBlob ( CRYPT_BIT_BLOB out,
const CRYPT_BIT_BLOB in 
)
static

Definition at line 1525 of file msg.c.

1526 {
1527  out->cbData = in->cbData;
1528  out->cUnusedBits = in->cUnusedBits;
1529  if (out->cbData)
1530  {
1531  out->pbData = CryptMemAlloc(out->cbData);
1532  if (out->pbData)
1533  memcpy(out->pbData, in->pbData, out->cbData);
1534  else
1535  return FALSE;
1536  }
1537  else
1538  out->pbData = NULL;
1539  return TRUE;
1540 }
#define TRUE
Definition: types.h:120
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint in
Definition: glext.h:9616

Referenced by CContentEncryptInfo_Construct(), and CRYPT_ExportKeyTrans().

◆ CRYPT_ConstructBlob()

static BOOL CRYPT_ConstructBlob ( CRYPT_DATA_BLOB out,
const CRYPT_DATA_BLOB in 
)
static

Definition at line 704 of file msg.c.

705 {
706  BOOL ret = TRUE;
707 
708  out->cbData = in->cbData;
709  if (out->cbData)
710  {
711  out->pbData = CryptMemAlloc(out->cbData);
712  if (out->pbData)
713  memcpy(out->pbData, in->pbData, out->cbData);
714  else
715  ret = FALSE;
716  }
717  else
718  out->pbData = NULL;
719  return ret;
720 }
#define TRUE
Definition: types.h:120
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint in
Definition: glext.h:9616

Referenced by CContentEncryptInfo_Construct(), CDecodeMsg_FinalizeEnvelopedContent(), CDecodeSignedMsg_VerifySignatureWithKey(), CRecipientInfo_Construct(), CRYPT_ConstructAlgorithmId(), CRYPT_ConstructBlobArray(), and CSignerInfo_Construct().

◆ CRYPT_ConstructBlobArray()

static BOOL CRYPT_ConstructBlobArray ( DWORD outCBlobs,
PCRYPT_DATA_BLOB outPBlobs,
DWORD  cBlobs,
const CRYPT_DATA_BLOB pBlobs 
)
static

Definition at line 722 of file msg.c.

724 {
725  BOOL ret = TRUE;
726 
727  *outCBlobs = cBlobs;
728  if (cBlobs)
729  {
730  *outPBlobs = CryptMemAlloc(cBlobs * sizeof(CRYPT_DATA_BLOB));
731  if (*outPBlobs)
732  {
733  DWORD i;
734 
735  memset(*outPBlobs, 0, cBlobs * sizeof(CRYPT_DATA_BLOB));
736  for (i = 0; ret && i < cBlobs; i++)
737  ret = CRYPT_ConstructBlob(&(*outPBlobs)[i], &pBlobs[i]);
738  }
739  else
740  ret = FALSE;
741  }
742  return ret;
743 }
#define TRUE
Definition: types.h:120
static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
Definition: msg.c:704
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CRYPT_ConstructAttribute(), and CSignedEncodeMsg_Open().

◆ CRYPT_CopyAlgorithmId()

static void CRYPT_CopyAlgorithmId ( CRYPT_ALGORITHM_IDENTIFIER out,
const CRYPT_ALGORITHM_IDENTIFIER in,
LPBYTE nextData 
)
inlinestatic

Definition at line 2615 of file msg.c.

2617 {
2618  if (in->pszObjId)
2619  {
2620  out->pszObjId = (LPSTR)*nextData;
2621  strcpy(out->pszObjId, in->pszObjId);
2622  *nextData += strlen(out->pszObjId) + 1;
2623  }
2624  CRYPT_CopyBlob(&out->Parameters, &in->Parameters, nextData);
2625 }
static void CRYPT_CopyBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in, LPBYTE *nextData)
Definition: msg.c:2603
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by CRYPT_CopyCMSSignerInfo(), and CRYPT_CopySignerInfo().

◆ CRYPT_CopyAttributes()

static void CRYPT_CopyAttributes ( CRYPT_ATTRIBUTES out,
const CRYPT_ATTRIBUTES in,
LPBYTE nextData 
)
inlinestatic

Definition at line 2627 of file msg.c.

2629 {
2630  out->cAttr = in->cAttr;
2631  if (in->cAttr)
2632  {
2633  DWORD i;
2634 
2635  *nextData = POINTER_ALIGN_DWORD_PTR(*nextData);
2636  out->rgAttr = (CRYPT_ATTRIBUTE *)*nextData;
2637  *nextData += in->cAttr * sizeof(CRYPT_ATTRIBUTE);
2638  for (i = 0; i < in->cAttr; i++)
2639  {
2640  if (in->rgAttr[i].pszObjId)
2641  {
2642  out->rgAttr[i].pszObjId = (LPSTR)*nextData;
2643  strcpy(out->rgAttr[i].pszObjId, in->rgAttr[i].pszObjId);
2644  *nextData += strlen(in->rgAttr[i].pszObjId) + 1;
2645  }
2646  if (in->rgAttr[i].cValue)
2647  {
2648  DWORD j;
2649 
2650  out->rgAttr[i].cValue = in->rgAttr[i].cValue;
2651  *nextData = POINTER_ALIGN_DWORD_PTR(*nextData);
2652  out->rgAttr[i].rgValue = (PCRYPT_DATA_BLOB)*nextData;
2653  *nextData += in->rgAttr[i].cValue * sizeof(CRYPT_DATA_BLOB);
2654  for (j = 0; j < in->rgAttr[i].cValue; j++)
2655  CRYPT_CopyBlob(&out->rgAttr[i].rgValue[j],
2656  &in->rgAttr[i].rgValue[j], nextData);
2657  }
2658  }
2659  }
2660 }
static void CRYPT_CopyBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in, LPBYTE *nextData)
Definition: msg.c:2603
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define POINTER_ALIGN_DWORD_PTR(p)
char * LPSTR
Definition: xmlstorage.h:182
struct _CRYPTOAPI_BLOB * PCRYPT_DATA_BLOB
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _CRYPTOAPI_BLOB CRYPT_DATA_BLOB
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _CRYPT_ATTRIBUTE CRYPT_ATTRIBUTE
GLuint in
Definition: glext.h:9616
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by CRYPT_CopyCMSSignerInfo(), and CRYPT_CopySignerInfo().

◆ CRYPT_CopyBlob()

static void CRYPT_CopyBlob ( CRYPT_DATA_BLOB out,
const CRYPT_DATA_BLOB in,
LPBYTE nextData 
)
inlinestatic

Definition at line 2603 of file msg.c.

2605 {
2606  out->cbData = in->cbData;
2607  if (in->cbData)
2608  {
2609  out->pbData = *nextData;
2610  memcpy(out->pbData, in->pbData, in->cbData);
2611  *nextData += in->cbData;
2612  }
2613 }
static FILE * out
Definition: regtests2xml.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint in
Definition: glext.h:9616

Referenced by CRYPT_CopyAlgorithmId(), CRYPT_CopyAttributes(), CRYPT_CopyCMSSignerInfo(), CRYPT_CopyRecipientInfo(), CRYPT_CopySignerCertInfo(), and CRYPT_CopySignerInfo().

◆ CRYPT_CopyCMSSignerInfo()

static BOOL CRYPT_CopyCMSSignerInfo ( void pvData,
DWORD pcbData,
const CMSG_CMS_SIGNER_INFO in 
)
static

Definition at line 2801 of file msg.c.

2803 {
2804  DWORD size = sizeof(CMSG_CMS_SIGNER_INFO);
2805  BOOL ret;
2806 
2807  TRACE("(%p, %d, %p)\n", pvData, pvData ? *pcbData : 0, in);
2808 
2809  if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
2810  {
2811  size += in->SignerId.u.IssuerSerialNumber.Issuer.cbData;
2812  size += in->SignerId.u.IssuerSerialNumber.SerialNumber.cbData;
2813  }
2814  else
2815  size += in->SignerId.u.KeyId.cbData;
2816  if (in->HashAlgorithm.pszObjId)