Export Method

CngKey.Export Method (CngKeyBlobFormat)


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

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

public byte[] Export(
	CngKeyBlobFormat format


Type: System.Security.Cryptography.CngKeyBlobFormat

An object that specifies the format of the key BLOB.

Return Value

Type: System.Byte[]

A BLOB that contains the key material in the specified format.

Exception Condition

format is null.


All other errors. Typically, the ExportPolicy does not allow the key to be exported.

Cryptography Next Generation (CNG) allows export in any format that the underlying key storage provider (KSP) supports. For example, on Windows Vista,the default KSP (which is MicrosoftSoftwareKeyStorageProvider) only allows export of private keys in the Pkcs8PrivateBlob, EccPrivateBlob, and OpaqueTransportBlob formats. This restriction is controlled by the underlying KSP. If you use a different KSP, other formats may apply.


for permission to sign data. Demand value: Demand. Associated enumeration: KeyContainerPermissionFlags.Export

Universal Windows Platform
Available since 10
.NET Framework
Available since 3.5
Return to top
© 2015 Microsoft