CngKey Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Defines the core functionality for keys that are used with Cryptography Next Generation (CNG) objects.

Namespace:   System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)

System.Object
  System.Security.Cryptography.CngKey

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
public sealed class CngKey : IDisposable

NameDescription
System_CAPS_pubpropertyAlgorithm

Gets the algorithm that is used by the key.

System_CAPS_pubpropertyAlgorithmGroup

Gets the algorithm group that is used by the key.

System_CAPS_pubpropertyExportPolicy

Gets the export policy that is used by the key.

System_CAPS_pubpropertyHandle

Gets a safe handle that represents a native key (NCRYPT_KEY_HANDLE).

System_CAPS_pubpropertyIsEphemeral

Gets the persistence state of the key.

System_CAPS_pubpropertyIsMachineKey

Gets the scope (machine or user) of the key.

System_CAPS_pubpropertyKeyName

Gets the name of the key.

System_CAPS_pubpropertyKeySize

Gets the key size in bits.

System_CAPS_pubpropertyKeyUsage

Gets the cryptographic operations specified by the key.

System_CAPS_pubpropertyParentWindowHandle

Gets or sets the window handle (HWND) that should be used for user interface (UI) prompts caused by accessing the key.

System_CAPS_pubpropertyProvider

Gets the key storage provider (KSP) that manages the key.

System_CAPS_pubpropertyProviderHandle

Gets a native handle (an NCRYPT_PROV_HANDLE) to the key storage provider (KSP).

System_CAPS_pubpropertyUIPolicy

Gets parameters that control the user interface (UI) for accessing the key.

System_CAPS_pubpropertyUniqueName

Gets the unique name for the key.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticCreate(CngAlgorithm)

Creates a CngKey object that can be used with the specified algorithm.

System_CAPS_pubmethodSystem_CAPS_staticCreate(CngAlgorithm, String)

Creates a named CngKey object that provides the specified algorithm.

System_CAPS_pubmethodSystem_CAPS_staticCreate(CngAlgorithm, String, CngKeyCreationParameters)

Creates a named CngKey object that provides the specified algorithm, using the supplied key creation parameters.

System_CAPS_pubmethodDelete()

Removes the key that is associated with the object.

System_CAPS_pubmethodDispose()

Releases all resources used by the current instance of the CngKey class.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticExists(String)

Checks to see whether a named key exists in the default key storage provider (KSP).

System_CAPS_pubmethodSystem_CAPS_staticExists(String, CngProvider)

Checks to see whether a named key exists in the specified key storage provider (KSP).

System_CAPS_pubmethodSystem_CAPS_staticExists(String, CngProvider, CngKeyOpenOptions)

Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.

System_CAPS_pubmethodExport(CngKeyBlobFormat)

Exports the key material into a BLOB, in the specified format.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetProperty(String, CngPropertyOptions)

Gets a property, given a name and a set of property options.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodHasProperty(String, CngPropertyOptions)

Checks to see whether the specified property exists on the key.

System_CAPS_pubmethodSystem_CAPS_staticImport(Byte[], CngKeyBlobFormat)

Creates a new key by importing the specified key material into the default key storage provider (KSP) and using the specified format.

System_CAPS_pubmethodSystem_CAPS_staticImport(Byte[], CngKeyBlobFormat, CngProvider)

Creates a new key by importing the specified key material into the specified key storage provider (KSP), using the specified format.

System_CAPS_pubmethodSystem_CAPS_staticOpen(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)

Creates an instance of an CngKey object by using a handle to an existing key.

System_CAPS_pubmethodSystem_CAPS_staticOpen(String)

Creates an instance of an CngKey object that represents an existing named key.

System_CAPS_pubmethodSystem_CAPS_staticOpen(String, CngProvider)

Creates an instance of an CngKey object that represents an existing named key, using the specified key storage provider (KSP).

System_CAPS_pubmethodSystem_CAPS_staticOpen(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.

System_CAPS_pubmethodSetProperty(CngProperty)

Sets a named property on the key.

System_CAPS_pubmethodToString()

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.

.NET Framework
Available since 3.5

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: