2 * Copyright 2002 Mike McCormack for CodeWeavers
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
33 /* this function is called by Internet Explorer when it is about to verify a downloaded component */
34 BOOL WINAPI
I_CryptCreateLruCache(DWORD x
, DWORD y
)
40 /* these functions all have an unknown number of args */
41 BOOL WINAPI
I_CryptFindLruEntryData(DWORD x
)
47 BOOL WINAPI
I_CryptFlushLruCache(DWORD x
)
53 BOOL WINAPI
I_CryptFreeLruCache(DWORD x
)
59 BOOL WINAPI
CryptSIPRemoveProvider(GUID
*pgProv
)
65 /* convert a guid to a wide character string */
66 static void CRYPT_guid2wstr( LPGUID guid
, LPWSTR wstr
)
70 sprintf(str
, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
71 guid
->Data1
, guid
->Data2
, guid
->Data3
,
72 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
73 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7] );
74 MultiByteToWideChar( CP_ACP
, 0, str
, -1, wstr
, 40 );
78 * Helper for CryptSIPAddProvider
80 * Add a registry key containing a dll name and function under
81 * "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\<func>\\<guid>"
83 static LONG
CRYPT_SIPWriteFunction( LPGUID guid
, LPCWSTR szKey
,
84 LPCWSTR szDll
, LPCWSTR szFunction
)
86 static const WCHAR szOID
[] = {
87 'S','o','f','t','w','a','r','e','\\',
88 'M','i','c','r','o','s','o','f','t','\\',
89 'C','r','y','p','t','o','g','r','a','p','h','y','\\',
91 'E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
92 'C','r','y','p','t','S','I','P','D','l','l', 0 };
93 static const WCHAR szBackSlash
[] = { '\\', 0 };
94 static const WCHAR szDllName
[] = { 'D','l','l',0 };
95 static const WCHAR szFuncName
[] = { 'F','u','n','c','N','a','m','e',0 };
96 WCHAR szFullKey
[ 0x100 ];
101 return ERROR_SUCCESS
;
103 /* max length of szFullKey depends on our code only, so we won't overrun */
104 lstrcpyW( szFullKey
, szOID
);
105 lstrcatW( szFullKey
, szKey
);
106 lstrcatW( szFullKey
, szBackSlash
);
107 CRYPT_guid2wstr( guid
, &szFullKey
[ lstrlenW( szFullKey
) ] );
108 lstrcatW( szFullKey
, szBackSlash
);
110 TRACE("key is %s\n", debugstr_w( szFullKey
) );
112 r
= RegCreateKeyW( HKEY_LOCAL_MACHINE
, szFullKey
, &hKey
);
113 if( r
!= ERROR_SUCCESS
)
116 /* write the values */
117 RegSetValueExW( hKey
, szFuncName
, 0, REG_SZ
, (const BYTE
*) szFunction
,
118 ( lstrlenW( szFunction
) + 1 ) * sizeof (WCHAR
) );
119 RegSetValueExW( hKey
, szDllName
, 0, REG_SZ
, (const BYTE
*) szDll
,
120 ( lstrlenW( szDll
) + 1) * sizeof (WCHAR
) );
124 return ERROR_SUCCESS
;
127 BOOL WINAPI
CryptSIPAddProvider(SIP_ADD_NEWPROVIDER
*psNewProv
)
129 static const WCHAR szCreate
[] = {
130 'C','r','e','a','t','e',
131 'I','n','d','i','r','e','c','t','D','a','t','a',0};
132 static const WCHAR szGetSigned
[] = {
133 'G','e','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
134 static const WCHAR szIsMyFile
[] = {
135 'I','s','M','y','F','i','l','e','T','y','p','e', 0 };
136 static const WCHAR szPutSigned
[] = {
137 'P','u','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
138 static const WCHAR szRemoveSigned
[] = {
139 'R','e','m','o','v','e',
140 'S','i','g','n','e','d','D','a','t','a','M','s','g',0};
141 static const WCHAR szVerify
[] = {
142 'V','e','r','i','f','y',
143 'I','n','d','i','r','e','c','t','D','a','t','a',0};
145 TRACE("%p\n", psNewProv
);
150 TRACE("%s %s %s %s\n",
151 debugstr_guid( psNewProv
->pgSubject
),
152 debugstr_w( psNewProv
->pwszDLLFileName
),
153 debugstr_w( psNewProv
->pwszMagicNumber
),
154 debugstr_w( psNewProv
->pwszIsFunctionName
) );
156 #define CRYPT_SIPADDPROV( key, field ) \
157 CRYPT_SIPWriteFunction( psNewProv->pgSubject, key, \
158 psNewProv->pwszDLLFileName, psNewProv->field)
160 CRYPT_SIPADDPROV( szGetSigned
, pwszGetFuncName
);
161 CRYPT_SIPADDPROV( szPutSigned
, pwszPutFuncName
);
162 CRYPT_SIPADDPROV( szCreate
, pwszCreateFuncName
);
163 CRYPT_SIPADDPROV( szVerify
, pwszVerifyFuncName
);
164 CRYPT_SIPADDPROV( szRemoveSigned
, pwszRemoveFuncName
);
165 CRYPT_SIPADDPROV( szIsMyFile
, pwszIsFunctionNameFmt2
);
167 #undef CRYPT_SIPADDPROV
172 BOOL WINAPI CryptSIPRetrieveSubjectGuid
173 (LPCWSTR FileName
, HANDLE hFileIn
, GUID
*pgSubject
)
179 BOOL WINAPI CryptSIPLoad
180 (const GUID
*pgSubject
, DWORD dwFlags
, SIP_DISPATCH_INFO
*pSipDispatch
)
186 BOOL WINAPI
CryptGetOIDFunctionValue(DWORD dwEncodingType
, LPCSTR pszFuncName
,
187 LPCSTR pszOID
, LPCWSTR pwszValueName
,
188 DWORD
*pdwValueType
, BYTE
*pbValueData
,
191 FIXME("(%lx,%s,%s,%s,%p,%p,%p) stub!\n", dwEncodingType
, pszFuncName
, pszOID
,
192 debugstr_w(pwszValueName
), pdwValueType
, pbValueData
, pcbValueData
);
196 BOOL WINAPI
CryptRegisterDefaultOIDFunction(DWORD dwEncodingType
,
197 LPCSTR pszFuncName
, DWORD dwIndex
,
200 FIXME("(%lx,%s,%lx,%s) stub!\n", dwEncodingType
, pszFuncName
, dwIndex
,
201 debugstr_w(pwszDll
));