From cf770571bf538f2794f56220f649b232688d1736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 25 May 2021 17:37:11 +0200 Subject: [PATCH] dssenh: Return NTE_BAD_KEYSET when key cannot be opened. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30244 Signed-off-by: RĂ©mi Bernon Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/dssenh/main.c | 3 ++- dlls/dssenh/tests/dssenh.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/dssenh/main.c b/dlls/dssenh/main.c index 6cfa04393fd..b03c05195cd 100644 --- a/dlls/dssenh/main.c +++ b/dlls/dssenh/main.c @@ -284,7 +284,8 @@ BOOL WINAPI CPAcquireContext( HCRYPTPROV *ret_prov, LPSTR container, DWORD flags { case 0: case 0 | CRYPT_MACHINE_KEYSET: - ret = read_key_container( name, flags ); + if (!(ret = read_key_container( name, flags ))) + SetLastError( NTE_BAD_KEYSET ); break; case CRYPT_NEWKEYSET: diff --git a/dlls/dssenh/tests/dssenh.c b/dlls/dssenh/tests/dssenh.c index b72b1e3a614..f0fe4a02f97 100644 --- a/dlls/dssenh/tests/dssenh.c +++ b/dlls/dssenh/tests/dssenh.c @@ -75,7 +75,7 @@ static void test_acquire_context(void) result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_DSS, 0); if (!result) { - todo_wine ok(GetLastError() == NTE_BAD_KEYSET, "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); + ok(GetLastError() == NTE_BAD_KEYSET, "Expected NTE_BAD_KEYSET, got %08x\n", GetLastError()); SetLastError(0xdeadbeef); result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_DSS, CRYPT_NEWKEYSET); }