ReactOS 0.4.15-dev-7842-g558ab78
message.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "wine/debug.h"
Include dependency graph for message.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
HCERTSTORE WINAPI CryptGetMessageCertificates (DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const BYTE *pbSignedBlob, DWORD cbSignedBlob)
 
LONG WINAPI CryptGetMessageSignerCount (DWORD dwMsgEncodingType, const BYTE *pbSignedBlob, DWORD cbSignedBlob)
 
static CERT_INFOCRYPT_GetSignerCertInfoFromMsg (HCRYPTMSG msg, DWORD dwSignerIndex)
 
static PCCERT_CONTEXT WINAPI CRYPT_DefaultGetSignerCertificate (void *pvGetArg, DWORD dwCertEncodingType, PCERT_INFO pSignerId, HCERTSTORE hMsgCertStore)
 
static PCCERT_CONTEXT CRYPT_GetSignerCertificate (HCRYPTMSG msg, PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, PCERT_INFO certInfo, HCERTSTORE store)
 
BOOL WINAPI CryptVerifyDetachedMessageSignature (PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex, const BYTE *pbDetachedSignBlob, DWORD cbDetachedSignBlob, DWORD cToBeSigned, const BYTE *rgpbToBeSigned[], DWORD rgcbToBeSigned[], PCCERT_CONTEXT *ppSignerCert)
 
BOOL WINAPI CryptVerifyMessageSignature (PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex, const BYTE *pbSignedBlob, DWORD cbSignedBlob, BYTE *pbDecoded, DWORD *pcbDecoded, PCCERT_CONTEXT *ppSignerCert)
 
BOOL WINAPI CryptHashMessage (PCRYPT_HASH_MESSAGE_PARA pHashPara, BOOL fDetachedHash, DWORD cToBeHashed, const BYTE *rgpbToBeHashed[], DWORD rgcbToBeHashed[], BYTE *pbHashedBlob, DWORD *pcbHashedBlob, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
BOOL WINAPI CryptVerifyDetachedMessageHash (PCRYPT_HASH_MESSAGE_PARA pHashPara, BYTE *pbDetachedHashBlob, DWORD cbDetachedHashBlob, DWORD cToBeHashed, const BYTE *rgpbToBeHashed[], DWORD rgcbToBeHashed[], BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
BOOL WINAPI CryptVerifyMessageHash (PCRYPT_HASH_MESSAGE_PARA pHashPara, BYTE *pbHashedBlob, DWORD cbHashedBlob, BYTE *pbToBeHashed, DWORD *pcbToBeHashed, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
BOOL WINAPI CryptSignMessage (PCRYPT_SIGN_MESSAGE_PARA pSignPara, BOOL fDetachedSignature, DWORD cToBeSigned, const BYTE *rgpbToBeSigned[], DWORD rgcbToBeSigned[], BYTE *pbSignedBlob, DWORD *pcbSignedBlob)
 
BOOL WINAPI CryptEncryptMessage (PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara, DWORD cRecipientCert, PCCERT_CONTEXT rgpRecipientCert[], const BYTE *pbToBeEncrypted, DWORD cbToBeEncrypted, BYTE *pbEncryptedBlob, DWORD *pcbEncryptedBlob)
 

Function Documentation

◆ CRYPT_DefaultGetSignerCertificate()

static PCCERT_CONTEXT WINAPI CRYPT_DefaultGetSignerCertificate ( void pvGetArg,
DWORD  dwCertEncodingType,
PCERT_INFO  pSignerId,
HCERTSTORE  hMsgCertStore 
)
static

Definition at line 88 of file message.c.

90{
91 return CertFindCertificateInStore(hMsgCertStore, dwCertEncodingType, 0,
92 CERT_FIND_SUBJECT_CERT, pSignerId, NULL);
93}
#define NULL
Definition: types.h:112
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
#define CERT_FIND_SUBJECT_CERT
Definition: wincrypt.h:2901
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5037

Referenced by CRYPT_GetSignerCertificate().

◆ CRYPT_GetSignerCertificate()

static PCCERT_CONTEXT CRYPT_GetSignerCertificate ( HCRYPTMSG  msg,
PCRYPT_VERIFY_MESSAGE_PARA  pVerifyPara,
PCERT_INFO  certInfo,
HCERTSTORE  store 
)
inlinestatic

Definition at line 95 of file message.c.

97{
99
100 if (pVerifyPara->pfnGetSignerCertificate)
101 getCert = pVerifyPara->pfnGetSignerCertificate;
102 else
104 return getCert(pVerifyPara->pvGetArg,
105 pVerifyPara->dwMsgAndCertEncodingType, certInfo, store);
106}
static PCCERT_CONTEXT WINAPI CRYPT_DefaultGetSignerCertificate(void *pvGetArg, DWORD dwCertEncodingType, PCERT_INFO pSignerId, HCERTSTORE hMsgCertStore)
Definition: message.c:88
PFN_CRYPT_GET_SIGNER_CERTIFICATE pfnGetSignerCertificate
Definition: wincrypt.h:1463
PCCERT_CONTEXT(WINAPI * PFN_CRYPT_GET_SIGNER_CERTIFICATE)(_Inout_opt_ void *pvGetArg, _In_ DWORD dwCertEncodingType, _In_ PCERT_INFO pSignerId, _In_ HCERTSTORE hMsgCertStore)
Definition: wincrypt.h:1453

Referenced by CryptVerifyDetachedMessageSignature(), and CryptVerifyMessageSignature().

◆ CRYPT_GetSignerCertInfoFromMsg()

static CERT_INFO * CRYPT_GetSignerCertInfoFromMsg ( HCRYPTMSG  msg,
DWORD  dwSignerIndex 
)
static

Definition at line 63 of file message.c.

65{
66 CERT_INFO *certInfo = NULL;
67 DWORD size;
68
70 &size))
71 {
72 certInfo = CryptMemAlloc(size);
73 if (certInfo)
74 {
76 dwSignerIndex, certInfo, &size))
77 {
78 CryptMemFree(certInfo);
79 certInfo = NULL;
80 }
81 }
82 }
83 else
85 return certInfo;
86}
#define msg(x)
Definition: auth_time.c:54
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3626
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
#define CMSG_SIGNER_CERT_INFO_PARAM
Definition: wincrypt.h:3931
#define CRYPT_E_UNEXPECTED_MSG_TYPE
Definition: winerror.h:3013

