From 674e237231805d15ea41545466e4ca4445bdc763 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 10 Nov 2004 01:31:50 +0000 Subject: [PATCH] Improve the CertStore code a little. --- dlls/crypt32/cert.c | 90 ++++++++++++++++++++++++++++++++++++--- dlls/crypt32/crypt32.spec | 4 +- 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 1b2f29bfe3..26d0841408 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -25,11 +25,47 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt); -HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwEncodingType, - HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara) +#define WINE_CRYPTCERTSTORE_MAGIC 0x74726563 + +typedef struct WINE_CRYPTCERTSTORE +{ + DWORD dwMagic; +} WINECRYPT_CERTSTORE; + + +/* + * CertOpenStore + * + * System Store CA is + * HKLM\\Software\\Microsoft\\SystemCertificates\\CA\\ + * Certificates\\ + * "Blob" = REG_BINARY + * CRLs\\ + * "Blob" = REG_BINARY + * CTLs\\ + * "Blob" = REG_BINARY + */ +HCERTSTORE WINAPI CertOpenStore( LPCSTR lpszStoreProvider, + DWORD dwMsgAndCertEncodingType, HCRYPTPROV hCryptProv, + DWORD dwFlags, const void* pvPara ) { - FIXME("(%s, %ld, %ld, %ld, %p), stub.\n", debugstr_a(lpszStoreProvider), dwEncodingType, hCryptProv, dwFlags, pvPara); - return (HCERTSTORE)1; + WINECRYPT_CERTSTORE *hcs; + + FIXME("%s %08lx %08lx %08lx %p stub\n", debugstr_a(lpszStoreProvider), + dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara); + + if( lpszStoreProvider == (LPCSTR) 0x0009 ) + { + FIXME("pvPara = %s\n", debugstr_a( (LPCSTR) pvPara ) ); + } + + hcs = HeapAlloc( GetProcessHeap(), 0, sizeof (WINECRYPT_CERTSTORE) ); + if( !hcs ) + return NULL; + + hcs->dwMagic = WINE_CRYPTCERTSTORE_MAGIC; + + return (HCERTSTORE) hcs; } HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV hProv, @@ -63,13 +99,55 @@ BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, PCCRL_CONTEXT WINAPI CertCreateCRLContext( DWORD dwCertEncodingType, const BYTE* pbCrlEncoded, DWORD cbCrlEncoded) { - FIXME("%08lx %p %08lx\n", dwCertEncodingType, pbCrlEncoded, cbCrlEncoded); - return NULL; + PCRL_CONTEXT pcrl; + BYTE* data; + + TRACE("%08lx %p %08lx\n", dwCertEncodingType, pbCrlEncoded, cbCrlEncoded); + + pcrl = HeapAlloc( GetProcessHeap(), 0, sizeof (CRL_CONTEXT) ); + if( !pcrl ) + return NULL; + + data = HeapAlloc( GetProcessHeap(), 0, cbCrlEncoded ); + if( !data ) + { + HeapFree( GetProcessHeap(), 0, pcrl ); + return NULL; + } + + pcrl->dwCertEncodingType = dwCertEncodingType; + pcrl->pbCrlEncoded = data; + pcrl->cbCrlEncoded = cbCrlEncoded; + pcrl->pCrlInfo = NULL; + pcrl->hCertStore = 0; + + return pcrl; +} + +BOOL WINAPI CertAddCRLContextToStore( HCERTSTORE hCertStore, + PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition, + PCCRL_CONTEXT* ppStoreContext ) +{ + FIXME("%p %p %08lx %p\n", hCertStore, pCrlContext, + dwAddDisposition, ppStoreContext); + return TRUE; +} + +BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) +{ + FIXME("%p\n", pCrlContext ); + + return TRUE; } BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags ) { FIXME("%p %08lx\n", hCertStore, dwFlags ); + if( ! hCertStore ) + return FALSE; + + HeapFree( GetProcessHeap(), 0, hCertStore ); + return TRUE; } diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec index 8f6d320477..65e2a8e7cb 100644 --- a/dlls/crypt32/crypt32.spec +++ b/dlls/crypt32/crypt32.spec @@ -1,4 +1,4 @@ -@ stub CertAddCRLContextToStore +@ stdcall CertAddCRLContextToStore(long ptr long ptr) @ stub CertAddCTLContextToStore @ stub CertAddCertificateContextToStore @ stub CertAddEncodedCRLToStore @@ -38,7 +38,7 @@ @ stub CertFindExtension @ stub CertFindRDNAttr @ stub CertFindSubjectInCTL -@ stub CertFreeCRLContext +@ stdcall CertFreeCRLContext(ptr) @ stub CertFreeCTLContext @ stub CertFreeCertificateChain @ stub CertFreeCertificateChainEngine -- 2.33.8