Example of displaying a key's attributes.
#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_ID "Key_Name"
{
switch(dwType)
{
}
}
int main()
{
int nRet;
dwKeyType,
dwPadding,
dwReadLocked,
dwKeyLen,
dwMode;
int i;
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: DGenerateKey \nError code: %d\n", nRet);
goto clean;
}
printf("Key generated successfully.\n");
if (nRet){
printf("Function failed: DGetUserKey \nError code: %d\n",nRet);
goto clean;
}
dwDataLen =
sizeof(
DWORD);
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
dwDataLen = sizeof(dwReadLocked);
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
printf("Key exportable? %s\n", dwReadLocked == 1 ? "No": "Yes " );
if (IsRSAKey(dwKeyType)){
printf("End of asymmetric key attributes.\n");
goto clean;
}
dwDataLen = 0;
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
pbData =
(BYTE *)malloc(dwDataLen);
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
printf("IV: ");
for (i = 0; i < (int)dwDataLen; i++)
printf("%02x ", pbData[i]);
printf("\n");
free(pbData);
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
dwDataLen = sizeof(dwMode);
if (nRet){
printf("Function failure: DGetKeyParam \nError code: %d\n",nRet);
goto clean;
}
clean:
if (hKey){
printf("Key context released.\n");
}
if (hSession){
printf("Session closed.\n");
}
printf("Libraries finished.\n");
return nRet;
}
HSM Application Programming Interface (API) Dinamo.
#define ALG_RSA_4096
Definition dinamo.h:1086
#define DKP_ALGID
Definition dinamo.h:1467
int BOOL
Definition dinamo.h:49
void * HSESSIONCTX
Definition dinamo.h:68
#define DEFAULT_PORT
Definition dinamo.h:1948
#define DKP_READ_LOCK
Definition dinamo.h:1473
#define ALG_RSA_512
Definition dinamo.h:1083
#define DKP_MODE
Definition dinamo.h:1470
#define ALG_RSA_1024_PUB
Definition dinamo.h:1211
#define ALG_AES_256
Definition dinamo.h:1028
#define ALG_RSA_4096_PUB
Definition dinamo.h:1213
#define DWORD_PRINT
Definition dinamo.h:55
#define DKP_IV
Definition dinamo.h:1468
unsigned char BYTE
Definition dinamo.h:45
#define DKP_KEYLEN
Definition dinamo.h:1475
unsigned int DWORD
Definition dinamo.h:46
#define ALG_RSA_2048_PUB
Definition dinamo.h:1212
#define ALG_RSA_1024
Definition dinamo.h:1084
#define ENCRYPTED_CONN
Definition dinamo.h:585
#define SS_USER_PWD
Definition dinamo.h:576
#define ALG_RSA_2048
Definition dinamo.h:1085
#define TRUE
Definition dinamo.h:61
#define FALSE
Definition dinamo.h:58
#define DKP_PADDING
Definition dinamo.h:1469
void * HKEYCTX
Definition dinamo.h:70
#define ALG_RSA_512_PUB
Definition dinamo.h:1210
int AAP_API DGetUserKey(HSESSIONCTX hSession, char *szKeyId, DWORD dwFlags, HKEYCTX *phKey)
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 DGetKeyParam(HKEYCTX hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
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)