NET API
HSM Dinamo
Loading...
Looking for...
No entries found
export_import_tr31.cs

Example of exporting and importing a key in TR-31 format.

See Note on examples.
using Dinamo.Hsm;
using System;
using System.Text;
using System.IO;
namespace TR31ExportImport
{
class Program
{
private static String strAddr = "127.0.0.1";
private static String strUsrId = "master";
private static String strPwd = "12345678";
static void Main(string[] args)
{
String szKbpk = "kbpk";
String szKey = "key";
try {
/*
Connect to HSM
*/
api.Connect(strAddr, strUsrId, strPwd);
/*
Exports the key in TR-31 format
*/
byte[] keyBlock = api.ExportTR31(szKbpk, szKey,
DinamoClient. EftExportUsage.EFT_ME_TR31_EXP_USAGE_AUTO,
DinamoClient. EftExportMode.EFT_ME_TR31_EXP_MODE_AUTO,
DinamoClient. EftExportExpType.EFT_ME_TR31_EXP_AUTO);
Console.Out.WriteLine(BitConverter.ToString(keyBlock));
Console.Out.WriteLine("Key exported successfully!");
/*
Import the key in TR-31 format
*/
String szImportedKey = "imp_key";
api.ImportTR31(szKbpk, szImportedKey, true, false, keyBlock);
Console.Out.WriteLine("Key imported successfully!");
} catch (DinamoException e) {
Console.Out.WriteLine(e.Message);
} finally{
/*
Disconnects from HSM
*/
api.Disconnect();
}
}
}
}
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
EftExportExpType
TR-31 export type identifier.
Definition DinamoClient.cs:526
EftExportMode
TR-31 export mode identifier.
Definition DinamoClient.cs:507
EftExportUsage
TR-31 export use identifier.
Definition DinamoClient.cs:462
Exception class for errors from Dinamo.
Definition DinamoException.cs:10
override string Message
Definition DinamoException.cs:42
byte[] ExportTR31(string kbpk, string key, EftExportUsage usage, EftExportMode mode, EftExportExpType exp)
Exports a key in TR-31 format according to the ASC X9 TR 31-2018 standard.
Definition DinamoClient.cs:4488
void ImportTR31(string kbpk, string key, bool isExportable, bool isTemporary, byte[] keyBlock)
Import a key in TR-31 format according to the ASC X9 TR 31-2018 standard.
Definition DinamoClient.cs:4523
void Connect(string User, string Password)
Establishes an encrypted connection to the HSM using the load balance settings.
Definition DinamoClient.cs:562
void Disconnect(bool flagClose)
Terminates the connection to the HSM.
Definition DinamoClient.cs:814
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12