From: Hans Leidekker <hans@codeweavers.com> --- dlls/crypt32/cert.c | 2 +- dlls/crypt32/pfx.c | 4 ++-- dlls/crypt32/tests/cert.c | 10 +++++----- dlls/secur32/schannel.c | 2 +- include/wincrypt.h | 9 ++++++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 08517456112..5014e2a5600 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -880,7 +880,7 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, break; } keyContext.cbSize = sizeof(keyContext); - keyContext.hCryptProv = *(const HCRYPTPROV *)pvData; + keyContext.hNCryptKey = *(const NCRYPT_KEY_HANDLE *)pvData; keyContext.dwKeySpec = CERT_NCRYPT_KEY_SPEC; ret = CertContext_SetKeyContextProperty(cert->base.properties, &keyContext); break; diff --git a/dlls/crypt32/pfx.c b/dlls/crypt32/pfx.c index 3a86fce3165..b7419e4f446 100644 --- a/dlls/crypt32/pfx.c +++ b/dlls/crypt32/pfx.c @@ -385,7 +385,7 @@ BOOL WINAPI PFXExportCertStoreEx( HCERTSTORE store, CRYPT_DATA_BLOB *pfx, const else if (key_ctx.dwKeySpec == CERT_NCRYPT_KEY_SPEC) { /* Query key blob size first. */ - sec_status = NCryptExportKey( key_ctx.hCryptProv, 0, BCRYPT_RSAFULLPRIVATE_BLOB, NULL, + sec_status = NCryptExportKey( key_ctx.hNCryptKey, 0, BCRYPT_RSAFULLPRIVATE_BLOB, NULL, NULL, 0, &key_blob_size, 0 ); if (sec_status) { @@ -403,7 +403,7 @@ BOOL WINAPI PFXExportCertStoreEx( HCERTSTORE store, CRYPT_DATA_BLOB *pfx, const return FALSE; } - sec_status = NCryptExportKey( key_ctx.hCryptProv, 0, BCRYPT_RSAFULLPRIVATE_BLOB, NULL, + sec_status = NCryptExportKey( key_ctx.hNCryptKey, 0, BCRYPT_RSAFULLPRIVATE_BLOB, NULL, key_blob, key_blob_size, &key_blob_size, 0 ); if (sec_status) { diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index f8d1c37b63c..57222591836 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -554,12 +554,12 @@ static void testCertProperties(void) /* Verify the key context was set with CERT_NCRYPT_KEY_SPEC */ size = sizeof(keyContext); - keyContext.hCryptProv = keyContext.dwKeySpec = 0; + keyContext.hNCryptKey = keyContext.dwKeySpec = 0; ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(keyContext.hCryptProv != 0, - "Expected non-zero hCryptProv, got 0\n"); + ok(keyContext.hNCryptKey != 0, + "Expected non-zero hNCryptKey, got 0\n"); ok(keyContext.dwKeySpec == CERT_NCRYPT_KEY_SPEC, "Expected dwKeySpec CERT_NCRYPT_KEY_SPEC, got %lx\n", keyContext.dwKeySpec); @@ -568,8 +568,8 @@ static void testCertProperties(void) ret = CertGetCertificateContextProperty(context, CERT_NCRYPT_KEY_HANDLE_PROP_ID, &retrievedHandle, &size); ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); - ok(retrievedHandle == keyContext.hCryptProv, - "Expected handle %Ix, got %Ix\n", keyContext.hCryptProv, retrievedHandle); + ok(retrievedHandle == keyContext.hNCryptKey, + "Expected handle %Ix, got %Ix\n", keyContext.hNCryptKey, retrievedHandle); ok(size == sizeof(retrievedHandle), "Expected size %Iu, got %lu\n", sizeof(retrievedHandle), size); diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c index 261d0606244..19eda9e0026 100644 --- a/dlls/secur32/schannel.c +++ b/dlls/secur32/schannel.c @@ -648,7 +648,7 @@ static BYTE *get_key_blob_ncrypt(const CERT_CONTEXT *ctx, DWORD *size) if (keyctx.dwKeySpec != CERT_NCRYPT_KEY_SPEC) return NULL; - key = keyctx.hCryptProv; + key = keyctx.hNCryptKey; status = NCryptExportKey(key, 0, BCRYPT_RSAFULLPRIVATE_BLOB, NULL, NULL, 0, &blob_size, 0); if (status) diff --git a/include/wincrypt.h b/include/wincrypt.h index 8d724d92092..362b88b9d9e 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -219,9 +219,12 @@ typedef struct _CRYPT_KEY_PROV_INFO { } CRYPT_KEY_PROV_INFO, *PCRYPT_KEY_PROV_INFO; typedef struct _CERT_KEY_CONTEXT { - DWORD cbSize; - HCRYPTPROV hCryptProv; - DWORD dwKeySpec; + DWORD cbSize; + union { + HCRYPTPROV hCryptProv; + NCRYPT_KEY_HANDLE hNCryptKey; + } DUMMYUNIONNAME; + DWORD dwKeySpec; } CERT_KEY_CONTEXT, *PCERT_KEY_CONTEXT; typedef struct _CERT_PUBLIC_KEY_INFO { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10948