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

Example of PIN block verification.

See Note on examples.
using System;
using System.IO;
using Dinamo.Hsm;
namespace EFTVerifyPINBlock
{
class Program
{
static void Main(string[] args)
{
string address = "127.0.0.1";
string user = "master";
string pass = "12345678";
/*
Connects to HSM
*/
hsm.Connect(address, user, pass);
/*
Import test keys, PGK and PTK.
*/
string pgk = "pgk";
byte[] pgkKeyData = {0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23,
0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23,
0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23};
IntPtr pgkHandle = hsm.ImportKey(pgk, IntPtr.Zero, pgkKeyData,
DinamoClient.BLOB_TYPE.PLAINTEXTKEY_BLOB,
DinamoClient.KEY_ALG.ALG_3DES_168);
string ptk = "ptk";
byte[] ptkKeyData = {0x4F, 0xDA, 0x0D, 0xE0, 0x7F, 0xCE, 0xD9, 0x58,
0xB5, 0x45, 0x4C, 0x25, 0xE3, 0xBA, 0xF4, 0x13,
0x16, 0xFD, 0x19, 0x0B, 0x31, 0xBF, 0xAD, 0x54 };
IntPtr ptkHandle = hsm.ImportKey(ptk, IntPtr.Zero, ptkKeyData,
DinamoClient.BLOB_TYPE.PLAINTEXTKEY_BLOB,
DinamoClient.KEY_ALG.ALG_3DES_168);
/*
Check a PINBlock
*/
byte[] pinblock = {0x5B, 0xFC, 0x77, 0x9A, 0x3A, 0x52, 0x60, 0xAA };
string pan ="4987654321098765";
string offset = "3152";
bool isValidPIN = hsm.VerifyPINBlock(ptk, pgk, pan, offset, pinblock);
Console.WriteLine("PIN is {0}!", isValidPIN ? "valid" : "invalid");
/*
Release handle, remove key and disconnect
*/
hsm.DestroyKey(pgkHandle);
hsm.DestroyKey(ptkHandle);
hsm.RemoveObject(pgk);
hsm.RemoveObject(ptk);
hsm.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
BLOB_TYPE
Definition DinamoClient.cs:449
bool VerifyPINBlock(string ptk, string pgk, string pan, string offset, byte[] pinblock)
Checks the validity of a PIN in a PIN Block. First the PIN is extracted from the PIN Block with the PTK key...
Definition DinamoClient.cs:4453
void DestroyKey(IntPtr hKey)
Release key handle.
Definition DinamoClient.cs:1953
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