I am trying to store the key in TPM using CNG NCryptOpenStorageProvide "MS_PLATFORM_CRYPTO_PROVIDER".
Please any one help on How to use CNG functions for accessing TPM read and Write.
I am trying to store the key in TPM using CNG NCryptOpenStorageProvide "MS_PLATFORM_CRYPTO_PROVIDER".
Please any one help on How to use CNG functions for accessing TPM read and Write.
Assuming by "store a key in TPM" you mean "create a persisted key in the TPM":
NCRYPT_PROV_HANDLE hProv = NULL;
NCRYPT_KEY_HANDLE hKey = NULL;
PCWSTR keyName = L"MyKey";
NCryptOpenStorageProvider(
&hProv,
MS_PLATFORM_CRYPTO_PROVIDER,
0);
NCryptCreatePersistedKey(
hProv,
&hKey,
BCRYPT_RSA_ALGORITHM,
keyName,
0,
NCRYPT_OVERWRITE_KEY_FLAG);
NCryptFinalizeKey(hKey, 0);
Obviously you should check the return code of each invoked function.