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

Exemplo de assinatura em batch utilizando o HSM.

Veja Nota sobre os exemplos.
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;//Máximo de 30 blocos para assinatura
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, 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};//Bloco com 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();
}
}
}
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