-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Securityin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Background and motivation
One of the Windows 11 builds has added framework to help secure Windows keys with virtualization-based security (VBS). With this new capability, keys can be protected from admin-level key theft attacks with negligible effect on performance, reliability, or scale.
Win API:
https://learn.microsoft.com/en-us/windows/win32/api/ncrypt/nf-ncrypt-ncryptcreatepersistedkey
The proposal is to extend existing CngKeyCreationOptions API to include the new flags.
API Proposal
namespace System.Security.Cryptography;
[Flags]
public enum CngKeyCreationOptions : int
{
// existing:
// None = 0x00000000,
// MachineKey = 0x00000020, // NCRYPT_MACHINE_KEY_FLAG
// OverwriteExistingKey = 0x00000080, // NCRYPT_OVERWRITE_KEY_FLAG
// new APIs:
PreferVbs = 0x00010000, // NCRYPT_PREFER_VBS_FLAG
RequireVbs = 0x00020000, // NCRYPT_REQUIRE_VBS_FLAG
UsePerBootKey = 0x00040000, // NCRYPT_USE_PER_BOOT_KEY_FLAG
}API Usage
// Note: this API is Windows only
using System.Security.Cryptography;
CngKeyCreationParameters cngCreationParams = new()
{
Provider = CngProvider.MicrosoftSoftwareKeyStorageProvider,
KeyCreationOptions = CngKeyCreationOptions.RequireVbs | CngKeyCreationOptions.OverwriteExistingKey,
};
using (CngKey key = CngKey.Create(CngAlgorithm.ECDsaP256, "mySoftwareKey", cngCreationParams))
using (ECDsaCng ecdsa = new ECDsaCng(key))
{
// do stuff with the key
}Alternative Designs
No response
Risks
Very low - new flags to existing API
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Securityin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged