mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
advapi32: Remove a useless macro.
This commit is contained in:
parent
9595ea7cd6
commit
f46cfe601c
@ -52,8 +52,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
||||
|
||||
static HWND crypt_hWindow;
|
||||
|
||||
#define CRYPT_ReturnLastError(err) do {SetLastError(err); return FALSE;} while(0)
|
||||
|
||||
#define CRYPT_Alloc(size) ((LPVOID)LocalAlloc(LMEM_ZEROINIT, size))
|
||||
#define CRYPT_Free(buffer) (LocalFree((HLOCAL)buffer))
|
||||
|
||||
@ -501,11 +499,15 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
|
||||
pszProvider, dwProvType, dwFlags);
|
||||
|
||||
if ( !CRYPT_ANSIToUnicode(pszContainer, &pContainer, -1) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !CRYPT_ANSIToUnicode(pszProvider, &pProvider, -1) )
|
||||
{
|
||||
CRYPT_Free(pContainer);
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = CryptAcquireContextW(phProv, pContainer, pProvider, dwProvType, dwFlags);
|
||||
@ -626,10 +628,16 @@ BOOL WINAPI CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
|
||||
TRACE("(0x%lx, %d, %p)\n", hProv, dwLen, pbBuffer);
|
||||
|
||||
if (!hProv)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return prov->pFuncs->pCPGenRandom(prov->hPrivate, dwLen, pbBuffer);
|
||||
}
|
||||
@ -663,13 +671,25 @@ BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
|
||||
TRACE("(0x%lx, 0x%x, 0x%lx, %08x, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
|
||||
|
||||
if (!prov)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!phHash || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags)
|
||||
CRYPT_ReturnLastError(NTE_BAD_FLAGS);
|
||||
{
|
||||
SetLastError(NTE_BAD_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !(hash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hash->pProvider = prov;
|
||||
|
||||
@ -714,7 +734,10 @@ BOOL WINAPI CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
|
||||
TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
|
||||
|
||||
if (!key || !pbData || !pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
return prov->pFuncs->pCPDecrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
|
||||
@ -747,11 +770,20 @@ BOOL WINAPI CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData
|
||||
TRACE("(0x%lx, 0x%08x, 0x%lx, 0x%08x, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
|
||||
|
||||
if (!prov || !hash)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!phKey || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
key->pProvider = prov;
|
||||
if (prov->pFuncs->pCPDeriveKey(prov->hPrivate, Algid, hash->hPrivate, dwFlags, &key->hPrivate))
|
||||
@ -787,11 +819,17 @@ BOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash)
|
||||
TRACE("(0x%lx)\n", hHash);
|
||||
|
||||
if (!hash)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
ret = prov->pFuncs->pCPDestroyHash(prov->hPrivate, hash->hPrivate);
|
||||
CRYPT_Free(hash);
|
||||
@ -819,10 +857,16 @@ BOOL WINAPI CryptDestroyKey (HCRYPTKEY hKey)
|
||||
TRACE("(0x%lx)\n", hKey);
|
||||
|
||||
if (!key)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
ret = prov->pFuncs->pCPDestroyKey(prov->hPrivate, key->hPrivate);
|
||||
@ -857,15 +901,22 @@ BOOL WINAPI CryptDuplicateHash (HCRYPTHASH hHash, DWORD *pdwReserved,
|
||||
if (!orghash || pdwReserved || !phHash || !orghash->pProvider ||
|
||||
orghash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
{
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = orghash->pProvider;
|
||||
if (!prov->pFuncs->pCPDuplicateHash)
|
||||
CRYPT_ReturnLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !(newhash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
newhash->pProvider = prov;
|
||||
if (prov->pFuncs->pCPDuplicateHash(prov->hPrivate, orghash->hPrivate, pdwReserved, dwFlags, &newhash->hPrivate))
|
||||
@ -903,15 +954,22 @@ BOOL WINAPI CryptDuplicateKey (HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags
|
||||
if (!orgkey || pdwReserved || !phKey || !orgkey->pProvider ||
|
||||
orgkey->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
{
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = orgkey->pProvider;
|
||||
if (!prov->pFuncs->pCPDuplicateKey)
|
||||
CRYPT_ReturnLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !(newkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
newkey->pProvider = prov;
|
||||
if (prov->pFuncs->pCPDuplicateKey(prov->hPrivate, orgkey->hPrivate, pdwReserved, dwFlags, &newkey->hPrivate))
|
||||
@ -956,7 +1014,10 @@ BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
|
||||
TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p, %d)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
|
||||
|
||||
if (!key || !pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
return prov->pFuncs->pCPEncrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
|
||||
@ -1001,11 +1062,22 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
||||
TRACE("(%d, %p, %d, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
|
||||
pdwProvType, pszProvName, pcbProvName);
|
||||
|
||||
if (pdwReserved || !pcbProvName) CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS);
|
||||
if (pdwReserved || !pcbProvName)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags)
|
||||
{
|
||||
SetLastError(NTE_BAD_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, providerW, &hKey))
|
||||
CRYPT_ReturnLastError(NTE_FAIL);
|
||||
{
|
||||
SetLastError(NTE_FAIL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pszProvName)
|
||||
{
|
||||
@ -1016,15 +1088,21 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (!(provNameW = CRYPT_Alloc(*pcbProvName * sizeof(WCHAR))))
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegEnumKeyExW(hKey, dwIndex, provNameW, pcbProvName, NULL, NULL, NULL, NULL);
|
||||
CRYPT_Free(provNameW);
|
||||
(*pcbProvName)++;
|
||||
*pcbProvName *= sizeof(WCHAR);
|
||||
|
||||
if (dwIndex >= numkeys)
|
||||
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
|
||||
{
|
||||
SetLastError(ERROR_NO_MORE_ITEMS);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
DWORD size = sizeof(DWORD);
|
||||
DWORD result;
|
||||
@ -1032,7 +1110,10 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
||||
|
||||
result = RegEnumKeyW(hKey, dwIndex, pszProvName, *pcbProvName / sizeof(WCHAR));
|
||||
if (result)
|
||||
CRYPT_ReturnLastError(result);
|
||||
{
|
||||
SetLastError(result);
|
||||
return FALSE;
|
||||
}
|
||||
if (RegOpenKeyW(hKey, pszProvName, &subkey))
|
||||
return FALSE;
|
||||
if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
|
||||
@ -1060,7 +1141,10 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
|
||||
|
||||
CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
|
||||
if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
ret = CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
|
||||
if (str)
|
||||
CRYPT_UnicodeToANSI(str, &pszProvName, *pcbProvName);
|
||||
@ -1069,7 +1153,10 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
|
||||
{
|
||||
CRYPT_Free(str);
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
CRYPT_ReturnLastError(ERROR_MORE_DATA);
|
||||
{
|
||||
SetLastError(ERROR_MORE_DATA);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1116,18 +1203,31 @@ BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
|
||||
dwFlags, pdwProvType, pszTypeName, pcbTypeName);
|
||||
|
||||
if (pdwReserved || !pdwProvType || !pcbTypeName)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags)
|
||||
{
|
||||
SetLastError(NTE_BAD_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, KEYSTR, &hKey))
|
||||
return FALSE;
|
||||
|
||||
RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &numkeys, &keylen, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (dwIndex >= numkeys)
|
||||
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
|
||||
{
|
||||
SetLastError(ERROR_NO_MORE_ITEMS);
|
||||
return FALSE;
|
||||
}
|
||||
keylen++;
|
||||
if ( !(keyname = CRYPT_Alloc(keylen*sizeof(WCHAR))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if ( RegEnumKeyW(hKey, dwIndex, keyname, keylen) ) {
|
||||
CRYPT_Free(keyname);
|
||||
return FALSE;
|
||||
@ -1142,7 +1242,10 @@ BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
|
||||
|
||||
result = RegQueryValueExW(hSubkey, typenameW, NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName);
|
||||
if (result)
|
||||
CRYPT_ReturnLastError(result);
|
||||
{
|
||||
SetLastError(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hSubkey);
|
||||
RegCloseKey(hKey);
|
||||
@ -1166,7 +1269,10 @@ BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
|
||||
|
||||
CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
|
||||
if ( pszTypeName && !(str = CRYPT_Alloc(strlen)) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
ret = CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
|
||||
if (str)
|
||||
CRYPT_UnicodeToANSI(str, &pszTypeName, *pcbTypeName);
|
||||
@ -1175,7 +1281,10 @@ BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
|
||||
{
|
||||
CRYPT_Free(str);
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
CRYPT_ReturnLastError(ERROR_MORE_DATA);
|
||||
{
|
||||
SetLastError(ERROR_MORE_DATA);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1210,7 +1319,10 @@ BOOL WINAPI CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType,
|
||||
TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
|
||||
|
||||
if (!key || !pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
return prov->pFuncs->pCPExportKey(prov->hPrivate, key->hPrivate, expkey ? expkey->hPrivate : 0,
|
||||
@ -1240,11 +1352,20 @@ BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKE
|
||||
TRACE("(0x%lx, %d, %08x, %p)\n", hProv, Algid, dwFlags, phKey);
|
||||
|
||||
if (!prov)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!phKey || !prov || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
key->pProvider = prov;
|
||||
|
||||
@ -1288,17 +1409,30 @@ BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved,
|
||||
static const WCHAR nameW[] = {'N','a','m','e',0};
|
||||
|
||||
if (pdwReserved || !pcbProvName)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags & ~(CRYPT_USER_DEFAULT | CRYPT_MACHINE_DEFAULT))
|
||||
CRYPT_ReturnLastError(NTE_BAD_FLAGS);
|
||||
{
|
||||
SetLastError(NTE_BAD_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwProvType > 999)
|
||||
CRYPT_ReturnLastError(NTE_BAD_PROV_TYPE);
|
||||
{
|
||||
SetLastError(NTE_BAD_PROV_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE ,keyname, &hKey))
|
||||
{
|
||||
CRYPT_Free(keyname);
|
||||
CRYPT_ReturnLastError(NTE_PROV_TYPE_NOT_DEF);
|
||||
SetLastError(NTE_PROV_TYPE_NOT_DEF);
|
||||
return FALSE;
|
||||
}
|
||||
CRYPT_Free(keyname);
|
||||
|
||||
@ -1333,7 +1467,10 @@ BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
|
||||
|
||||
CryptGetDefaultProviderW(dwProvType, pdwReserved, dwFlags, NULL, &strlen);
|
||||
if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
ret = CryptGetDefaultProviderW(dwProvType, pdwReserved, dwFlags, str, &strlen);
|
||||
if (str)
|
||||
CRYPT_UnicodeToANSI(str, &pszProvName, *pcbProvName);
|
||||
@ -1342,7 +1479,10 @@ BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
|
||||
{
|
||||
CRYPT_Free(str);
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
CRYPT_ReturnLastError(ERROR_MORE_DATA);
|
||||
{
|
||||
SetLastError(ERROR_MORE_DATA);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1375,7 +1515,10 @@ BOOL WINAPI CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData,
|
||||
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hHash, dwParam, pbData, pdwDataLen, dwFlags);
|
||||
|
||||
if (!hash || !pdwDataLen || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
return prov->pFuncs->pCPGetHashParam(prov->hPrivate, hash->hPrivate, dwParam,
|
||||
@ -1410,7 +1553,10 @@ BOOL WINAPI CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData,
|
||||
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hKey, dwParam, pbData, pdwDataLen, dwFlags);
|
||||
|
||||
if (!key || !pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
return prov->pFuncs->pCPGetKeyParam(prov->hPrivate, key->hPrivate, dwParam,
|
||||
@ -1444,7 +1590,10 @@ BOOL WINAPI CryptGetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData,
|
||||
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hProv, dwParam, pbData, pdwDataLen, dwFlags);
|
||||
|
||||
if (!prov || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return prov->pFuncs->pCPGetProvParam(prov->hPrivate, dwParam, pbData, pdwDataLen, dwFlags);
|
||||
}
|
||||
@ -1471,11 +1620,20 @@ BOOL WINAPI CryptGetUserKey (HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUse
|
||||
TRACE("(0x%lx, %d, %p)\n", hProv, dwKeySpec, phUserKey);
|
||||
|
||||
if (!prov)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!phUserKey || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
key->pProvider = prov;
|
||||
|
||||
@ -1514,9 +1672,15 @@ BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen
|
||||
TRACE("(0x%lx, %p, %d, %08x)\n", hHash, pbData, dwDataLen, dwFlags);
|
||||
|
||||
if (!hash)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
return prov->pFuncs->pCPHashData(prov->hPrivate, hash->hPrivate, pbData, dwDataLen, dwFlags);
|
||||
@ -1545,10 +1709,16 @@ BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags
|
||||
TRACE("(0x%lx, 0x%lx, %08x)\n", hHash, hKey, dwFlags);
|
||||
|
||||
if (!hash || !key)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
return prov->pFuncs->pCPHashSessionKey(prov->hPrivate, hash->hPrivate, key->hPrivate, dwFlags);
|
||||
@ -1580,10 +1750,16 @@ BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
|
||||
TRACE("(0x%lx, %p, %d, 0x%lx, %08x, %p)\n", hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
|
||||
|
||||
if (!prov || !pbData || !dwDataLen || !phKey || prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !(importkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
importkey->pProvider = prov;
|
||||
if (prov->pFuncs->pCPImportKey(prov->hPrivate, pbData, dwDataLen,
|
||||
@ -1629,9 +1805,15 @@ BOOL WINAPI CryptSignHashW (HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescript
|
||||
hHash, dwKeySpec, debugstr_w(sDescription), dwFlags, pbSignature, pdwSigLen);
|
||||
|
||||
if (!hash)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!pdwSigLen || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
return prov->pFuncs->pCPSignHash(prov->hPrivate, hash->hPrivate, dwKeySpec, sDescription,
|
||||
@ -1682,7 +1864,10 @@ BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DW
|
||||
TRACE("(0x%lx, %d, %p, %08x)\n", hHash, dwParam, pbData, dwFlags);
|
||||
|
||||
if (!hash || !pbData || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
return prov->pFuncs->pCPSetHashParam(prov->hPrivate, hash->hPrivate,
|
||||
@ -1712,7 +1897,10 @@ BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD
|
||||
TRACE("(0x%lx, %d, %p, %08x)\n", hKey, dwParam, pbData, dwFlags);
|
||||
|
||||
if (!key || !pbData || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = key->pProvider;
|
||||
return prov->pFuncs->pCPSetKeyParam(prov->hPrivate, key->hPrivate,
|
||||
@ -1773,20 +1961,33 @@ BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *p
|
||||
TRACE("(%s, %d, %p, %08x)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags);
|
||||
|
||||
if (!pszProvName || pdwReserved)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwProvType > MAXPROVTYPES)
|
||||
CRYPT_ReturnLastError(NTE_BAD_PROV_TYPE);
|
||||
{
|
||||
SetLastError(NTE_BAD_PROV_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags & ~(CRYPT_MACHINE_DEFAULT | CRYPT_USER_DEFAULT | CRYPT_DELETE_DEFAULT)
|
||||
|| dwFlags == CRYPT_DELETE_DEFAULT)
|
||||
CRYPT_ReturnLastError(NTE_BAD_FLAGS);
|
||||
|
||||
{
|
||||
SetLastError(NTE_BAD_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)))
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
keyname, &hTypeKey))
|
||||
{
|
||||
CRYPT_Free(keyname);
|
||||
CRYPT_ReturnLastError(NTE_BAD_PROVIDER);
|
||||
SetLastError(NTE_BAD_PROVIDER);
|
||||
return FALSE;
|
||||
}
|
||||
CRYPT_Free(keyname);
|
||||
|
||||
@ -1799,14 +2000,16 @@ BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *p
|
||||
if (!(keyname = CRYPT_GetProvKeyName(pszProvName)))
|
||||
{
|
||||
RegCloseKey(hTypeKey);
|
||||
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
keyname, &hProvKey))
|
||||
{
|
||||
CRYPT_Free(keyname);
|
||||
RegCloseKey(hTypeKey);
|
||||
CRYPT_ReturnLastError(NTE_BAD_PROVIDER);
|
||||
SetLastError(NTE_BAD_PROVIDER);
|
||||
return FALSE;
|
||||
}
|
||||
CRYPT_Free(keyname);
|
||||
|
||||
@ -1867,9 +2070,15 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DW
|
||||
TRACE("(0x%lx, %d, %p, %08x)\n", hProv, dwParam, pbData, dwFlags);
|
||||
|
||||
if (!prov)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (prov->dwMagic != MAGIC_CRYPTPROV)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (dwFlags & PP_USE_HARDWARE_RNG)
|
||||
{
|
||||
FIXME("PP_USE_HARDWARE_RNG: What do I do with this?\n");
|
||||
@ -1924,12 +2133,16 @@ BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dw
|
||||
dwSigLen, hPubKey, debugstr_w(sDescription), dwFlags);
|
||||
|
||||
if (!hash || !key)
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!pbSignature || !dwSigLen ||
|
||||
!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV ||
|
||||
!key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
|
||||
{
|
||||
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prov = hash->pProvider;
|
||||
|
Loading…
Reference in New Issue
Block a user