CngKey Class
Defines the core functionality for keys that are used with Cryptography Next Generation (CNG) objects.
Assembly: System.Core (in System.Core.dll)
The CngKey type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Algorithm | Gets the algorithm that is used by the key. |
![]() | AlgorithmGroup | Gets the algorithm group that is used by the key. |
![]() | ExportPolicy | Gets the export policy that is used by the key. |
![]() | Handle | Gets a safe handle that represents a native key (NCRYPT_KEY_HANDLE). |
![]() | IsEphemeral | Gets the persistence state of the key. |
![]() | IsMachineKey | Gets the scope (machine or user) of the key. |
![]() | KeyName | Gets the name of the key. |
![]() | KeySize | Gets the key size in bits. |
![]() | KeyUsage | Gets the cryptographic operations specified by the key. |
![]() | ParentWindowHandle | Gets or sets the window handle (HWND) that should be used for user interface (UI) prompts caused by accessing the key. |
![]() | Provider | Gets the key storage provider (KSP) that manages the key. |
![]() | ProviderHandle | Gets a native handle (an NCRYPT_PROV_HANDLE) to the key storage provider (KSP). |
![]() | UIPolicy | Gets parameters that control the user interface (UI) for accessing the key. |
![]() | UniqueName | Gets the unique name for the key. |
| Name | Description | |
|---|---|---|
![]() ![]() | Create(CngAlgorithm) | Creates a CngKey object that can be used with the specified algorithm. |
![]() ![]() | Create(CngAlgorithm, String) | Creates a named CngKey object that provides the specified algorithm. |
![]() ![]() | Create(CngAlgorithm, String, CngKeyCreationParameters) | Creates a named CngKey object that provides the specified algorithm, using the supplied key creation parameters. |
![]() | Delete | Removes the key that is associated with the object. |
![]() | Dispose | Releases all resources used by the current instance of the CngKey class. |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() ![]() | Exists(String) | Checks to see whether a named key exists in the default key storage provider (KSP). |
![]() ![]() | Exists(String, CngProvider) | Checks to see whether a named key exists in the specified key storage provider (KSP). |
![]() ![]() | Exists(String, CngProvider, CngKeyOpenOptions) | Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options. |
![]() | Export | Exports the key material into a BLOB, in the specified format. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetProperty | Gets a property, given a name and a set of property options. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | HasProperty | Checks to see whether the specified property exists on the key. |
![]() ![]() | Import(Byte[], CngKeyBlobFormat) | Creates a new key by importing the specified key material into the default key storage provider (KSP) and using the specified format. |
![]() ![]() | Import(Byte[], CngKeyBlobFormat, CngProvider) | Creates a new key by importing the specified key material into the specified key storage provider (KSP), using the specified format. |
![]() ![]() | Open(String) | Creates an instance of an CngKey object that represents an existing named key. |
![]() ![]() | Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions) | Creates an instance of an CngKey object by using a handle to an existing key. |
![]() ![]() | Open(String, CngProvider) | Creates an instance of an CngKey object that represents an existing named key, using the specified key storage provider (KSP). |
![]() ![]() | Open(String, CngProvider, CngKeyOpenOptions) | Creates an instance of an CngKey object that represents an existing named key, using the specified key storage provider (KSP) and key open options. |
![]() | SetProperty | Sets a named property on the key. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
This class wraps NCrypt keys, not BCrypt keys. NCrypt is a subset of CNG that provides key storage functionality. BCrypt is a subset that provides base cryptographic services such as random number generation, hash functions, signatures, and encryption keys.
Note |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: MayLeakOnAbort. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



Note