ReactOS 0.4.15-dev-8241-g63935f8
main.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winreg.h"
#include "wincrypt.h"
#include "wintrust.h"
#include "winuser.h"
#include "objbase.h"
#include "cryptdlg.h"
#include "cryptuiapi.h"
#include "cryptres.h"
#include "wine/debug.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define NONAMELESSUNION
 
#define szOID_MICROSOFT_Encryption_Key_Preference   "1.3.6.1.4.1.311.16.4"
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (cryptdlg)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
DWORD WINAPI GetFriendlyNameOfCertA (PCCERT_CONTEXT pccert, LPSTR pchBuffer, DWORD cchBuffer)
 
DWORD WINAPI GetFriendlyNameOfCertW (PCCERT_CONTEXT pccert, LPWSTR pchBuffer, DWORD cchBuffer)
 
HRESULT WINAPI CertTrustInit (CRYPT_PROVIDER_DATA *pProvData)
 
BOOL WINAPI CertTrustCertPolicy (CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSignerChain, DWORD idxCounterSigner)
 
HRESULT WINAPI CertTrustCleanup (CRYPT_PROVIDER_DATA *pProvData)
 
static BOOL CRYPTDLG_CheckOnlineCRL (void)
 
static BOOL CRYPTDLG_IsCertAllowed (PCCERT_CONTEXT pCert)
 
static DWORD CRYPTDLG_TrustStatusToConfidence (DWORD errorStatus)
 
static BOOL CRYPTDLG_CopyChain (CRYPT_PROVIDER_DATA *data, PCCERT_CHAIN_CONTEXT chain)
 
static CERT_VERIFY_CERTIFICATE_TRUSTCRYPTDLG_GetVerifyData (CRYPT_PROVIDER_DATA *data)
 
static HCERTCHAINENGINE CRYPTDLG_MakeEngine (CERT_VERIFY_CERTIFICATE_TRUST *cert)
 
HRESULT WINAPI CertTrustFinalPolicy (CRYPT_PROVIDER_DATA *data)
 
BOOL WINAPI CertViewPropertiesA (CERT_VIEWPROPERTIES_STRUCT_A *info)
 
BOOL WINAPI CertViewPropertiesW (CERT_VIEWPROPERTIES_STRUCT_W *info)
 
static BOOL CRYPT_FormatHexString (const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
 
static BOOL CRYPT_FormatCPS (DWORD dwCertEncodingType, DWORD dwFormatStrType, const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
 
static BOOL CRYPT_FormatUserNotice (DWORD dwCertEncodingType, DWORD dwFormatStrType, const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
 
BOOL WINAPI FormatVerisignExtension (DWORD dwCertEncodingType, DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat)
 
HRESULT WINAPI DllRegisterServer (void)
 
HRESULT WINAPI DllUnregisterServer (void)
 

Variables

static HINSTANCE hInstance
 
static const WCHAR indent [] = { ' ',' ',' ',' ',' ',0 }
 
static const WCHAR colonCrlf [] = { ':','\r','\n',0 }
 
static const WCHAR colonSpace [] = { ':',' ',0 }
 
static const WCHAR crlf [] = { '\r','\n',0 }
 
static const WCHAR commaSep [] = { ',',' ',0 }
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 19 of file main.c.

◆ szOID_MICROSOFT_Encryption_Key_Preference

#define szOID_MICROSOFT_Encryption_Key_Preference   "1.3.6.1.4.1.311.16.4"

Definition at line 1119 of file main.c.

Function Documentation

◆ CertTrustCertPolicy()

BOOL WINAPI CertTrustCertPolicy ( CRYPT_PROVIDER_DATA pProvData,
DWORD  idxSigner,
BOOL  fCounterSignerChain,
DWORD  idxCounterSigner 
)

Definition at line 98 of file main.c.

99{
100 FIXME("(%p, %d, %s, %d)\n", pProvData, idxSigner, fCounterSignerChain ? "TRUE" : "FALSE", idxCounterSigner);
101 return FALSE;
102}
#define FIXME(fmt,...)
Definition: debug.h:114
#define FALSE
Definition: types.h:117

◆ CertTrustCleanup()

HRESULT WINAPI CertTrustCleanup ( CRYPT_PROVIDER_DATA pProvData)

Definition at line 107 of file main.c.

108{
109 FIXME("(%p)\n", pProvData);
110 return E_NOTIMPL;
111}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CertTrustFinalPolicy()

HRESULT WINAPI CertTrustFinalPolicy ( CRYPT_PROVIDER_DATA data)

Definition at line 302 of file main.c.

303{
304 BOOL ret;
305 DWORD err = S_OK;
307
308 TRACE("(%p)\n", data);
309
310 if (data->pWintrustData->dwUIChoice != WTD_UI_NONE)
311 FIXME("unimplemented for UI choice %d\n",
312 data->pWintrustData->dwUIChoice);
313 if (pCert)
314 {
315 DWORD flags = 0;
316 CERT_CHAIN_PARA chainPara;
317 HCERTCHAINENGINE engine;
318
319 memset(&chainPara, 0, sizeof(chainPara));
320 chainPara.cbSize = sizeof(chainPara);
323 engine = CRYPTDLG_MakeEngine(pCert);
324 GetSystemTimeAsFileTime(&data->sftSystemTime);
326 if (ret)
327 {
329
330 ret = CertGetCertificateChain(engine, pCert->pccert,
331 &data->sftSystemTime, NULL, &chainPara, flags, NULL, &chain);
332 if (ret)
333 {
334 if (chain->cChain != 1)
335 {
336 FIXME("unimplemented for more than 1 simple chain\n");
338 ret = FALSE;
339 }
340 else if ((ret = CRYPTDLG_CopyChain(data, chain)))
341 {
342 if (CertVerifyTimeValidity(&data->sftSystemTime,
343 pCert->pccert->pCertInfo))
344 {
345 ret = FALSE;
347 }
348 }
349 else
352 }
353 else
355 }
357 }
358 else
359 {
360 ret = FALSE;
362 }
363 /* Oddly, native doesn't set the error in the trust step error location,
364 * probably because this action is more advisory than anything else.
365 * Instead it stores it as the final error, but the function "succeeds" in
366 * any case.
367 */
368 if (!ret)
369 data->dwFinalError = err;
370 TRACE("returning %d (%08x)\n", S_OK, data->dwFinalError);
371 return S_OK;
372}
#define NULL
Definition: types.h:112
LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify, PCERT_INFO pCertInfo)
Definition: cert.c:2158
BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine, PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore, PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved, PCCERT_CHAIN_CONTEXT *ppChainContext)
Definition: chain.c:2879
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2960
void WINAPI CertFreeCertificateChainEngine(HCERTCHAINENGINE hChainEngine)
Definition: chain.c:249
static BOOL CRYPTDLG_CheckOnlineCRL(void)
Definition: main.c:113
static BOOL CRYPTDLG_CopyChain(CRYPT_PROVIDER_DATA *data, PCCERT_CHAIN_CONTEXT chain)
Definition: main.c:190
static CERT_VERIFY_CERTIFICATE_TRUST * CRYPTDLG_GetVerifyData(CRYPT_PROVIDER_DATA *data)
Definition: main.c:238
static BOOL CRYPTDLG_IsCertAllowed(PCCERT_CONTEXT pCert)
Definition: main.c:146
static HCERTCHAINENGINE CRYPTDLG_MakeEngine(CERT_VERIFY_CERTIFICATE_TRUST *cert)
Definition: main.c:255
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:52
#define err(...)
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
PCERT_INFO pCertInfo
Definition: wincrypt.h:482
struct sock * chain
Definition: tcpcore.h:1
int ret
#define CERT_CHAIN_REVOCATION_CHECK_END_CERT
Definition: wincrypt.h:1056
#define TRUST_E_SUBJECT_NOT_TRUSTED
Definition: winerror.h:3115
#define TRUST_E_SUBJECT_FORM_UNKNOWN
Definition: winerror.h:3114
#define TRUST_E_NOSIGNATURE
Definition: winerror.h:3116
#define TRUST_E_SYSTEM_ERROR
Definition: winerror.h:3104
#define CERT_E_EXPIRED
Definition: winerror.h:3117
#define WTD_UI_NONE
Definition: wintrust.h:84

◆ CertTrustInit()

HRESULT WINAPI CertTrustInit ( CRYPT_PROVIDER_DATA pProvData)

Definition at line 82 of file main.c.

83{
85
86 TRACE("(%p)\n", pProvData);
87
88 if (pProvData->padwTrustStepErrors &&
90 ret = S_OK;
91 TRACE("returning %08x\n", ret);
92 return ret;
93}
DWORD * padwTrustStepErrors
Definition: wintrust.h:358
#define S_FALSE
Definition: winerror.h:2357
#define TRUSTERROR_STEP_FINAL_WVTINIT
Definition: wintrust.h:273

◆ CertViewPropertiesA()

BOOL WINAPI CertViewPropertiesA ( CERT_VIEWPROPERTIES_STRUCT_A info)

Definition at line 377 of file main.c.

378{
380 LPWSTR title = NULL;
381 BOOL ret;
382
383 TRACE("(%p)\n", info);
384
385 memcpy(&infoW, info, sizeof(infoW));
386 if (info->szTitle)
387 {
388 int len = MultiByteToWideChar(CP_ACP, 0, info->szTitle, -1, NULL, 0);
389
390 title = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
391 if (title)
392 {
393 MultiByteToWideChar(CP_ACP, 0, info->szTitle, -1, title, len);
394 infoW.szTitle = title;
395 }
396 else
397 {
398 ret = FALSE;
399 goto error;
400 }
401 }
404error:
405 return ret;
406}
BOOL WINAPI CertViewPropertiesW(CERT_VIEWPROPERTIES_STRUCT_W *info)
Definition: main.c:411
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
static const SecPkgInfoW infoW
Definition: kerberos.c:293
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char title[]
Definition: ps.c:92
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CertViewPropertiesW()

BOOL WINAPI CertViewPropertiesW ( CERT_VIEWPROPERTIES_STRUCT_W info)

Definition at line 411 of file main.c.

412{
413 static GUID cert_action_verify = CERT_CERTIFICATE_ACTION_VERIFY;
416 WINTRUST_DATA wtd;
417 LONG err;
418 BOOL ret;
419
420 TRACE("(%p)\n", info);
421
422 memset(&trust, 0, sizeof(trust));
423 trust.cbSize = sizeof(trust);
424 trust.pccert = info->pCertContext;
425 trust.cRootStores = info->cRootStores;
426 trust.rghstoreRoots = info->rghstoreRoots;
427 trust.cStores = info->cStores;
428 trust.rghstoreCAs = info->rghstoreCAs;
429 trust.cTrustStores = info->cTrustStores;
430 trust.rghstoreTrust = info->rghstoreTrust;
431 memset(&blob, 0, sizeof(blob));
432 blob.cbStruct = sizeof(blob);
433 blob.cbMemObject = sizeof(trust);
434 blob.pbMemObject = (BYTE *)&trust;
435 memset(&wtd, 0, sizeof(wtd));
436 wtd.cbStruct = sizeof(wtd);
439 wtd.u.pBlob = &blob;
441 err = WinVerifyTrust(NULL, &cert_action_verify, &wtd);
442 if (err == ERROR_SUCCESS)
443 {
445 BOOL propsChanged = FALSE;
446
447 memset(&uiInfo, 0, sizeof(uiInfo));
448 uiInfo.dwSize = sizeof(uiInfo);
449 uiInfo.hwndParent = info->hwndParent;
450 uiInfo.dwFlags =
452 uiInfo.szTitle = info->szTitle;
453 uiInfo.pCertContext = info->pCertContext;
454 uiInfo.cPurposes = info->cArrayPurposes;
455 uiInfo.rgszPurposes = (LPCSTR *)info->arrayPurposes;
456 uiInfo.u.hWVTStateData = wtd.hWVTStateData;
458 uiInfo.cPropSheetPages = info->cArrayPropSheetPages;
459 uiInfo.rgPropSheetPages = info->arrayPropSheetPages;
460 uiInfo.nStartPage = info->nStartPage;
461 ret = CryptUIDlgViewCertificateW(&uiInfo, &propsChanged);
463 WinVerifyTrust(NULL, &cert_action_verify, &wtd);
464 }
465 else
466 ret = FALSE;
467 return ret;
468}
#define CERT_CERTIFICATE_ACTION_VERIFY
Definition: cryptdlg.h:236
#define CRYPTUI_ENABLE_EDITPROPERTIES
Definition: cryptuiapi.h:76
#define CRYPTUI_DISABLE_ADDTOSTORE
Definition: cryptuiapi.h:77
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
BOOL WINAPI CryptUIDlgViewCertificateW(PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertViewInfo, BOOL *pfPropertiesChanged)
Definition: main.c:4413
long LONG
Definition: pedump.c:60
DWORD dwUnionChoice
Definition: wintrust.h:104
DWORD dwStateAction
Definition: wintrust.h:114
HANDLE hWVTStateData
Definition: wintrust.h:115
struct WINTRUST_BLOB_INFO_ * pBlob
Definition: wintrust.h:109
DWORD cbStruct
Definition: wintrust.h:99
DWORD dwUIChoice
Definition: wintrust.h:102
Definition: image.c:134
LPCPROPSHEETPAGEW rgPropSheetPages
Definition: cryptuiapi.h:140
#define WTD_CHOICE_BLOB
Definition: wintrust.h:93
#define WTD_STATEACTION_CLOSE
Definition: wintrust.h:124
#define WTD_STATEACTION_VERIFY
Definition: wintrust.h:123
LONG WINAPI WinVerifyTrust(HWND hwnd, GUID *ActionID, LPVOID ActionData)
const char * LPCSTR
Definition: xmlstorage.h:183
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CertViewPropertiesA().

◆ CRYPT_FormatCPS()

static BOOL CRYPT_FormatCPS ( DWORD  dwCertEncodingType,
DWORD  dwFormatStrType,
const BYTE pbEncoded,
DWORD  cbEncoded,
WCHAR str,
DWORD pcchStr 
)
static

Definition at line 522 of file main.c.

525{
526 BOOL ret;
527 DWORD size, charsNeeded = 1;
528 CERT_NAME_VALUE *cpsValue;
529
531 pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &cpsValue, &size)))
532 {
533 LPCWSTR sep;
534 DWORD sepLen;
535
536 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
537 sep = crlf;
538 else
539 sep = commaSep;
540
541 sepLen = lstrlenW(sep);
542
543 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
544 {
545 charsNeeded += 3 * lstrlenW(indent);
546 if (str && *pcchStr >= charsNeeded)
547 {
549 str += lstrlenW(indent);
551 str += lstrlenW(indent);
553 str += lstrlenW(indent);
554 }
555 }
556 charsNeeded += cpsValue->Value.cbData / sizeof(WCHAR);
557 if (str && *pcchStr >= charsNeeded)
558 {
559 lstrcpyW(str, (LPWSTR)cpsValue->Value.pbData);
560 str += cpsValue->Value.cbData / sizeof(WCHAR);
561 }
562 charsNeeded += sepLen;
563 if (str && *pcchStr >= charsNeeded)
564 {
565 lstrcpyW(str, sep);
566 str += sepLen;
567 }
568 LocalFree(cpsValue);
569 if (!str)
570 *pcchStr = charsNeeded;
571 else if (*pcchStr < charsNeeded)
572 {
573 *pcchStr = charsNeeded;
575 ret = FALSE;
576 }
577 else
578 *pcchStr = charsNeeded;
579 }
580 return ret;
581}
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 ERROR_MORE_DATA
Definition: dderror.h:13
static const WCHAR commaSep[]
Definition: main.c:520
static const WCHAR indent[]
Definition: main.c:516
static const WCHAR crlf[]
Definition: main.c:519
#define SetLastError(x)
Definition: compat.h:752
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static LPCSTR DWORD void BYTE * pbEncoded
Definition: str.c:196
const WCHAR * str
CERT_RDN_VALUE_BLOB Value
Definition: wincrypt.h:273
BYTE * pbData
Definition: wincrypt.h:103
#define X509_UNICODE_ANY_STRING
Definition: wincrypt.h:3390
#define CRYPT_FORMAT_STR_MULTI_LINE
Definition: wincrypt.h:3510
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5037
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by FormatVerisignExtension().

◆ CRYPT_FormatHexString()

static BOOL CRYPT_FormatHexString ( const BYTE pbEncoded,
DWORD  cbEncoded,
WCHAR str,
DWORD pcchStr 
)
static

Definition at line 470 of file main.c.

472{
473 BOOL ret;
474 DWORD charsNeeded;
475
476 if (cbEncoded)
477 charsNeeded = (cbEncoded * 3);
478 else
479 charsNeeded = 1;
480 if (!str)
481 {
482 *pcchStr = charsNeeded;
483 ret = TRUE;
484 }
485 else if (*pcchStr < charsNeeded)
486 {
487 *pcchStr = charsNeeded;
489 ret = FALSE;
490 }
491 else
492 {
493 static const WCHAR fmt[] = { '%','0','2','x',' ',0 };
494 static const WCHAR endFmt[] = { '%','0','2','x',0 };
495 DWORD i;
496 LPWSTR ptr = str;
497
498 *pcchStr = charsNeeded;
499 if (cbEncoded)
500 {
501 for (i = 0; i < cbEncoded; i++)
502 {
503 if (i < cbEncoded - 1)
504 ptr += swprintf(ptr, fmt, pbEncoded[i]);
505 else
506 ptr += swprintf(ptr, endFmt, pbEncoded[i]);
507 }
508 }
509 else
510 *ptr = 0;
511 ret = TRUE;
512 }
513 return ret;
514}
#define swprintf
Definition: precomp.h:40
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
static PVOID ptr
Definition: dispmode.c:27
Definition: dsound.c:943

Referenced by FormatVerisignExtension().

◆ CRYPT_FormatUserNotice()

static BOOL CRYPT_FormatUserNotice ( DWORD  dwCertEncodingType,
DWORD  dwFormatStrType,
const BYTE pbEncoded,
DWORD  cbEncoded,
WCHAR str,
DWORD pcchStr 
)
static

Definition at line 583 of file main.c.

586{
587 BOOL ret;
588 DWORD size, charsNeeded = 1;
590
594 {
595 static const WCHAR numFmt[] = { '%','d',0 };
597 notice->pNoticeReference;
598 LPCWSTR headingSep, sep;
599 DWORD headingSepLen, sepLen;
600 LPWSTR noticeRef, organization, noticeNum, noticeText;
601 DWORD noticeRefLen, organizationLen, noticeNumLen, noticeTextLen;
602 WCHAR noticeNumStr[11];
603
604 noticeRefLen = LoadStringW(hInstance, IDS_NOTICE_REF,
605 (LPWSTR)&noticeRef, 0);
606 organizationLen = LoadStringW(hInstance, IDS_ORGANIZATION,
607 (LPWSTR)&organization, 0);
608 noticeNumLen = LoadStringW(hInstance, IDS_NOTICE_NUM,
609 (LPWSTR)&noticeNum, 0);
610 noticeTextLen = LoadStringW(hInstance, IDS_NOTICE_TEXT,
611 (LPWSTR)&noticeText, 0);
612 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
613 {
614 headingSep = colonCrlf;
615 sep = crlf;
616 }
617 else
618 {
619 headingSep = colonSpace;
620 sep = commaSep;
621 }
622 sepLen = lstrlenW(sep);
623 headingSepLen = lstrlenW(headingSep);
624
625 if (pNoticeRef)
626 {
627 DWORD k;
628 LPCSTR src;
629
630 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
631 {
632 charsNeeded += 3 * lstrlenW(indent);
633 if (str && *pcchStr >= charsNeeded)
634 {
636 str += lstrlenW(indent);
638 str += lstrlenW(indent);
640 str += lstrlenW(indent);
641 }
642 }
643 charsNeeded += noticeRefLen;
644 if (str && *pcchStr >= charsNeeded)
645 {
646 memcpy(str, noticeRef, noticeRefLen * sizeof(WCHAR));
647 str += noticeRefLen;
648 }
649 charsNeeded += headingSepLen;
650 if (str && *pcchStr >= charsNeeded)
651 {
652 lstrcpyW(str, headingSep);
653 str += headingSepLen;
654 }
655 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
656 {
657 charsNeeded += 4 * lstrlenW(indent);
658 if (str && *pcchStr >= charsNeeded)
659 {
661 str += lstrlenW(indent);
663 str += lstrlenW(indent);
665 str += lstrlenW(indent);
667 str += lstrlenW(indent);
668 }
669 }
670 charsNeeded += organizationLen;
671 if (str && *pcchStr >= charsNeeded)
672 {
673 memcpy(str, organization, organizationLen * sizeof(WCHAR));
674 str += organizationLen;
675 }
676 charsNeeded += strlen(pNoticeRef->pszOrganization);
677 if (str && *pcchStr >= charsNeeded)
678 for (src = pNoticeRef->pszOrganization; src && *src;
679 src++, str++)
680 *str = *src;
681 charsNeeded += sepLen;
682 if (str && *pcchStr >= charsNeeded)
683 {
684 lstrcpyW(str, sep);
685 str += sepLen;
686 }
687 for (k = 0; k < pNoticeRef->cNoticeNumbers; k++)
688 {
689 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
690 {
691 charsNeeded += 4 * lstrlenW(indent);
692 if (str && *pcchStr >= charsNeeded)
693 {
695 str += lstrlenW(indent);
697 str += lstrlenW(indent);
699 str += lstrlenW(indent);
701 str += lstrlenW(indent);
702 }
703 }
704 charsNeeded += noticeNumLen;
705 if (str && *pcchStr >= charsNeeded)
706 {
707 memcpy(str, noticeNum, noticeNumLen * sizeof(WCHAR));
708 str += noticeNumLen;
709 }
710 swprintf(noticeNumStr, numFmt, k + 1);
711 charsNeeded += lstrlenW(noticeNumStr);
712 if (str && *pcchStr >= charsNeeded)
713 {
714 lstrcpyW(str, noticeNumStr);
715 str += lstrlenW(noticeNumStr);
716 }
717 charsNeeded += sepLen;
718 if (str && *pcchStr >= charsNeeded)
719 {
720 lstrcpyW(str, sep);
721 str += sepLen;
722 }
723 }
724 }
725 if (notice->pszDisplayText)
726 {
727 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
728 {
729 charsNeeded += 3 * lstrlenW(indent);
730 if (str && *pcchStr >= charsNeeded)
731 {
733 str += lstrlenW(indent);
735 str += lstrlenW(indent);
737 str += lstrlenW(indent);
738 }
739 }
740 charsNeeded += noticeTextLen;
741 if (str && *pcchStr >= charsNeeded)
742 {
743 memcpy(str, noticeText, noticeTextLen * sizeof(WCHAR));
744 str += noticeTextLen;
745 }
746 charsNeeded += lstrlenW(notice->pszDisplayText);
747 if (str && *pcchStr >= charsNeeded)
748 {
749 lstrcpyW(str, notice->pszDisplayText);
750 str += lstrlenW(notice->pszDisplayText);
751 }
752 charsNeeded += sepLen;
753 if (str && *pcchStr >= charsNeeded)
754 {
755 lstrcpyW(str, sep);
756 str += sepLen;
757 }
758 }
760 if (!str)
761 *pcchStr = charsNeeded;
762 else if (*pcchStr < charsNeeded)
763 {
764 *pcchStr = charsNeeded;
766 ret = FALSE;
767 }
768 else
769 *pcchStr = charsNeeded;
770 }
771 return ret;
772}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
HINSTANCE hInstance
Definition: charmap.c:19
#define IDS_ORGANIZATION
Definition: cryptres.h:65
#define IDS_NOTICE_TEXT
Definition: cryptres.h:33
#define IDS_NOTICE_NUM
Definition: cryptres.h:32
#define IDS_NOTICE_REF
Definition: cryptres.h:30
static const WCHAR colonSpace[]
Definition: main.c:518
static const WCHAR colonCrlf[]
Definition: main.c:517
GLenum src
Definition: glext.h:6340
static WCHAR noticeText[]
Definition: encode.c:7449
int k
Definition: mpi.c:3369
notice
Definition: t1tokens.h:26
#define X509_PKIX_POLICY_QUALIFIER_USERNOTICE
Definition: wincrypt.h:3414
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by FormatVerisignExtension().

◆ CRYPTDLG_CheckOnlineCRL()

static BOOL CRYPTDLG_CheckOnlineCRL ( void  )
static

Definition at line 113 of file main.c.

114{
115 static const WCHAR policyFlagsKey[] = { 'S','o','f','t','w','a','r','e',
116 '\\','M','i','c','r','o','s','o','f','t','\\','C','r','y','p','t','o','g',
117 'r','a','p','h','y','\\','{','7','8','0','1','e','b','d','0','-','c','f',
118 '4','b','-','1','1','d','0','-','8','5','1','f','-','0','0','6','0','9',
119 '7','9','3','8','7','e','a','}',0 };
120 static const WCHAR policyFlags[] = { 'P','o','l','i','c','y','F','l','a',
121 'g','s',0 };
122 HKEY key;
123 BOOL ret = FALSE;
124
125 if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE, policyFlagsKey, 0, KEY_READ, &key))
126 {
127 DWORD type, flags, size = sizeof(flags);
128
129 if (!RegQueryValueExW(key, policyFlags, NULL, &type, (BYTE *)&flags,
130 &size) && type == REG_DWORD)
131 {
132 /* The flag values aren't defined in any header I'm aware of, but
133 * this value is well documented on the net.
134 */
135 if (flags & 0x00010000)
136 ret = TRUE;
137 }
139 }
140 return ret;
141}
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define KEY_READ
Definition: nt_native.h:1023
#define REG_DWORD
Definition: sdbapi.c:596
Definition: copy.c:22
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CertTrustFinalPolicy().

◆ CRYPTDLG_CopyChain()

static BOOL CRYPTDLG_CopyChain ( CRYPT_PROVIDER_DATA data,
PCCERT_CHAIN_CONTEXT  chain 
)
static

Definition at line 190 of file main.c.

