Example of using OTP to authenticate HSM users.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define HSM_USR_ADM "master"
#define HSM_USR "user"
#define HSM_IP "127.0.0.1"
#define HSM_PWD "12345678"
int NewHsmUser(
HSESSIONCTX hSession,
const char *szUser,
const char *szPwd)
{
int nRet = 0;
if (nRet)
{
printf("DCreateUser : Failed! %d.\n", nRet);
return nRet;
}
return 0;
}
int main(void)
{
int nRet = 0;
const char cszOTP[] = "992271";
{
0xD5, 0x17, 0xED, 0x40, 0x1D, 0xF3, 0x03, 0x38, 0x37, 0xE0, 0x8B, 0x62, 0x55, 0xBE, 0xDB, 0xF9,
0x52, 0x0E, 0xF8, 0x8E,
};
strncpy(stAuthInfoAdm.
szAddr, HSM_IP,
sizeof(stAuthInfoAdm.
szAddr));
if(nRet)
{
printf("DOpenSession (adm) : Failed! %d.\n", nRet);
goto clean;
}
nRet = NewHsmUser(hSessionAdm, HSM_USR, HSM_PWD);
if (nRet)
{
printf("NewHsmUser : Failed! %d.\n", nRet);
goto clean;
}
memcpy(stTokenParam.
key, pbOtpKey,
sizeof(pbOtpKey));
stTokenParam.
key_len =
sizeof(pbOtpKey);
HSM_USR,
sizeof(stTokenParam));
if( nRet )
{
printf("DAssignToken : Failed! %d.\n", nRet);
goto clean;
}
strncpy(stAuthInfoUser.
szAddr, HSM_IP,
sizeof(stAuthInfoUser.
szAddr));
if (nRet)
{
printf("DOpenSession (user) : Failed! %d.\n", nRet);
goto clean;
}
HSM_USR,
"758993",
"864532",
0);
if (nRet)
{
printf("DOATHResync : Failed! %d.\n", nRet);
goto clean;
}
HSM_USR);
if (nRet)
{
printf("DUnassignToken : Failed! %d.\n", nRet);
goto clean;
}
clean:
if (hSessionAdm != NULL)
{
}
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1934
#define CACHE_BYPASS
Definição dinamo.h:574
#define SA_AUTH_NONE
Definição dinamo.h:579
#define SA_AUTH_OTP
Definição dinamo.h:580
unsigned char BYTE
Definição dinamo.h:45
#define LB_BYPASS
Definição dinamo.h:573
#define OATH_SA_v1_HOTP_DYN_TRUNC_OFF
Definição dinamo.h:839
#define ENCRYPTED_CONN
Definição dinamo.h:570
#define OATH_SA_v1_type_SHA1
Definição dinamo.h:838
#define SS_USR_PWD_EX
Definição dinamo.h:564
#define AT_OATH_TOKEN
Definição dinamo.h:830
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 DRemoveUser(HSESSIONCTX hSession, char *szUserId)
int AAP_API DUnassignToken(const HSESSIONCTX hSession, const DWORD dwParam, const char *szUserId)
int AAP_API DAssignToken(const HSESSIONCTX hSession, const char *szUserId, const DWORD dwParam, BYTE *pbData, const DWORD dwDataLen)
int AAP_API DCreateUser(HSESSIONCTX hSession, struct USER_INFO userInfo)
int AAP_API DOATHResync(const HSESSIONCTX hSession, char *szUser, char *szOTP1, char *szOTP2, DWORD dwParam)
int nPort
Definição dinamo.h:3124
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3125
DWORD dwAuthType
Definição dinamo.h:3127
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3123
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3126
int nStrongAuthLen
Definição dinamo.h:3133
BYTE * pbStrongAuth
Definição dinamo.h:3132
BYTE key_len
Definição dinamo.h:2832
BYTE key[MAX_OATH_HMAC_LEN]
Definição dinamo.h:2833
BYTE type
Definição dinamo.h:2828
BYTE truncation_offset
Definição dinamo.h:2834
char szPassword[MAX_USR_PWD+1]
Definição dinamo.h:3190
char szUserId[MAX_USR_LEN+1]
Definição dinamo.h:3189