1

The below powershell command correctly lists all the keys for my local machine store:

certutil -csp "Microsoft Software Key Storage Provider" -key

However, I am not able to do the same through C++ code using NCryptOpenStorageProvider and NCryptOpenKey APIs. I suspect that NCryptOpenStorageProvider is not giving me the list that includes Local Machine keys. My API usage is as below:

NCryptOpenStorageProvider(&prov, MS_KEY_STORAGE_PROVIDER, 0);
NCryptOpenKey(prov, &keyHandle, pCryptKeyProvInfo->pwszContainerName, 0, NCRYPT_MACHINE_KEY_FLAG);

Can someone provide a clue on this? Thanks in advance.

Additional info: certutil -csp "Microsoft Software Key Storage Provider" -key returns NULL when run normally, but gives the proper list of keys only when run with Admin privilge. So, I assume it has something to do with privileges. Can someone suggest where I can update the privileges for my KSP corresponding to Local Machine?

Braiam
  • 1
  • 11
  • 47
  • 78

0 Answers0