Hans Leidekker (@hans) commented about dlls/crypt32/tests/cert.c:
+ CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); + ok(keyContext.hCryptProv == 0xBEEF1234, + "Expected hCryptProv 0xBEEF1234, got %Ix\n", keyContext.hCryptProv); + ok(keyContext.dwKeySpec == CERT_NCRYPT_KEY_SPEC, + "Expected dwKeySpec CERT_NCRYPT_KEY_SPEC, got %lx\n", keyContext.dwKeySpec); + + /* Get the NCrypt handle back via property 78 */ + size = sizeof(retrievedHandle); + ret = CertGetCertificateContextProperty(context, + CERT_NCRYPT_KEY_HANDLE_PROP_ID, &retrievedHandle, &size); + ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError()); + ok(retrievedHandle == 0xBEEF1234, + "Expected handle 0xBEEF1234, got %Ix\n", retrievedHandle); + ok(size == sizeof(retrievedHandle), + "Expected size %Iu, got %lu\n", sizeof(retrievedHandle), size); You should initialize the fields before the call:
/* Verify the key context was set with CERT_NCRYPT_KEY_SPEC */
size = sizeof(keyContext);
keyContext.hCryptProv = 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.dwKeySpec == CERT_NCRYPT_KEY_SPEC,
"Expected dwKeySpec CERT_NCRYPT_KEY_SPEC, got %lx\n", keyContext.dwKeySpec);
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10521#note_134526