Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
131f1d20
Commit
131f1d20
authored
Aug 16, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Aug 17, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Move provider stores to a separate file.
parent
9f85156e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
310 additions
and
276 deletions
+310
-276
Makefile.in
dlls/crypt32/Makefile.in
+1
-0
crypt32_private.h
dlls/crypt32/crypt32_private.h
+6
-0
provstore.c
dlls/crypt32/provstore.c
+303
-0
store.c
dlls/crypt32/store.c
+0
-276
No files found.
dlls/crypt32/Makefile.in
View file @
131f1d20
...
...
@@ -21,6 +21,7 @@ C_SRCS = \
oid.c
\
proplist.c
\
protectdata.c
\
provstore.c
\
serialize.c
\
sip.c
\
store.c
\
...
...
dlls/crypt32/crypt32_private.h
View file @
131f1d20
...
...
@@ -237,6 +237,12 @@ void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store);
PWINECRYPT_CERTSTORE
CRYPT_CollectionOpenStore
(
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
const
void
*
pvPara
);
PWINECRYPT_CERTSTORE
CRYPT_ProvCreateStore
(
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
PWINECRYPT_CERTSTORE
memStore
,
const
CERT_STORE_PROV_INFO
*
pProvInfo
);
PWINECRYPT_CERTSTORE
CRYPT_ProvOpenStore
(
LPCSTR
lpszStoreProvider
,
DWORD
dwEncodingType
,
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
const
void
*
pvPara
);
/* Helper function for store reading functions and
* CertAddSerializedElementToStore. Returns a context of the appropriate type
...
...
dlls/crypt32/provstore.c
0 → 100644
View file @
131f1d20
/*
* Copyright 2004-2007 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
typedef
struct
_WINE_PROVIDERSTORE
{
WINECRYPT_CERTSTORE
hdr
;
DWORD
dwStoreProvFlags
;
PWINECRYPT_CERTSTORE
memStore
;
HCERTSTOREPROV
hStoreProv
;
PFN_CERT_STORE_PROV_CLOSE
provCloseStore
;
PFN_CERT_STORE_PROV_WRITE_CERT
provWriteCert
;
PFN_CERT_STORE_PROV_DELETE_CERT
provDeleteCert
;
PFN_CERT_STORE_PROV_WRITE_CRL
provWriteCrl
;
PFN_CERT_STORE_PROV_DELETE_CRL
provDeleteCrl
;
PFN_CERT_STORE_PROV_CONTROL
provControl
;
}
WINE_PROVIDERSTORE
,
*
PWINE_PROVIDERSTORE
;
static
void
WINAPI
CRYPT_ProvCloseStore
(
HCERTSTORE
hCertStore
,
DWORD
dwFlags
)
{
PWINE_PROVIDERSTORE
store
=
(
PWINE_PROVIDERSTORE
)
hCertStore
;
TRACE
(
"(%p, %08x)
\n
"
,
store
,
dwFlags
);
if
(
store
->
provCloseStore
)
store
->
provCloseStore
(
store
->
hStoreProv
,
dwFlags
);
if
(
!
(
store
->
dwStoreProvFlags
&
CERT_STORE_PROV_EXTERNAL_FLAG
))
CertCloseStore
(
store
->
memStore
,
dwFlags
);
CRYPT_FreeStore
((
PWINECRYPT_CERTSTORE
)
store
);
}
static
BOOL
CRYPT_ProvAddCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
cert
,
void
*
toReplace
,
const
void
**
ppStoreContext
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
;
TRACE
(
"(%p, %p, %p, %p)
\n
"
,
store
,
cert
,
toReplace
,
ppStoreContext
);
if
(
toReplace
)
ret
=
ps
->
memStore
->
certs
.
addContext
(
ps
->
memStore
,
cert
,
toReplace
,
ppStoreContext
);
else
{
ret
=
TRUE
;
if
(
ps
->
provWriteCert
)
ret
=
ps
->
provWriteCert
(
ps
->
hStoreProv
,
(
PCCERT_CONTEXT
)
cert
,
CERT_STORE_PROV_WRITE_ADD_FLAG
);
if
(
ret
)
ret
=
ps
->
memStore
->
certs
.
addContext
(
ps
->
memStore
,
cert
,
NULL
,
ppStoreContext
);
}
/* dirty trick: replace the returned context's hCertStore with
* store.
*/
if
(
ppStoreContext
)
(
*
(
PCERT_CONTEXT
*
)
ppStoreContext
)
->
hCertStore
=
store
;
return
ret
;
}
static
void
*
CRYPT_ProvEnumCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
pPrev
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
void
*
ret
;
ret
=
ps
->
memStore
->
certs
.
enumContext
(
ps
->
memStore
,
pPrev
);
if
(
ret
)
{
/* same dirty trick: replace the returned context's hCertStore with
* store.
*/
((
PCERT_CONTEXT
)
ret
)
->
hCertStore
=
store
;
}
return
ret
;
}
static
BOOL
CRYPT_ProvDeleteCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
cert
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %p)
\n
"
,
store
,
cert
);
if
(
ps
->
provDeleteCert
)
ret
=
ps
->
provDeleteCert
(
ps
->
hStoreProv
,
cert
,
0
);
if
(
ret
)
ret
=
ps
->
memStore
->
certs
.
deleteContext
(
ps
->
memStore
,
cert
);
return
ret
;
}
static
BOOL
CRYPT_ProvAddCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
crl
,
void
*
toReplace
,
const
void
**
ppStoreContext
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
;
TRACE
(
"(%p, %p, %p, %p)
\n
"
,
store
,
crl
,
toReplace
,
ppStoreContext
);
if
(
toReplace
)
ret
=
ps
->
memStore
->
crls
.
addContext
(
ps
->
memStore
,
crl
,
toReplace
,
ppStoreContext
);
else
{
if
(
ps
->
hdr
.
dwOpenFlags
&
CERT_STORE_READONLY_FLAG
)
{
SetLastError
(
ERROR_ACCESS_DENIED
);
ret
=
FALSE
;
}
else
{
ret
=
TRUE
;
if
(
ps
->
provWriteCrl
)
ret
=
ps
->
provWriteCrl
(
ps
->
hStoreProv
,
(
PCCRL_CONTEXT
)
crl
,
CERT_STORE_PROV_WRITE_ADD_FLAG
);
if
(
ret
)
ret
=
ps
->
memStore
->
crls
.
addContext
(
ps
->
memStore
,
crl
,
NULL
,
ppStoreContext
);
}
}
/* dirty trick: replace the returned context's hCertStore with
* store.
*/
if
(
ppStoreContext
)
(
*
(
PCRL_CONTEXT
*
)
ppStoreContext
)
->
hCertStore
=
store
;
return
ret
;
}
static
void
*
CRYPT_ProvEnumCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
pPrev
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
void
*
ret
;
ret
=
ps
->
memStore
->
crls
.
enumContext
(
ps
->
memStore
,
pPrev
);
if
(
ret
)
{
/* same dirty trick: replace the returned context's hCertStore with
* store.
*/
((
PCRL_CONTEXT
)
ret
)
->
hCertStore
=
store
;
}
return
ret
;
}
static
BOOL
CRYPT_ProvDeleteCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
crl
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %p)
\n
"
,
store
,
crl
);
if
(
ps
->
provDeleteCrl
)
ret
=
ps
->
provDeleteCrl
(
ps
->
hStoreProv
,
crl
,
0
);
if
(
ret
)
ret
=
ps
->
memStore
->
crls
.
deleteContext
(
ps
->
memStore
,
crl
);
return
ret
;
}
static
BOOL
WINAPI
CRYPT_ProvControl
(
HCERTSTORE
hCertStore
,
DWORD
dwFlags
,
DWORD
dwCtrlType
,
void
const
*
pvCtrlPara
)
{
PWINE_PROVIDERSTORE
store
=
(
PWINE_PROVIDERSTORE
)
hCertStore
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %08x, %d, %p)
\n
"
,
hCertStore
,
dwFlags
,
dwCtrlType
,
pvCtrlPara
);
if
(
store
->
provControl
)
ret
=
store
->
provControl
(
store
->
hStoreProv
,
dwFlags
,
dwCtrlType
,
pvCtrlPara
);
return
ret
;
}
PWINECRYPT_CERTSTORE
CRYPT_ProvCreateStore
(
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
PWINECRYPT_CERTSTORE
memStore
,
const
CERT_STORE_PROV_INFO
*
pProvInfo
)
{
PWINE_PROVIDERSTORE
ret
=
CryptMemAlloc
(
sizeof
(
WINE_PROVIDERSTORE
));
if
(
ret
)
{
CRYPT_InitStore
(
&
ret
->
hdr
,
hCryptProv
,
dwFlags
,
StoreTypeProvider
);
ret
->
dwStoreProvFlags
=
pProvInfo
->
dwStoreProvFlags
;
if
(
ret
->
dwStoreProvFlags
&
CERT_STORE_PROV_EXTERNAL_FLAG
)
{
CertCloseStore
(
memStore
,
0
);
ret
->
memStore
=
NULL
;
}
else
ret
->
memStore
=
memStore
;
ret
->
hStoreProv
=
pProvInfo
->
hStoreProv
;
ret
->
hdr
.
closeStore
=
CRYPT_ProvCloseStore
;
ret
->
hdr
.
certs
.
addContext
=
CRYPT_ProvAddCert
;
ret
->
hdr
.
certs
.
enumContext
=
CRYPT_ProvEnumCert
;
ret
->
hdr
.
certs
.
deleteContext
=
CRYPT_ProvDeleteCert
;
ret
->
hdr
.
crls
.
addContext
=
CRYPT_ProvAddCRL
;
ret
->
hdr
.
crls
.
enumContext
=
CRYPT_ProvEnumCRL
;
ret
->
hdr
.
crls
.
deleteContext
=
CRYPT_ProvDeleteCRL
;
ret
->
hdr
.
control
=
CRYPT_ProvControl
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_CLOSE_FUNC
)
ret
->
provCloseStore
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_CLOSE_FUNC
];
else
ret
->
provCloseStore
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_WRITE_CERT_FUNC
)
ret
->
provWriteCert
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_WRITE_CERT_FUNC
];
else
ret
->
provWriteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_DELETE_CERT_FUNC
)
ret
->
provDeleteCert
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_DELETE_CERT_FUNC
];
else
ret
->
provDeleteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_WRITE_CRL_FUNC
)
ret
->
provWriteCrl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_WRITE_CRL_FUNC
];
else
ret
->
provWriteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_DELETE_CRL_FUNC
)
ret
->
provDeleteCrl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_DELETE_CRL_FUNC
];
else
ret
->
provDeleteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_CONTROL_FUNC
)
ret
->
provControl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_CONTROL_FUNC
];
else
ret
->
provControl
=
NULL
;
}
return
(
PWINECRYPT_CERTSTORE
)
ret
;
}
PWINECRYPT_CERTSTORE
CRYPT_ProvOpenStore
(
LPCSTR
lpszStoreProvider
,
DWORD
dwEncodingType
,
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
const
void
*
pvPara
)
{
static
HCRYPTOIDFUNCSET
set
=
NULL
;
PFN_CERT_DLL_OPEN_STORE_PROV_FUNC
provOpenFunc
;
HCRYPTOIDFUNCADDR
hFunc
;
PWINECRYPT_CERTSTORE
ret
=
NULL
;
if
(
!
set
)
set
=
CryptInitOIDFunctionSet
(
CRYPT_OID_OPEN_STORE_PROV_FUNC
,
0
);
CryptGetOIDFunctionAddress
(
set
,
dwEncodingType
,
lpszStoreProvider
,
0
,
(
void
**
)
&
provOpenFunc
,
&
hFunc
);
if
(
provOpenFunc
)
{
CERT_STORE_PROV_INFO
provInfo
=
{
0
};
provInfo
.
cbSize
=
sizeof
(
provInfo
);
if
(
dwFlags
&
CERT_STORE_DELETE_FLAG
)
provOpenFunc
(
lpszStoreProvider
,
dwEncodingType
,
hCryptProv
,
dwFlags
,
pvPara
,
NULL
,
&
provInfo
);
else
{
HCERTSTORE
memStore
;
memStore
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
if
(
memStore
)
{
if
(
provOpenFunc
(
lpszStoreProvider
,
dwEncodingType
,
hCryptProv
,
dwFlags
,
pvPara
,
memStore
,
&
provInfo
))
ret
=
CRYPT_ProvCreateStore
(
hCryptProv
,
dwFlags
,
memStore
,
&
provInfo
);
else
CertCloseStore
(
memStore
,
0
);
}
}
CryptFreeOIDFunctionAddress
(
hFunc
,
0
);
}
else
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
ret
;
}
dlls/crypt32/store.c
View file @
131f1d20
...
...
@@ -128,20 +128,6 @@ typedef struct _WINE_MSGSTOREINFO
HCRYPTMSG
msg
;
}
WINE_MSGSTOREINFO
,
*
PWINE_MSGSTOREINFO
;
typedef
struct
_WINE_PROVIDERSTORE
{
WINECRYPT_CERTSTORE
hdr
;
DWORD
dwStoreProvFlags
;
PWINECRYPT_CERTSTORE
memStore
;
HCERTSTOREPROV
hStoreProv
;
PFN_CERT_STORE_PROV_CLOSE
provCloseStore
;
PFN_CERT_STORE_PROV_WRITE_CERT
provWriteCert
;
PFN_CERT_STORE_PROV_DELETE_CERT
provDeleteCert
;
PFN_CERT_STORE_PROV_WRITE_CRL
provWriteCrl
;
PFN_CERT_STORE_PROV_DELETE_CRL
provDeleteCrl
;
PFN_CERT_STORE_PROV_CONTROL
provControl
;
}
WINE_PROVIDERSTORE
,
*
PWINE_PROVIDERSTORE
;
void
CRYPT_InitStore
(
WINECRYPT_CERTSTORE
*
store
,
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
CertStoreType
type
)
{
...
...
@@ -313,268 +299,6 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
return
(
PWINECRYPT_CERTSTORE
)
store
;
}
static
void
WINAPI
CRYPT_ProvCloseStore
(
HCERTSTORE
hCertStore
,
DWORD
dwFlags
)
{
PWINE_PROVIDERSTORE
store
=
(
PWINE_PROVIDERSTORE
)
hCertStore
;
TRACE
(
"(%p, %08x)
\n
"
,
store
,
dwFlags
);
if
(
store
->
provCloseStore
)
store
->
provCloseStore
(
store
->
hStoreProv
,
dwFlags
);
if
(
!
(
store
->
dwStoreProvFlags
&
CERT_STORE_PROV_EXTERNAL_FLAG
))
CertCloseStore
(
store
->
memStore
,
dwFlags
);
CRYPT_FreeStore
((
PWINECRYPT_CERTSTORE
)
store
);
}
static
BOOL
CRYPT_ProvAddCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
cert
,
void
*
toReplace
,
const
void
**
ppStoreContext
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
;
TRACE
(
"(%p, %p, %p, %p)
\n
"
,
store
,
cert
,
toReplace
,
ppStoreContext
);
if
(
toReplace
)
ret
=
ps
->
memStore
->
certs
.
addContext
(
ps
->
memStore
,
cert
,
toReplace
,
ppStoreContext
);
else
{
ret
=
TRUE
;
if
(
ps
->
provWriteCert
)
ret
=
ps
->
provWriteCert
(
ps
->
hStoreProv
,
(
PCCERT_CONTEXT
)
cert
,
CERT_STORE_PROV_WRITE_ADD_FLAG
);
if
(
ret
)
ret
=
ps
->
memStore
->
certs
.
addContext
(
ps
->
memStore
,
cert
,
NULL
,
ppStoreContext
);
}
/* dirty trick: replace the returned context's hCertStore with
* store.
*/
if
(
ppStoreContext
)
(
*
(
PCERT_CONTEXT
*
)
ppStoreContext
)
->
hCertStore
=
store
;
return
ret
;
}
static
void
*
CRYPT_ProvEnumCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
pPrev
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
void
*
ret
;
ret
=
ps
->
memStore
->
certs
.
enumContext
(
ps
->
memStore
,
pPrev
);
if
(
ret
)
{
/* same dirty trick: replace the returned context's hCertStore with
* store.
*/
((
PCERT_CONTEXT
)
ret
)
->
hCertStore
=
store
;
}
return
ret
;
}
static
BOOL
CRYPT_ProvDeleteCert
(
PWINECRYPT_CERTSTORE
store
,
void
*
cert
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %p)
\n
"
,
store
,
cert
);
if
(
ps
->
provDeleteCert
)
ret
=
ps
->
provDeleteCert
(
ps
->
hStoreProv
,
cert
,
0
);
if
(
ret
)
ret
=
ps
->
memStore
->
certs
.
deleteContext
(
ps
->
memStore
,
cert
);
return
ret
;
}
static
BOOL
CRYPT_ProvAddCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
crl
,
void
*
toReplace
,
const
void
**
ppStoreContext
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
;
TRACE
(
"(%p, %p, %p, %p)
\n
"
,
store
,
crl
,
toReplace
,
ppStoreContext
);
if
(
toReplace
)
ret
=
ps
->
memStore
->
crls
.
addContext
(
ps
->
memStore
,
crl
,
toReplace
,
ppStoreContext
);
else
{
if
(
ps
->
hdr
.
dwOpenFlags
&
CERT_STORE_READONLY_FLAG
)
{
SetLastError
(
ERROR_ACCESS_DENIED
);
ret
=
FALSE
;
}
else
{
ret
=
TRUE
;
if
(
ps
->
provWriteCrl
)
ret
=
ps
->
provWriteCrl
(
ps
->
hStoreProv
,
(
PCCRL_CONTEXT
)
crl
,
CERT_STORE_PROV_WRITE_ADD_FLAG
);
if
(
ret
)
ret
=
ps
->
memStore
->
crls
.
addContext
(
ps
->
memStore
,
crl
,
NULL
,
ppStoreContext
);
}
}
/* dirty trick: replace the returned context's hCertStore with
* store.
*/
if
(
ppStoreContext
)
(
*
(
PCRL_CONTEXT
*
)
ppStoreContext
)
->
hCertStore
=
store
;
return
ret
;
}
static
void
*
CRYPT_ProvEnumCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
pPrev
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
void
*
ret
;
ret
=
ps
->
memStore
->
crls
.
enumContext
(
ps
->
memStore
,
pPrev
);
if
(
ret
)
{
/* same dirty trick: replace the returned context's hCertStore with
* store.
*/
((
PCRL_CONTEXT
)
ret
)
->
hCertStore
=
store
;
}
return
ret
;
}
static
BOOL
CRYPT_ProvDeleteCRL
(
PWINECRYPT_CERTSTORE
store
,
void
*
crl
)
{
PWINE_PROVIDERSTORE
ps
=
(
PWINE_PROVIDERSTORE
)
store
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %p)
\n
"
,
store
,
crl
);
if
(
ps
->
provDeleteCrl
)
ret
=
ps
->
provDeleteCrl
(
ps
->
hStoreProv
,
crl
,
0
);
if
(
ret
)
ret
=
ps
->
memStore
->
crls
.
deleteContext
(
ps
->
memStore
,
crl
);
return
ret
;
}
static
BOOL
WINAPI
CRYPT_ProvControl
(
HCERTSTORE
hCertStore
,
DWORD
dwFlags
,
DWORD
dwCtrlType
,
void
const
*
pvCtrlPara
)
{
PWINE_PROVIDERSTORE
store
=
(
PWINE_PROVIDERSTORE
)
hCertStore
;
BOOL
ret
=
TRUE
;
TRACE
(
"(%p, %08x, %d, %p)
\n
"
,
hCertStore
,
dwFlags
,
dwCtrlType
,
pvCtrlPara
);
if
(
store
->
provControl
)
ret
=
store
->
provControl
(
store
->
hStoreProv
,
dwFlags
,
dwCtrlType
,
pvCtrlPara
);
return
ret
;
}
static
PWINECRYPT_CERTSTORE
CRYPT_ProvCreateStore
(
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
PWINECRYPT_CERTSTORE
memStore
,
const
CERT_STORE_PROV_INFO
*
pProvInfo
)
{
PWINE_PROVIDERSTORE
ret
=
CryptMemAlloc
(
sizeof
(
WINE_PROVIDERSTORE
));
if
(
ret
)
{
CRYPT_InitStore
(
&
ret
->
hdr
,
hCryptProv
,
dwFlags
,
StoreTypeProvider
);
ret
->
dwStoreProvFlags
=
pProvInfo
->
dwStoreProvFlags
;
if
(
ret
->
dwStoreProvFlags
&
CERT_STORE_PROV_EXTERNAL_FLAG
)
{
CertCloseStore
(
memStore
,
0
);
ret
->
memStore
=
NULL
;
}
else
ret
->
memStore
=
memStore
;
ret
->
hStoreProv
=
pProvInfo
->
hStoreProv
;
ret
->
hdr
.
closeStore
=
CRYPT_ProvCloseStore
;
ret
->
hdr
.
certs
.
addContext
=
CRYPT_ProvAddCert
;
ret
->
hdr
.
certs
.
enumContext
=
CRYPT_ProvEnumCert
;
ret
->
hdr
.
certs
.
deleteContext
=
CRYPT_ProvDeleteCert
;
ret
->
hdr
.
crls
.
addContext
=
CRYPT_ProvAddCRL
;
ret
->
hdr
.
crls
.
enumContext
=
CRYPT_ProvEnumCRL
;
ret
->
hdr
.
crls
.
deleteContext
=
CRYPT_ProvDeleteCRL
;
ret
->
hdr
.
control
=
CRYPT_ProvControl
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_CLOSE_FUNC
)
ret
->
provCloseStore
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_CLOSE_FUNC
];
else
ret
->
provCloseStore
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_WRITE_CERT_FUNC
)
ret
->
provWriteCert
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_WRITE_CERT_FUNC
];
else
ret
->
provWriteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_DELETE_CERT_FUNC
)
ret
->
provDeleteCert
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_DELETE_CERT_FUNC
];
else
ret
->
provDeleteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_WRITE_CRL_FUNC
)
ret
->
provWriteCrl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_WRITE_CRL_FUNC
];
else
ret
->
provWriteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_DELETE_CRL_FUNC
)
ret
->
provDeleteCrl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_DELETE_CRL_FUNC
];
else
ret
->
provDeleteCert
=
NULL
;
if
(
pProvInfo
->
cStoreProvFunc
>
CERT_STORE_PROV_CONTROL_FUNC
)
ret
->
provControl
=
pProvInfo
->
rgpvStoreProvFunc
[
CERT_STORE_PROV_CONTROL_FUNC
];
else
ret
->
provControl
=
NULL
;
}
return
(
PWINECRYPT_CERTSTORE
)
ret
;
}
static
PWINECRYPT_CERTSTORE
CRYPT_ProvOpenStore
(
LPCSTR
lpszStoreProvider
,
DWORD
dwEncodingType
,
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
const
void
*
pvPara
)
{
static
HCRYPTOIDFUNCSET
set
=
NULL
;
PFN_CERT_DLL_OPEN_STORE_PROV_FUNC
provOpenFunc
;
HCRYPTOIDFUNCADDR
hFunc
;
PWINECRYPT_CERTSTORE
ret
=
NULL
;
if
(
!
set
)
set
=
CryptInitOIDFunctionSet
(
CRYPT_OID_OPEN_STORE_PROV_FUNC
,
0
);
CryptGetOIDFunctionAddress
(
set
,
dwEncodingType
,
lpszStoreProvider
,
0
,
(
void
**
)
&
provOpenFunc
,
&
hFunc
);
if
(
provOpenFunc
)
{
CERT_STORE_PROV_INFO
provInfo
=
{
0
};
provInfo
.
cbSize
=
sizeof
(
provInfo
);
if
(
dwFlags
&
CERT_STORE_DELETE_FLAG
)
provOpenFunc
(
lpszStoreProvider
,
dwEncodingType
,
hCryptProv
,
dwFlags
,
pvPara
,
NULL
,
&
provInfo
);
else
{
HCERTSTORE
memStore
;
memStore
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
if
(
memStore
)
{
if
(
provOpenFunc
(
lpszStoreProvider
,
dwEncodingType
,
hCryptProv
,
dwFlags
,
pvPara
,
memStore
,
&
provInfo
))
ret
=
CRYPT_ProvCreateStore
(
hCryptProv
,
dwFlags
,
memStore
,
&
provInfo
);
else
CertCloseStore
(
memStore
,
0
);
}
}
CryptFreeOIDFunctionAddress
(
hFunc
,
0
);
}
else
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
ret
;
}
static
void
CRYPT_HashToStr
(
const
BYTE
*
hash
,
LPWSTR
asciiHash
)
{
static
const
WCHAR
fmt
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
0
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment