ReactOS 0.4.17-dev-470-gf9e3448
serialize.c
Go to the documentation of this file.
1/*
2 * Copyright 2004-2007 Juan Lang
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include <stdarg.h>
20#include "windef.h"
21#include "winbase.h"
22#include "wincrypt.h"
23#include "wine/debug.h"
24#include "wine/exception.h"
25#include "crypt32_private.h"
26
28
29/* An extended certificate property in serialized form is prefixed by this
30 * header.
31 */
33{
35 DWORD unknown; /* always 1 */
38
40{
48};
49
51{
56};
57
59{
60 struct store_CRYPT_KEY_PROV_INFO *store;
62 DWORD size = sizeof(struct store_CRYPT_KEY_PROV_INFO), i;
63 BYTE *data;
64
65 if (info->pwszContainerName)
66 size += (lstrlenW(info->pwszContainerName) + 1) * sizeof(WCHAR);
67 if (info->pwszProvName)
68 size += (lstrlenW(info->pwszProvName) + 1) * sizeof(WCHAR);
69
70 for (i = 0; i < info->cProvParam; i++)
71 size += sizeof(struct store_CRYPT_KEY_PROV_PARAM) + info->rgProvParam[i].cbData;
72
73 if (!ret) return size;
74
75 store = CryptMemAlloc(size);
76 if (!store) return 0;
77
78 param = (struct store_CRYPT_KEY_PROV_PARAM *)(store + 1);
79 data = (BYTE *)param + sizeof(struct store_CRYPT_KEY_PROV_PARAM) * info->cProvParam;
80
81 if (info->pwszContainerName)
82 {
83 store->pwszContainerName = data - (BYTE *)store;
84 lstrcpyW((LPWSTR)data, info->pwszContainerName);
85 data += (lstrlenW(info->pwszContainerName) + 1) * sizeof(WCHAR);
86 }
87 else
88 store->pwszContainerName = 0;
89
90 if (info->pwszProvName)
91 {
92 store->pwszProvName = data - (BYTE *)store;
93 lstrcpyW((LPWSTR)data, info->pwszProvName);
94 data += (lstrlenW(info->pwszProvName) + 1) * sizeof(WCHAR);
95 }
96 else
97 store->pwszProvName = 0;
98
99 store->dwProvType = info->dwProvType;
100 store->dwFlags = info->dwFlags;
101 store->cProvParam = info->cProvParam;
102 store->rgProvParam = info->cProvParam ? (BYTE *)param - (BYTE *)store : 0;
103 store->dwKeySpec = info->dwKeySpec;
104
105 for (i = 0; i < info->cProvParam; i++)
106 {
107 param[i].dwParam = info->rgProvParam[i].dwParam;
108 param[i].dwFlags = info->rgProvParam[i].dwFlags;
109 param[i].cbData = info->rgProvParam[i].cbData;
110 param[i].pbData = param[i].cbData ? data - (BYTE *)store : 0;
111 memcpy(data, info->rgProvParam[i].pbData, info->rgProvParam[i].cbData);
112 data += info->rgProvParam[i].cbData;
113 }
114
115 *ret = store;
116 return size;
117}
118
120 const BYTE *encodedContext, DWORD cbEncodedContext, DWORD contextPropID,
121 const WINE_CONTEXT_INTERFACE *contextInterface, DWORD dwFlags, BOOL omitHashes,
122 BYTE *pbElement, DWORD *pcbElement)
123{
124 BOOL ret;
125
126 TRACE("(%p, %p, %08lx, %d, %p, %p)\n", context, contextInterface, dwFlags,
127 omitHashes, pbElement, pcbElement);
128
129 if (context)
130 {
131 DWORD bytesNeeded = sizeof(WINE_CERT_PROP_HEADER) + cbEncodedContext;
132 DWORD prop = 0;
133
134 ret = TRUE;
135 do {
136 prop = contextInterface->enumProps(context, prop);
137 if (prop && (!omitHashes || !IS_CERT_HASH_PROP_ID(prop)))
138 {
139 DWORD propSize = 0;
140
141 ret = contextInterface->getProp(context, prop, NULL, &propSize);
142 if (ret)
143 {
144 if (prop == CERT_KEY_PROV_INFO_PROP_ID)
145 {
146 BYTE *info = CryptMemAlloc(propSize);
147 contextInterface->getProp(context, prop, info, &propSize);
150 }
151 bytesNeeded += sizeof(WINE_CERT_PROP_HEADER) + propSize;
152 }
153 }
154 } while (ret && prop != 0);
155
156 if (!pbElement)
157 {
158 *pcbElement = bytesNeeded;
159 ret = TRUE;
160 }
161 else if (*pcbElement < bytesNeeded)
162 {
163 *pcbElement = bytesNeeded;
165 ret = FALSE;
166 }
167 else
168 {
170 DWORD bufSize = 0;
171 LPBYTE buf = NULL;
172
173 prop = 0;
174 do {
175 prop = contextInterface->enumProps(context, prop);
176 if (prop && (!omitHashes || !IS_CERT_HASH_PROP_ID(prop)))
177 {
178 DWORD propSize = 0;
179
180 ret = contextInterface->getProp(context, prop, NULL,
181 &propSize);
182 if (ret)
183 {
184 if (bufSize < propSize)
185 {
186 if (buf)
187 buf = CryptMemRealloc(buf, propSize);
188 else
189 buf = CryptMemAlloc(propSize);
190 bufSize = propSize;
191 }
192 if (buf)
193 {
194 ret = contextInterface->getProp(context, prop, buf,
195 &propSize);
196 if (ret)
197 {
198 if (prop == CERT_KEY_PROV_INFO_PROP_ID)
199 {
200 struct store_CRYPT_KEY_PROV_INFO *store;
201 propSize = serialize_KeyProvInfoProperty((const CRYPT_KEY_PROV_INFO *)buf, &store);
203 buf = (BYTE *)store;
204 }
205
206 hdr = (WINE_CERT_PROP_HEADER*)pbElement;
207 hdr->propID = prop;
208 hdr->unknown = 1;
209 hdr->cb = propSize;
210 pbElement += sizeof(WINE_CERT_PROP_HEADER);
211 if (propSize)
212 {
213 memcpy(pbElement, buf, propSize);
214 pbElement += propSize;
215 }
216 }
217 }
218 else
219 ret = FALSE;
220 }
221 }
222 } while (ret && prop != 0);
224
225 hdr = (WINE_CERT_PROP_HEADER*)pbElement;
226 hdr->propID = contextPropID;
227 hdr->unknown = 1;
228 hdr->cb = cbEncodedContext;
229 memcpy(pbElement + sizeof(WINE_CERT_PROP_HEADER),
230 encodedContext, cbEncodedContext);
231 }
232 }
233 else
234 ret = FALSE;
235 return ret;
236}
237
239 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
240{
241 return CRYPT_SerializeStoreElement(pCertContext,
242 pCertContext->pbCertEncoded, pCertContext->cbCertEncoded,
243 CERT_CERT_PROP_ID, pCertInterface, dwFlags, FALSE, pbElement, pcbElement);
244}
245
247 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
248{
249 return CRYPT_SerializeStoreElement(pCrlContext,
250 pCrlContext->pbCrlEncoded, pCrlContext->cbCrlEncoded,
251 CERT_CRL_PROP_ID, pCRLInterface, dwFlags, FALSE, pbElement, pcbElement);
252}
253
255 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
256{
257 return CRYPT_SerializeStoreElement(pCtlContext,
258 pCtlContext->pbCtlEncoded, pCtlContext->cbCtlEncoded,
259 CERT_CTL_PROP_ID, pCTLInterface, dwFlags, FALSE, pbElement, pcbElement);
260}
261
262/* Looks for the property with ID propID in the buffer buf. Returns a pointer
263 * to its header if a valid header is found, NULL if not. Valid means the
264 * length of the property won't overrun buf, and the unknown field is 1.
265 */
267 DWORD size, DWORD propID)
268{
270 BOOL done = FALSE;
271
272 while (size && !ret && !done)
273 {
274 if (size < sizeof(WINE_CERT_PROP_HEADER))
275 {
277 done = TRUE;
278 }
279 else
280 {
282 (const WINE_CERT_PROP_HEADER *)buf;
283
284 size -= sizeof(WINE_CERT_PROP_HEADER);
285 buf += sizeof(WINE_CERT_PROP_HEADER);
286 if (size < hdr->cb)
287 {
289 done = TRUE;
290 }
291 else if (!hdr->propID)
292 {
293 /* assume a zero prop ID means the data are uninitialized, so
294 * stop looking.
295 */
296 done = TRUE;
297 }
298 else if (hdr->unknown != 1)
299 {
301 done = TRUE;
302 }
303 else if (hdr->propID == propID)
304 ret = hdr;
305 else
306 {
307 buf += hdr->cb;
308 size -= hdr->cb;
309 }
310 }
311 }
312 return ret;
313}
314
316{
317 const struct store_CRYPT_KEY_PROV_PARAM *param;
319 DWORD size = sizeof(CRYPT_KEY_PROV_INFO), i;
320 const BYTE *base;
321 BYTE *data;
322
323 base = (const BYTE *)store;
324 param = (const struct store_CRYPT_KEY_PROV_PARAM *)(base + store->rgProvParam);
325
326 if (store->pwszContainerName)
327 size += (lstrlenW((LPCWSTR)(base + store->pwszContainerName)) + 1) * sizeof(WCHAR);
328 if (store->pwszProvName)
329 size += (lstrlenW((LPCWSTR)(base + store->pwszProvName)) + 1) * sizeof(WCHAR);
330
331 for (i = 0; i < store->cProvParam; i++)
332 size += sizeof(CRYPT_KEY_PROV_PARAM) + param[i].cbData;
333
335 if (!info)
336 {
338 return 0;
339 }
340
341 data = (BYTE *)(info + 1) + sizeof(CRYPT_KEY_PROV_PARAM) * store->cProvParam;
342
343 if (store->pwszContainerName)
344 {
345 info->pwszContainerName = (LPWSTR)data;
346 lstrcpyW(info->pwszContainerName, (LPCWSTR)((const BYTE *)store + store->pwszContainerName));
347 data += (lstrlenW(info->pwszContainerName) + 1) * sizeof(WCHAR);
348 }
349 else
350 info->pwszContainerName = NULL;
351
352 if (store->pwszProvName)
353 {
354 info->pwszProvName = (LPWSTR)data;
355 lstrcpyW(info->pwszProvName, (LPCWSTR)((const BYTE *)store + store->pwszProvName));
356 data += (lstrlenW(info->pwszProvName) + 1) * sizeof(WCHAR);
357 }
358 else
359 info->pwszProvName = NULL;
360
361 info->dwProvType = store->dwProvType;
362 info->dwFlags = store->dwFlags;
363 info->dwKeySpec = store->dwKeySpec;
364 info->cProvParam = store->cProvParam;
365
366 if (info->cProvParam)
367 {
368 DWORD i;
369
370 info->rgProvParam = (CRYPT_KEY_PROV_PARAM *)(info + 1);
371
372 for (i = 0; i < info->cProvParam; i++)
373 {
374 info->rgProvParam[i].dwParam = param[i].dwParam;
375 info->rgProvParam[i].dwFlags = param[i].dwFlags;
376 info->rgProvParam[i].cbData = param[i].cbData;
377 info->rgProvParam[i].pbData = param[i].cbData ? data : NULL;
378 memcpy(info->rgProvParam[i].pbData, base + param[i].pbData, param[i].cbData);
379 data += param[i].cbData;
380 }
381 }
382 else
383 info->rgProvParam = NULL;
384
385 TRACE("%s,%s,%lu,%08lx,%lu,%p,%lu\n", debugstr_w(info->pwszContainerName), debugstr_w(info->pwszProvName),
386 info->dwProvType, info->dwFlags, info->cProvParam, info->rgProvParam, info->dwKeySpec);
387
388 *ret = info;
389 return size;
390}
391
393 const WINE_CONTEXT_INTERFACE *contextInterface, const void *context,
394 const WINE_CERT_PROP_HEADER *hdr, const BYTE *pbElement, DWORD cbElement)
395{
396 BOOL ret;
397
398 if (cbElement < hdr->cb)
399 {
401 ret = FALSE;
402 }
403 else if (hdr->unknown != 1)
404 {
406 ret = FALSE;
407 }
408 else if (hdr->propID >= CERT_FIRST_USER_PROP_ID && hdr->propID <= CERT_LAST_USER_PROP_ID)
409 {
410 CRYPT_DATA_BLOB blob = { hdr->cb, (LPBYTE)pbElement };
411
412 ret = contextInterface->setProp(context, hdr->propID, 0, &blob);
413 }
414 else if (hdr->propID != CERT_CERT_PROP_ID &&
415 hdr->propID != CERT_CRL_PROP_ID && hdr->propID != CERT_CTL_PROP_ID)
416 {
417 /* Have to create a blob for most types, but not
418 * for all.. arghh.
419 */
420 switch (hdr->propID)
421 {
438 {
439 CRYPT_DATA_BLOB blob = { hdr->cb,
440 (LPBYTE)pbElement };
441
442 ret = contextInterface->setProp(context,
443 hdr->propID, 0, &blob);
444 break;
445 }
447 ret = contextInterface->setProp(context,
448 hdr->propID, 0, pbElement);
449 break;
451 {
453
455 {
456 ret = contextInterface->setProp(context, hdr->propID, 0, info);
458 }
459 else
460 ret = FALSE;
461 break;
462 }
464 {
467 ret = contextInterface->setProp(context, hdr->propID, 0, &ctx);
468 break;
469 }
470 default:
471 ret = FALSE;
472 }
473 }
474 else
475 {
476 /* ignore the context itself */
477 ret = TRUE;
478 }
479 return ret;
480}
481
482const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement,
483 DWORD dwContextTypeFlags, DWORD *pdwContentType)
484{
485 const void *context;
486
487 TRACE("(%p, %ld, %08lx, %p)\n", pbElement, cbElement, dwContextTypeFlags,
488 pdwContentType);
489
490 if (!cbElement)
491 {
493 return NULL;
494 }
495
496 __TRY
497 {
498 const WINE_CONTEXT_INTERFACE *contextInterface = NULL;
500 DWORD type = 0;
501 BOOL ret;
502
503 ret = TRUE;
504 context = NULL;
505 if (dwContextTypeFlags == CERT_STORE_ALL_CONTEXT_FLAG)
506 {
507 hdr = CRYPT_findPropID(pbElement, cbElement, CERT_CERT_PROP_ID);
508 if (hdr)
510 else
511 {
512 hdr = CRYPT_findPropID(pbElement, cbElement, CERT_CRL_PROP_ID);
513 if (hdr)
515 else
516 {
517 hdr = CRYPT_findPropID(pbElement, cbElement,
519 if (hdr)
521 }
522 }
523 }
524 else if (dwContextTypeFlags & CERT_STORE_CERTIFICATE_CONTEXT_FLAG)
525 {
526 hdr = CRYPT_findPropID(pbElement, cbElement, CERT_CERT_PROP_ID);
528 }
529 else if (dwContextTypeFlags & CERT_STORE_CRL_CONTEXT_FLAG)
530 {
531 hdr = CRYPT_findPropID(pbElement, cbElement, CERT_CRL_PROP_ID);
533 }
534 else if (dwContextTypeFlags & CERT_STORE_CTL_CONTEXT_FLAG)
535 {
536 hdr = CRYPT_findPropID(pbElement, cbElement, CERT_CTL_PROP_ID);
538 }
539
540 switch (type)
541 {
543 contextInterface = pCertInterface;
544 break;
546 contextInterface = pCRLInterface;
547 break;
549 contextInterface = pCTLInterface;
550 break;
551 default:
553 ret = FALSE;
554 }
555 if (!hdr)
556 ret = FALSE;
557
558 if (ret)
559 context = contextInterface->create(X509_ASN_ENCODING,
560 (BYTE *)hdr + sizeof(WINE_CERT_PROP_HEADER), hdr->cb);
561 if (ret && context)
562 {
563 BOOL noMoreProps = FALSE;
564
565 while (!noMoreProps && ret)
566 {
567 if (cbElement < sizeof(WINE_CERT_PROP_HEADER))
568 ret = FALSE;
569 else
570 {
572 (const WINE_CERT_PROP_HEADER *)pbElement;
573
574 TRACE("prop is %ld\n", hdr->propID);
575 cbElement -= sizeof(WINE_CERT_PROP_HEADER);
576 pbElement += sizeof(WINE_CERT_PROP_HEADER);
577 if (!hdr->propID)
578 {
579 /* Like in CRYPT_findPropID, stop if the propID is zero
580 */
581 noMoreProps = TRUE;
582 }
583 else
584 ret = CRYPT_ReadContextProp(contextInterface, context,
585 hdr, pbElement, cbElement);
586 pbElement += hdr->cb;
587 cbElement -= hdr->cb;
588 if (!cbElement)
589 noMoreProps = TRUE;
590 }
591 }
592 if (ret)
593 {
594 if (pdwContentType)
595 *pdwContentType = type;
596 }
597 else
598 {
600 context = NULL;
601 }
602 }
603 }
605 {
607 context = NULL;
608 }
610 return context;
611}
612
613static const BYTE fileHeader[] = { 0, 0, 0, 0, 'C','E','R','T' };
614
615typedef BOOL (*read_serialized_func)(void *handle, void *buffer,
616 DWORD bytesToRead, DWORD *bytesRead);
617
619 read_serialized_func read_func, HCERTSTORE store)
620{
621 BYTE fileHeaderBuf[sizeof(fileHeader)];
622 DWORD read;
623 BOOL ret;
624
625 /* Failure reading is non-critical, we'll leave the store empty */
626 ret = read_func(handle, fileHeaderBuf, sizeof(fileHeaderBuf), &read);
627 if (ret)
628 {
629 if (!read)
630 ; /* an empty file is okay */
631 else if (read != sizeof(fileHeaderBuf))
632 ret = FALSE;
633 else if (!memcmp(fileHeaderBuf, fileHeader, read))
634 {
635 WINE_CERT_PROP_HEADER propHdr;
636 const void *context = NULL;
637 const WINE_CONTEXT_INTERFACE *contextInterface = NULL;
638 LPBYTE buf = NULL;
639 DWORD bufSize = 0;
640
641 do {
642 ret = read_func(handle, &propHdr, sizeof(propHdr), &read);
643 if (ret && read == sizeof(propHdr))
644 {
645 if (contextInterface && context &&
646 (propHdr.propID == CERT_CERT_PROP_ID ||
647 propHdr.propID == CERT_CRL_PROP_ID ||
648 propHdr.propID == CERT_CTL_PROP_ID))
649 {
650 /* We have a new context, so free the existing one */
652 }
653 if (propHdr.cb > bufSize)
654 {
655 /* Not reusing realloc, because the old data aren't
656 * needed any longer.
657 */
659 buf = CryptMemAlloc(propHdr.cb);
660 bufSize = propHdr.cb;
661 }
662 if (!propHdr.cb)
663 ; /* Property is empty, nothing to do */
664 else if (buf)
665 {
666 ret = read_func(handle, buf, propHdr.cb, &read);
667 if (ret && read == propHdr.cb)
668 {
669 if (propHdr.propID == CERT_CERT_PROP_ID)
670 {
671 contextInterface = pCertInterface;
672 ret = contextInterface->addEncodedToStore(store,
675 }
676 else if (propHdr.propID == CERT_CRL_PROP_ID)
677 {
678 contextInterface = pCRLInterface;
679 ret = contextInterface->addEncodedToStore(store,
682 }
683 else if (propHdr.propID == CERT_CTL_PROP_ID)
684 {
685 contextInterface = pCTLInterface;
686 ret = contextInterface->addEncodedToStore(store,
689 }
690 else
691 {
692 if (!contextInterface)
693 {
694 WARN("prop id %ld before a context id\n",
695 propHdr.propID);
696 ret = FALSE;
697 }
698 else
700 contextInterface, context, &propHdr, buf,
701 read);
702 }
703 }
704 }
705 else
706 ret = FALSE;
707 }
708 } while (ret && read > 0 && propHdr.cb);
709 if (contextInterface && context)
710 {
711 /* Free the last context added */
713 }
715 ret = TRUE;
716 }
717 else
718 ret = FALSE;
719 }
720 else
721 ret = TRUE;
722 return ret;
723}
724
725static BOOL read_file_wrapper(void *handle, void *buffer, DWORD bytesToRead,
726 DWORD *bytesRead)
727{
728 return ReadFile(handle, buffer, bytesToRead, bytesRead, NULL);
729}
730
732{
734}
735
737{
740};
741
742static BOOL read_blob_wrapper(void *handle, void *buffer, DWORD bytesToRead,
743 DWORD *bytesRead)
744{
745 struct BlobReader *reader = handle;
746 BOOL ret;
747
748 if (reader->current < reader->blob->cbData)
749 {
750 *bytesRead = min(bytesToRead, reader->blob->cbData - reader->current);
751 memcpy(buffer, reader->blob->pbData + reader->current, *bytesRead);
752 reader->current += *bytesRead;
753 ret = TRUE;
754 }
755 else if (reader->current == reader->blob->cbData)
756 {
757 *bytesRead = 0;
758 ret = TRUE;
759 }
760 else
761 ret = FALSE;
762 return ret;
763}
764
766 HCERTSTORE store)
767{
768 struct BlobReader reader = { blob, 0 };
769
771}
772
774 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
775{
776 return CRYPT_SerializeStoreElement(pCertContext,
777 pCertContext->pbCertEncoded, pCertContext->cbCertEncoded,
778 CERT_CERT_PROP_ID, pCertInterface, dwFlags, TRUE, pbElement, pcbElement);
779}
780
782 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
783{
784 return CRYPT_SerializeStoreElement(pCrlContext,
785 pCrlContext->pbCrlEncoded, pCrlContext->cbCrlEncoded,
786 CERT_CRL_PROP_ID, pCRLInterface, dwFlags, TRUE, pbElement, pcbElement);
787}
788
790 DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
791{
792 return CRYPT_SerializeStoreElement(pCtlContext,
793 pCtlContext->pbCtlEncoded, pCtlContext->cbCtlEncoded,
794 CERT_CTL_PROP_ID, pCTLInterface, dwFlags, TRUE, pbElement, pcbElement);
795}
796
797typedef BOOL (*SerializedOutputFunc)(void *handle, const void *buffer,
798 DWORD size);
799
801 void *handle, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE store)
802{
803 const void *context = NULL;
804 BOOL ret;
805
806 do {
807 context = contextInterface->enumContextsInStore(store, context);
808 if (context)
809 {
810 DWORD size = 0;
811 LPBYTE buf = NULL;
812
813 ret = contextInterface->serialize(context, 0, NULL, &size);
814 if (size)
816 if (buf)
817 {
818 ret = contextInterface->serialize(context, 0, buf, &size);
819 if (ret)
820 ret = output(handle, buf, size);
821 }
823 }
824 else
825 ret = TRUE;
826 } while (ret && context != NULL);
827 if (context)
829 return ret;
830}
831
833 SerializedOutputFunc output, void *handle)
834{
835 static const BYTE fileTrailer[12] = { 0 };
837 BOOL ret;
838
839 ret = output(handle, fileHeader, sizeof(fileHeader));
840 if (ret)
841 {
842 interface = *pCertInterface;
845 store);
846 }
847 if (ret)
848 {
849 interface = *pCRLInterface;
852 store);
853 }
854 if (ret)
855 {
856 interface = *pCTLInterface;
859 store);
860 }
861 if (ret)
862 ret = output(handle, fileTrailer, sizeof(fileTrailer));
863 return ret;
864}
865
866static BOOL CRYPT_FileOutputFunc(void *handle, const void *buffer, DWORD size)
867{
868 return WriteFile(handle, buffer, size, &size, NULL);
869}
870
872{
875 file);
876}
877
879 DWORD dwMsgAndCertEncodingType, void *handle)
880{
882 CRYPT_SIGNED_INFO signedInfo = { 0 };
885 DWORD size;
886 BOOL ret = TRUE;
887
888 TRACE("(%ld, %p)\n", blob->pbData ? blob->cbData : 0, blob->pbData);
889
890 do {
892 if (cert)
893 signedInfo.cCertEncoded++;
894 } while (cert);
895 if (signedInfo.cCertEncoded)
896 {
897 signedInfo.rgCertEncoded = CryptMemAlloc(
898 signedInfo.cCertEncoded * sizeof(CERT_BLOB));
899 if (!signedInfo.rgCertEncoded)
900 {
902 ret = FALSE;
903 }
904 else
905 {
906 DWORD i = 0;
907
908 do {
910 if (cert)
911 {
912 signedInfo.rgCertEncoded[i].cbData = cert->cbCertEncoded;
913 signedInfo.rgCertEncoded[i].pbData = cert->pbCertEncoded;
914 i++;
915 }
916 } while (cert);
917 }
918 }
919
920 do {
921 crl = CertEnumCRLsInStore(store, crl);
922 if (crl)
923 signedInfo.cCrlEncoded++;
924 } while (crl);
925 if (signedInfo.cCrlEncoded)
926 {
927 signedInfo.rgCrlEncoded = CryptMemAlloc(
928 signedInfo.cCrlEncoded * sizeof(CERT_BLOB));
929 if (!signedInfo.rgCrlEncoded)
930 {
932 ret = FALSE;
933 }
934 else
935 {
936 DWORD i = 0;
937
938 do {
939 crl = CertEnumCRLsInStore(store, crl);
940 if (crl)
941 {
942 signedInfo.rgCrlEncoded[i].cbData = crl->cbCrlEncoded;
943 signedInfo.rgCrlEncoded[i].pbData = crl->pbCrlEncoded;
944 i++;
945 }
946 } while (crl);
947 }
948 }
949 if (ret)
950 {
951 ret = CRYPT_AsnEncodeCMSSignedInfo(&signedInfo, NULL, &size);
952 if (ret)
953 {
954 if (!blob->pbData)
955 blob->cbData = size;
956 else if (blob->cbData < size)
957 {
958 blob->cbData = size;
960 ret = FALSE;
961 }
962 else
963 {
964 blob->cbData = size;
965 ret = CRYPT_AsnEncodeCMSSignedInfo(&signedInfo, blob->pbData,
966 &blob->cbData);
967 }
968 }
969 }
970 CryptMemFree(signedInfo.rgCertEncoded);
971 CryptMemFree(signedInfo.rgCrlEncoded);
972 TRACE("returning %d\n", ret);
973 return ret;
974}
975
977 DWORD dwMsgAndCertEncodingType, void *handle)
978{
979 CERT_BLOB blob = { 0, NULL };
980 BOOL ret;
981
982 TRACE("(%p)\n", handle);
983
984 ret = CRYPT_SavePKCSToMem(store, dwMsgAndCertEncodingType, &blob);
985 if (ret)
986 {
987 blob.pbData = CryptMemAlloc(blob.cbData);
988 if (blob.pbData)
989 {
990 ret = CRYPT_SavePKCSToMem(store, dwMsgAndCertEncodingType, &blob);
991 if (ret)
992 ret = WriteFile(handle, blob.pbData, blob.cbData,
993 &blob.cbData, NULL);
994 }
995 else
996 {
998 ret = FALSE;
999 }
1000 }
1001 TRACE("returning %d\n", ret);
1002 return ret;
1003}
1004
1006 DWORD dwMsgAndCertEncodingType, void *handle)
1007{
1009}
1010
1012{
1016};
1017
1018/* handle is a pointer to a MemWrittenTracker. Assumes its pointer is valid. */
1019static BOOL CRYPT_MemOutputFunc(void *handle, const void *buffer, DWORD size)
1020{
1021 struct MemWrittenTracker *tracker = handle;
1022 BOOL ret;
1023
1024 if (tracker->written + size > tracker->cbData)
1025 {
1027 /* Update written so caller can notify its caller of the required size
1028 */
1029 tracker->written += size;
1030 ret = FALSE;
1031 }
1032 else
1033 {
1034 memcpy(tracker->pbData + tracker->written, buffer, size);
1035 tracker->written += size;
1036 ret = TRUE;
1037 }
1038 return ret;
1039}
1040
1042 DWORD size)
1043{
1044 *(DWORD *)handle += size;
1045 return TRUE;
1046}
1047
1049 DWORD dwMsgAndCertEncodingType, void *handle)
1050{
1052 DWORD size = 0;
1053 BOOL ret;
1054
1056 &size);
1057 if (ret)
1058 {
1059 if (!blob->pbData)
1060 blob->cbData = size;
1061 else if (blob->cbData < size)
1062 {
1064 blob->cbData = size;
1065 ret = FALSE;
1066 }
1067 else
1068 {
1069 struct MemWrittenTracker tracker = { blob->cbData, blob->pbData,
1070 0 };
1071
1073 &tracker);
1074 if (!ret && GetLastError() == ERROR_MORE_DATA)
1075 blob->cbData = tracker.written;
1076 }
1077 }
1078 TRACE("returning %d\n", ret);
1079 return ret;
1080}
1081
1082BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType,
1083 DWORD dwSaveAs, DWORD dwSaveTo, void *pvSaveToPara, DWORD dwFlags)
1084{
1085 BOOL (*saveFunc)(HCERTSTORE, DWORD, void *);
1086 void *handle;
1087 BOOL ret, closeFile = TRUE;
1088
1089 TRACE("(%p, %08lx, %ld, %ld, %p, %08lx)\n", hCertStore,
1090 dwMsgAndCertEncodingType, dwSaveAs, dwSaveTo, pvSaveToPara, dwFlags);
1091
1092 switch (dwSaveAs)
1093 {
1095 if (dwSaveTo == CERT_STORE_SAVE_TO_MEMORY)
1096 saveFunc = CRYPT_SaveSerializedToMem;
1097 else
1098 saveFunc = CRYPT_SaveSerializedToFile;
1099 break;
1101 if (dwSaveTo == CERT_STORE_SAVE_TO_MEMORY)
1102 saveFunc = CRYPT_SavePKCSToMem;
1103 else
1104 saveFunc = CRYPT_SavePKCSToFile;
1105 break;
1106 default:
1107 WARN("unimplemented for %ld\n", dwSaveAs);
1109 return FALSE;
1110 }
1111 switch (dwSaveTo)
1112 {
1114 handle = pvSaveToPara;
1115 closeFile = FALSE;
1116 break;
1118 handle = CreateFileA(pvSaveToPara, GENERIC_WRITE, 0, NULL,
1119 CREATE_ALWAYS, 0, NULL);
1120 break;
1122 handle = CreateFileW(pvSaveToPara, GENERIC_WRITE, 0, NULL,
1123 CREATE_ALWAYS, 0, NULL);
1124 break;
1126 handle = pvSaveToPara;
1127 break;
1128 default:
1129 WARN("unimplemented for %ld\n", dwSaveTo);
1131 return FALSE;
1132 }
1133 ret = saveFunc(hCertStore, dwMsgAndCertEncodingType, handle);
1134 if (closeFile)
1136 TRACE("returning %d\n", ret);
1137 return ret;
1138}
1139
1141 const BYTE *pbElement, DWORD cbElement, DWORD dwAddDisposition, DWORD dwFlags,
1142 DWORD dwContextTypeFlags, DWORD *pdwContentType, const void **ppvContext)
1143{
1144 const void *context;
1145 DWORD type;
1146 BOOL ret;
1147
1148 TRACE("(%p, %p, %ld, %08lx, %08lx, %08lx, %p, %p)\n", hCertStore,
1149 pbElement, cbElement, dwAddDisposition, dwFlags, dwContextTypeFlags,
1150 pdwContentType, ppvContext);
1151
1152 /* Call the internal function, then delete the hashes. Tests show this
1153 * function uses real hash values, not whatever's stored in the hash
1154 * property.
1155 */
1156 context = CRYPT_ReadSerializedElement(pbElement, cbElement,
1157 dwContextTypeFlags, &type);
1158 if (context)
1159 {
1160 const WINE_CONTEXT_INTERFACE *contextInterface = NULL;
1161
1162 switch (type)
1163 {
1165 contextInterface = pCertInterface;
1166 break;
1168 contextInterface = pCRLInterface;
1169 break;
1171 contextInterface = pCTLInterface;
1172 break;
1173 default:
1175 }
1176 if (contextInterface)
1177 {
1178 contextInterface->setProp(context, CERT_HASH_PROP_ID, 0, NULL);
1179 contextInterface->setProp(context, CERT_MD5_HASH_PROP_ID, 0, NULL);
1180 contextInterface->setProp(context, CERT_SIGNATURE_HASH_PROP_ID, 0,
1181 NULL);
1182 if (pdwContentType)
1183 *pdwContentType = type;
1184 ret = contextInterface->addContextToStore(hCertStore, context,
1185 dwAddDisposition, ppvContext);
1187 }
1188 else
1189 ret = FALSE;
1190 }
1191 else
1192 ret = FALSE;
1193 return ret;
1194}
#define read
Definition: acwin.h:97
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
#define interface
Definition: basetyps.h:61
BOOL(WINAPI * SerializeElementFunc)(const void *context, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
#define CERT_CTL_PROP_ID
#define CERT_CRL_PROP_ID
const WINE_CONTEXT_INTERFACE * pCTLInterface
Definition: store.c:77
const WINE_CONTEXT_INTERFACE * pCertInterface
Definition: store.c:51
#define CERT_CERT_PROP_ID
static context_t * context_from_ptr(const void *ptr)
const WINE_CONTEXT_INTERFACE * pCRLInterface
Definition: store.c:64
BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *, void *pvData, DWORD *pcbData)
Definition: encode.c:4345
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define E_INVALIDARG
Definition: ddrawi.h:101
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void CRYPT_ConvertKeyContext(const struct store_CERT_KEY_CONTEXT *src, CERT_KEY_CONTEXT *dst)
Definition: cert.c:429
void Context_Release(context_t *context)
Definition: context.c:106
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:136
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:141
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:146
PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore, PCCRL_CONTEXT pPrev)
Definition: store.c:1095
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:922
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_BEGIN
Definition: compat.h:761
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define __TRY
Definition: compat.h:80
#define CreateFileW
Definition: compat.h:741
#define __ENDTRY
Definition: compat.h:82
#define lstrcpyW
Definition: compat.h:749
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_ACCESS_VIOLATION
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat param
Definition: glext.h:5796
GLuint GLsizei bufSize
Definition: glext.h:6040
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
char hdr[14]
Definition: iptest.cpp:33
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const BYTE crl[]
Definition: message.c:817
static BYTE cert[]
Definition: msg.c:1374
#define min(a, b)
Definition: monoChain.cc:55
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
short WCHAR
Definition: pedump.c:58
BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store)
Definition: serialize.c:731
BOOL(* SerializedOutputFunc)(void *handle, const void *buffer, DWORD size)
Definition: serialize.c:797
const void * CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType)
Definition: serialize.c:482
static BOOL CRYPT_CountSerializedBytes(void *handle, const void *buffer, DWORD size)
Definition: serialize.c:1041
static BOOL CRYPT_SerializeStoreElement(const void *context, const BYTE *encodedContext, DWORD cbEncodedContext, DWORD contextPropID, const WINE_CONTEXT_INTERFACE *contextInterface, DWORD dwFlags, BOOL omitHashes, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:119
BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, DWORD dwSaveAs, DWORD dwSaveTo, void *pvSaveToPara, DWORD dwFlags)
Definition: serialize.c:1082
static BOOL CRYPT_SaveSerializedToFile(HCERTSTORE store, DWORD dwMsgAndCertEncodingType, void *handle)
Definition: serialize.c:1005
static BOOL read_blob_wrapper(void *handle, void *buffer, DWORD bytesToRead, DWORD *bytesRead)
Definition: serialize.c:742
BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:246
BOOL(* read_serialized_func)(void *handle, void *buffer, DWORD bytesToRead, DWORD *bytesRead)
Definition: serialize.c:615
static BOOL read_file_wrapper(void *handle, void *buffer, DWORD bytesToRead, DWORD *bytesRead)
Definition: serialize.c:725
static BOOL CRYPT_SaveSerializedToMem(HCERTSTORE store, DWORD dwMsgAndCertEncodingType, void *handle)
Definition: serialize.c:1048
static BOOL WINAPI CRYPT_SerializeCTLNoHash(PCCTL_CONTEXT pCtlContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:789
static BOOL CRYPT_MemOutputFunc(void *handle, const void *buffer, DWORD size)
Definition: serialize.c:1019
BOOL CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB *blob, HCERTSTORE store)
Definition: serialize.c:765
static const WINE_CERT_PROP_HEADER * CRYPT_findPropID(const BYTE *buf, DWORD size, DWORD propID)
Definition: serialize.c:266
static DWORD read_serialized_KeyProvInfoProperty(const struct store_CRYPT_KEY_PROV_INFO *store, CRYPT_KEY_PROV_INFO **ret)
Definition: serialize.c:315
static DWORD serialize_KeyProvInfoProperty(const CRYPT_KEY_PROV_INFO *info, struct store_CRYPT_KEY_PROV_INFO **ret)
Definition: serialize.c:58
static const BYTE fileHeader[]
Definition: serialize.c:613
static BOOL CRYPT_WriteSerializedStoreToStream(HCERTSTORE store, SerializedOutputFunc output, void *handle)
Definition: serialize.c:832
static BOOL CRYPT_ReadSerializedStore(void *handle, read_serialized_func read_func, HCERTSTORE store)
Definition: serialize.c:618
BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore, const BYTE *pbElement, DWORD cbElement, DWORD dwAddDisposition, DWORD dwFlags, DWORD dwContextTypeFlags, DWORD *pdwContentType, const void **ppvContext)
Definition: serialize.c:1140
static BOOL CRYPT_SavePKCSToMem(HCERTSTORE store, DWORD dwMsgAndCertEncodingType, void *handle)
Definition: serialize.c:878
BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:254
static BOOL CRYPT_FileOutputFunc(void *handle, const void *buffer, DWORD size)
Definition: serialize.c:866
static BOOL CRYPT_ReadContextProp(const WINE_CONTEXT_INTERFACE *contextInterface, const void *context, const WINE_CERT_PROP_HEADER *hdr, const BYTE *pbElement, DWORD cbElement)
Definition: serialize.c:392
static BOOL CRYPT_SerializeContextsToStream(SerializedOutputFunc output, void *handle, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE store)
Definition: serialize.c:800
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:238
static BOOL CRYPT_WriteSerializedStoreToFile(HANDLE file, HCERTSTORE store)
Definition: serialize.c:871
static BOOL CRYPT_SavePKCSToFile(HCERTSTORE store, DWORD dwMsgAndCertEncodingType, void *handle)
Definition: serialize.c:976
static BOOL WINAPI CRYPT_SerializeCRLNoHash(PCCRL_CONTEXT pCrlContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:781
static BOOL WINAPI CRYPT_SerializeCertNoHash(PCCERT_CONTEXT pCertContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:773
struct _WINE_CERT_PROP_HEADER WINE_CERT_PROP_HEADER
#define TRACE(s)
Definition: solgame.cpp:4
const CRYPT_DATA_BLOB * blob
Definition: serialize.c:738
DWORD current
Definition: serialize.c:739
BYTE * pbCertEncoded
Definition: wincrypt.h:489
DWORD cbCertEncoded
Definition: wincrypt.h:490
DWORD cbCrlEncoded
Definition: wincrypt.h:733
BYTE * pbCrlEncoded
Definition: wincrypt.h:732
BYTE * pbData
Definition: wincrypt.h:112
PCERT_BLOB rgCertEncoded
DWORD cbCtlEncoded
Definition: wincrypt.h:858
BYTE * pbCtlEncoded
Definition: wincrypt.h:857
CreateContextFunc create
SetContextPropertyFunc setProp
AddEncodedContextToStoreFunc addEncodedToStore
EnumPropertiesFunc enumProps
GetContextPropertyFunc getProp
SerializeElementFunc serialize
AddContextToStoreFunc addContextToStore
EnumContextsInStoreFunc enumContextsInStore
Definition: image.c:134
Definition: http.c:7252
Definition: fci.c:127
Definition: reader.h:84
const uint16_t * LPCWSTR
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CERT_PVK_FILE_PROP_ID
Definition: wincrypt.h:2845
#define CERT_CROSS_CERT_DIST_POINTS_PROP_ID
Definition: wincrypt.h:2856
#define CERT_ENROLLMENT_PROP_ID
Definition: wincrypt.h:2859
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2836
#define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2857
#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2858
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2837
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2853
#define CERT_STORE_SAVE_AS_STORE
Definition: wincrypt.h:2793
#define IS_CERT_HASH_PROP_ID(x)
Definition: wincrypt.h:2898
void * HCERTSTORE
Definition: wincrypt.h:60
#define CERT_STORE_SAVE_AS_PKCS7
Definition: wincrypt.h:2794
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2833
#define CERT_FIRST_USER_PROP_ID
Definition: wincrypt.h:2895
#define CERT_DESCRIPTION_PROP_ID
Definition: wincrypt.h:2846
#define CERT_NEXT_UPDATE_LOCATION_PROP_ID
Definition: wincrypt.h:2843
#define CERT_STORE_CTL_CONTEXT_FLAG
Definition: wincrypt.h:3128
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CERT_STORE_CRL_CONTEXT_FLAG
Definition: wincrypt.h:3127
#define CERT_STORE_ALL_CONTEXT_FLAG
Definition: wincrypt.h:3124
#define CERT_PUBKEY_ALG_PARA_PROP_ID
Definition: wincrypt.h:2855
#define CERT_AUTO_ENROLL_PROP_ID
Definition: wincrypt.h:2854
#define CERT_FRIENDLY_NAME_PROP_ID
Definition: wincrypt.h:2844
#define CERT_CTL_USAGE_PROP_ID
Definition: wincrypt.h:2842
#define CERT_STORE_CERTIFICATE_CONTEXT
Definition: wincrypt.h:3121
#define CERT_STORE_CTL_CONTEXT
Definition: wincrypt.h:3123
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2651
#define CERT_STORE_SAVE_TO_MEMORY
Definition: wincrypt.h:2797
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2835
#define CERT_RENEWAL_PROP_ID
Definition: wincrypt.h:2871
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2848
#define CERT_STORE_CERTIFICATE_CONTEXT_FLAG
Definition: wincrypt.h:3125
#define CERT_STORE_SAVE_TO_FILE
Definition: wincrypt.h:2796
#define CERT_LAST_USER_PROP_ID
Definition: wincrypt.h:2896
struct _CRYPT_KEY_PROV_INFO CRYPT_KEY_PROV_INFO
#define CERT_STORE_CRL_CONTEXT
Definition: wincrypt.h:3122
#define CERT_STORE_SAVE_TO_FILENAME_A
Definition: wincrypt.h:2798
struct _CRYPT_KEY_PROV_PARAM CRYPT_KEY_PROV_PARAM
#define CERT_DATE_STAMP_PROP_ID
Definition: wincrypt.h:2860
#define CERT_STORE_SAVE_TO_FILENAME_W
Definition: wincrypt.h:2799
#define WINAPI
Definition: msvc.h:6
#define CRYPT_E_FILE_ERROR
Definition: winerror.h:4420
#define ERROR_END_OF_MEDIA
Definition: winerror.h:960
unsigned char BYTE
Definition: xxhash.c:193