Is it acceptable that I cache HCRYPTPROV
returned by CryptAcquireContext when my app starts and reuse it for later cryptographic calls (i.e. calculating HMACs and encrypting/AES) in a form as such:
HCRYPTPROV global_hProvSingleton = NULL;
HCRYPTPROV getCryptoContextSingleton()
{
if(!global_hProvSingleton)
{
//Do it only once
::CryptAcquireContext(&global_hProvSingleton, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_NEWKEYSET);
}
return global_hProvSingleton;
}