Respect the sDescription parameter in CryptSignHash and

CryptVerifySignature.
This commit is contained in:
Michael Jung 2004-12-21 14:34:18 +00:00 committed by Alexandre Julliard
parent 6fb1a20020
commit a3b97e051a
2 changed files with 64 additions and 32 deletions

View File

@ -81,7 +81,7 @@
@ stdcall CryptImportKey(long ptr long long long ptr) @ stdcall CryptImportKey(long ptr long long long ptr)
@ stdcall CryptReleaseContext(long long) @ stdcall CryptReleaseContext(long long)
@ stdcall CryptSignHashA(long long ptr long ptr ptr) @ stdcall CryptSignHashA(long long ptr long ptr ptr)
@ stdcall CryptSignHashW(long long ptr long ptr ptr) CryptSignHashA @ stdcall CryptSignHashW(long long ptr long ptr ptr)
@ stdcall CryptSetHashParam(long long ptr long) @ stdcall CryptSetHashParam(long long ptr long)
@ stdcall CryptSetKeyParam(long long ptr long) @ stdcall CryptSetKeyParam(long long ptr long)
@ stdcall CryptSetProviderA(str long) @ stdcall CryptSetProviderA(str long)
@ -90,7 +90,7 @@
@ stdcall CryptSetProviderExW(wstr long ptr long) @ stdcall CryptSetProviderExW(wstr long ptr long)
@ stdcall CryptSetProvParam(long long ptr long) @ stdcall CryptSetProvParam(long long ptr long)
@ stdcall CryptVerifySignatureA(long ptr long long ptr long) @ stdcall CryptVerifySignatureA(long ptr long long ptr long)
@ stdcall CryptVerifySignatureW(long ptr long long ptr long) CryptVerifySignatureA @ stdcall CryptVerifySignatureW(long ptr long long ptr long)
@ stdcall DecryptFileA(str long) @ stdcall DecryptFileA(str long)
@ stdcall DecryptFileW(wstr long) @ stdcall DecryptFileW(wstr long)
@ stdcall DeleteAce(ptr long) @ stdcall DeleteAce(ptr long)

View File

