ReactOS 0.4.15-dev-7924-g5949c20
ctl.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "wine/debug.h"
#include "crypt32_private.h"
Include dependency graph for ctl.c:

Go to the source code of this file.

Typedefs

typedef BOOL(* CtlCompareFunc) (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static void CTL_free (context_t *context)
 
static context_tCTL_clone (context_t *context, WINECRYPT_CERTSTORE *store, BOOL use_link)
 
BOOL WINAPI CertAddCTLContextToStore (HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition, PCCTL_CONTEXT *ppStoreContext)
 
BOOL WINAPI CertAddEncodedCTLToStore (HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded, DWORD dwAddDisposition, PCCTL_CONTEXT *ppCtlContext)
 
PCCTL_CONTEXT WINAPI CertEnumCTLsInStore (HCERTSTORE hCertStore, PCCTL_CONTEXT pPrev)
 
static BOOL compare_ctl_any (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_ctl_by_md5_hash (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_ctl_by_sha1_hash (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_ctl_existing (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
PCCTL_CONTEXT WINAPI CertFindCTLInStore (HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void *pvFindPara, PCCTL_CONTEXT pPrevCtlContext)
 
BOOL WINAPI CertDeleteCTLFromStore (PCCTL_CONTEXT pCtlContext)
 
PCCTL_CONTEXT WINAPI CertCreateCTLContext (DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded)
 
PCCTL_CONTEXT WINAPI CertDuplicateCTLContext (PCCTL_CONTEXT pCtlContext)
 
BOOL WINAPI CertFreeCTLContext (PCCTL_CONTEXT pCTLContext)
 
DWORD WINAPI CertEnumCTLContextProperties (PCCTL_CONTEXT pCTLContext, DWORD dwPropId)
 
static BOOL CTLContext_SetProperty (ctl_t *ctl, DWORD dwPropId, DWORD dwFlags, const void *pvData)
 
static BOOL CTLContext_GetHashProp (ctl_t *ctl, DWORD dwPropId, ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData, DWORD *pcbData)
 
static BOOL CTLContext_GetProperty (ctl_t *ctl, DWORD dwPropId, void *pvData, DWORD *pcbData)
 
BOOL WINAPI CertGetCTLContextProperty (PCCTL_CONTEXT pCTLContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
 
BOOL WINAPI CertSetCTLContextProperty (PCCTL_CONTEXT pCTLContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
 

Variables

static const context_vtbl_t ctl_vtbl
 

Typedef Documentation

◆ CtlCompareFunc

typedef BOOL(* CtlCompareFunc) (PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)

Definition at line 215 of file ctl.c.

Function Documentation

◆ CertAddCTLContextToStore()

BOOL WINAPI CertAddCTLContextToStore ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  pCtlContext,
DWORD  dwAddDisposition,
PCCTL_CONTEXT ppStoreContext 
)

Definition at line 63 of file ctl.c.

66{
67 WINECRYPT_CERTSTORE *store = hCertStore;
68 BOOL ret = TRUE;
69 PCCTL_CONTEXT toAdd = NULL, existing = NULL;
70
71 TRACE("(%p, %p, %08x, %p)\n", hCertStore, pCtlContext, dwAddDisposition,
73
75 {
76 existing = CertFindCTLInStore(hCertStore, 0, 0, CTL_FIND_EXISTING,
78 }
79
80 switch (dwAddDisposition)
81 {
84 break;
86 if (existing)
87 {
88 TRACE("found matching CTL, not adding\n");
90 ret = FALSE;
91 }
92 else
94 break;
96 if (existing)
97 {
98 LONG newer = CompareFileTime(&existing->pCtlInfo->ThisUpdate,
100
101 if (newer < 0)
103 else
104 {
105 TRACE("existing CTL is newer, not adding\n");
107 ret = FALSE;
108 }
109 }
110 else
112 break;
114 if (existing)
115 {
116 LONG newer = CompareFileTime(&existing->pCtlInfo->ThisUpdate,
118
119 if (newer < 0)
120 {
123 }
124 else
125 {
126 TRACE("existing CTL is newer, not adding\n");
128 ret = FALSE;
129 }
130 }
131 else
133 break;
136 break;
139 if (existing)
140 Context_CopyProperties(toAdd, existing);
141 break;
143 if (existing)
144 {
146 if (ppStoreContext)
148 }
149 else
151 break;
152 default:
153 FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
154 ret = FALSE;
155 }
156
157 if (toAdd)
158 {
159 if (store) {
160 context_t *ret_ctx;
161
162 ret = store->vtbl->ctls.addContext(store, context_from_ptr(toAdd),
163 existing ? context_from_ptr(existing) : NULL, ppStoreContext ? &ret_ctx : NULL, TRUE);
164 if(ret && ppStoreContext)
165 *ppStoreContext = context_ptr(ret_ctx);
166 }else if (ppStoreContext) {
168 }
169 CertFreeCTLContext(toAdd);
170 }
171 CertFreeCTLContext(existing);
172
173 TRACE("returning %d\n", ret);
174 return ret;
175}
void newer(int argc, const char *argv[])
Definition: cmds.c:2278
#define FIXME(fmt,...)
Definition: debug.h:111
static void * context_ptr(context_t *context)
static context_t * context_from_ptr(const void *ptr)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void Context_CopyProperties(const void *to, const void *from)
Definition: context.c:123
BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
Definition: ctl.c:499
PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext)
Definition: ctl.c:491
PCCTL_CONTEXT WINAPI CertFindCTLInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void *pvFindPara, PCCTL_CONTEXT pPrevCtlContext)
Definition: ctl.c:291
#define SetLastError(x)
Definition: compat.h:752
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
BOOL(* addContext)(struct WINE_CRYPTCERTSTORE *, context_t *, context_t *, context_t **, BOOL)
PCTL_INFO pCtlInfo
Definition: wincrypt.h:747
FILETIME ThisUpdate
Definition: wincrypt.h:734
CONTEXT_FUNCS ctls
int ret
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2484
#define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
Definition: wincrypt.h:2488
#define CERT_STORE_ADD_NEWER
Definition: wincrypt.h:2487
_In_ PCCERT_CONTEXT _In_ DWORD dwAddDisposition
Definition: wincrypt.h:4984
_In_ PCCTL_CONTEXT pCtlContext
Definition: wincrypt.h:5001
#define CTL_FIND_EXISTING
Definition: wincrypt.h:2948
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2483
_In_ PCCERT_CONTEXT _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppStoreContext
Definition: wincrypt.h:4985
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2482
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2485
#define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
Definition: wincrypt.h:2486
#define CRYPT_E_EXISTS
Definition: winerror.h:3008

Referenced by CertAddEncodedCTLToStore(), CRYPT_CreateAny(), CRYPT_CreateCTL(), and import_ctl().

◆ CertAddEncodedCTLToStore()

BOOL WINAPI CertAddEncodedCTLToStore ( HCERTSTORE  hCertStore,
DWORD  dwMsgAndCertEncodingType,
const BYTE pbCtlEncoded,
DWORD  cbCtlEncoded,
DWORD  dwAddDisposition,
PCCTL_CONTEXT ppCtlContext 
)

Definition at line 177 of file ctl.c.

180{
182 pbCtlEncoded, cbCtlEncoded);
183 BOOL ret;
184
185 TRACE("(%p, %08x, %p, %d, %08x, %p)\n", hCertStore,
188
189 if (ctl)
190 {
194 }
195 else
196 ret = FALSE;
197 return ret;
198}
PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded)
Definition: ctl.c:363
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition, PCCTL_CONTEXT *ppStoreContext)
Definition: ctl.c:63
_In_ DWORD dwMsgAndCertEncodingType
Definition: wincrypt.h:5076
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_opt_ PCCTL_CONTEXT * ppCtlContext
Definition: wincrypt.h:5080
_In_ DWORD _In_ DWORD cbCtlEncoded
Definition: wincrypt.h:5078

Referenced by testAddCTLToStore(), and testCloseStore().

◆ CertCreateCTLContext()

PCCTL_CONTEXT WINAPI CertCreateCTLContext ( DWORD  dwMsgAndCertEncodingType,
const BYTE pbCtlEncoded,
DWORD  cbCtlEncoded 
)

Definition at line 363 of file ctl.c.

365{
366 ctl_t *ctl = NULL;
368 BOOL ret;
369 BYTE *content = NULL;
370 DWORD contentSize = 0, size;
371 PCTL_INFO ctlInfo = NULL;
372
373 TRACE("(%08x, %p, %d)\n", dwMsgAndCertEncodingType, pbCtlEncoded,
375
377 {
379 return NULL;
380 }
381 if (!pbCtlEncoded || !cbCtlEncoded)
382 {
384 return NULL;
385 }
387 0, NULL, NULL);
388 if (!msg)
389 return NULL;
390 ret = CryptMsgUpdate(msg, pbCtlEncoded, cbCtlEncoded, TRUE);
391 if (!ret)
392 {
394 goto end;
395 }
396 /* Check that it's really a CTL */
398 if (ret)
399 {
400 char *innerContent = CryptMemAlloc(size);
401
402 if (innerContent)
403 {
405 innerContent, &size);
406 if (ret)
407 {
408 if (strcmp(innerContent, szOID_CTL))
409 {
411 ret = FALSE;
412 }
413 }
414 CryptMemFree(innerContent);
415 }
416 else
417 {
419 ret = FALSE;
420 }
421 }
422 if (!ret)
423 goto end;
424 ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &contentSize);
425 if (!ret)
426 goto end;
427 content = CryptMemAlloc(contentSize);
428 if (content)
429 {
431 &contentSize);
432 if (ret)
433 {
435 content, contentSize, CRYPT_DECODE_ALLOC_FLAG, NULL,
436 &ctlInfo, &size);
437 if (ret)
438 {
440 if (ctl)
441 {
443
444 if (data)
445 {
446 memcpy(data, pbCtlEncoded, cbCtlEncoded);
449 ctl->ctx.pbCtlEncoded = data;
451 ctl->ctx.pCtlInfo = ctlInfo;
452 ctl->ctx.hCertStore = &empty_store;
453 ctl->ctx.hCryptMsg = msg;
454 ctl->ctx.pbCtlContext = content;
455 ctl->ctx.cbCtlContext = contentSize;
456 }
457 else
458 {
460 ret = FALSE;
461 }
462 }
463 else
464 {
466 ret = FALSE;
467 }
468 }
469 }
470 }
471 else
472 {
474 ret = FALSE;
475 }
476
477end:
478 if (!ret)
479 {
480 if(ctl)
481 Context_Release(&ctl->base);
482 ctl = NULL;
483 LocalFree(ctlInfo);
486 return NULL;
487 }
488 return &ctl->ctx;
489}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define msg(x)
Definition: auth_time.c:54
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 E_INVALIDARG
Definition: ddrawi.h:101
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
content
Definition: atl_ax.c:994
void Context_Release(context_t *context)
Definition: context.c:106
context_t * Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl, WINECRYPT_CERTSTORE *store)
Definition: context.c:28
static const context_vtbl_t ctl_vtbl
Definition: ctl.c:58
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3552
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3626
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
WINECRYPT_CERTSTORE empty_store
Definition: store.c:1509
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD cbCtlEncoded
Definition: wincrypt.h:746
BYTE * pbCtlEncoded
Definition: wincrypt.h:745
HCRYPTMSG hCryptMsg
Definition: wincrypt.h:749
DWORD dwMsgAndCertEncodingType
Definition: wincrypt.h:744
HCERTSTORE hCertStore
Definition: wincrypt.h:748
BYTE * pbCtlContext
Definition: wincrypt.h:750
DWORD cbCtlContext
Definition: wincrypt.h:751
context_t base
CTL_CONTEXT ctx
#define GET_CERT_ENCODING_TYPE(x)
Definition: wincrypt.h:2292
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define CMSG_INNER_CONTENT_TYPE_PARAM
Definition: wincrypt.h:3928
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
#define szOID_CTL
Definition: wincrypt.h:3245
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define PKCS_CTL
Definition: wincrypt.h:3404
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
#define ERROR_INVALID_DATA
Definition: winerror.h:116
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CertAddEncodedCTLToStore(), CertCreateContext(), testCreateCTL(), testCTLProperties(), testDupCTL(), and testEmptyStore().

◆ CertDeleteCTLFromStore()

BOOL WINAPI CertDeleteCTLFromStore ( PCCTL_CONTEXT  pCtlContext)

Definition at line 341 of file ctl.c.

342{
345 BOOL ret;
346
347 TRACE("(%p)\n", pCtlContext);
348
349 if (!pCtlContext)
350 return TRUE;
351
352 hcs = pCtlContext->hCertStore;
353
355 return FALSE;
356
357 ret = hcs->vtbl->ctls.delete(hcs, &ctl->base);
358 if (ret)
360 return ret;
361}
#define WINE_CRYPTCERTSTORE_MAGIC
static ctl_t * ctl_from_ptr(const CTL_CONTEXT *ptr)
BOOL(* delete)(struct WINE_CRYPTCERTSTORE *, context_t *)

Referenced by Collection_deleteCTL().

◆ CertDuplicateCTLContext()

PCCTL_CONTEXT WINAPI CertDuplicateCTLContext ( PCCTL_CONTEXT  pCtlContext)

Definition at line 491 of file ctl.c.

492{
493 TRACE("(%p)\n", pCtlContext);
494 if (pCtlContext)
496 return pCtlContext;
497}
void Context_AddRef(context_t *context)
Definition: context.c:78

Referenced by CertAddCTLContextToStore(), and testDupCTL().

◆ CertEnumCTLContextProperties()

DWORD WINAPI CertEnumCTLContextProperties ( PCCTL_CONTEXT  pCTLContext,
DWORD  dwPropId 
)

Definition at line 508 of file ctl.c.

510{
511 ctl_t *ctl = ctl_from_ptr(pCTLContext);
512 DWORD ret;
513
514 TRACE("(%p, %d)\n", pCTLContext, dwPropId);
515
516 if (ctl->base.properties)
518 else
519 ret = 0;
520 return ret;
521}
DWORD ContextPropertyList_EnumPropIDs(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN
Definition: proplist.c:170
CONTEXT_PROPERTY_LIST * properties
_In_ DWORD dwPropId
Definition: wincrypt.h:4948

Referenced by testCTLProperties().

◆ CertEnumCTLsInStore()

PCCTL_CONTEXT WINAPI CertEnumCTLsInStore ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  pPrev 
)

Definition at line 200 of file ctl.c.

201{
202 ctl_t *prev = pPrev ? ctl_from_ptr(pPrev) : NULL, *ret;
203 WINECRYPT_CERTSTORE *hcs = hCertStore;
204
205 TRACE("(%p, %p)\n", hCertStore, pPrev);
206 if (!hCertStore)
207 ret = NULL;
208 else if (hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC)
209 ret = NULL;
210 else
211 ret = (ctl_t*)hcs->vtbl->ctls.enumContext(hcs, prev ? &prev->base : NULL);
212 return ret ? &ret->ctx : NULL;
213}
context_t *(* enumContext)(struct WINE_CRYPTCERTSTORE *store, context_t *prev)

Referenced by CertFindCTLInStore(), check_store_context_type(), import_store(), and testAddCTLToStore().

◆ CertFindCTLInStore()

PCCTL_CONTEXT WINAPI CertFindCTLInStore ( HCERTSTORE  hCertStore,
DWORD  dwCertEncodingType,
DWORD  dwFindFlags,
DWORD  dwFindType,
const void pvFindPara,
PCCTL_CONTEXT  pPrevCtlContext 
)

Definition at line 291 of file ctl.c.

294{
297
298 TRACE("(%p, %d, %d, %d, %p, %p)\n", hCertStore, dwCertEncodingType,
299 dwFindFlags, dwFindType, pvFindPara, pPrevCtlContext);
300
301 switch (dwFindType)
302 {
303 case CTL_FIND_ANY:
305 break;
308 break;
311 break;
314 break;
315 default:
316 FIXME("find type %08x unimplemented\n", dwFindType);
317 compare = NULL;
318 }
319
320 if (compare)
321 {
323
325 do {
326 ret = CertEnumCTLsInStore(hCertStore, ret);
327 if (ret)
328 matches = compare(ret, dwFindType, dwFindFlags, pvFindPara);
329 } while (ret != NULL && !matches);
330 if (!ret)
332 }
333 else
334 {
336 ret = NULL;
337 }
338 return ret;
339}
#define compare
PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(HCERTSTORE hCertStore, PCCTL_CONTEXT pPrev)
Definition: ctl.c:200
static BOOL compare_ctl_existing(PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: ctl.c:266
static BOOL compare_ctl_by_md5_hash(PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: ctl.c:224
static BOOL compare_ctl_by_sha1_hash(PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: ctl.c:245
static BOOL compare_ctl_any(PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: ctl.c:218
BOOL(* CtlCompareFunc)(PCCTL_CONTEXT pCtlContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: ctl.c:215
#define matches(FN)
Definition: match.h:70
Definition: bug.cpp:8
#define CTL_FIND_SHA1_HASH
Definition: wincrypt.h:2944
#define CTL_FIND_ANY
Definition: wincrypt.h:2943
#define CTL_FIND_MD5_HASH
Definition: wincrypt.h:2945
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5037
_In_ PCCERT_STORE_PROV_FIND_INFO _In_ PCCTL_CONTEXT pPrevCtlContext
Definition: wincrypt.h:1334
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007

Referenced by CertAddCTLContextToStore().

◆ CertFreeCTLContext()

BOOL WINAPI CertFreeCTLContext ( PCCTL_CONTEXT  pCTLContext)

Definition at line 499 of file ctl.c.

500{
501 TRACE("(%p)\n", pCTLContext);
502
503 if (pCTLContext)
504 Context_Release(&ctl_from_ptr(pCTLContext)->base);
505 return TRUE;
506}

Referenced by CertAddCTLContextToStore(), CertAddEncodedCTLToStore(), CertDeleteCTLFromStore(), check_store_context_type(), CRYPT_CreateAny(), testCloseStore(), testCreateCTL(), testCTLProperties(), testDupCTL(), and testEmptyStore().

◆ CertGetCTLContextProperty()

BOOL WINAPI CertGetCTLContextProperty ( PCCTL_CONTEXT  pCTLContext,
DWORD  dwPropId,
void pvData,
DWORD pcbData 
)

Definition at line 590 of file ctl.c.

592{
593 BOOL ret;
594
595 TRACE("(%p, %d, %p, %p)\n", pCTLContext, dwPropId, pvData, pcbData);
596
597 switch (dwPropId)
598 {
599 case 0:
601 case CERT_CRL_PROP_ID:
602 case CERT_CTL_PROP_ID:
604 ret = FALSE;
605 break;
607 if (!pvData)
608 {
609 *pcbData = sizeof(DWORD);
610 ret = TRUE;
611 }
612 else if (*pcbData < sizeof(DWORD))
613 {
615 *pcbData = sizeof(DWORD);
616 ret = FALSE;
617 }
618 else
619 {
621 }
622 break;
623 default:
625 pcbData);
626 }
627 return ret;
628}
#define CERT_CTL_PROP_ID
#define CERT_CRL_PROP_ID
#define CERT_CERT_PROP_ID
#define ERROR_MORE_DATA
Definition: dderror.h:13
static BOOL CTLContext_GetProperty(ctl_t *ctl, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: ctl.c:541
BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: store.c:1172
#define DWORD
Definition: nt_native.h:44
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2700
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4950
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749

Referenced by checkHash(), compare_ctl_by_md5_hash(), compare_ctl_by_sha1_hash(), and testCTLProperties().

◆ CertSetCTLContextProperty()

BOOL WINAPI CertSetCTLContextProperty ( PCCTL_CONTEXT  pCTLContext,
DWORD  dwPropId,
DWORD  dwFlags,
const void pvData 
)

Definition at line 685 of file ctl.c.

687{
688 BOOL ret;
689
690 TRACE("(%p, %d, %08x, %p)\n", pCTLContext, dwPropId, dwFlags, pvData);
691
692 /* Handle special cases for "read-only"/invalid prop IDs. Windows just
693 * crashes on most of these, I'll be safer.
694 */
695 switch (dwPropId)
696 {
697 case 0:
700 case CERT_CRL_PROP_ID:
701 case CERT_CTL_PROP_ID:
703 return FALSE;
704 }
706 TRACE("returning %d\n", ret);
707 return ret;
708}
static BOOL CTLContext_SetProperty(ctl_t *ctl, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: ctl.c:630
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ compare_ctl_any()

static BOOL compare_ctl_any ( PCCTL_CONTEXT  pCtlContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 218 of file ctl.c.

220{
221 return TRUE;
222}

Referenced by CertFindCTLInStore().

◆ compare_ctl_by_md5_hash()

static BOOL compare_ctl_by_md5_hash ( PCCTL_CONTEXT  pCtlContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 224 of file ctl.c.

226{
227 BOOL ret;
228 BYTE hash[16];
229 DWORD size = sizeof(hash);
230
232 &size);
233 if (ret)
234 {
235 const CRYPT_HASH_BLOB *pHash = pvPara;
236
237 if (size == pHash->cbData)
238 ret = !memcmp(pHash->pbData, hash, size);
239 else
240 ret = FALSE;
241 }
242 return ret;
243}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: ctl.c:590
BYTE * pbData
Definition: wincrypt.h:103
Definition: _hash_fun.h:40
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2689
_In_ void * pvPara
Definition: wincrypt.h:6077

Referenced by CertFindCTLInStore().

◆ compare_ctl_by_sha1_hash()

static BOOL compare_ctl_by_sha1_hash ( PCCTL_CONTEXT  pCtlContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 245 of file ctl.c.

247{
248 BOOL ret;
249 BYTE hash[20];
250 DWORD size = sizeof(hash);
251
253 &size);
254 if (ret)
255 {
256 const CRYPT_HASH_BLOB *pHash = pvPara;
257
258 if (size == pHash->cbData)
259 ret = !memcmp(pHash->pbData, hash, size);
260 else
261 ret = FALSE;
262 }
263 return ret;
264}
#define CERT_SHA1_HASH_PROP_ID
Definition: wincrypt.h:2687

Referenced by CertFindCTLInStore().

◆ compare_ctl_existing()

static BOOL compare_ctl_existing ( PCCTL_CONTEXT  pCtlContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 266 of file ctl.c.

268{
269 BOOL ret;
270
271 if (pvPara)
272 {
273 PCCTL_CONTEXT ctl = pvPara;
274
276 {
277 if (ctl->cbCtlContext)
279 ctl->cbCtlContext);
280 else
281 ret = TRUE;
282 }
283 else
284 ret = FALSE;
285 }
286 else
287 ret = FALSE;
288 return ret;
289}

Referenced by CertFindCTLInStore().

◆ CTL_clone()

static context_t * CTL_clone ( context_t context,
WINECRYPT_CERTSTORE store,
BOOL  use_link 
)
static

Definition at line 41 of file ctl.c.

42{
43 ctl_t *ctl;
44
45 if(!use_link) {
46 FIXME("Only links supported\n");
47 return NULL;
48 }
49
50 ctl = (ctl_t*)Context_CreateLinkContext(sizeof(CTL_CONTEXT), context, store);
51 if(!ctl)
52 return NULL;
53
54 ctl->ctx.hCertStore = store;
55 return &ctl->base;
56}
context_t * Context_CreateLinkContext(unsigned int contextSize, context_t *linked, WINECRYPT_CERTSTORE *store)
Definition: context.c:54
Definition: http.c:7252

◆ CTL_free()

static void CTL_free ( context_t context)
static

Definition at line 31 of file ctl.c.

32{
33 ctl_t *ctl = (ctl_t*)context;
34
39}

◆ CTLContext_GetHashProp()

static BOOL CTLContext_GetHashProp ( ctl_t ctl,
DWORD  dwPropId,
ALG_ID  algID,
const BYTE toHash,
DWORD  toHashLen,
void pvData,
DWORD pcbData 
)
static

Definition at line 526 of file ctl.c.

529{
530 BOOL ret = CryptHashCertificate(0, algID, 0, toHash, toHashLen, pvData,
531 pcbData);
532 if (ret && pvData)
533 {
535
537 }
538 return ret;
539}
BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2187
Definition: image.c:134

Referenced by CTLContext_GetProperty().

◆ CTLContext_GetProperty()

static BOOL CTLContext_GetProperty ( ctl_t ctl,
DWORD  dwPropId,
void pvData,
DWORD pcbData 
)
static

Definition at line 541 of file ctl.c.

543{
544 BOOL ret;
546
547 TRACE("(%p, %d, %p, %p)\n", ctl, dwPropId, pvData, pcbData);
548
549 if (ctl->base.properties)
551 else
552 ret = FALSE;
553 if (ret)
554 {
555 if (!pvData)
556 *pcbData = blob.cbData;
557 else if (*pcbData < blob.cbData)
558 {
560 *pcbData = blob.cbData;
561 ret = FALSE;
562 }
563 else
564 {
565 memcpy(pvData, blob.pbData, blob.cbData);
566 *pcbData = blob.cbData;
567 }
568 }
569 else
570 {
571 /* Implicit properties */
572 switch (dwPropId)
573 {
577 break;
581 break;
582 default:
584 }
585 }
586 TRACE("returning %d\n", ret);
587 return ret;
588}
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
static BOOL CTLContext_GetHashProp(ctl_t *ctl, DWORD dwPropId, ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData, DWORD *pcbData)
Definition: ctl.c:526
#define CALG_SHA1
Definition: wincrypt.h:1807
#define CALG_MD5
Definition: wincrypt.h:1805

Referenced by CertGetCTLContextProperty().

◆ CTLContext_SetProperty()

static BOOL CTLContext_SetProperty ( ctl_t ctl,
DWORD  dwPropId,
DWORD  dwFlags,
const void pvData 
)
static

Definition at line 630 of file ctl.c.

632{
633 BOOL ret;
634
635 TRACE("(%p, %d, %08x, %p)\n", ctl, dwPropId, dwFlags, pvData);
636
637 if (!ctl->base.properties)
638 ret = FALSE;
639 else if (!pvData)
640 {
642 ret = TRUE;
643 }
644 else
645 {
646 switch (dwPropId)
647 {
649 case CERT_CTL_USAGE_PROP_ID: /* same as CERT_ENHKEY_USAGE_PROP_ID */
665 {
667
669 blob->pbData, blob->cbData);
670 break;
671 }
674 pvData, sizeof(FILETIME));
675 break;
676 default:
677 FIXME("%d: stub\n", dwPropId);
678 ret = FALSE;
679 }
680 }
681 TRACE("returning %d\n", ret);
682 return ret;
683}
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
void ContextPropertyList_RemoveProperty(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN
Definition: proplist.c:149
#define CERT_PVK_FILE_PROP_ID
Definition: wincrypt.h:2698
#define CERT_CROSS_CERT_DIST_POINTS_PROP_ID
Definition: wincrypt.h:2709
#define CERT_ENROLLMENT_PROP_ID
Definition: wincrypt.h:2712
#define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2710
#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2711
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2706
#define CERT_DESCRIPTION_PROP_ID
Definition: wincrypt.h:2699
struct _CRYPTOAPI_BLOB * PCRYPT_DATA_BLOB
#define CERT_NEXT_UPDATE_LOCATION_PROP_ID
Definition: wincrypt.h:2696
#define CERT_PUBKEY_ALG_PARA_PROP_ID
Definition: wincrypt.h:2708
#define CERT_AUTO_ENROLL_PROP_ID
Definition: wincrypt.h:2707
#define CERT_FRIENDLY_NAME_PROP_ID
Definition: wincrypt.h:2697
#define CERT_CTL_USAGE_PROP_ID
Definition: wincrypt.h:2695
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2688
#define CERT_RENEWAL_PROP_ID
Definition: wincrypt.h:2724
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2701
#define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID
Definition: wincrypt.h:2715
#define CERT_DATE_STAMP_PROP_ID
Definition: wincrypt.h:2713

Referenced by CertSetCTLContextProperty(), and CTLContext_GetHashProp().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ ctl_vtbl

const context_vtbl_t ctl_vtbl
static
Initial value:
= {
}
static context_t * CTL_clone(context_t *context, WINECRYPT_CERTSTORE *store, BOOL use_link)
Definition: ctl.c:41
static void CTL_free(context_t *context)
Definition: ctl.c:31

Definition at line 58 of file ctl.c.

Referenced by CertCreateCTLContext().