Ejemplo de recuperación de información del secreto y verificación de las partes utilizando el módulo de custodia.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "maestro"
#define USER_PWD "12345678"
static int OpenSession
(HSESSIONCTX *hSession,
const char *cszIp,
const char *cszUser,
const char *cszContraseña)
{
strncpy(authPwd.
szAddr, HOST_ADDR,
sizeof(authPwd
.szAddr));
strncpy(authPwd.
szContraseña, USER_PWD,
sizeof(authPwd
.szContraseña));
}
static void PrintError(const char *cszFunction, int nRet)
{
printf("Fallo de función: %s \nCódigo de error: %d\n", cszFunción, nRet);
}
int main()
{
int nRet = 0;
#define M (2)
#define N (3)
const char *szId = "secreto";
si (nRet)
{
PrintError("DInitialise", nRet);
ir a limpiar;
}
printf("Bibliotecas inicializadas.\n");
nRet = OpenSession(&hSession, HOST_ADDR, USER_ID, USER_PWD);
si (nRet)
{
PrintError("DOpenSession", nRet);
ir a limpiar;
}
printf("Sesión con Dinamo establecida.\n");
if(nRet)
{
PrintError("DSKeepNewSecret", nRet);
ir a limpiar;
}
printf("Secreto creado con éxito.\n");
si (nRet)
{
PrintError("DSKeepProbeSecret", nRet);
ir a limpiar;
}
printf("Información secreta recuperada con éxito.\n");
si (nRet)
{
PrintError("DSKeepSplitSecret", nRet);
ir a limpiar;
}
printf("Secreto dividir con éxito.\n");
si (nRet)
{
PrintError("DSKeepMatchSecret", nRet);
ir a limpiar;
}
printf("Piezas verificadas con éxito.\n");
si (nRet)
{
PrintError("DSKeepRemoveSecret", nRet);
ir a limpiar;
}
printf("Secreto eliminado con éxito.\n");
limpia:
printf("Sesión cerrada.\n");
printf("Bibliotecas finalizadas.\n");
devolver nRet;
}
Interfaz de programación de aplicaciones (API) de HSM Dinamo.
void * HSESSIONCTX
Definición dinamo.h:68
#define PUERTO_DEFAULT
Definición dinamo.h:1948
unsigned short WORD
Definición dinamo.h:48
unsigned char BYTE
Definición dinamo.h:45
#define ENCRYPTED_CONN
dinamoDefinición.h:585
#define SS_USER_PWD
dinamoDefinición.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
dinamoDefinición.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
dinamoDefinición.h:9086
int AAP_API DSKeepSplitSecret(HSESSIONCTX hSession, const char *cszId, BYTE bSecLevel, WORD wAuthType, BYTE bM, BYTE bN, SKeepShare *pstShares, DWORD dwReserved)
int nPuerto
Definición dinamo.h:3091
char szUserId[MAX_USR_LEN]
Definición dinamo.h:3092
char szAddr[MAX_ADDR_LEN]
Definición dinamo.h:3090
char szContraseña[MAX_USR_PWD]
dinamoDefinición.h:3093