@ -1552,14 +1552,6 @@ BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
} }
/****************************************************************************** /******************************************************************************
* CryptSignHashA
*
* Note: Since the sDesciption (string) is supposed to be NULL and
* is only retained for compatibility no string conversions are required
* and only one implementation is required for both ANSI and Unicode.
* We still need to export both:
*
* CryptSignHashA (ADVAPI32.@)
* CryptSignHashW (ADVAPI32.@) * CryptSignHashW (ADVAPI32.@)
* *
* Signs data. * Signs data.
@ -1567,7 +1559,7 @@ BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
* PARAMS * PARAMS
* hHash [I] Handle of the hash object to be signed. * hHash [I] Handle of the hash object to be signed.
* dwKeySpec [I] Private key to use. * dwKeySpec [I] Private key to use.
* sDescription [I] Must be NULL. * sDescription [I] Should be NULL.
* dwFlags [I] CRYPT_NOHASHOID/X931_FORMAT. * dwFlags [I] CRYPT_NOHASHOID/X931_FORMAT.
* pbSignature [O] Buffer of the signature data. * pbSignature [O] Buffer of the signature data.
* pdwSigLen [I/O] Size of the pbSignature buffer. * pdwSigLen [I/O] Size of the pbSignature buffer.
@ -1575,16 +1567,20 @@ BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
* RETURNS * RETURNS
* Success: TRUE * Success: TRUE
* Failure: FALSE * Failure: FALSE
*
* NOTES
* Because of security flaws sDescription should not be used and should thus be
* NULL. It is supported only for compatibility with Microsoft's Cryptographic
* Providers.
*/ */
BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription, BOOL WINAPI CryptSignHashW (HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription,
DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen) DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
{ {
PCRYPTHASH hash = (PCRYPTHASH)hHash; PCRYPTHASH hash = (PCRYPTHASH)hHash;
PCRYPTPROV prov; PCRYPTPROV prov;
TRACE("(0x%lx, %ld, %08ld, %p, %p)\n", hHash, dwKeySpec, dwFlags, pbSignature, pdwSigLen); TRACE("(0x%lx, %ld, %s, %08ld, %p, %p)\n",
if (sDescription) hHash, dwKeySpec, debugstr_w(sDescription), dwFlags, pbSignature, pdwSigLen);
WARN("The sDescription parameter is not supported (and no longer used). Ignoring.\n");
if (!hash) if (!hash)
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE); CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@ -1592,10 +1588,31 @@ BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescripti
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER); CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
prov = hash->pProvider; prov = hash->pProvider;
return prov->pFuncs->pCPSignHash(prov->hPrivate, hash->hPrivate, dwKeySpec, NULL, return prov->pFuncs->pCPSignHash(prov->hPrivate, hash->hPrivate, dwKeySpec, sDescription,
dwFlags, pbSignature, pdwSigLen); dwFlags, pbSignature, pdwSigLen);
} }
/******************************************************************************
* CryptSignHashA (ADVAPI32.@)
*
* ASCII version of CryptSignHashW
*/
BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription,
DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
{
LPWSTR wsDescription;
BOOL result;
TRACE("(0x%lx, %ld, %s, %08ld, %p, %p)\n",
hHash, dwKeySpec, debugstr_a(sDescription), dwFlags, pbSignature, pdwSigLen);
CRYPT_ANSIToUnicode(sDescription, &wsDescription, -1);
result = CryptSignHashW(hHash, dwKeySpec, wsDescription, dwFlags, pbSignature, pdwSigLen);
if (wsDescription) CRYPT_Free(wsDescription);
return result;
}
/****************************************************************************** /******************************************************************************
* CryptSetHashParam (ADVAPI32.@) * CryptSetHashParam (ADVAPI32.@)
* *
@ -1825,14 +1842,6 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DW
} }
/****************************************************************************** /******************************************************************************
* CryptVerifySignatureA
*
* Note: Since the sDesciption (string) is supposed to be NULL and
* is only retained for compatibility no string conversions are required
* and only one implementation is required for both ANSI and Unicode.
* We still need to export both:
*
* CryptVerifySignatureA (ADVAPI32.@)
* CryptVerifySignatureW (ADVAPI32.@) * CryptVerifySignatureW (ADVAPI32.@)
* *
* Verifies the signature of a hash object. * Verifies the signature of a hash object.
@ -1842,24 +1851,27 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DW
* pbSignature [I] Signature data to verify. * pbSignature [I] Signature data to verify.
* dwSigLen [I] Size of pbSignature. * dwSigLen [I] Size of pbSignature.
* hPubKey [I] Handle to the public key to authenticate signature. * hPubKey [I] Handle to the public key to authenticate signature.
* sDescription [I] Must be set to NULL. * sDescription [I] Should be NULL.
* dwFlags [I] See MSDN doc. * dwFlags [I] See MSDN doc.
* *
* RETURNS * RETURNS
* Success: TRUE * Success: TRUE
* Failure: FALSE * Failure: FALSE
*
* NOTES
* Because of security flaws sDescription should not be used and should thus be
* NULL. It is supported only for compatibility with Microsoft's Cryptographic
* Providers.
*/ */
BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dwSigLen, BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dwSigLen,
HCRYPTKEY hPubKey, LPCSTR sDescription, DWORD dwFlags) HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
{ {
PCRYPTHASH hash = (PCRYPTHASH)hHash; PCRYPTHASH hash = (PCRYPTHASH)hHash;
PCRYPTKEY key = (PCRYPTKEY)hPubKey; PCRYPTKEY key = (PCRYPTKEY)hPubKey;
PCRYPTPROV prov; PCRYPTPROV prov;
TRACE("(0x%lx, %p, %ld, 0x%lx, %08ld)\n", hHash, pbSignature, TRACE("(0x%lx, %p, %ld, 0x%lx, %s, %08ld)\n", hHash, pbSignature,
dwSigLen, hPubKey, dwFlags); dwSigLen, hPubKey, debugstr_w(sDescription), dwFlags);
if (sDescription)
WARN("The sDescription parameter is not supported (and no longer used). Ignoring.\n");
if (!hash || !key) if (!hash || !key)
CRYPT_ReturnLastError(ERROR_INVALID_HANDLE); CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@ -1868,9 +1880,29 @@ BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dw
prov = hash->pProvider; prov = hash->pProvider;
return prov->pFuncs->pCPVerifySignature(prov->hPrivate, hash->hPrivate, pbSignature, dwSigLen, return prov->pFuncs->pCPVerifySignature(prov->hPrivate, hash->hPrivate, pbSignature, dwSigLen,
key->hPrivate, NULL, dwFlags); key->hPrivate, sDescription, dwFlags);
} }
/******************************************************************************
* CryptVerifySignatureA (ADVAPI32.@)
*
* ASCII version of CryptVerifySignatureW
*/
BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dwSigLen,
HCRYPTKEY hPubKey, LPCSTR sDescription, DWORD dwFlags)
{
LPWSTR wsDescription;
BOOL result;
TRACE("(0x%lx, %p, %ld, 0x%lx, %s, %08ld)\n", hHash, pbSignature,
dwSigLen, hPubKey, debugstr_a(sDescription), dwFlags);
CRYPT_ANSIToUnicode(sDescription, &wsDescription, -1);
result = CryptVerifySignatureW(hHash, pbSignature, dwSigLen, hPubKey, wsDescription, dwFlags);
if (wsDescription) CRYPT_Free(wsDescription);
return result;
}
/* /*
These functions have nearly identical prototypes to CryptProtectMemory and CryptUnprotectMemory, These functions have nearly identical prototypes to CryptProtectMemory and CryptUnprotectMemory,