Example of EFT to generate and verify CVV.
#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 PAN "4123456789012345"
#define EXPIRATION_DATE "8701"
#define SERVICE_CODE "101"
#define CVV_RESULT "561"
#define KEY_ID "CHAVE_CVV"
#define KEY_VALUE { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }
#define KEY_TYPE ALG_3DES_112
int main()
{
int nRet = 0;
BYTE pbKeyData[] = KEY_VALUE;
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;
}
nRet =
DGenerateCVV( hSession, KEY_ID, PAN, EXPIRATION_DATE, SERVICE_CODE, szCVV, 0);
if(nRet){
printf("Falha na funcao: DGenerateCVV\nCodigo de erro: %d\n", nRet);
goto clean;
}
if( strcmp( szCVV, CVV_RESULT ) ) {
printf("Falha na comparação entre CVV gerado (%s) e esperado (%s).", szCVV, CVV_RESULT);
}
nRet =
DVerifyCVV( hSession, KEY_ID, PAN, EXPIRATION_DATE, SERVICE_CODE, szCVV, 0);
if(nRet){
printf("Falha na funcao: DVerifyCVV\nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("CVV verificado com sucesso!");
clean:
if (hKey) {
printf("Contexto de chave liberada.\n");
}
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 MIN_CVV_LEN
Definição dinamo.h:1586
#define DEFAULT_PORT
Definição dinamo.h:1949
#define TEMPORARY_KEY
Definição dinamo.h:1425
unsigned char BYTE
Definição dinamo.h:45
#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 DVerifyCVV(HSESSIONCTX hSession, char *szKeyId, char *szPAN, char *szExpirationDate, char *szServiceCode, char *szCVV, DWORD dwParam)
int AAP_API DGenerateCVV(HSESSIONCTX hSession, char *szKeyId, char *szPAN, char *szExpirationDate, char *szServiceCode, char *szCVV, 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: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