Referenced by CryptVerifyDetachedMessageSignature(), and CryptVerifyMessageSignature().

◆ CryptEncryptMessage()

BOOL WINAPI CryptEncryptMessage ( PCRYPT_ENCRYPT_MESSAGE_PARA  pEncryptPara,
DWORD  cRecipientCert,
PCCERT_CONTEXT  rgpRecipientCert[],
const BYTE pbToBeEncrypted,
DWORD  cbToBeEncrypted,
BYTE pbEncryptedBlob,
DWORD pcbEncryptedBlob 
)

Definition at line 521 of file message.c.

525{
526 BOOL ret = TRUE;
527 DWORD i;
528 PCERT_INFO *certInfo = NULL;
529 CMSG_ENVELOPED_ENCODE_INFO envelopedInfo;
530 HCRYPTMSG msg = 0;
531
532 TRACE("(%p, %d, %p, %p, %d, %p, %p)\n", pEncryptPara, cRecipientCert,
533 rgpRecipientCert, pbToBeEncrypted, cbToBeEncrypted, pbEncryptedBlob,
534 pcbEncryptedBlob);
535
536 if (pEncryptPara->cbSize != sizeof(CRYPT_ENCRYPT_MESSAGE_PARA) ||
539 {
540 *pcbEncryptedBlob = 0;
542 return FALSE;
543 }
544
545 memset(&envelopedInfo, 0, sizeof(envelopedInfo));
546 envelopedInfo.cbSize = sizeof(envelopedInfo);
547 envelopedInfo.hCryptProv = pEncryptPara->hCryptProv;
548 envelopedInfo.ContentEncryptionAlgorithm =
549 pEncryptPara->ContentEncryptionAlgorithm;
550 envelopedInfo.pvEncryptionAuxInfo = pEncryptPara->pvEncryptionAuxInfo;
551
552 if (cRecipientCert)
553 {
554 certInfo = CryptMemAlloc(sizeof(PCERT_INFO) * cRecipientCert);
555 if (certInfo)
556 {
557 for (i = 0; i < cRecipientCert; ++i)
558 certInfo[i] = rgpRecipientCert[i]->pCertInfo;
559 envelopedInfo.cRecipients = cRecipientCert;
560 envelopedInfo.rgpRecipientCert = certInfo;
561 }
562 else
563 ret = FALSE;
564 }
565
566 if (ret)
567 msg = CryptMsgOpenToEncode(pEncryptPara->dwMsgEncodingType, 0,
568 CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
569 if (msg)
570 {
571 ret = CryptMsgUpdate(msg, pbToBeEncrypted, cbToBeEncrypted, TRUE);
572 if (ret)
573 ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, pbEncryptedBlob,
574 pcbEncryptedBlob);
576 }
577 else
578 ret = FALSE;
579
580 CryptMemFree(certInfo);
581 if (!ret) *pcbEncryptedBlob = 0;
582 return ret;
583}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:2034
BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:3616
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3597
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
HCRYPTPROV_LEGACY hCryptProv
Definition: wincrypt.h:3819
PCERT_INFO * rgpRecipientCert
Definition: wincrypt.h:3823
CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm
Definition: wincrypt.h:3820
HCRYPTPROV_LEGACY hCryptProv
Definition: wincrypt.h:1470
CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm
Definition: wincrypt.h:1471
int ret
#define CMSG_ENVELOPED
Definition: wincrypt.h:3681
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define GET_CMSG_ENCODING_TYPE(x)
Definition: wincrypt.h:2293
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926

Referenced by test_encrypt_message().

◆ CryptGetMessageCertificates()

HCERTSTORE WINAPI CryptGetMessageCertificates ( DWORD  dwMsgAndCertEncodingType,
HCRYPTPROV_LEGACY  hCryptProv,
DWORD  dwFlags,
const BYTE pbSignedBlob,
DWORD  cbSignedBlob 
)

Definition at line 28 of file message.c.

31{
32 CRYPT_DATA_BLOB blob = { cbSignedBlob, (LPBYTE)pbSignedBlob };
33
34 TRACE("(%08x, %ld, %d08x %p, %d)\n", dwMsgAndCertEncodingType, hCryptProv,
35 dwFlags, pbSignedBlob, cbSignedBlob);
36
38 hCryptProv, dwFlags, &blob);
39}
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
Definition: image.c:134
unsigned char * LPBYTE
Definition: typedefs.h:53
_In_ DWORD dwMsgAndCertEncodingType
Definition: wincrypt.h:5076
#define CERT_STORE_PROV_PKCS7
Definition: wincrypt.h:2254
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ CryptGetMessageSignerCount()

