Commit f3eff523 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Implement CryptRegisterOIDFunction and CryptSIPAddProvider.

parent 3cd1cfea
......@@ -18,10 +18,13 @@
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "winreg.h"
#include "winnls.h"
#include "mssip.h"
#include "wine/debug.h"
......@@ -77,10 +80,111 @@ BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
return FALSE;
}
/* convert a guid to a wide character string */
static void CRYPT_guid2wstr( LPGUID guid, LPWSTR wstr )
{
char str[40];
sprintf(str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 40 );
}
/*
* Helper for CryptSIPAddProvider
*
* Add a registry key containing a dll name and function under
* "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\<func>\\<guid>"
*/
static LONG CRYPT_SIPWriteFunction( LPGUID guid, LPCWSTR szKey,
LPCWSTR szDll, LPCWSTR szFunction )
{
const WCHAR szOID[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'O','I','D','\\',
'E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
'C','r','y','p','t','S','I','P','D','l','l', 0 };
const WCHAR szBackSlash[] = { '\\', 0 };
const WCHAR szDllName[] = { 'D','l','l',0 };
const WCHAR szFuncName[] = { 'F','u','n','c','N','a','m','e',0 };
WCHAR szFullKey[ 0x100 ];
LONG r;
HKEY hKey;
if( !szFunction )
return ERROR_SUCCESS;
/* max length of szFullKey depends on our code only, so we won't overrun */
lstrcpyW( szFullKey, szOID );
lstrcatW( szFullKey, szKey );
lstrcatW( szFullKey, szBackSlash );
CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
lstrcatW( szFullKey, szBackSlash );
TRACE("key is %s\n", debugstr_w( szFullKey ) );
r = RegCreateKeyW( HKEY_LOCAL_MACHINE, szFullKey, &hKey );
if( r != ERROR_SUCCESS )
return r;
/* write the values */
RegSetValueExW( hKey, szFuncName, 0, REG_SZ, (LPBYTE) szFunction,
( lstrlenW( szFunction ) + 1 ) * sizeof (WCHAR) );
RegSetValueExW( hKey, szDllName, 0, REG_SZ, (LPBYTE) szDll,
( lstrlenW( szDll ) + 1) * sizeof (WCHAR) );
RegCloseKey( hKey );
return ERROR_SUCCESS;
}
BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
{
FIXME("stub!\n");
return FALSE;
const WCHAR szCreate[] = {
'C','r','e','a','t','e',
'I','n','d','i','r','e','c','t','D','a','t','a',0};
const WCHAR szGetSigned[] = {
'G','e','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
const WCHAR szIsMyFile[] = {
'I','s','M','y','F','i','l','e','T','y','p','e', 0 };
const WCHAR szPutSigned[] = {
'P','u','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
const WCHAR szRemoveSigned[] = {
'R','e','m','o','v','e',
'S','i','g','n','e','d','D','a','t','a','M','s','g',0};
const WCHAR szVerify[] = {
'V','e','r','i','f','y',
'I','n','d','i','r','e','c','t','D','a','t','a',0};
TRACE("%p\n", psNewProv);
if( !psNewProv )
return FALSE;
TRACE("%s %s %s %s\n",
debugstr_guid( psNewProv->pgSubject ),
debugstr_w( psNewProv->pwszDLLFileName ),
debugstr_w( psNewProv->pwszMagicNumber ),
debugstr_w( psNewProv->pwszIsFunctionName ) );
#define CRYPT_SIPADDPROV( key, field ) \
CRYPT_SIPWriteFunction( psNewProv->pgSubject, key, \
psNewProv->pwszDLLFileName, psNewProv->field)
CRYPT_SIPADDPROV( szGetSigned, pwszGetFuncName );
CRYPT_SIPADDPROV( szPutSigned, pwszPutFuncName );
CRYPT_SIPADDPROV( szCreate, pwszCreateFuncName );
CRYPT_SIPADDPROV( szVerify, pwszVerifyFuncName );
CRYPT_SIPADDPROV( szRemoveSigned, pwszRemoveFuncName );
CRYPT_SIPADDPROV( szIsMyFile, pwszIsFunctionNameFmt2 );
#undef CRYPT_SIPADDPROV
return TRUE;
}
BOOL WINAPI CryptSIPRetrieveSubjectGuid
......@@ -117,11 +221,50 @@ BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD dwEncodingType,
}
BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName)
LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName)
{
FIXME("(%lx,%s,%s,%s,%s) stub!\n", dwEncodingType, pszFuncName, pszOID,
LONG r;
const char szOID[] = "Software\\Microsoft\\Cryptography\\OID";
const char szType1[] = "EncodingType 1";
const WCHAR szDllName[] = { 'D','l','l',0 };
HKEY hKey;
LPSTR szKey;
UINT len;
TRACE("%lx %s %s %s %s\n", dwEncodingType, pszFuncName, pszOID,
debugstr_w(pwszDll), pszOverrideFuncName);
return FALSE;
if( dwEncodingType & PKCS_7_ASN_ENCODING )
FIXME("PKCS_7_ASN_ENCODING not implemented\n");
if( dwEncodingType & X509_ASN_ENCODING )
{
/* construct the name of the key */
len = sizeof szOID + sizeof szType1 + 2 +
lstrlenA( pszFuncName ) + lstrlenA( pszOID );
szKey = HeapAlloc( GetProcessHeap(), 0, len );
if( !szKey )
return FALSE;
sprintf( szKey, "%s\\%s\\%s\\%s",
szOID, szType1, pszFuncName, pszOID );
TRACE("Key name is %s\n", debugstr_a( szKey ) );
r = RegCreateKeyA( HKEY_LOCAL_MACHINE, szKey, &hKey );
HeapFree( GetProcessHeap(), 0, szKey );
if( r != ERROR_SUCCESS )
return FALSE;
/* write the values */
RegSetValueExA( hKey, "FuncName", 0, REG_SZ, pszOverrideFuncName,
lstrlenA( pszOverrideFuncName ) + 1 );
RegSetValueExW( hKey, szDllName, 0, REG_SZ, (LPBYTE) pwszDll,
(lstrlenW( pwszDll ) + 1) * sizeof (WCHAR) );
RegCloseKey( hKey );
}
return TRUE;
}
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
......
......@@ -483,6 +483,22 @@ static const WCHAR MS_SCARD_PROV_W[] = { 'M','i','c','r','o','s','o','
#define PUBLICKEYBLOBEX 0xA
#define SYMMETRICWRAPKEYBLOB 0xB
#define CERT_STORE_PROV_MSG ((LPCSTR)1)
#define CERT_STORE_PROV_MEMORY ((LPCSTR)2)
#define CERT_STORE_PROV_FILE ((LPCSTR)3)
#define CERT_STORE_PROV_REG ((LPCSTR)4)
#define CERT_STORE_PROV_PKCS7 ((LPCSTR)5)
#define CERT_STORE_PROV_SERIALIZED ((LPCSTR)6)
#define CERT_STORE_PROV_FILENAME_A ((LPCSTR)7)
#define CERT_STORE_PROV_FILENAME_W ((LPCSTR)8)
#define CERT_STORE_PROV_SYSTEM_A ((LPCSTR)9)
#define CERT_STORE_PROV_SYSTEM_W ((LPCSTR)10)
#define X509_ASN_ENCODING 0x00000001
#define X509_NDR_ENCODING 0x00000002
#define PKCS_7_ASN_ENCODING 0x00010000
#define PKCS_7_NDR_ENCODING 0x00020000
/* function declarations */
/* advapi32.dll */
BOOL WINAPI CryptAcquireContextA(HCRYPTPROV *phProv, LPCSTR pszContainer,
......@@ -535,6 +551,8 @@ BOOL WINAPI CryptHashData (HCRYPTHASH hHash, BYTE *pbData, DWORD dwDataLen, DWOR
BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags);
BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey);
BOOL WINAPI CryptRegisterOIDFunction(DWORD,LPCSTR,LPCSTR,LPCWSTR,LPCSTR);
BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, DWORD dwFlags);
BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription,
DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment