Export (0) Print
Expand All

CngKey.Export Method

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
)

Parameters

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.

ExceptionCondition
ArgumentNullException

format is null.

CryptographicException

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft