https://bugs.winehq.org/show_bug.cgi?id=47038
--- Comment #3 from Dmitry Timoshkov dmitry@baikal.ru --- (In reply to tijs96 from comment #2)
I don't have a windows machine to test right now, but the documentation suggests wine is correct in returning an error.
The documentation for the NTE_BAD_KEYSET error code says:
"The key container could not be opened. A common cause of this error is that the key container does not exist. To create a key container, call CryptAcquireContext using the CRYPT_NEWKEYSET flag." https://docs.microsoft.com/en-us/windows/desktop/api/wincrypt/nf-wincrypt- cryptacquirecontexta
The application never makes a call with that flag set. The application might be relying on *phProv getting set to null when an error occurs. In that case CryptGenRandom would also just return an error instead of crashing.
Example code on https://docs.microsoft.com/en-us/windows/desktop/SecCrypto/example-c-program... creating-a-key-container-and-generating-keys also checks for that error and tries again with the CRYPT_NEWKEYSET flag.
The problem has nothing to do with NTE_BAD_KEYSET error code, the app asks to open the default container, and that fails under Wine.