192{
193 BOOL ret;
194 CRYPT_PROVIDER_SGNR signer;
195 PCERT_SIMPLE_CHAIN simpleChain = chain->rgpChain[0];
196 DWORD i;
197
198 memset(&signer, 0, sizeof(signer));
199 signer.cbStruct = sizeof(signer);
200 ret = data->psPfns->pfnAddSgnr2Chain(data, FALSE, 0, &signer);
201 if (ret)
202 {
204 FALSE, 0);
205
206 if (sgnr)
207 {
208 sgnr->dwError = simpleChain->TrustStatus.dwErrorStatus;
210 }
211 else
212 ret = FALSE;
213 for (i = 0; ret && i < simpleChain->cElement; i++)
214 {
215 ret = data->psPfns->pfnAddCert2Chain(data, 0, FALSE, 0,
216 simpleChain->rgpElement[i]->pCertContext);
217 if (ret)
218 {
220
221 if ((cert = WTHelperGetProvCertFromChain(sgnr, i)))
222 {
223 CERT_CHAIN_ELEMENT *element = simpleChain->rgpElement[i];
224
226 element->TrustStatus.dwErrorStatus);
227 cert->dwError = element->TrustStatus.dwErrorStatus;
228 cert->pChainElement = element;
229 }
230 else
231 ret = FALSE;
232 }
233 }
234 }
235 return ret;
236}
PCCERT_CHAIN_CONTEXT WINAPI CertDuplicateCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2948
static DWORD CRYPTDLG_TrustStatusToConfidence(DWORD errorStatus)
Definition: main.c:176
static BYTE cert[]
Definition: msg.c:1437
PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:916
CERT_TRUST_STATUS TrustStatus
Definition: wincrypt.h:926
PCERT_CHAIN_ELEMENT * rgpElement
Definition: wincrypt.h:928
PCCERT_CHAIN_CONTEXT pChainContext
Definition: wintrust.h:241
CRYPT_PROVIDER_CERT *WINAPI WTHelperGetProvCertFromChain(CRYPT_PROVIDER_SGNR *pSgnr, DWORD idxCert)
CRYPT_PROVIDER_SGNR *WINAPI WTHelperGetProvSignerFromChain(CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSigner, DWORD idxCounterSigner)

Referenced by CertTrustFinalPolicy().

◆ CRYPTDLG_GetVerifyData()

static CERT_VERIFY_CERTIFICATE_TRUST * CRYPTDLG_GetVerifyData ( CRYPT_PROVIDER_DATA data)
static

Definition at line 238 of file main.c.

240{
242
243 /* This should always be true, but just in case the calling function is
244 * called directly:
245 */
246 if (data->pWintrustData->dwUnionChoice == WTD_CHOICE_BLOB &&
247 data->pWintrustData->u.pBlob && data->pWintrustData->u.pBlob->cbMemObject ==
249 data->pWintrustData->u.pBlob->pbMemObject)
251 data->pWintrustData->u.pBlob->pbMemObject;
252 return pCert;
253}

Referenced by CertTrustFinalPolicy().

◆ CRYPTDLG_IsCertAllowed()

static BOOL CRYPTDLG_IsCertAllowed ( PCCERT_CONTEXT  pCert)
static

Definition at line 146 of file main.c.

147{
148 BOOL ret;
149 BYTE hash[20];
150 DWORD size = sizeof(hash);
151
154 {
155 static const WCHAR disallowedW[] =
156 { 'D','i','s','a','l','l','o','w','e','d',0 };
159
160 if (disallowed)
161 {
164
165 if (found)
166 {
167 ret = FALSE;
169 }
171 }
172 }
173 return ret;
174}
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
static const WCHAR disallowed[]
Definition: main.c:459
Definition: _hash_fun.h:40
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define CERT_STORE_PROV_SYSTEM_W
Definition: wincrypt.h:2259
#define CERT_FIND_SIGNATURE_HASH
Definition: wincrypt.h:2869
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2701
#define CERT_SYSTEM_STORE_CURRENT_USER
Definition: wincrypt.h:2324

Referenced by CertTrustFinalPolicy().

◆ CRYPTDLG_MakeEngine()

static HCERTCHAINENGINE CRYPTDLG_MakeEngine ( CERT_VERIFY_CERTIFICATE_TRUST cert)
static

Definition at line 255 of file main.c.

256{
257 HCERTCHAINENGINE engine = NULL;
258 HCERTSTORE root = NULL, trust = NULL;
259 DWORD i;
260
261 if (cert->cRootStores)
262 {
265 if (root)
266 {
267 for (i = 0; i < cert->cRootStores; i++)
268 CertAddStoreToCollection(root, cert->rghstoreRoots[i], 0, 0);
269 }
270 }
271 if (cert->cTrustStores)
272 {
275 if (trust)
276 {
277 for (i = 0; i < cert->cTrustStores; i++)
278 CertAddStoreToCollection(trust, cert->rghstoreTrust[i], 0, 0);
279 }
280 }
281 if (cert->cRootStores || cert->cStores || cert->cTrustStores)
282 {
284
285 memset(&config, 0, sizeof(config));
286 config.cbSize = sizeof(config);
287 config.hRestrictedRoot = root;
288 config.hRestrictedTrust = trust;
289 config.cAdditionalStore = cert->cStores;
290 config.rghAdditionalStore = cert->rghstoreCAs;
291 config.hRestrictedRoot = root;
294 CertCloseStore(trust, 0);
295 }
296 return engine;
297}
struct _root root
BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore, HCERTSTORE hSiblingStore, DWORD dwUpdateFlags, DWORD dwPriority)
struct config_s config
BOOL WINAPI CertCreateCertificateChainEngine(PCERT_CHAIN_ENGINE_CONFIG pConfig, HCERTCHAINENGINE *phChainEngine)
Definition: chain.c:225
#define CERT_STORE_PROV_COLLECTION
Definition: wincrypt.h:2261
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464

Referenced by CertTrustFinalPolicy().

◆ CRYPTDLG_TrustStatusToConfidence()

static DWORD CRYPTDLG_TrustStatusToConfidence ( DWORD  errorStatus)
static

Definition at line 176 of file main.c.

177{
178 DWORD confidence = 0;
179
180 confidence = 0;
181 if (!(errorStatus & CERT_TRUST_IS_NOT_SIGNATURE_VALID))
182 confidence |= CERT_CONFIDENCE_SIG;
183 if (!(errorStatus & CERT_TRUST_IS_NOT_TIME_VALID))
184 confidence |= CERT_CONFIDENCE_TIME;
185 if (!(errorStatus & CERT_TRUST_IS_NOT_TIME_NESTED))
186 confidence |= CERT_CONFIDENCE_TIMENEST;
187 return confidence;
188}
#define CERT_TRUST_IS_NOT_TIME_NESTED
Definition: wincrypt.h:871
#define CERT_TRUST_IS_NOT_SIGNATURE_VALID
Definition: wincrypt.h:873
#define CERT_TRUST_IS_NOT_TIME_VALID
Definition: wincrypt.h:870
#define CERT_CONFIDENCE_TIME
Definition: wintrust.h:225
#define CERT_CONFIDENCE_TIMENEST
Definition: wintrust.h:226
#define CERT_CONFIDENCE_SIG
Definition: wintrust.h:224

