Example of retrieving information from the secret and verifying the parties using the Safe Keeping module.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
static int OpenSession
(HSESSIONCTX *hSession,
const char *cszIp,
const char *cszUser,
const char *cszPassword)
{
strncpy(authPwd.
szAddr, HOST_ADDR,
sizeof(authPwd
.szAddr));
strncpy(authPwd.
szUserId, USER_ID,
sizeof(authPwd
.szUserId));
strncpy(authPwd.
szPassword, USER_PWD,
sizeof(authPwd
.szPassword));
}
static void PrintError(const char *cszFunction, int nRet)
{
printf("Function failure: %s \nError code: %d\n", cszFunction, nRet);
}
int main()
{
int nRet = 0;
#define M (2)
#define N (3)
const char *szId = "secret";
if (nRet)
{
PrintError("DInitialize", nRet);
goto clean;
}
printf("Libraries initialized.\n");
nRet = OpenSession(&hSession, HOST_ADDR, USER_ID, USER_PWD);
if (nRet)
{
PrintError("DOpenSession", nRet);
goto clean;
}
printf("Session with Dinamo established.\n");
if(nRet)
{
PrintError("DSKeepNewSecret", nRet);
goto clean;
}
printf("Secret successfully created.\n");
if (nRet)
{
PrintError("DSKeepProbeSecret", nRet);
goto clean;
}
printf("Secret information successfully retrieved.\n");
if (nRet)
{
PrintError("DSKeepSplitSecret", nRet);
goto clean;
}
printf("Secret split successfully.\n");
if (nRet)
{
PrintError("DSKeepMatchSecret", nRet);
goto clean;
}
printf("Parts successfully verified.\n");
if (nRet)
{
PrintError("DSKeepRemoveSecret", nRet);
goto clean;
}
printf("Secret successfully removed.\n");
clean:
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
unsigned short WORD
Definition dinamo.h:48
unsigned char BYTE
Definition dinamo.h:45
#define ENCRYPTED_CONN
Definition dinamo.h:585
#define SS_USER_PWD
Definition dinamo.h:576
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 AAP_API DSKeepNewSecret(HSESSIONCTX hSession, const char *cszId, BYTE bSecLevel, WORD wAuthType, DWORD dwReserved)
#define DN_SKEEP_SEC_LEVEL_160b
Definition dinamo.h:9083
int AAP_API DSKeepProbeSecret(HSESSIONCTX hSession, const char *cszId, SKeepProbeInfo *pstInfo, DWORD dwReserved)
int AAP_API DSKeepMatchSecret(HSESSIONCTX hSession, const char *cszId, const SKeepShare *cpstShares, DWORD dwSharesCount, DWORD dwReserved)
int AAP_API DSKeepRemoveSecret(HSESSIONCTX hSession, const char *cszId, BYTE bSecLevel, WORD wAuthType, DWORD dwReserved)
#define DN_SKEEP_TYPE_NMIND
Definition dinamo.h:9086
int AAP_API DSKeepSplitSecret(HSESSIONCTX hSession, const char *cszId, BYTE bSecLevel, WORD wAuthType, BYTE bM, BYTE bN, SKeepShare *pstShares, 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