LONG WINAPI CryptGetMessageSignerCount ( DWORD  dwMsgEncodingType,
const BYTE pbSignedBlob,
DWORD  cbSignedBlob 
)

Definition at line 41 of file message.c.

43{
45 LONG count = -1;
46
47 TRACE("(%08x, %p, %d)\n", dwMsgEncodingType, pbSignedBlob, cbSignedBlob);
48
49 msg = CryptMsgOpenToDecode(dwMsgEncodingType, 0, 0, 0, NULL, NULL);
50 if (msg)
51 {
52 if (CryptMsgUpdate(msg, pbSignedBlob, cbSignedBlob, TRUE))
53 {
54 DWORD size = sizeof(count);
55
57 }
59 }
60 return count;
61}
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3552
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define CMSG_SIGNER_COUNT_PARAM
Definition: wincrypt.h:3929

Referenced by test_msg_get_signer_count().

◆ CryptHashMessage()

BOOL WINAPI CryptHashMessage ( PCRYPT_HASH_MESSAGE_PARA  pHashPara,
BOOL  fDetachedHash,
DWORD  cToBeHashed,
const BYTE rgpbToBeHashed[],
DWORD  rgcbToBeHashed[],
BYTE pbHashedBlob,
DWORD pcbHashedBlob,
BYTE pbComputedHash,
DWORD pcbComputedHash 
)

Definition at line 255 of file message.c.