Referenced by CRYPTDLG_CopyChain().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 43 of file main.c.

44{
45 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
46
47 switch (fdwReason)
48 {
49 case DLL_WINE_PREATTACH:
50 return FALSE; /* prefer native version */
53 hInstance = hinstDLL;
54 break;
55 }
56 return TRUE;
57}
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static IN DWORD IN LPVOID lpvReserved

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Definition at line 1124 of file main.c.

1125{
1126 static WCHAR cryptdlg[] = { 'c','r','y','p','t','d','l','g','.',
1127 'd','l','l',0 };
1128 static WCHAR wintrust[] = { 'w','i','n','t','r','u','s','t','.',
1129 'd','l','l',0 };
1130 static WCHAR certTrustInit[] = { 'C','e','r','t','T','r','u','s','t',
1131 'I','n','i','t',0 };
1132 static WCHAR wintrustCertificateTrust[] = { 'W','i','n','t','r','u','s','t',
1133 'C','e','r','t','i','f','i','c','a','t','e','T','r','u','s','t',0 };
1134 static WCHAR certTrustCertPolicy[] = { 'C','e','r','t','T','r','u','s','t',
1135 'C','e','r','t','P','o','l','i','c','y',0 };
1136 static WCHAR certTrustFinalPolicy[] = { 'C','e','r','t','T','r','u','s','t',
1137 'F','i','n','a','l','P','o','l','i','c','y',0 };
1138 static WCHAR certTrustCleanup[] = { 'C','e','r','t','T','r','u','s','t',
1139 'C','l','e','a','n','u','p',0 };
1140 static const WCHAR cryptDlg[] = { 'c','r','y','p','t','d','l','g','.',
1141 'd','l','l',0 };
1144 HRESULT hr = S_OK;
1145
1146 memset(&reg, 0, sizeof(reg));
1147 reg.cbStruct = sizeof(reg);
1148 reg.sInitProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
1149 reg.sInitProvider.pwszDLLName = cryptdlg;
1150 reg.sInitProvider.pwszFunctionName = certTrustInit;
1151 reg.sCertificateProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
1152 reg.sCertificateProvider.pwszDLLName = wintrust;
1153 reg.sCertificateProvider.pwszFunctionName = wintrustCertificateTrust;
1154 reg.sCertificatePolicyProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
1155 reg.sCertificatePolicyProvider.pwszDLLName = cryptdlg;
1156 reg.sCertificatePolicyProvider.pwszFunctionName = certTrustCertPolicy;
1157 reg.sFinalPolicyProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
1158 reg.sFinalPolicyProvider.pwszDLLName = cryptdlg;
1159 reg.sFinalPolicyProvider.pwszFunctionName = certTrustFinalPolicy;
1160 reg.sCleanupProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
1161 reg.sCleanupProvider.pwszDLLName = cryptdlg;
1162 reg.sCleanupProvider.pwszFunctionName = certTrustCleanup;
1164 hr = GetLastError();
1166 "1.3.6.1.4.1.311.16.1.1", cryptDlg, "EncodeAttrSequence");
1168 szOID_MICROSOFT_Encryption_Key_Preference, cryptDlg, "EncodeRecipientID");
1170 "1.3.6.1.4.1.311.16.1.1", cryptDlg, "DecodeAttrSequence");
1172 szOID_MICROSOFT_Encryption_Key_Preference, cryptDlg, "DecodeRecipientID");
1174 szOID_PKIX_KP_EMAIL_PROTECTION, cryptDlg, "FormatPKIXEmailProtection");
1176 szOID_CERT_POLICIES, cryptDlg, "FormatVerisignExtension");
1177 return hr;
1178}
BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName)
Definition: oid.c:647
#define szOID_MICROSOFT_Encryption_Key_Preference
Definition: main.c:1119
BOOL WINAPI WintrustAddActionID(GUID *pgActionID, DWORD fdwFlags, CRYPT_REGISTER_ACTIONID *psProvInfo)
Definition: register.c:238
static int reg
Definition: i386-dis.c:1290
const GUID * guid
HRESULT hr
Definition: shlfolder.c:183
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CRYPT_OID_FORMAT_OBJECT_FUNC
Definition: wincrypt.h:2499
#define CRYPT_OID_DECODE_OBJECT_FUNC
Definition: wincrypt.h:2493
#define szOID_CERT_POLICIES
Definition: wincrypt.h:3197
#define szOID_PKIX_KP_EMAIL_PROTECTION
Definition: wincrypt.h:3297
#define CRYPT_OID_ENCODE_OBJECT_FUNC
Definition: wincrypt.h:2492
#define WT_ADD_ACTION_ID_RET_RESULT_FLAG
Definition: wintrust.h:448
struct _CRYPT_TRUST_REG_ENTRY CRYPT_TRUST_REG_ENTRY

◆ DllUnregisterServer()

◆ FormatVerisignExtension()

BOOL WINAPI FormatVerisignExtension ( DWORD  dwCertEncodingType,
DWORD  dwFormatType,
DWORD  dwFormatStrType,
void pFormatStruct,
LPCSTR  lpszStructType,
const BYTE pbEncoded,
DWORD  cbEncoded,
void pbFormat,
DWORD pcbFormat 
)

Definition at line 777 of file main.c.

781{
782 CERT_POLICIES_INFO *policies;
783 DWORD size;
784 BOOL ret = FALSE;
785
786 if (!cbEncoded)
787 {
789 return FALSE;
790 }
792 pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &policies, &size)))
793 {
794 static const WCHAR numFmt[] = { '%','d',0 };
795 DWORD charsNeeded = 1; /* space for NULL terminator */
796 LPCWSTR headingSep, sep;
797 DWORD headingSepLen, sepLen;
798 WCHAR policyNum[11], policyQualifierNum[11];
799 LPWSTR certPolicy, policyId, policyQualifierInfo, policyQualifierId;
800 LPWSTR cps, userNotice, qualifier;
801 DWORD certPolicyLen, policyIdLen, policyQualifierInfoLen;
802 DWORD policyQualifierIdLen, cpsLen, userNoticeLen, qualifierLen;
803 DWORD i;
804 LPWSTR str = pbFormat;
805
806 certPolicyLen = LoadStringW(hInstance, IDS_CERT_POLICY,
807 (LPWSTR)&certPolicy, 0);
808 policyIdLen = LoadStringW(hInstance, IDS_POLICY_ID, (LPWSTR)&policyId,
809 0);
810 policyQualifierInfoLen = LoadStringW(hInstance,
811 IDS_POLICY_QUALIFIER_INFO, (LPWSTR)&policyQualifierInfo, 0);
812 policyQualifierIdLen = LoadStringW(hInstance, IDS_POLICY_QUALIFIER_ID,
813 (LPWSTR)&policyQualifierId, 0);
814 cpsLen = LoadStringW(hInstance, IDS_CPS, (LPWSTR)&cps, 0);
815 userNoticeLen = LoadStringW(hInstance, IDS_USER_NOTICE,
816 (LPWSTR)&userNotice, 0);
817 qualifierLen = LoadStringW(hInstance, IDS_QUALIFIER,
818 (LPWSTR)&qualifier, 0);
819 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
820 {
821 headingSep = colonCrlf;
822 sep = crlf;
823 }
824 else
825 {
826 headingSep = colonSpace;
827 sep = commaSep;
828 }
829 sepLen = lstrlenW(sep);
830 headingSepLen = lstrlenW(headingSep);
831
832 for (i = 0; ret && i < policies->cPolicyInfo; i++)
833 {
834 CERT_POLICY_INFO *policy = &policies->rgPolicyInfo[i];
835 DWORD j;
836 LPCSTR src;
837
838 charsNeeded += 1; /* '['*/
839 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
840 *str++ = '[';
841 swprintf(policyNum, numFmt, i + 1);
842 charsNeeded += lstrlenW(policyNum);
843 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
844 {
845 lstrcpyW(str, policyNum);
846 str += lstrlenW(policyNum);
847 }
848 charsNeeded += 1; /* ']'*/
849 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
850 *str++ = ']';
851 charsNeeded += certPolicyLen;
852 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
853 {
854 memcpy(str, certPolicy, certPolicyLen * sizeof(WCHAR));
855 str += certPolicyLen;
856 }
857 charsNeeded += headingSepLen;
858 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
859 {
860 lstrcpyW(str, headingSep);
861 str += headingSepLen;
862 }
863 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
864 {
865 charsNeeded += lstrlenW(indent);
866 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
867 {
869 str += lstrlenW(indent);
870 }
871 }
872 charsNeeded += policyIdLen;
873 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
874 {
875 memcpy(str, policyId, policyIdLen * sizeof(WCHAR));
876 str += policyIdLen;
877 }
878 charsNeeded += strlen(policy->pszPolicyIdentifier);
879 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
880 {
881 for (src = policy->pszPolicyIdentifier; src && *src;
882 src++, str++)
883 *str = *src;
884 }
885 charsNeeded += sepLen;
886 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
887 {
888 lstrcpyW(str, sep);
889 str += sepLen;
890 }
891 for (j = 0; j < policy->cPolicyQualifier; j++)
892 {
893 CERT_POLICY_QUALIFIER_INFO *qualifierInfo =
894 &policy->rgPolicyQualifier[j];
895 DWORD sizeRemaining;
896
897 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
898 {
899 charsNeeded += lstrlenW(indent);
900 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
901 {
903 str += lstrlenW(indent);
904 }
905 }
906 charsNeeded += 1; /* '['*/
907 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
908 *str++ = '[';
909 charsNeeded += lstrlenW(policyNum);
910 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
911 {
912 lstrcpyW(str, policyNum);
913 str += lstrlenW(policyNum);
914 }
915 charsNeeded += 1; /* ','*/
916 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
917 *str++ = ',';
918 swprintf(policyQualifierNum, numFmt, j + 1);
919 charsNeeded += lstrlenW(policyQualifierNum);
920 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
921 {
922 lstrcpyW(str, policyQualifierNum);
923 str += lstrlenW(policyQualifierNum);
924 }
925 charsNeeded += 1; /* ']'*/
926 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
927 *str++ = ']';
928 charsNeeded += policyQualifierInfoLen;
929 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
930 {
931 memcpy(str, policyQualifierInfo,
932 policyQualifierInfoLen * sizeof(WCHAR));
933 str += policyQualifierInfoLen;
934 }
935 charsNeeded += headingSepLen;
936 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
937 {
938 lstrcpyW(str, headingSep);
939 str += headingSepLen;
940 }
941 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
942 {
943 charsNeeded += 2 * lstrlenW(indent);
944 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
945 {
947 str += lstrlenW(indent);
949 str += lstrlenW(indent);
950 }
951 }
952 charsNeeded += policyQualifierIdLen;
953 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
954 {
955 memcpy(str, policyQualifierId,
956 policyQualifierIdLen * sizeof(WCHAR));
957 str += policyQualifierIdLen;
958 }
959 if (!strcmp(qualifierInfo->pszPolicyQualifierId,
961 {
962 charsNeeded += cpsLen;
963 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
964 {
965 memcpy(str, cps, cpsLen * sizeof(WCHAR));
966 str += cpsLen;
967 }
968 }
969 else if (!strcmp(qualifierInfo->pszPolicyQualifierId,
971 {
972 charsNeeded += userNoticeLen;
973 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
974 {
975 memcpy(str, userNotice, userNoticeLen * sizeof(WCHAR));
976 str += userNoticeLen;
977 }
978 }
979 else
980 {
981 charsNeeded += strlen(qualifierInfo->pszPolicyQualifierId);
982 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
983 {
984 for (src = qualifierInfo->pszPolicyQualifierId;
985 src && *src; src++, str++)
986 *str = *src;
987 }
988 }
989 charsNeeded += sepLen;
990 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
991 {
992 lstrcpyW(str, sep);
993 str += sepLen;
994 }
995 if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
996 {
997 charsNeeded += 2 * lstrlenW(indent);
998 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
999 {
1001 str += lstrlenW(indent);
1003 str += lstrlenW(indent);
1004 }
1005 }
1006 charsNeeded += qualifierLen;
1007 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
1008 {
1009 memcpy(str, qualifier, qualifierLen * sizeof(WCHAR));
1010 str += qualifierLen;
1011 }
1012 charsNeeded += headingSepLen;
1013 if (str && *pcbFormat >= charsNeeded * sizeof(WCHAR))
1014 {
1015 lstrcpyW(str, headingSep);
1016 str += headingSepLen;
1017 }
1018 /* This if block is deliberately redundant with the same if
1019 * block above, in order to keep the code more readable (the
1020 * code flow follows the order in which the strings are output.)
1021 */
1022 if (!strcmp(qualifierInfo->pszPolicyQualifierId,
1024 {
1025 if (!str || *pcbFormat < charsNeeded * sizeof(WCHAR))
1026 {
1027 /* Insufficient space, determine how much is needed. */
1029 dwFormatStrType, qualifierInfo->Qualifier.pbData,
1030 qualifierInfo->Qualifier.cbData, NULL, &size);
1031 if (ret)
1032 charsNeeded += size - 1;
1033 }
1034 else
1035 {
1036 sizeRemaining = *pcbFormat / sizeof(WCHAR);
1037 sizeRemaining -= str - (LPWSTR)pbFormat;
1039 dwFormatStrType, qualifierInfo->Qualifier.pbData,
1040 qualifierInfo->Qualifier.cbData, str, &sizeRemaining);
1041 if (ret || GetLastError() == ERROR_MORE_DATA)
1042 {
1043 charsNeeded += sizeRemaining - 1;
1044 str += sizeRemaining - 1;
1045 }
1046 }
1047 }
1048 else if (!strcmp(qualifierInfo->pszPolicyQualifierId,
1050 {
1051 if (!str || *pcbFormat < charsNeeded * sizeof(WCHAR))
1052 {
1053 /* Insufficient space, determine how much is needed. */
1055 dwFormatStrType, qualifierInfo->Qualifier.pbData,
1056 qualifierInfo->Qualifier.cbData, NULL, &size);
1057 if (ret)
1058 charsNeeded += size - 1;
1059 }
1060 else
1061 {
1062 sizeRemaining = *pcbFormat / sizeof(WCHAR);
1063 sizeRemaining -= str - (LPWSTR)pbFormat;
1065 dwFormatStrType, qualifierInfo->Qualifier.pbData,
1066 qualifierInfo->Qualifier.cbData, str, &sizeRemaining);
1067 if (ret || GetLastError() == ERROR_MORE_DATA)
1068 {
1069 charsNeeded += sizeRemaining - 1;
1070 str += sizeRemaining - 1;
1071 }
1072 }
1073 }
1074 else
1075 {
1076 if (!str || *pcbFormat < charsNeeded * sizeof(WCHAR))
1077 {
1078 /* Insufficient space, determine how much is needed. */
1080 qualifierInfo->Qualifier.pbData,
1081 qualifierInfo->Qualifier.cbData, NULL, &size);
1082 if (ret)
1083 charsNeeded += size - 1;
1084 }
1085 else
1086 {
1087 sizeRemaining = *pcbFormat / sizeof(WCHAR);
1088 sizeRemaining -= str - (LPWSTR)pbFormat;
1090 qualifierInfo->Qualifier.pbData,
1091 qualifierInfo->Qualifier.cbData, str, &sizeRemaining);
1092 if (ret || GetLastError() == ERROR_MORE_DATA)
1093 {
1094 charsNeeded += sizeRemaining - 1;
1095 str += sizeRemaining - 1;
1096 }
1097 }
1098 }
1099 }
1100 }
1101 LocalFree(policies);
1102 if (ret)
1103 {
1104 if (!pbFormat)
1105 *pcbFormat = charsNeeded * sizeof(WCHAR);
1106 else if (*pcbFormat < charsNeeded * sizeof(WCHAR))
1107 {
1108 *pcbFormat = charsNeeded * sizeof(WCHAR);
1110 ret = FALSE;
1111 }
1112 else
1113 *pcbFormat = charsNeeded * sizeof(WCHAR);
1114 }
1115 }
1116 return ret;
1117}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define IDS_CPS
Definition: cryptres.h:49
#define IDS_USER_NOTICE
Definition: cryptres.h:50
#define IDS_POLICY_QUALIFIER_INFO
Definition: cryptres.h:25
#define IDS_CERT_POLICY
Definition: cryptres.h:23
#define IDS_QUALIFIER
Definition: cryptres.h:29
#define IDS_POLICY_ID
Definition: cryptres.h:24
#define IDS_POLICY_QUALIFIER_ID
Definition: cryptres.h:26
#define E_INVALIDARG
Definition: ddrawi.h:101
static BOOL CRYPT_FormatCPS(DWORD dwCertEncodingType, DWORD dwFormatStrType, const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
Definition: main.c:522
static BOOL CRYPT_FormatUserNotice(DWORD dwCertEncodingType, DWORD dwFormatStrType, const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
Definition: main.c:583
static BOOL CRYPT_FormatHexString(const BYTE *pbEncoded, DWORD cbEncoded, WCHAR *str, DWORD *pcchStr)
Definition: main.c:470
WDF_INTERRUPT_POLICY policy
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 APTTYPEQUALIFIER * qualifier
Definition: compobj.c:79
CERT_POLICY_INFO * rgPolicyInfo
Definition: wincrypt.h:400
CRYPT_OBJID_BLOB Qualifier
Definition: wincrypt.h:389
#define szOID_PKIX_POLICY_QUALIFIER_CPS
Definition: wincrypt.h:3291
#define X509_CERT_POLICIES
Definition: wincrypt.h:3381
#define szOID_PKIX_POLICY_QUALIFIER_USERNOTICE
Definition: wincrypt.h:3292

◆ GetFriendlyNameOfCertA()

DWORD WINAPI GetFriendlyNameOfCertA ( PCCERT_CONTEXT  pccert,
LPSTR  pchBuffer,
DWORD  cchBuffer 
)

Definition at line 62 of file main.c.

64{
66 pchBuffer, cchBuffer);
67}
DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, LPSTR pszNameString, DWORD cchNameString)
Definition: str.c:1127
static DWORD cchBuffer
Definition: fusion.c:85
#define CERT_NAME_FRIENDLY_DISPLAY_TYPE
Definition: wincrypt.h:3501

◆ GetFriendlyNameOfCertW()

DWORD WINAPI GetFriendlyNameOfCertW ( PCCERT_CONTEXT  pccert,
LPWSTR  pchBuffer,
DWORD  cchBuffer 
)

Definition at line 72 of file main.c.

74{
76 pchBuffer, cchBuffer);
77}
DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, LPWSTR pszNameString, DWORD cchNameString)
Definition: str.c:1228

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( cryptdlg  )

Variable Documentation

◆ colonCrlf

const WCHAR colonCrlf[] = { ':','\r','\n',0 }
static

Definition at line 517 of file main.c.

Referenced by CRYPT_FormatUserNotice(), and FormatVerisignExtension().

◆ colonSpace

const WCHAR colonSpace[] = { ':',' ',0 }
static

Definition at line 518 of file main.c.

Referenced by CRYPT_FormatUserNotice(), and FormatVerisignExtension().

◆ commaSep

◆ crlf

const WCHAR crlf[] = { '\r','\n',0 }
static

Definition at line 519 of file main.c.

Referenced by CRYPT_FormatCPS(), CRYPT_FormatUserNotice(), and FormatVerisignExtension().

◆ hInstance

HINSTANCE hInstance
static

Definition at line 41 of file main.c.

◆ indent

const WCHAR indent[] = { ' ',' ',' ',' ',' ',0 }
static

Definition at line 516 of file main.c.

Referenced by CRYPT_FormatCPS(), CRYPT_FormatUserNotice(), and FormatVerisignExtension().