79170504

Date: 2024-11-08 14:56:00
Score: 2
Natty:
Report link

I have updated the code with the final answer.

After the first call to CryptAcquireContext fails with error "Keyset does not exist" I make a second call to CryptAcquireContext with dwFlags parameter set to CRYPT_NEWKEYSET. This succeeded, and when it is run again, the first call now succeeds. The first CSP with PROV_RSA_FULL type: Microsoft Base Cryptographic Provider v1.0 now has a default Keyset. This implies none of my CSPs with PROV_RSA_FULL type had a default Keyset.

Thanks to bartonjs for catching the pszName parameter issue. "pszName is the name of the CSP, but you're passing it to CryptAcquireContext as the name of a key container" With this fixed, the first call to CryptAcquireContext still returned the same error "Keyset does not exist".

https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/SecCrypto/example-c-program-using-cryptacquirecontext.md is an example of creating a Keyset

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: John Rainey