Exemplo de utilização de OTP para autenticação de usuários do HSM.
#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:1949
#define CACHE_BYPASS
Definição dinamo.h:589
#define SA_AUTH_NONE
Definição dinamo.h:594
#define SA_AUTH_OTP
Definição dinamo.h:595
unsigned char BYTE
Definição dinamo.h:45
#define LB_BYPASS
Definição dinamo.h:588
#define OATH_SA_v1_HOTP_DYN_TRUNC_OFF
Definição dinamo.h:854
#define ENCRYPTED_CONN
Definição dinamo.h:585
#define OATH_SA_v1_type_SHA1
Definição dinamo.h:853
#define SS_USR_PWD_EX
Definição dinamo.h:579
#define AT_OATH_TOKEN
Definição dinamo.h:845
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:3104
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3105
DWORD dwAuthType
Definição dinamo.h:3107
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3103
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3106
int nStrongAuthLen
Definição dinamo.h:3113
BYTE * pbStrongAuth
Definição dinamo.h:3112
BYTE key_len
Definição dinamo.h:2812
BYTE key[MAX_OATH_HMAC_LEN]
Definição dinamo.h:2813
BYTE type
Definição dinamo.h:2808
BYTE truncation_offset
Definição dinamo.h:2814
char szPassword[MAX_USR_PWD+1]
Definição dinamo.h:3170
char szUserId[MAX_USR_LEN+1]
Definição dinamo.h:3169