8131fca92c
- eliminati i goto - versione a 64 bit compilata con LLVM.
90 lines
2.7 KiB
C++
90 lines
2.7 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2021
|
|
//----------------------------------------------------------------------------
|
|
// File : DongleId.cpp Data : 20.08.21 Versione : 2.3h1
|
|
// Contenuto : Funzioni per gestione/calcolo Id chiave OxySec.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 27.07.15 DS Creazione modulo.
|
|
// 30.12.17 DS Passaggio a nuova interfaccia xNodus.
|
|
// 20.08.21 DS Eliminati goto.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//------------------ Include -------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "Obfuscate.h"
|
|
#include "DongleId.h"
|
|
#include "/EgtDev/Include/EgtBase64.h"
|
|
#include "/EgtDev/Include/EgtCrc32.h"
|
|
#include "/EgtDev/Extern/OxySec/Include/xnd.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GetDongleId( string& sDongleId)
|
|
{
|
|
// cerco la chiave
|
|
unsigned char label[XLT_LABEL_SIZE] ;
|
|
string sLabel = "EgalTech s.r.l. - CAD/CAM/CIM Software Solutions" ;
|
|
strcpy_s( (char*)label, XLT_LABEL_SIZE, sLabel.c_str()) ;
|
|
memset( label + sLabel.size(), 0x00, sizeof( label) - sLabel.size()) ;
|
|
XND_XLT_ENV env = xnd_xlt_env_create() ;
|
|
if ( env == nullptr)
|
|
return false ;
|
|
int nStatus = 0 ;
|
|
XND_DEVICE_CONTEXT dev_ctx = xnd_xlt_locate( env, label, &nStatus) ;
|
|
if ( dev_ctx == nullptr) {
|
|
xnd_xlt_env_release( env) ;
|
|
return false ;
|
|
}
|
|
// richiamo funzioni di verifica chiave con decifratura RSA 512 di dati generati al volo
|
|
// ... DA FARE ...
|
|
// leggo l'identificativo della chiave dal banco 0
|
|
unsigned char pwd[XLT_PASSWORD_SIZE] ;
|
|
unsigned char data[XLT_BANK_SIZE] ;
|
|
// M0nt3ReC@st3llo1985
|
|
pwd[ 0] = 'M' ;
|
|
pwd[ 2] = 'n' ;
|
|
pwd[ 4] = '3' ;
|
|
pwd[ 6] = 'e' ;
|
|
pwd[ 8] = '@' ;
|
|
pwd[10] = 't' ;
|
|
pwd[12] = 'l' ;
|
|
pwd[14] = 'o' ;
|
|
pwd[16] = '9' ;
|
|
pwd[18] = '5' ;
|
|
pwd[20] = '\0' ;
|
|
pwd[22] = '\0' ;
|
|
pwd[24] = '\0' ;
|
|
pwd[26] = '\0' ;
|
|
pwd[28] = '\0' ;
|
|
pwd[30] = '\0' ;
|
|
pwd[ 1] = '0' ;
|
|
pwd[ 3] = 't' ;
|
|
pwd[ 5] = 'R' ;
|
|
pwd[ 7] = 'C' ;
|
|
pwd[ 9] = 's' ;
|
|
pwd[11] = '3' ;
|
|
pwd[13] = 'l' ;
|
|
pwd[15] = '1' ;
|
|
pwd[17] = '8' ;
|
|
pwd[19] = '\0' ;
|
|
pwd[21] = '\0' ;
|
|
pwd[23] = '\0' ;
|
|
pwd[25] = '\0' ;
|
|
pwd[27] = '\0' ;
|
|
pwd[29] = '\0' ;
|
|
pwd[31] = '\0' ;
|
|
int nRes = xnd_xlt_read( dev_ctx, pwd, 0, data) ;
|
|
bool bOk = ( nRes == XLT_ERROR_SUCCESS) ;
|
|
if ( bOk)
|
|
sDongleId = (char*) data ;
|
|
// rilascio
|
|
xnd_xlt_devctx_release( dev_ctx) ;
|
|
xnd_xlt_env_release( env) ;
|
|
return bOk ;
|
|
}
|