Example of PIN block verification.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
#define PGK_KEY_TYPE ALG_3DES_168
#define PTK_KEY_TYPE ALG_3DES_112
int main()
{
int nRet = 0;
BYTE pbPgkKeyData[] = {0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23,
0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23,
0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23};
BYTE pbPtkKeyData[] = {0xF2, 0x15, 0x75, 0xBA, 0x54, 0x68, 0xC4, 0x1C,
0xD5, 0xC7, 0x4A, 0xFE, 0x64, 0x94, 0x08, 0x37};
BYTE pbPinBlock[] = {0x19, 0x37, 0x35, 0x9B, 0x46, 0x93, 0x2D, 0x3C};
char szPgk[] = "pgk";
char szPtk[] = "ptk";
char szPan[] = "4987654321098765";
char szOffset[] = "3152";
if (nRet){
printf("Falha na funcao: DInitialize \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Bibliotecas inicializadas.\n");
if (nRet){
printf("Falha na funcao: DOpenSession \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Sessao com o Dinamo estabelecida.\n");
if(nRet){
printf("Falha na funcao: DImportKey\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Chave PGK importada com sucesso!\n");
if (nRet)
{
printf("Falha na funcao: DImportKey\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Chave PTK importada com sucesso!\n");
nRet =
DVerifyPINBlock(hSession, szPtk, szPgk, szPan, szOffset, pbPinBlock, 0);
if(nRet){
printf("Falha na funcao: DVerifyPINBlock\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIN block verificado com sucesso!\n");
clean:
if (hSession) {
printf("Sessao encerrada.\n");
}
printf("Bibliotecas finalizada.\n");
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1934
#define TEMPORARY_KEY
Definição dinamo.h:1410
unsigned char BYTE
Definição dinamo.h:45
#define ENCRYPTED_CONN
Definição dinamo.h:570
#define SS_USER_PWD
Definição dinamo.h:561
void * HKEYCTX
Definição dinamo.h:70
#define PLAINTEXTKEY_BLOB
Definição dinamo.h:1367
int AAP_API DVerifyPINBlock(HSESSIONCTX hSession, char *szPTK, char *szPGK, char *szPAN, char *szOffset, BYTE *pbInPinBlock, DWORD dwParam)
int AAP_API DDestroyKey(HKEYCTX *phKey, DWORD dwFlags)
int AAP_API DImportKey(HSESSIONCTX hSession, char *szKeyId, HKEYCTX hKEKey, DWORD dwBlobType, int nAlgId, DWORD dwFlags, BYTE *pbData, DWORD dwDataLen, HKEYCTX *phKey)
int AAP_API DOpenSession(HSESSIONCTX *phSession, DWORD dwParam, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
int AAP_API DCloseSession(HSESSIONCTX *phSession, DWORD dwFlags)
int AAP_API DInitialize(DWORD dwReserved)
int nPort
Definição dinamo.h:3112
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3113
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3111
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3114