9 Commits

Author SHA1 Message Date
Dario Sassi 0abaaacff6 EgtLock :
- correzione calcolo giorni di assistenza per versioni da 3.1 in poi.
2026-03-23 17:45:14 +01:00
Dario Sassi 5490eaa2dd EgtLock :
- aggiunta lettura Serial Number anche per chiavi di rete.
2026-02-06 10:24:36 +01:00
Dario Sassi 049a453c2a EgtLock 3.1a1 :
- nuova gestione protezione per versioni da 2801 a 36812
- su versioni 27xx aggiunto salto di 300 per un anno di aggiornamento automatico per poter pssare direttamente a 31xx.
2026-01-02 12:31:17 +01:00
Dario Sassi 52f0109a95 EgtLock :
- ricompilazione per passaggio a C++ 20.
2025-11-01 17:17:44 +01:00
Dario Sassi 3f14c9a4c9 EgtLock 2.7a1 :
- cambio annuale di versione
- compilazione 32bit senza più limiti per Windows XP.
2025-01-09 18:02:00 +01:00
Dario Sassi e932c32346 EgtLock :
- estesa gestione chiavi di rete a 10 utenti per ciascuna (Anonymous + User1...User9)
- migliorata discriminazione errori chiave di rete (collegamento o posti tutti occupati).
2024-04-30 16:52:42 +02:00
Dario Sassi 1b02ee8b0f EgtLock :
- modifiche per meglio riconoscere il tipo di errore con la chiave di rete.
2024-04-09 14:42:55 +02:00
Dario Sassi cf274d21b0 EgtLock 2.6a1 :
- aggiunta funzione GetKeyLevelEx con i giorni mancanti alla scadenza dell'assistenza.
2024-01-25 18:19:03 +01:00
Dario Sassi a9eff6ff4b EgtLock 2.6a1 :
- aggiornamenti per versione 26.
2024-01-16 10:37:09 +01:00
6 changed files with 213 additions and 39 deletions
+9 -5
View File
@@ -22,14 +22,14 @@
<ProjectGuid>{DD7F3502-6761-4B6D-BE79-B2DF4A5FC426}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>EgtLock</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -42,7 +42,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -101,6 +101,8 @@
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp20</LanguageStandard>
<OpenMPSupport>false</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -120,7 +122,7 @@ copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\</Command>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<SuppressStartupBanner>false</SuppressStartupBanner>
</ClCompile>
<Link>
@@ -144,6 +146,8 @@ copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\</Command>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<LanguageStandard>stdcpp20</LanguageStandard>
<OpenMPSupport>false</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -168,7 +172,7 @@ copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\</Command>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<OmitFramePointers>false</OmitFramePointers>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<SuppressStartupBanner>false</SuppressStartupBanner>
</ClCompile>
<Link>
+86 -17
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2023
// EgalTech 2014-2026
//----------------------------------------------------------------------------
// File : KeyProc.cpp Data : 01.01.23 Versione : 2.5a1
// File : KeyProc.cpp Data : 02.01.26 Versione : 3.1a1
// Contenuto : Funzioni per la gestione della chiave.
//
//
@@ -10,6 +10,8 @@
// 29.02.16 DS Controllo prodotti con & (and bit a bit).
// 12.07.16 DS In recupero opzioni, se chiave ko azzero risultati.
// 26.12.20 DS Gestione versione MMmm (vecchie chiavi convertite).
// 24.01.24 DS Aggiunta GetKeyLevelEx con anche giorni scadenza assistenza.
// 02.01.26 DS Aggiunta gestione versioni da 2801 a 36812.
//
//----------------------------------------------------------------------------
@@ -29,7 +31,7 @@
using namespace std ;
//----------------------------------------------------------------------------
static const int MIN_DAYS = 19358 ; // giorni dal 01/01/1970 al 01/01/2023
static const int MIN_DAYS = 20454 ; // giorni dal 01/01/1970 al 01/01/2026
static const int N_STEP = 7 ;
//----------------------------------------------------------------------------
@@ -38,20 +40,35 @@ MakeKey( int nProd, int nVer, int nLev, int nExpDays,
unsigned int nOpt1, unsigned int nOpt2, int nOptExpDays,
const string& sScramKey, string& sKey)
{
// sistemazioni per nuova versione mensile valide fino alla 2806
// ( 16->16, 19->19, 21->21, 22->22, 2201->22, 2202->23 ... 2212->33, 2301->34, 2302->35 ... 2312->45)
int nVerNew ;
if ( nVer >= 1 && nVer <= 22)
// sistemazioni per nuova versione mensile valide fino alla 2712
// ( 16->16, 19->19, 21->21, 22->22, 2201->22, 2202->23 ... 2212->33, 2301->34, 2302->35 ... 2312->45, 2701->82 ... 2712->93)
// nuove sistemazioni valide dalla 2801 alla 36812 (sempre NNN01 ... NNN12, dove NNN è la versione e il resto è il mese)
int nVerNew = 0 ;
int nVerTot = 0 ;
int nVerA1 = -1 ;
int nVerA2 = -1 ;
if ( nVer >= 1 && nVer <= 22) {
nVerNew = nVer ;
else if ( nVer >= 2201) {
int nVerY = ( nVer >= 100 ? nVer / 100 : nVer) ;
int nVerM = ( nVer >= 100 ? Clamp( nVer % 100 - 1, 0, 11) : 0) ;
nVerTot = nVerNew ;
}
else if ( nVer >= 2201 && nVer <= 2712) {
int nVerY = nVer / 100 ;
int nVerM = Clamp( nVer % 100 - 1, 0, 11) ;
nVerNew = Clamp( 22 + 12 * ( nVerY - 22) + nVerM, 0, 99) ;
nVerTot = nVerNew ;
}
else if ( nVer >= 2801 && nVer <= 36812) {
int nVerY = nVer / 100 ;
int nVerM = Clamp( nVer % 100 - 1, 0, 11) ;
nVerNew = Clamp( 94 + nVerY % 6, 94, 99) ;
nVerTot = Clamp( 12 * ( nVerY - 28) + nVerM, 0, 4095) ;
nVerA1 = nVerTot / 64 ;
nVerA2 = nVerTot % 64 ;
}
else
return false ;
// inizializzo parte pseudorandom
srand( nVerNew + nLev) ;
srand( nVerTot + nLev) ;
// preparo la stringa da criptare
string sClearKey ;
sClearKey += ToString( ( rand() % 9), 1) ;
@@ -61,6 +78,7 @@ MakeKey( int nProd, int nVer, int nLev, int nExpDays,
sClearKey += ToString( ( rand() % 9), 1) ;
sClearKey += ToString( nExpDays, 6) ;
sClearKey += ToString( ( rand() % 9), 1) ;
if ( nVerA1 >= 0) sClearKey[16] = nVerA1 + 63 ;
sClearKey += " " ;
sClearKey[17] = ( nOpt1 >> 0) & 0xFF ;
sClearKey[18] = ( nOpt1 >> 8) & 0xFF ;
@@ -72,6 +90,7 @@ MakeKey( int nProd, int nVer, int nLev, int nExpDays,
sClearKey[23] = ( nOpt2 >> 16) & 0xFF ;
sClearKey[24] = ( nOpt2 >> 24) & 0xFF ;
sClearKey += ToString( ( rand() % 9), 1) ;
if ( nVerA2 >= 0) sClearKey[25] = nVerA2 + 63 ;
sClearKey += ToString( nOptExpDays, 6) ;
// eseguo la cifratura
string sMidKey = sClearKey ;
@@ -117,9 +136,18 @@ ReadKey( const string& sKey, const string& sScramKey,
( ((unsigned char)sClearKey[23]) << 16) | ( ((unsigned char)sClearKey[24]) << 24) ;
if ( ! FromString( sClearKey.substr( 26, 6), nOptExpDays))
return false ;
// sistemazioni per nuova versione mensile valide fino alla 2806
// ( 2201->22, 2202->23 ... 2212->33, 2301->34, 2302->35 ... 2312->45)
if ( nVer > 22) {
// sistemazioni per nuova versione mensile valide fino alla 2712
// ( 16->16, 19->19, 21->21, 22->22, 2201->22, 2202->23 ... 2212->33, 2301->34, 2302->35 ... 2312->45, 2701->82 ... 2712->93)
// nuove sistemazioni valide dalla 2801 alla 36812 (sempre NNN01 ... NNN12, dove NNN è la versione e il resto è il mese)
if ( nVer > 93) {
int nVerA1 = sClearKey[16] - 63 ;
int nVerA2 = sClearKey[25] - 63 ;
int nVerTot = nVerA1 * 64 + nVerA2 ;
int nVerY = 28 + nVerTot / 12 ;
int nVerM = nVerTot - ( 12 * ( nVerY - 28)) ;
nVer = nVerY * 100 + nVerM + 1 ;
}
else if ( nVer > 22) {
int nVerY = 22 + ( nVer - 22) / 12 ;
int nVerM = nVer - ( 22 + 12 * ( nVerY - 22)) ;
nVer = nVerY * 100 + nVerM + 1 ;
@@ -135,8 +163,12 @@ VerifyKey( const string& sKey, int nProd, int nVer, int nLev,
{
// creo la chiave di scramble
string sLockId2 ;
if ( ! GetLockId2( sLockId2))
return KEY_ERR_MACHID ;
if ( ! GetLockId2( sLockId2)) {
if ( NotFoundNetHwKey())
return KEY_ERR_NETKEY_NOTFOUND ;
else
return KEY_ERR_MACHID ;
}
string sScramKey ;
if ( ! ConvertLockId2ToScramKey( sLockId2, sScramKey))
return KEY_ERR_SCRAMKEY ;
@@ -145,11 +177,13 @@ VerifyKey( const string& sKey, int nProd, int nVer, int nLev,
nKProd, nKVer, nKLev, nKExpDays,
nKOpt1, nKOpt2, nKOptExpDays))
return KEY_ERR_KEYDECODE ;
// aggiusto i dati di versione
// aggiusto i dati di versione (da 2712 si salta a 3101)
if ( nVer < 100)
nVer = nVer * 100 + 7 ;
if ( nKVer < 100)
nKVer = nKVer * 100 + 7 ;
else if ( nKVer >= 2701 && nKVer <= 2712)
nKVer += 300 ;
// verifico dati prodotto
if ( ( nProd & nKProd) != nProd)
return KEY_ERR_PROD ;
@@ -197,6 +231,41 @@ GetKeyLevel( const string& sKey, int nProd, int nVer, int nLev,
return nErr ;
}
//----------------------------------------------------------------------------
int
GetKeyLevelEx( const string& sKey, int nProd, int nVer, int nLev,
int& nKLev, int& nKExpDays, int& nKAssExpDays)
{
int nKProd, nKVer ;
unsigned int nKOpt1, nKOpt2 ;
int nKOptExpDays ;
int nErr = VerifyKey( sKey, nProd, nVer, nLev,
nKProd, nKVer, nKLev, nKExpDays,
nKOpt1, nKOpt2, nKOptExpDays) ;
if ( nErr != KEY_OK) {
nKLev = 0 ;
nKExpDays = 0 ;
nKAssExpDays = 0 ;
}
else {
// sistemazioni per vecchie gestioni chiavi
// 16xx -> 17xx, 18xx -> 18xx, 19xx -> 19xx, 21xx -> 20xx, 22xx -> 21xx, ... , 27xx -> 26xx, 31xx -> 27xx, ...
int nKAssEnd = nKVer + ( nKVer < 1800 ? 100 : ( nKVer < 2000 ? 0 : ( nKVer < 3100 ? -100 : -400))) ;
// si considera il primo giorno del mese successivo (mesi sono 0-based, con dicembre si va a gennaio anno dopo)
int nKAssEndM = Clamp( nKAssEnd % 100, 1, 12) ;
int nKAssEndY = nKAssEnd / 100 + 100 ;
if ( nKAssEndM == 12) {
nKAssEndM = 0 ;
nKAssEndY += 1 ;
}
struct tm tmAssEnd = { 0, 0, 0, 1, nKAssEndM, nKAssEndY, 0, 0, 0} ;
time_t nClock = mktime( &tmAssEnd) ;
nKAssExpDays = int( nClock / ( 24 * 3600)) ; // (24*3600) secondi in un giorno
nKAssExpDays = min( nKAssExpDays, nKExpDays) ;
}
return nErr ;
}
//----------------------------------------------------------------------------
int
GetKeyOptions( const string& sKey, int nProd, int nVer, int nLev,
+14 -5
View File
@@ -65,6 +65,16 @@ CloseNetHwKey( void)
return NetDongleClose() ;
}
//----------------------------------------------------------------------------
bool
NotFoundNetHwKey( void)
{
if ( s_bNetHwKey)
return NetDongleNotFound() ;
else
return false ;
}
//----------------------------------------------------------------------------
bool
GetLockId( string& sLockId)
@@ -80,10 +90,10 @@ GetLockId( string& sLockId)
case KEY_LOCK_TYPE_SW :
return GetMachineId( sLockId) ;
case KEY_LOCK_TYPE_HW :
if ( ! s_bNetHwKey)
return GetDongleId( sLockId) ;
else
if ( s_bNetHwKey)
return GetNetDongleId( s_nNetUserId, s_sAddrPort, sLockId) ;
else
return GetDongleId( sLockId) ;
}
}
@@ -178,8 +188,7 @@ GetLockSN( int& nLockSN)
if ( ! s_bNetHwKey)
return GetDongleSN( nLockSN) ;
else {
nLockSN = 0 ;
return false ;
return GetNetDongleSN( nLockSN) ;
}
}
}
+99 -9
View File
@@ -38,6 +38,34 @@ static const char* user2_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIz9JWqyWVZU
"dyFMPUWdRN6TwYzvn_t1ie1WnX20_3VC1pEMfwUyM8SKT_QU38DqhNhh2GSzAQoeU9GxzyUptxX"\
"t9AGjs0G6e0IuDQHvhRMo3tY2bNNyqitBkhZl35PnaIr8G1vqiWfUMIdNQKmKLRMxzVwfphnb65"\
"-3jSoQhjm8qDwWJuiKGlqcLeX0DTvEsW5Oe1EZTUHoAAPSdgz65Wj2H6T0hmPAF" ;
static const char* user3_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIW1HNpulC8Ae0eSrxQZoIP1UorXSxEa7T05SncGa7xym"\
"RjJUZSfLfSh2dc7Jv1sUNbMLUpiga4YZ_F6k7c1nAvd5xZEk9abhlyUcxFKIWQ2_cr3cRv5m5Iu"\
"5jQjQndR0ZpTKIE00itXLarSn4_iyIq4EnveH2fZ81TnyQvXk2XCg5EaS2DVMrlDr4f034CPDw5"\
"XncjkeeNsQhACpnfvMLVfIW557CxUMKkeE5259NVb8AtOhGM0DY0KtOlZJG9Ap1" ;
static const char* user4_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIFWU_1cR02fpTFyK2rpiZDQPjSyiFBjwcuXzNPDsBRVb"\
"yLOmr34-iYzs_Uo1IflcOJejXaYmePjgt8lzoeXFDSDjXgolN3f-SB5dCKYpFp_kfuk8sX9wIoz"\
"sZtI5aCLU_rt-by1rn57ommIEqKsHVvVXE07hFRjDk6ocF0JSY09Yp74NLw934nfX5JPbESkAc7"\
"mpRFTIff5f-TVR0Xq9826Yv7bIwuOsJqm9HtRNheTanjA3B2NlLX11ZWOqDdy7i" ;
static const char* user5_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIoMFpbVWHwzzO5cMRfcIBXfrNDpME4MNTjdfuRzRX1kV"\
"2SPVEwBZCfS6pFXbYuYBQHLH7H_cGP26tE5x-EyxPEjqMwIzLlo81orex9B1ZI10nRZ16sFEEHX"\
"wosxMhAa7H30vWfq70YgAmHKwks-76W1hYuF5pXYVixJUsG2RSY5CwTzUE6BSMElto9hxHD52K9"\
"onHP8juJ8UHw0z-riibH-5bgiAWDE6qiFSikf-HB5EKMwmaTzkR2hWNoz7kfkWz" ;
static const char* user6_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIf69IY1tbJvTzrHWcNzicRrLhiFq8aqPkit2wwGE6e57"\
"ecv3CH7fu5-0uui1Qdx9jHfs1pKTcO_scPC3KUboUSUl9pmknn6tjKXFmwyXMKYi74kR_brOy5F"\
"uAI8dhNfN56M6uIlyHbqJ-RcErC2ZEdjKCtznrbaUJpeH1ztr-FMCYBn4zx23wvi15sosmmaN3e"\
"2_uKGXAyhCqtivi9QNRlLDgQEv9ZcwageZ8KUCycUYgGNngx1ZiNFswsI-YXPSs" ;
static const char* user7_data_blob = "DHn2Cq9uYJKBJUYCRuVyQInD31qNrhc0_zj4cN8i9cVBgK_TXRCWgPNXf94qAzYr6"\
"HUiu3y4cqzTwtfGcQFsHrmvXPbp-NOC-Ge_JBtSb_yz2phREuoYdIyWQirZMIZx51EPBAwTnjTZ"\
"ts6QxZHfgPKiByZoCSsLP3cTS-vOZ2YRUsw7S6bswiz6AyArUnpj0nWCOVgvYk5YqEWs-vicYYQ"\
"sL8ZwZZWETfZSjIY-oNTViSdqU4nhVEFytwyHWcEVE0_hHMZASpJAG0PlIxujyN" ;
static const char* user8_data_blob = "DHn2Cq9uYJKBJUYCRuVyQI8I6EFK2sRnyORhqUDtkiOHF3RQz8F0iIGWewMaaz4sT"\
"ewTDo78183qXrAld2r9NsV8VndXCM42rkzgkLWAYKk5NKbtcMgT0ojajbFg5q8yjrrSbJ9jRvUj"\
"eExgZjwm-RcvHQpVdHuIgjVvNva2qipgyM7EeCtVCSJ1DuYNtTkGLJuyvG75XQ7iQMymV_YXeul"\
"TxDa6HGCgQSaAiz_hBrA-ojjQxUh9pJhCwr0dXJVBi4Ugpv_IHcO2d_JHolKQJ6" ;
static const char* user9_data_blob = "DHn2Cq9uYJKBJUYCRuVyQI9ZLGhVgBSQAjUXHm-k0T1SY0SK1pq2mHdosAUUz-CEs"\
"s510O3YynKN42QBWrM01CTknvirL5NWCp9QQ_0j4QftwdwVB_EIIBy8IaeirFpttCbn7Z0acIwi"\
"ojAEDQK4an_VyVFHhvaX50Ab5mXg8Fqa9VjvI7S_JK-ay8YOEcKuoi0izmFafAP4QexavrLPwc3"\
"Qzu3d29a4mXT3boWupXo3YBCNUpV6829KFHN7aXRcDF0Uc8qUUvmrmQc-4at_X8" ;
//----------------------------------------------------------------------------
bool
@@ -109,11 +137,13 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort)
strcpy_s( (char*)label, XLT_LABEL_SIZE, sLabel.c_str()) ;
memset( label + sLabel.size(), 0x00, sizeof( label) - sLabel.size()) ;
int nStatusND = 0 ;
if ( &sAddrPort == nullptr || sAddrPort.empty() ||
if ( sAddrPort.empty() ||
sAddrPort.find_first_not_of( " \t\r\n") == std::string::npos)
s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 30000, 0, 0, &nStatusND) ;
else
s_net_data = xnd_net_data_create_resolving_addr_port( s_env, s_sAddrPort.c_str(), 0, 30000, &nStatusND) ;
s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 10000, 0, 0, &nStatusND) ;
else {
s_sAddrPort = sAddrPort ;
s_net_data = xnd_net_data_create_resolving_addr_port( s_env, s_sAddrPort.c_str(), 0, 0, &nStatusND) ;
}
if ( s_net_data == nullptr) {
xnd_xlt_env_release( s_env) ;
return false ;
@@ -171,26 +201,79 @@ NetDongleConnect( int nNetUserId, const string& sAddrPort)
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 3 : {
string sUsDB = string{ UsBase} + user3_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 4 : {
string sUsDB = string{ UsBase} + user4_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 5 : {
string sUsDB = string{ UsBase} + user5_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 6 : {
string sUsDB = string{ UsBase} + user6_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 7 : {
string sUsDB = string{ UsBase} + user7_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 8 : {
string sUsDB = string{ UsBase} + user8_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
case 9 : {
string sUsDB = string{ UsBase} + user9_data_blob ;
s_dev_ctx = xnd_xlt_devctx_xnodus_create2( s_env, s_net_data, sXnKB.c_str(), sUsDB.c_str(), 0, XND_XLT_DEVCTX_FLAG_XNODUS_MULTI_INSTANCE, 0, &nStatusDC) ;
break ;
}
}
if ( s_dev_ctx == nullptr) {
xnd_xlt_env_release( s_env) ;
s_env = nullptr ;
s_net_data = nullptr ;
return false ;
}
// apro la sessione
int nStatOP = xnd_xlt_session_open( s_dev_ctx, 0) ;
if ( nStatOP != 0) {
xnd_xlt_devctx_release( s_dev_ctx) ;
xnd_xlt_devctx_release( s_dev_ctx) ; // this close also the session!
xnd_xlt_env_release( s_env) ;
s_env = nullptr ;
s_net_data = nullptr ;
s_dev_ctx = nullptr ;
// collegamento con la chiave non riuscito, imposto opportunamente lo stato
if ( nStatOP == XND_ERROR_NET_RECV_FAILURE)
s_net_data = nullptr ;
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GetNetDongleSN( int& nDongleSN)
{
// default
nDongleSN = 0 ;
// verifico validità contesto
if ( s_dev_ctx == nullptr)
return false ;
// recupero informazioni sulla chiave
XND_INFO xInfo ;
int nStatIF = xnd_get_info( s_dev_ctx, &xInfo) ;
if ( nStatIF != 0)
return false ;
// ricavo il SN
nDongleSN = *((unsigned int*)&xInfo.sn[12]) ;
return true ;
}
//----------------------------------------------------------------------------
bool
NetDongleClose( void)
@@ -202,3 +285,10 @@ NetDongleClose( void)
s_env = nullptr ;
return true ;
}
//----------------------------------------------------------------------------
bool
NetDongleNotFound( void)
{
return ( s_env != nullptr && s_net_data == nullptr) ;
}
+4 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2022-2023
// EgalTech 2022-2024
//----------------------------------------------------------------------------
// File : NetDongleId.h Data : 09.10.23 Versione : 2.5j1
// File : NetDongleId.h Data : 09.04.24 Versione : 2.6d2
// Contenuto : Dichiarazione funzioni locali per gestione/calcolo Id chiave.
//
//
@@ -18,4 +18,6 @@
//-------------------------------------------------------------------------------
bool GetNetDongleId( int nNetUserId, const std::string& sAddrPort, std::string& sDongleId) ;
bool NetDongleConnect( int nNetUserId, const std::string& sAddrPort) ;
bool GetNetDongleSN( int& nDongleSN) ;
bool NetDongleClose( void) ;
bool NetDongleNotFound( void) ;
+1 -1
View File
@@ -119,7 +119,7 @@ CharScramble( char cVal, char cOp)
//----------------------------------------------------------------------------
// LenMask e Step devono essere primi tra loro e senza sottomultipli in comune :
// con LenMask = 24, Step è bene sia 7 o 11, Step 9 non è efficiente.
// con LenMask = 24, Step è bene sia 7 o 11, Step 9 non è efficiente.
//----------------------------------------------------------------------------
bool
ScrambleData( string& sData, const string& sMask, const int nStep)