259{
260 DWORD i, flags;
261 BOOL ret = FALSE;
264
265 TRACE("(%p, %d, %d, %p, %p, %p, %p, %p, %p)\n", pHashPara, fDetachedHash,
266 cToBeHashed, rgpbToBeHashed, rgcbToBeHashed, pbHashedBlob, pcbHashedBlob,
267 pbComputedHash, pcbComputedHash);
268
269 if (pHashPara->cbSize != sizeof(CRYPT_HASH_MESSAGE_PARA))
270 {
272 return FALSE;
273 }
274 /* Native seems to ignore any encoding type other than the expected
275 * PKCS_7_ASN_ENCODING
276 */
279 return TRUE;
280 /* Native also seems to do nothing if the output parameter isn't given */
281 if (!pcbHashedBlob)
282 return TRUE;
283
284 flags = fDetachedHash ? CMSG_DETACHED_FLAG : 0;
285 memset(&info, 0, sizeof(info));
286 info.cbSize = sizeof(info);
287 info.hCryptProv = pHashPara->hCryptProv;
288 info.HashAlgorithm = pHashPara->HashAlgorithm;
289 info.pvHashAuxInfo = pHashPara->pvHashAuxInfo;
291 &info, NULL, NULL);
292 if (msg)
293 {
294 for (i = 0, ret = TRUE; ret && i < cToBeHashed; i++)
295 ret = CryptMsgUpdate(msg, rgpbToBeHashed[i], rgcbToBeHashed[i], i == cToBeHashed - 1);
296 if (ret)
297 {
298 ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, pbHashedBlob,
299 pcbHashedBlob);
300 if (ret && pcbComputedHash)
302 pbComputedHash, pcbComputedHash);
303 }
305 }
306 return ret;
307}
GLbitfield flags
Definition: glext.h:7161
CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm
Definition: wincrypt.h:1493
HCRYPTPROV_LEGACY hCryptProv
Definition: wincrypt.h:1492
#define CMSG_HASHED
Definition: wincrypt.h:3683
#define CMSG_COMPUTED_HASH_PARAM
Definition: wincrypt.h:3945
#define CMSG_DETACHED_FLAG
Definition: wincrypt.h:3862

Referenced by test_hash_message().

◆ CryptSignMessage()

BOOL WINAPI CryptSignMessage ( PCRYPT_SIGN_MESSAGE_PARA  pSignPara,
BOOL  fDetachedSignature,
DWORD  cToBeSigned,
const BYTE rgpbToBeSigned[],
DWORD  rgcbToBeSigned[],
BYTE pbSignedBlob,
DWORD pcbSignedBlob 
)

Definition at line 406 of file message.c.

