Commit 1d7800bd authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Implemented parallel hashing in CPEncrypt and CPDecrypt.

Implemented CPHashSessionKey.
parent 054f9ecc
...@@ -240,6 +240,15 @@ RSAENH_CPImportKey( ...@@ -240,6 +240,15 @@ RSAENH_CPImportKey(
HCRYPTKEY *phKey HCRYPTKEY *phKey
); );
BOOL WINAPI
RSAENH_CPHashData(
HCRYPTPROV hProv,
HCRYPTHASH hHash,
CONST BYTE *pbData,
DWORD dwDataLen,
DWORD dwFlags
);
/****************************************************************************** /******************************************************************************
* CSP's handle table (used by all acquired key containers) * CSP's handle table (used by all acquired key containers)
*/ */
...@@ -1317,9 +1326,6 @@ BOOL WINAPI RSAENH_CPDuplicateKey(HCRYPTPROV hUID, HCRYPTKEY hKey, DWORD *pdwRes ...@@ -1317,9 +1326,6 @@ BOOL WINAPI RSAENH_CPDuplicateKey(HCRYPTPROV hUID, HCRYPTKEY hKey, DWORD *pdwRes
* This is useful for message signatures. * This is useful for message signatures.
* *
* This function uses the standard WINAPI protocol for querying data of dynamic length. * This function uses the standard WINAPI protocol for querying data of dynamic length.
*
* FIXME
* Parallel hashing not yet implemented.
*/ */
BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen) DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen)
...@@ -1359,6 +1365,10 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, ...@@ -1359,6 +1365,10 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash,
return FALSE; return FALSE;
} }
if (is_valid_handle(&handle_table, hHash, RSAENH_MAGIC_HASH)) {
if (!RSAENH_CPHashData(hProv, hHash, pbData, *pdwDataLen, 0)) return FALSE;
}
if (GET_ALG_TYPE(pCryptKey->aiAlgid) == ALG_TYPE_BLOCK) { if (GET_ALG_TYPE(pCryptKey->aiAlgid) == ALG_TYPE_BLOCK) {
if (!Final && (*pdwDataLen % pCryptKey->dwBlockLen)) { if (!Final && (*pdwDataLen % pCryptKey->dwBlockLen)) {
SetLastError(NTE_BAD_DATA); SetLastError(NTE_BAD_DATA);
...@@ -1438,9 +1448,6 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, ...@@ -1438,9 +1448,6 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash,
* This is useful for message signatures. * This is useful for message signatures.
* *
* This function uses the standard WINAPI protocol for querying data of dynamic length. * This function uses the standard WINAPI protocol for querying data of dynamic length.
*
* FIXME
* Parallel hashing not yet implemented.
*/ */
BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen) DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
...@@ -1520,6 +1527,10 @@ BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, ...@@ -1520,6 +1527,10 @@ BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash,
} }
if (Final) setup_key(pCryptKey); if (Final) setup_key(pCryptKey);
if (is_valid_handle(&handle_table, hHash, RSAENH_MAGIC_HASH)) {
if (!RSAENH_CPHashData(hProv, hHash, pbData, *pdwDataLen, 0)) return FALSE;
}
return TRUE; return TRUE;
} }
...@@ -2533,12 +2544,50 @@ BOOL WINAPI RSAENH_CPHashData(HCRYPTPROV hProv, HCRYPTHASH hHash, CONST BYTE *pb ...@@ -2533,12 +2544,50 @@ BOOL WINAPI RSAENH_CPHashData(HCRYPTPROV hProv, HCRYPTHASH hHash, CONST BYTE *pb
/****************************************************************************** /******************************************************************************
* CPHashSessionKey (RSAENH.@) * CPHashSessionKey (RSAENH.@)
*
* Updates a hash object with the binary representation of a symmetric key.
*
* PARAMS
* hProv [I] Key container to which the hash object belongs.
* hHash [I] Hash object which is to be updated.
* hKey [I] The symmetric key, whose binary value will be added to the hash.
* dwFlags [I] CRYPT_LITTLE_ENDIAN, if the binary key value shall be interpreted as little endian.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE.
*/ */
BOOL WINAPI RSAENH_CPHashSessionKey(HCRYPTPROV hProv, HCRYPTHASH hHash, HCRYPTKEY hKey, BOOL WINAPI RSAENH_CPHashSessionKey(HCRYPTPROV hProv, HCRYPTHASH hHash, HCRYPTKEY hKey,
DWORD dwFlags) DWORD dwFlags)
{ {
FIXME("(stub)\n"); BYTE abKeyValue[RSAENH_MAX_KEY_SIZE], bTemp;
return FALSE; CRYPTKEY *pKey;
DWORD i;
TRACE("(hProv=%08lx, hHash=%08lx, hKey=%08lx, dwFlags=%08lx)\n", hProv, hHash, hKey, dwFlags);
if (!lookup_handle(&handle_table, (unsigned int)hKey, RSAENH_MAGIC_KEY, (OBJECTHDR**)&pKey) ||
(GET_ALG_CLASS(pKey->aiAlgid) != ALG_CLASS_DATA_ENCRYPT))
{
SetLastError(NTE_BAD_KEY);
return FALSE;
}
if (dwFlags & ~CRYPT_LITTLE_ENDIAN) {
SetLastError(NTE_BAD_FLAGS);
return FALSE;
}
memcpy(abKeyValue, pKey->abKeyValue, pKey->dwKeyLen);
if (!(dwFlags & CRYPT_LITTLE_ENDIAN)) {
for (i=0; i<pKey->dwKeyLen/2; i++) {
bTemp = abKeyValue[i];
abKeyValue[i] = abKeyValue[pKey->dwKeyLen-i-1];
abKeyValue[pKey->dwKeyLen-i-1] = bTemp;
}
}
return RSAENH_CPHashData(hProv, hHash, abKeyValue, pKey->dwKeyLen, 0);
} }
/****************************************************************************** /******************************************************************************
......
...@@ -748,10 +748,15 @@ static const WCHAR MS_SCARD_PROV_W[] = { 'M','i','c','r','o','s','o',' ...@@ -748,10 +748,15 @@ static const WCHAR MS_SCARD_PROV_W[] = { 'M','i','c','r','o','s','o','
#define CRYPT_NO_SALT 0x00000010 #define CRYPT_NO_SALT 0x00000010
#define CRYPT_PREGEN 0x00000040 #define CRYPT_PREGEN 0x00000040
#define CRYPT_ARCHIVABLE 0x00004000 #define CRYPT_ARCHIVABLE 0x00004000
/* CryptExportKey */
#define CRYPT_SSL2_FALLBACK 0x00000002 #define CRYPT_SSL2_FALLBACK 0x00000002
#define CRYPT_DESTROYKEY 0x00000004 #define CRYPT_DESTROYKEY 0x00000004
#define CRYPT_OAEP 0x00000040 #define CRYPT_OAEP 0x00000040
/* CryptHashSessionKey */
#define CRYPT_LITTLE_ENDIAN 0x00000001
/* Blob Types */ /* Blob Types */
#define SIMPLEBLOB 0x1 #define SIMPLEBLOB 0x1
#define PUBLICKEYBLOB 0x6 #define PUBLICKEYBLOB 0x6
......
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