Example of PIN block translation .
#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 KEY_TYPE ALG_3DES_112
#define SRC_KEY_VALUE \
{ \
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, \
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 \
}
#define FAKE_PINBLOCK \
{ \
0xD9, 0x3B, 0x9C, 0xC2, 0x8B, 0x8F, 0x11, 0xF9 \
}
int main()
{
int nRet = 0;
BYTE pbKeyData[] = SRC_KEY_VALUE;
BYTE pbPinBlock[] = FAKE_PINBLOCK;
char szSrcKey[] = "src_key";
char szDstKey[] = "dst_key";
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 de origem importada com sucesso!\n");
if(nRet){
printf("Falha na funcao: DGenerateKey\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Chave de destino gerada com sucesso!\n");
NULL, pbPinBlock, pbOutPinBlock, 0);
if(nRet){
printf("Falha na funcao: DPINBlockTranslate\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIN block traduzido 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:1949
#define TEMPORARY_KEY
Definição dinamo.h:1425
#define TP_TRANSLATE_TYPE_AUTO
Definição dinamo.h:1675
unsigned char BYTE
Definição dinamo.h:45
#define DES_BLOCK
Definição dinamo.h:1056
#define ENCRYPTED_CONN
Definição dinamo.h:585
#define SS_USER_PWD
Definição dinamo.h:576
void * HKEYCTX
Definição dinamo.h:70
#define PLAINTEXTKEY_BLOB
Definição dinamo.h:1382
int AAP_API DPINBlockTranslate(HSESSIONCTX hSession, char *szSrcPEK, char *szDstPEK, BYTE bTransBlockType, char *szPAN, BYTE *pbInPinBlock, BYTE *pbOutPinBlock, DWORD dwParam)
int AAP_API DGenerateKey(HSESSIONCTX hSession, char *szKeyId, int nAlgId, DWORD dwFlags, HKEYCTX *phKey)
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:3092
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3093
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3091
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3094