Example of PIN block translation .
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("Function failure: DInitialize \nError code: %d\n", nRet);
goto clean;
}
printf("Libraries initialized.\n");
strncpy(authPwd.
szAddr, HOST_ADDR,
sizeof(authPwd
.szAddr));
strncpy(authPwd.
szUserId, USER_ID,
sizeof(authPwd
.szUserId));
strncpy(authPwd.
szPassword, USER_PWD,
sizeof(authPwd
.szPassword));
if (nRet){
printf("Function failure: DOpenSession \nError code: %d\n", nRet);
goto clean;
}
printf("Session with Dinamo established.\n");
if(nRet){
printf("Function failure: DImportKey\nError code: %d\n", nRet);
goto clean;
}
printf("Source key imported successfully!\n");
if(nRet){
printf("Function failure: DGenerateKey\nError code: %d\n", nRet);
goto clean;
}
printf("Target key generated successfully!\n");
NULL, pbPinBlock, pbOutPinBlock, 0);
if(nRet){
printf("Function failure: DPINBlockTranslate\nError code: %d\n", nRet);
goto clean;
}
printf("PIN block successfully translated!\n");
clean:
if (hSession) {
printf("Session closed.\n");
}
printf("Libraries finished.\n");
return nRet;
}
HSM Application Programming Interface (API) Dinamo.
void * HSESSIONCTX
Definition dinamo.h:68
#define DEFAULT_PORT
Definition dinamo.h:1948
#define TEMPORARY_KEY
Definition dinamo.h:1424
#define TP_TRANSLATE_TYPE_AUTO
Definition dinamo.h:1674
unsigned char BYTE
Definition dinamo.h:45
#define DES_BLOCK
Definition dinamo.h:1055
#define ENCRYPTED_CONN
Definition dinamo.h:585
#define SS_USER_PWD
Definition dinamo.h:576
void * HKEYCTX
Definition dinamo.h:70
#define PLAINTEXTKEY_BLOB
Definition dinamo.h:1381
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
Definition dinamo.h:3091
char szUserId[MAX_USR_LEN]
Definition dinamo.h:3092
char szAddr[MAX_ADDR_LEN]
Definition dinamo.h:3090
char szPassword[MAX_USR_PWD]
Definition dinamo.h:3093