API C/C++
HSM Dinamo
Cargando...
Buscando...
No se han encontrado entradas
lista_claves.c

Ejemplo de listado de claves de usuario.

Véase la nota sobre ejemplos.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dinamo.h> /* header do Dinamo */
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
int AAP_API ListObjsCallback(char *szObjName, void * pParam, BOOL bFinal)
{
UNUSED(pParam);
if (!bFinal)
fprintf(stdout, "\t%s\n", szObjName);
return 0;
}
int main()
{
int nRet;
struct AUTH_PWD authPwd;
HSESSIONCTX hSession = NULL;
//Inicializa as bibliotecas do Dinamo
nRet = DInitialize(0);
if (nRet){
printf("Falha na funcao: DInitialize \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Bibliotecas inicializadas.\n");
//Inicializa a estrutura para conexão com o HSM
strncpy(authPwd.szAddr, HOST_ADDR, sizeof(authPwd.szAddr));
authPwd.nPort = DEFAULT_PORT;
strncpy(authPwd.szUserId, USER_ID, sizeof(authPwd.szUserId));
strncpy(authPwd.szPassword, USER_PWD, sizeof(authPwd.szPassword));
nRet = DOpenSession(&hSession, SS_USER_PWD, (BYTE *)&authPwd, sizeof(authPwd), ENCRYPTED_CONN);
if (nRet) {
printf("Falha na funcao: DOpenSession \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Sessao com o Dinamo estabelecida.\n");
printf("-----INICIO-----\n");
nRet = DListObjs(hSession, ListObjsCallback, NULL);
if (nRet) {
printf("Falha na funcao: DListObjs \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("-----FIM-----\n");
clean:
if (hSession) {
DCloseSession(&hSession, 0);
printf("Sessao encerrada.\n");
}
printf("Bibliotecas finalizada.\n");
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
int BOOL
Definição dinamo.h:49
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1949
unsigned char BYTE
Definição dinamo.h:45
#define AAP_API
Definição dinamo.h:42
#define ENCRYPTED_CONN
Definição dinamo.h:585
#define SS_USER_PWD
Definição dinamo.h:576
int AAP_API DListObjs(HSESSIONCTX hSession, funcListKeyCallback fncallback, void *pParam)
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 DFinalize()
Definição dinamo.h:3090