Export (0) Print
Expand All

CngKey Class

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

System.Object
  System.Security.Cryptography.CngKey

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

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

The CngKey type exposes the following members.

  NameDescription
Public propertyAlgorithmGets the algorithm that is used by the key.
Public propertyAlgorithmGroupGets the algorithm group that is used by the key.
Public propertyExportPolicyGets the export policy that is used by the key.
Public propertyHandleGets a safe handle that represents a native key (NCRYPT_KEY_HANDLE).
Public propertyIsEphemeralGets the persistence state of the key.
Public propertyIsMachineKeyGets the scope (machine or user) of the key.
Public propertyKeyNameGets the name of the key.
Public propertyKeySizeGets the key size in bits.
Public propertyKeyUsageGets the cryptographic operations specified by the key.
Public propertyParentWindowHandleGets or sets the window handle (HWND) that should be used for user interface (UI) prompts caused by accessing the key.
Public propertyProviderGets the key storage provider (KSP) that manages the key.
Public propertyProviderHandleGets a native handle (an NCRYPT_PROV_HANDLE) to the key storage provider (KSP).
Public propertyUIPolicyGets parameters that control the user interface (UI) for accessing the key.
Public propertyUniqueNameGets the unique name for the key.
Top

  NameDescription
Public methodStatic memberCreate(CngAlgorithm)Creates a CngKey object that can be used with the specified algorithm.
Public methodStatic memberCreate(CngAlgorithm, String)Creates a named CngKey object that provides the specified algorithm.
Public methodStatic memberCreate(CngAlgorithm, String, CngKeyCreationParameters)Creates a named CngKey object that provides the specified algorithm, using the supplied key creation parameters.
Public methodDeleteRemoves the key that is associated with the object.
Public methodDisposeReleases all resources used by the current instance of the CngKey class.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodStatic memberExists(String)Checks to see whether a named key exists in the default key storage provider (KSP).
Public methodStatic memberExists(String, CngProvider)Checks to see whether a named key exists in the specified key storage provider (KSP).
Public methodStatic memberExists(String, CngProvider, CngKeyOpenOptions)Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.
Public methodExportExports the key material into a BLOB, in the specified format.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPropertyGets a property, given a name and a set of property options.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodHasPropertyChecks to see whether the specified property exists on the key.
Public methodStatic memberImport(Byte[], CngKeyBlobFormat)Creates a new key by importing the specified key material into the default key storage provider (KSP) and using the specified format.
Public methodStatic memberImport(Byte[], CngKeyBlobFormat, CngProvider)Creates a new key by importing the specified key material into the specified key storage provider (KSP), using the specified format.
Public methodStatic memberOpen(String)Creates an instance of an CngKey object that represents an existing named key.
Public methodStatic memberOpen(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)Creates an instance of an CngKey object by using a handle to an existing key.
Public methodStatic memberOpen(String, CngProvider)Creates an instance of an CngKey object that represents an existing named key, using the specified key storage provider (KSP).
Public methodStatic memberOpen(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.
Public methodSetPropertySets a named property on the key.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

NoteNote

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, 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.

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