Respect the flags member of the CHOOSEFONT structure, and don't
[wine] / dlls / crypt32 / cert.c
1 /*
2  * Copyright 2002 Mike McCormack for CodeWeavers
3  * Copyright (C) 2004 Juan Lang
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winreg.h"
23 #include "wincrypt.h"
24 #include "wine/debug.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
27
28 #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
29
30 typedef struct WINE_CRYPTCERTSTORE
31 {
32     DWORD dwMagic;
33 } WINECRYPT_CERTSTORE;
34
35
36 /*
37  * CertOpenStore
38  *
39  * System Store CA is
40  *  HKLM\\Software\\Microsoft\\SystemCertificates\\CA\\
41  *    Certificates\\<compressed guid>
42  *         "Blob" = REG_BINARY
43  *    CRLs\\<compressed guid>
44  *         "Blob" = REG_BINARY
45  *    CTLs\\<compressed guid>
46  *         "Blob" = REG_BINARY
47  */
48 HCERTSTORE WINAPI CertOpenStore( LPCSTR lpszStoreProvider,
49               DWORD dwMsgAndCertEncodingType, HCRYPTPROV hCryptProv, 
50               DWORD dwFlags, const void* pvPara )
51 {
52     WINECRYPT_CERTSTORE *hcs;
53
54     FIXME("%s %08lx %08lx %08lx %p stub\n", debugstr_a(lpszStoreProvider),
55           dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara);
56
57     if( lpszStoreProvider == (LPCSTR) 0x0009 )
58     {
59         FIXME("pvPara = %s\n", debugstr_a( (LPCSTR) pvPara ) );
60     }
61
62     hcs = HeapAlloc( GetProcessHeap(), 0, sizeof (WINECRYPT_CERTSTORE) );
63     if( !hcs )
64         return NULL;
65
66     hcs->dwMagic = WINE_CRYPTCERTSTORE_MAGIC;
67
68     return (HCERTSTORE) hcs;
69 }
70
71 HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV hProv,
72  LPCSTR szSubSystemProtocol)
73 {
74     FIXME("(%ld, %s), stub\n", hProv, debugstr_a(szSubSystemProtocol));
75     return (HCERTSTORE)1;
76 }
77
78 HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV hProv,
79  LPCWSTR szSubSystemProtocol)
80 {
81     FIXME("(%ld, %s), stub\n", hProv, debugstr_w(szSubSystemProtocol));
82     return (HCERTSTORE)1;
83 }
84
85 PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
86 {
87     FIXME("(%p,%p)\n", hCertStore, pPrev);
88     return NULL;
89 }
90
91 BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType,
92              DWORD dwSaveAs, DWORD dwSaveTo, void* pvSaveToPara, DWORD dwFlags)
93 {
94     FIXME("(%p,%ld,%ld,%ld,%p,%08lx) stub!\n", hCertStore, 
95           dwMsgAndCertEncodingType, dwSaveAs, dwSaveTo, pvSaveToPara, dwFlags);
96     return TRUE;
97 }
98
99 PCCRL_CONTEXT WINAPI CertCreateCRLContext( DWORD dwCertEncodingType,
100   const BYTE* pbCrlEncoded, DWORD cbCrlEncoded)
101 {
102     PCRL_CONTEXT pcrl;
103     BYTE* data;
104
105     TRACE("%08lx %p %08lx\n", dwCertEncodingType, pbCrlEncoded, cbCrlEncoded);
106
107     pcrl = HeapAlloc( GetProcessHeap(), 0, sizeof (CRL_CONTEXT) );
108     if( !pcrl )
109         return NULL;
110
111     data = HeapAlloc( GetProcessHeap(), 0, cbCrlEncoded );
112     if( !data )
113     {
114         HeapFree( GetProcessHeap(), 0, pcrl );
115         return NULL;
116     }
117
118     pcrl->dwCertEncodingType = dwCertEncodingType;
119     pcrl->pbCrlEncoded       = data;
120     pcrl->cbCrlEncoded       = cbCrlEncoded;
121     pcrl->pCrlInfo           = NULL;
122     pcrl->hCertStore         = 0;
123
124     return pcrl;
125 }
126
127 BOOL WINAPI CertAddCRLContextToStore( HCERTSTORE hCertStore,
128              PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition,
129              PCCRL_CONTEXT* ppStoreContext )
130 {
131     FIXME("%p %p %08lx %p\n", hCertStore, pCrlContext,
132           dwAddDisposition, ppStoreContext);
133     return TRUE;
134 }
135
136 BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext)
137 {
138     FIXME("%p\n", pCrlContext );
139
140     return TRUE;
141 }
142
143 BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags )
144 {
145     FIXME("%p %08lx\n", hCertStore, dwFlags );
146     if( ! hCertStore )
147         return FALSE;
148
149     HeapFree( GetProcessHeap(), 0, hCertStore );
150
151     return TRUE;
152 }
153
154 BOOL WINAPI CertFreeCertificateContext( PCCERT_CONTEXT pCertContext )
155 {
156     FIXME("%p stub\n", pCertContext);
157     return TRUE;
158 }
159
160 PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore,
161                 DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType,
162                 const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
163 {
164     FIXME("stub: %p %ld %ld %ld %p %p\n", hCertStore, dwCertEncodingType,
165         dwFlags, dwType, pvPara, pPrevCertContext);
166     SetLastError(CRYPT_E_NOT_FOUND);
167     return NULL;
168 }