Exporting a Key
You can export both the symmetric and asymmetric keys. To export a key:
Call the
ExportKey
method from theNaeKeyManagement
class.NaeKeyManagement nkm = new NaeKeyManagement(session);
Pass the key name and key type as an argument that you want to export.
nkm.ExportKey("Example_Rijndael_key", NaeKeyManagement.KeyType.None);
The Enum KeyType
is defined as:
public enum KeyType
{
Public = 0,
PublicPrivate = 1,
None = 2
}
For symmetric keys, use KeyType.None
.
For asymmetric keys, use KeyType.Public
to get only the public key. Use KeyType.PublicPrivate
to get both public and private keys.
To export a particular version of a versioned key, pass the version number with the key name.
NaeKeyManagement nkm = new NaeKeyManagement(session);
nkm.ExportKey("Example_RSA_key#2", NaeKeyManagement.KeyType.Public);
Note
• When no version is passed for a versioned key then the latest active version is exported.
• Exporting a key is not supported in the local mode.