409{
410 HCRYPTPROV hCryptProv;
411 BOOL ret, freeProv = FALSE;
412 DWORD i, keySpec;
413 PCERT_BLOB certBlob = NULL;
414 PCRL_BLOB crlBlob = NULL;
417 HCRYPTMSG msg = 0;
418
419 TRACE("(%p, %d, %d, %p, %p, %p, %p)\n", pSignPara, fDetachedSignature,
420 cToBeSigned, rgpbToBeSigned, rgcbToBeSigned, pbSignedBlob, pcbSignedBlob);
421
422 if (pSignPara->cbSize != sizeof(CRYPT_SIGN_MESSAGE_PARA) ||
425 {
426 *pcbSignedBlob = 0;
428 return FALSE;
429 }
430 if (!pSignPara->pSigningCert)
431 return TRUE;
432
434 CRYPT_ACQUIRE_CACHE_FLAG, NULL, &hCryptProv, &keySpec, &freeProv);
435 if (!ret)
436 return FALSE;
437
438 memset(&signer, 0, sizeof(signer));
439 signer.cbSize = sizeof(signer);
440 signer.pCertInfo = pSignPara->pSigningCert->pCertInfo;
441 signer.hCryptProv = hCryptProv;
442 signer.dwKeySpec = keySpec;
443 signer.HashAlgorithm = pSignPara->HashAlgorithm;
444 signer.pvHashAuxInfo = pSignPara->pvHashAuxInfo;
445 signer.cAuthAttr = pSignPara->cAuthAttr;
446 signer.rgAuthAttr = pSignPara->rgAuthAttr;
447 signer.cUnauthAttr = pSignPara->cUnauthAttr;
448 signer.rgUnauthAttr = pSignPara->rgUnauthAttr;
449
450 memset(&signInfo, 0, sizeof(signInfo));
451 signInfo.cbSize = sizeof(signInfo);
452 signInfo.cSigners = 1;
453 signInfo.rgSigners = &signer;
454
455 if (pSignPara->cMsgCert)
456 {
457 certBlob = CryptMemAlloc(sizeof(CERT_BLOB) * pSignPara->cMsgCert);
458 if (certBlob)
459 {
460 for (i = 0; i < pSignPara->cMsgCert; ++i)
461 {
462 certBlob[i].cbData = pSignPara->rgpMsgCert[i]->cbCertEncoded;
463 certBlob[i].pbData = pSignPara->rgpMsgCert[i]->pbCertEncoded;
464 }
465 signInfo.cCertEncoded = pSignPara->cMsgCert;
466 signInfo.rgCertEncoded = certBlob;
467 }
468 else
469 ret = FALSE;
470 }
471 if (pSignPara->cMsgCrl)
472 {
473 crlBlob = CryptMemAlloc(sizeof(CRL_BLOB) * pSignPara->cMsgCrl);
474 if (crlBlob)
475 {
476 for (i = 0; i < pSignPara->cMsgCrl; ++i)
477 {
478 crlBlob[i].cbData = pSignPara->rgpMsgCrl[i]->cbCrlEncoded;
479 crlBlob[i].pbData = pSignPara->rgpMsgCrl[i]->pbCrlEncoded;
480 }
481 signInfo.cCrlEncoded = pSignPara->cMsgCrl;
482 signInfo.rgCrlEncoded = crlBlob;
483 }
484 else
485 ret = FALSE;
486 }
487 if (pSignPara->dwFlags || pSignPara->dwInnerContentType)
488 FIXME("unimplemented feature\n");
489
490 if (ret)
492 fDetachedSignature ? CMSG_DETACHED_FLAG : 0, CMSG_SIGNED, &signInfo,
493 NULL, NULL);
494 if (msg)
495 {
496 if (cToBeSigned)
497 {
498 for (i = 0; ret && i < cToBeSigned; ++i)
499 {
500 ret = CryptMsgUpdate(msg, rgpbToBeSigned[i], rgcbToBeSigned[i],
501 i == cToBeSigned - 1);
502 }
503 }
504 else
506 if (ret)
507 ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, pbSignedBlob,
508 pcbSignedBlob);
510 }
511 else
512 ret = FALSE;
513
514 CryptMemFree(crlBlob);
515 CryptMemFree(certBlob);
516 if (freeProv)
517 CryptReleaseContext(hCryptProv, 0);
518 return ret;
519}
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert, DWORD dwFlags, void *pvReserved, HCRYPTPROV_OR_NCRYPT_KEY_HANDLE *phCryptProv, DWORD *pdwKeySpec, BOOL *pfCallerFreeProv)
Definition: cert.c:881
PCERT_INFO pCertInfo
Definition: wincrypt.h:482
BYTE * pbCertEncoded
Definition: wincrypt.h:480
DWORD cbCertEncoded
Definition: wincrypt.h:481
PCMSG_SIGNER_ENCODE_INFO rgSigners
Definition: wincrypt.h:3731
PCERT_BLOB rgCertEncoded
Definition: wincrypt.h:3733
CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm
Definition: wincrypt.h:3714
PCRYPT_ATTRIBUTE rgAuthAttr
Definition: wincrypt.h:3717
PCRYPT_ATTRIBUTE rgUnauthAttr
Definition: wincrypt.h:3719
DWORD cbCrlEncoded
Definition: wincrypt.h:621
BYTE * pbCrlEncoded
Definition: wincrypt.h:620
BYTE * pbData
Definition: wincrypt.h:103
PCCERT_CONTEXT * rgpMsgCert
Definition: wincrypt.h:1432
CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm
Definition: wincrypt.h:1429
PCRYPT_ATTRIBUTE rgUnauthAttr
Definition: wincrypt.h:1438
PCCERT_CONTEXT pSigningCert
Definition: wincrypt.h:1428
PCRYPT_ATTRIBUTE rgAuthAttr
Definition: wincrypt.h:1436
PCCRL_CONTEXT * rgpMsgCrl
Definition: wincrypt.h:1434
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define CMSG_SIGNED
Definition: wincrypt.h:3680
#define CRYPT_ACQUIRE_CACHE_FLAG
Definition: wincrypt.h:3601

Referenced by test_sign_message().

◆ CryptVerifyDetachedMessageHash()

BOOL WINAPI CryptVerifyDetachedMessageHash ( PCRYPT_HASH_MESSAGE_PARA  pHashPara,
BYTE pbDetachedHashBlob,
DWORD  cbDetachedHashBlob,
DWORD  cToBeHashed,
const BYTE rgpbToBeHashed[],
DWORD  rgcbToBeHashed[],
BYTE pbComputedHash,
DWORD pcbComputedHash 
)

