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

Example of using HMAC generation with Swift Local Authentication (LAU).

See Note on examples.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dinamo;
using Dinamo.Hsm;
namespace GenerateMAC
{
class Program
{
static void Main(string[] args)
{
string address = "10.0.0.1";
string user = "master";
string pass = "12345678";
din.Connect(address, user, pass);
string hmacKeyName = "hmac_key";
Console.Out.WriteLine("Generate HMAC key: {0}\n", hmacKeyName);
din.RemoveObject(hmacKeyName);
byte[] hmacKeyData = Encoding.ASCII.GetBytes("LEFTLAUCSHARPNETRIGHTLAUSWIFTRJE");
din.ImportKey(hmacKeyName, IntPtr.Zero, hmacKeyData,
DinamoClient.BLOB_TYPE.PLAINTEXTKEY_BLOB,
DinamoClient.KEY_ALG.ALG_HMAC_SHA2_256);
String message = @"{1:F01BANKAEBBAXXX0004000001}{2:I999BANKAEBBXXXXN}{4:
:20:LAUTEST1
:79:THIS IS EXAMPLE1 FOR LAU TEST RJE CSHARP
-}";
Console.Out.WriteLine("Generate HMAC in one call.\n");
byte[] hmac = din.generateMAC(DinamoClient.HASH_ALG.ALG_HMAC_SHA2_256,
hmacKeyName, Encoding.ASCII.GetBytes(message));
Console.Out.WriteLine("hmac: {0}\n", BitConverter.ToString(hmac).Replace("-", string.Empty));
din.Disconnect();
}
}
}
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
KEY_ALG
Definition DinamoClient.cs:227
HASH_ALG
Hash algorithm for signatures.
Definition DinamoClient.cs:137
BLOB_TYPE
Definition DinamoClient.cs:449
byte[] generateMAC(HASH_ALG AlgId, String KeyId, byte[] Data, int Flags)
Generates a MAC in just one call.
Definition DinamoClient.cs:3797
IntPtr ImportKey(string KeyId, IntPtr hKeyEncryptionKey, byte[] byKeyBlob, BLOB_TYPE BlobType, KEY_ALG AlgId)
Definition DinamoClient.cs:2668
void RemoveObject(string ObjectId)
Removes an object from the HSM.
Definition DinamoClient.cs:2397
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
Definition DinamoClient.cs:12