CngKey CngKey CngKey CngKey Class

Definition

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

public ref class CngKey sealed : IDisposable
public sealed class CngKey : IDisposable
type CngKey = class
    interface IDisposable
Public NotInheritable Class CngKey
Implements IDisposable
Inheritance
CngKeyCngKeyCngKeyCngKey
Implements

Remarks

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.

Constructors

CngKey() CngKey() CngKey() CngKey()

Properties

Algorithm Algorithm Algorithm Algorithm

Gets the algorithm that is used by the key.

AlgorithmGroup AlgorithmGroup AlgorithmGroup AlgorithmGroup

Gets the algorithm group that is used by the key.

ExportPolicy ExportPolicy ExportPolicy ExportPolicy

Gets the export policy that is used by the key.

Handle Handle Handle Handle

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

IsEphemeral IsEphemeral IsEphemeral IsEphemeral

Gets the persistence state of the key.

IsMachineKey IsMachineKey IsMachineKey IsMachineKey

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

KeyName KeyName KeyName KeyName

Gets the name of the key.

KeySize KeySize KeySize KeySize

Gets the key size in bits.

KeyUsage KeyUsage KeyUsage KeyUsage

Gets the cryptographic operations specified by the key.

ParentWindowHandle ParentWindowHandle ParentWindowHandle ParentWindowHandle

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

Provider Provider Provider Provider

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

ProviderHandle ProviderHandle ProviderHandle ProviderHandle

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

UIPolicy UIPolicy UIPolicy UIPolicy

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

UniqueName UniqueName UniqueName UniqueName

Gets the unique name for the key.

Methods

Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm)

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

Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String)

Creates a named CngKey object that provides the specified algorithm.

Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters)

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

Delete() Delete() Delete() Delete()

Removes the key that is associated with the object.

Dispose() Dispose() Dispose() Dispose()

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Exists(String) Exists(String) Exists(String) Exists(String)

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

Exists(String, CngProvider) Exists(String, CngProvider) Exists(String, CngProvider) Exists(String, CngProvider)

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

Exists(String, CngProvider, CngKeyOpenOptions) Exists(String, CngProvider, CngKeyOpenOptions) Exists(String, CngProvider, CngKeyOpenOptions) 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(CngKeyBlobFormat) Export(CngKeyBlobFormat) Export(CngKeyBlobFormat) Export(CngKeyBlobFormat)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetProperty(String, CngPropertyOptions) GetProperty(String, CngPropertyOptions) GetProperty(String, CngPropertyOptions) GetProperty(String, CngPropertyOptions)

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

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
HasProperty(String, CngPropertyOptions) HasProperty(String, CngPropertyOptions) HasProperty(String, CngPropertyOptions) HasProperty(String, CngPropertyOptions)

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

Import(Byte[], CngKeyBlobFormat) Import(Byte[], CngKeyBlobFormat) Import(Byte[], CngKeyBlobFormat) 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) Import(Byte[], CngKeyBlobFormat, CngProvider) Import(Byte[], CngKeyBlobFormat, CngProvider) 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.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions) Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions) Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions) Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)

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

Open(String) Open(String) Open(String) Open(String)

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

Open(String, CngProvider) Open(String, CngProvider) Open(String, CngProvider) 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) Open(String, CngProvider, CngKeyOpenOptions) Open(String, CngProvider, CngKeyOpenOptions) 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(CngProperty) SetProperty(CngProperty) SetProperty(CngProperty) SetProperty(CngProperty)

Sets a named property on the key.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to