Definition at line 309 of file message.c.

313{
315 BOOL ret = FALSE;
316
317 TRACE("(%p, %p, %d, %d, %p, %p, %p, %p)\n", pHashPara, pbDetachedHashBlob,
318 cbDetachedHashBlob, cToBeHashed, rgpbToBeHashed, rgcbToBeHashed,
319 pbComputedHash, pcbComputedHash);
320
321 if (pHashPara->cbSize != sizeof(CRYPT_HASH_MESSAGE_PARA))
322 {
324 return FALSE;
325 }
328 {
330 return FALSE;
331 }
333 0, pHashPara->hCryptProv, NULL, NULL);
334 if (msg)
335 {
336 DWORD i;
337
338 ret = CryptMsgUpdate(msg, pbDetachedHashBlob, cbDetachedHashBlob, TRUE);
339 if (ret)
340 {
341 if (cToBeHashed)
342 {
343 for (i = 0; ret && i < cToBeHashed; i++)
344 {
345 ret = CryptMsgUpdate(msg, rgpbToBeHashed[i],
346 rgcbToBeHashed[i], i == cToBeHashed - 1);
347 }
348 }
349 else
351 }
352 if (ret)
353 {
355 if (ret && pcbComputedHash)
357 pbComputedHash, pcbComputedHash);
358 }
360 }
361 return ret;
362}
BOOL WINAPI CryptMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara)
Definition: msg.c:3636
#define CMSG_CTRL_VERIFY_HASH
Definition: wincrypt.h:3871

Referenced by test_verify_detached_message_hash().

◆ CryptVerifyDetachedMessageSignature()

BOOL WINAPI CryptVerifyDetachedMessageSignature ( PCRYPT_VERIFY_MESSAGE_PARA  pVerifyPara,
DWORD  dwSignerIndex,
const BYTE pbDetachedSignBlob,
DWORD  cbDetachedSignBlob,
DWORD  cToBeSigned,
const BYTE rgpbToBeSigned[],
DWORD  rgcbToBeSigned[],
PCCERT_CONTEXT ppSignerCert 
)

Definition at line 108 of file message.c.

113{
114 BOOL ret = FALSE;
116
117 TRACE("(%p, %d, %p, %d, %d, %p, %p, %p)\n", pVerifyPara, dwSignerIndex,
118 pbDetachedSignBlob, cbDetachedSignBlob, cToBeSigned, rgpbToBeSigned,
119 rgcbToBeSigned, ppSignerCert);
120
121 if (ppSignerCert)
122 *ppSignerCert = NULL;
123 if (!pVerifyPara ||
124 pVerifyPara->cbSize != sizeof(CRYPT_VERIFY_MESSAGE_PARA) ||
127 {
129 return FALSE;
130 }
131
133 CMSG_DETACHED_FLAG, 0, pVerifyPara->hCryptProv, NULL, NULL);
134 if (msg)
135 {
136 ret = CryptMsgUpdate(msg, pbDetachedSignBlob, cbDetachedSignBlob, TRUE);
137 if (ret)
138 {
139 DWORD i;
140
141 for (i = 0; ret && i < cToBeSigned; i++)
142 ret = CryptMsgUpdate(msg, rgpbToBeSigned[i], rgcbToBeSigned[i],
143 i == cToBeSigned - 1);
144 }
145 if (ret)
146 {
148 dwSignerIndex);
149
150 ret = FALSE;
151 if (certInfo)
152 {
154 pVerifyPara->dwMsgAndCertEncodingType,
155 pVerifyPara->hCryptProv, 0, msg);
156
157 if (store)
158 {
160 msg, pVerifyPara, certInfo, store);
161
162 if (cert)
163 {
165 CMSG_CTRL_VERIFY_SIGNATURE, cert->pCertInfo);
166 if (ret && ppSignerCert)
167 *ppSignerCert = cert;
168 else
170 }
171 else
173 CertCloseStore(store, 0);
174 }
175 CryptMemFree(certInfo);
176 }
177 }
179 }
180 TRACE("returning %d\n", ret);
181 return ret;
182}
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
static CERT_INFO * CRYPT_GetSignerCertInfoFromMsg(HCRYPTMSG msg, DWORD dwSignerIndex)
Definition: message.c:63
static PCCERT_CONTEXT CRYPT_GetSignerCertificate(HCRYPTMSG msg, PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, PCERT_INFO certInfo, HCERTSTORE store)
Definition: message.c:95
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
static BYTE cert[]
Definition: msg.c:1437
HCRYPTPROV_LEGACY hCryptProv
Definition: wincrypt.h:1462
#define CERT_STORE_PROV_MSG
Definition: wincrypt.h:2250
#define CMSG_CTRL_VERIFY_SIGNATURE
Definition: wincrypt.h:3869
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007

