API .Net HSM Dinamo
API Proprietária .Net do HSM Dinamo
generate_hmac_lau.cs

Exemplo de uso de geração HMAC com Swift Local Authentication (LAU).

Veja Nota sobre os exemplos.
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";
DinamoClient din = new DinamoClient();
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();
}
}
}
Namespace que denota um conjunto de funções para acesso ao HSM Dinamo e suas respectivas exceptions.
Definition: DinamoClient.cs:12
Definition: DinamoClient.cs:12