[PATCH 5/5] dssenh: Implement CPHashData.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> --- dlls/dssenh/main.c | 12 +++++++++++- dlls/dssenh/tests/dssenh.c | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dlls/dssenh/main.c b/dlls/dssenh/main.c index e406117e97..77b5570fc5 100644 --- a/dlls/dssenh/main.c +++ b/dlls/dssenh/main.c @@ -1,5 +1,6 @@ /* * Copyright 2008 Maarten Lankhorst + * Copyright 2020 Hans Leidekker for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -413,7 +414,16 @@ BOOL WINAPI CPDestroyHash( HCRYPTPROV hprov, HCRYPTHASH hhash ) BOOL WINAPI CPHashData( HCRYPTPROV hprov, HCRYPTHASH hhash, const BYTE *data, DWORD len, DWORD flags ) { - return FALSE; + struct hash *hash = (struct hash *)hhash; + + TRACE("%p, %p, %p, %u, %08x\n", hprov, hhash, data, len, flags ); + + if (hash->magic != MAGIC_HASH) return FALSE; + + if (hash->finished || BCryptHashData( hash->handle, (UCHAR *)data, len, 0 )) return FALSE; + + hash->finished = TRUE; + return TRUE; } BOOL WINAPI CPGetHashParam( HCRYPTPROV hprov, HCRYPTHASH hhash, DWORD param, BYTE *data, DWORD *len, DWORD flags ) diff --git a/dlls/dssenh/tests/dssenh.c b/dlls/dssenh/tests/dssenh.c index f06cdd1433..cc4650b2c8 100644 --- a/dlls/dssenh/tests/dssenh.c +++ b/dlls/dssenh/tests/dssenh.c @@ -449,15 +449,15 @@ static void test_hash(const struct hash_test *tests, int testLen) ok(result, "Expected creation of a hash.\n"); result = CryptHashData(hHash, data, dataLen, 0); + ok(result, "Expected data to be added to hash.\n"); + + dataLen = sizeof(DWORD); + result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE *)&hashLen, &dataLen, 0); if (!result) { skip("skipping hash tests\n"); return; } - ok(result, "Expected data to be added to hash.\n"); - - dataLen = sizeof(DWORD); - result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE *)&hashLen, &dataLen, 0); ok(result && (hashLen == tests[i].hashLen), "Expected %d hash len, got %d.Error: %x\n", tests[i].hashLen, hashLen, GetLastError()); @@ -608,15 +608,15 @@ static void test_data_encryption(const struct encrypt_test *tests, int testLen) ok(result, "Expected creation of a MD5 hash for key derivation.\n"); result = CryptHashData(hHash, (BYTE *)dataToHash, sizeof(dataToHash), 0); + ok(result, "Expected data to be added to hash for key derivation.\n"); + + /* Derive key */ + result = CryptDeriveKey(hProv, tests[i].algid, hHash, tests[i].keyLength, &pKey); if (!result) { skip("skipping encryption tests\n"); return; } - ok(result, "Expected data to be added to hash for key derivation.\n"); - - /* Derive key */ - result = CryptDeriveKey(hProv, tests[i].algid, hHash, tests[i].keyLength, &pKey); ok(result, "Expected a derived key.\n"); result = CryptDestroyHash(hHash); @@ -698,15 +698,15 @@ static void test_cipher_modes(const struct ciphermode_test *tests, int testLen) ok(result, "Expected creation of a MD5 hash for key derivation.\n"); result = CryptHashData(hHash, (BYTE *)dataToHash, sizeof(dataToHash), 0); + ok(result, "Expected data to be added to hash for key derivation.\n"); + + /* Derive a CALG_RC2 key, but could be any other encryption cipher */ + result = CryptDeriveKey(hProv, CALG_RC2, hHash, 40 << 16, &pKey); if (!result) { skip("skipping ciper modes tests\n"); return; } - ok(result, "Expected data to be added to hash for key derivation.\n"); - - /* Derive a CALG_RC2 key, but could be any other encryption cipher */ - result = CryptDeriveKey(hProv, CALG_RC2, hHash, 40 << 16, &pKey); ok(result, "Expected a derived key.\n"); result = CryptDestroyHash(hHash); -- 2.28.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=80034 Your paranoid android. === debiant (32 bit report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019 === debiant (32 bit French report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019 === debiant (32 bit Japanese:Japan report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019 === debiant (32 bit Chinese:China report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019 === debiant (32 bit WoW report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019 === debiant (64 bit WoW report) === dssenh: dssenh.c:57: Test failed: Expected NTE_PROV_TYPE_NO_MATCH, got 80090019
participants (2)
-
Hans Leidekker -
Marvin