Files
EgtLock/DongleId.cpp
T
Dario Sassi c20365bce5 EgtLock :
- modifiche per nuova libreria delle chiavi.
2018-01-02 14:27:43 +00:00

96 lines
2.7 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2017
//----------------------------------------------------------------------------
// File : DongleId.cpp Data : 30.12.17 Versione : 1.8l4
// Contenuto : Funzioni per gestione/calcolo Id chiave OxySec.
//
//
//
// Modifiche : 27.07.15 DS Creazione modulo.
// 30.12.17 DS Passaggio a nuova interfaccia xNodus.
//
//----------------------------------------------------------------------------
//------------------ 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)
{
// imposto l'esito
bool bOk = true ;
// 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) {
bOk = false ;
goto end ;
}
int nStatus = 0 ;
XND_DEVICE_CONTEXT dev_ctx = xnd_xlt_locate( env, label, &nStatus) ;
if ( dev_ctx == nullptr) {
bOk = false ;
goto end ;
}
// 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) ;
if ( nRes != XLT_ERROR_SUCCESS) {
bOk = false ;
goto end ;
}
sDongleId = (char*) data ;
end :
xnd_xlt_devctx_release( dev_ctx) ;
xnd_xlt_env_release( env) ;
return bOk ;
}