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

Example of a batch signature using HSM.

See Note on examples.
using System;
using System.Collections.Generic;
using System.Text;
using Dinamo;
using Dinamo.Hsm;
namespace TesteBatchSign
{
class Program
{
static void Main(string[] args)
{
string address = "10.0.62.47";
string user = "master";
string pass = "12345678";
string keyId = "privateKey";//RSA 2048
const Int32 blockCount = 30;//Maximum of 30 blocks for signature
const Int32 keySize = 256;//RSA 2048
byte[] pbKeyBlock = new byte[keySize]{ 0x00, 0x01, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x30,
0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x1a, 0xa2,
0x64, 0x75, 0x84, 0x33, 0x24, 0x30, 0xfd, 0xe1,
0x3f, 0x47, 0x6b, 0xc1, 0x89, 0x89, 0xb7, 0xfc,
0x5b, 0x27};//Block with hash + padding PKCS#1
byte[] pbBlock = new byte[DinamoApi.DN_BATCH_SIGN_BLOCK_HEADER + (blockCount * keySize)];
for (int i = DinamoApi.DN_BATCH_SIGN_BLOCK_HEADER; i < blockCount * keySize; i += keySize)
{
Array.Copy(pbKeyBlock, 0, pbBlock, i, pbKeyBlock.Length);
}
DinamoClient dnClient = new DinamoClient();
dnClient.Connect(address, user, pass);
dnClient. BatchSign(keyId, pbBlock, blockCount, 0);
dnClient.Disconnect();
Console.In.ReadLine();
}
}
}
Low-level class for accessing the HSM. To use this class you need to understand more ...
Definition DinamoApi.cs:15
const Int32 DN_BATCH_SIGN_BLOCK_HEADER
Definition DinamoApi.cs:1407
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
void BatchSign(string strKeyId, byte[] pbBlock, Int32 dwBlockCount, Int32 dwFlags)
Sends a batch of blocks for signature in the HSM.
Definition DinamoClient.cs:3994
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