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;//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();
}
}
}
Classe de baixo nível para acesso ao HSM. Para utilizar essa classe é necessário o entendimento mais ...
Definição DinamoApi.cs:15
const Int32 DN_BATCH_SIGN_BLOCK_HEADER
Definição DinamoApi.cs:1409
Classe de API para acesso às funcionalidades do HSM Dinamo. Nessa classe é possível programar utiliza...
Definição DinamoClient.cs:93
void BatchSign(string strKeyId, byte[] pbBlock, Int32 dwBlockCount, Int32 dwFlags)
Envia um lote de blocos para assinatura no HSM.
Definição DinamoClient.cs:3994
void Connect(string User, string Password)
Estabelece uma conexão cifrada com o HSM utilizando as configurações de load balance.
Definição DinamoClient.cs:562
void Disconnect(bool flagClose)
Encerra a conexão com o HSM.
Definição DinamoClient.cs:814
Namespace que denota um conjunto de funções para acesso ao HSM Dinamo e suas respectivas exceptions.
Definição DinamoClient.cs:12
Definição DinamoClient.cs:12