Referenced by test_verify_detached_message_signature().

◆ CryptVerifyMessageHash()

BOOL WINAPI CryptVerifyMessageHash ( PCRYPT_HASH_MESSAGE_PARA  pHashPara,
BYTE pbHashedBlob,
DWORD  cbHashedBlob,
BYTE pbToBeHashed,
DWORD pcbToBeHashed,
BYTE pbComputedHash,
DWORD pcbComputedHash 
)

Definition at line 364 of file message.c.

367{
369 BOOL ret = FALSE;
370
371 TRACE("(%p, %p, %d, %p, %p, %p, %p)\n", pHashPara, pbHashedBlob,
372 cbHashedBlob, pbToBeHashed, pcbToBeHashed, pbComputedHash,
373 pcbComputedHash);
374
375 if (pHashPara->cbSize != sizeof(CRYPT_HASH_MESSAGE_PARA))
376 {
378 return FALSE;
379 }
382 {
384 return FALSE;
385 }
386 msg = CryptMsgOpenToDecode(pHashPara->dwMsgEncodingType, 0, 0,
387 pHashPara->hCryptProv, NULL, NULL);
388 if (msg)
389 {
390 ret = CryptMsgUpdate(msg, pbHashedBlob, cbHashedBlob, TRUE);
391 if (ret)
392 {
394 if (ret && pcbToBeHashed)
396 pbToBeHashed, pcbToBeHashed);
397 if (ret && pcbComputedHash)
399 pbComputedHash, pcbComputedHash);
400 }
402 }
403 return ret;
404}

Referenced by test_verify_message_hash().

◆ CryptVerifyMessageSignature()

BOOL WINAPI CryptVerifyMessageSignature ( PCRYPT_VERIFY_MESSAGE_PARA  pVerifyPara,
DWORD  dwSignerIndex,
const BYTE pbSignedBlob,
DWORD  cbSignedBlob,
BYTE pbDecoded,
DWORD pcbDecoded,
PCCERT_CONTEXT ppSignerCert 
)

Definition at line 184 of file message.c.

187{
188 BOOL ret = FALSE;
190
191 TRACE("(%p, %d, %p, %d, %p, %p, %p)\n",
192 pVerifyPara, dwSignerIndex, pbSignedBlob, cbSignedBlob,
193 pbDecoded, pcbDecoded, ppSignerCert);
194
195 if (ppSignerCert)
196 *ppSignerCert = NULL;
197 if (!pVerifyPara ||
198 pVerifyPara->cbSize != sizeof(CRYPT_VERIFY_MESSAGE_PARA) ||
201 {
202 if(pcbDecoded)
203 *pcbDecoded = 0;
205 return FALSE;
206 }
207
209 pVerifyPara->hCryptProv, NULL, NULL);
210 if (msg)
211 {
212 ret = CryptMsgUpdate(msg, pbSignedBlob, cbSignedBlob, TRUE);
213 if (ret && pcbDecoded)
215 pcbDecoded);
216 if (ret)
217 {
219 dwSignerIndex);
220
221 ret = FALSE;
222 if (certInfo)
223 {
225 pVerifyPara->dwMsgAndCertEncodingType,
226 pVerifyPara->hCryptProv, 0, msg);
227
228 if (store)
229 {
231 msg, pVerifyPara, certInfo, store);
232
233 if (cert)
234 {
236 CMSG_CTRL_VERIFY_SIGNATURE, cert->pCertInfo);
237 if (ret && ppSignerCert)
238 *ppSignerCert = cert;
239 else
241 }
242 CertCloseStore(store, 0);
243 }
244 }
245 CryptMemFree(certInfo);
246 }
248 }
249 if(!ret && pcbDecoded)
250 *pcbDecoded = 0;
251 TRACE("returning %d\n", ret);
252 return ret;
253}

Referenced by test_verify_message_signature().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )