Przeglądaj źródła

Z991239-1057 #comment other:准入实体能够通过编译

雷志明80280620 5 lat temu
rodzic
commit
00d09d64bb

Plik diff jest za duży
+ 299 - 140
Module/mod_accessauth/AccessAuthConn.cpp


+ 61 - 26
Module/mod_accessauth/AccessAuthConn.h

@@ -1,4 +1,5 @@
-#pragma once
+#ifndef __ACCESSAUTHCONN_H
+#define __ACCESSAUTHCONN_H
 
 #include "SpSecureClient.h"
 #include "AccessAuthorization_def_g.h"
@@ -35,6 +36,18 @@ struct SMWKUpdateRet
 	BYTE kmcData[0];        // 变长1到300
 };
 
+//获取KMC密钥
+struct KMCKeyReq {
+	char TerminalNo[16];
+};
+
+struct KMCKeyRet {
+	char TMK[64];
+	char TPK[64];
+	char EDK[64];
+	char Reserved[256];
+};
+
 // 请求TOKEN时附带设备信息(未加密) 102 byte
 struct RequestTokenInfo
 {
@@ -49,7 +62,13 @@ struct RequestTokenInfo
     char chTerminalState;		//	终端生命阶段状态	char	1
     char chRunState;			//	系统状态	char	1
 };
-
+//判断是否进行了国密改造
+struct RequestTokenReq0
+{
+	int isSM; 
+	int isFirst;//是否国密改造之后的第一次准入
+	BYTE FingerPrintSM[16];
+};
 // 请求Token设备信息加密后结构(使用密码键盘加密)
 // [StructName("TOKEN_R1")]
 struct RequestTokenReq1
@@ -104,7 +123,12 @@ struct RequestTokenRet
 	BYTE sharedSK[16];		// 共享会话密钥
 	BYTE retHash[4];		// 返回结构Hash
 };
-
+//国密
+struct RequestTokenRet2
+{
+	BYTE enToken[256];      // 使用准入服务签名后的TOKEN
+	BYTE retHash[32];		// 返回结构Hash
+};
 // 退出准入上报
 // [StructName("EXIT_REQ")]
 struct TerminalExitReq
@@ -139,7 +163,11 @@ struct SyncTimeReq
 	DWORD dwCurTime;		// 终端当前时间
 	BYTE byReserved[64];		// 保留字段
 };
-
+//是否进行国密改造
+struct SyncTimeReq2
+{
+	int isSm;
+};
 // [StructName("SYNC_A1")]
 struct SyncTimeAns
 {
@@ -206,33 +234,39 @@ class CAccessAuthConn : public SpSecureClient
 public:
 	CAccessAuthConn(CEntityBase *pEntity, CAccessAuthFSM *pFSM);
 
-	ErrorCodeEnum SendWKUpdatePackage();
-	ErrorCodeEnum SendGetTokenPackage();
-	ErrorCodeEnum SendExitNoticePackage(int nReason, int nWay);
-	ErrorCodeEnum SendTerminalStagePackage(char cNewStage, CSmallDateTime dtNewStageTime, char cOldStage, CSmallDateTime dtOldStageTime);
-	ErrorCodeEnum SendSyncTimePackage();
-	ErrorCodeEnum SendSyncTimePackageNew();
-	ErrorCodeEnum SendInitDevicePackage(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
-	ErrorCodeEnum SendReportStatePackage(const char*pszEventType, DWORD dwErrCode, const char *pszErrMsg);
-	ErrorCodeEnum SendLockStatePackage();
-	ErrorCodeEnum SendCheckMD5Package(const char* pMD5Value);
-	ErrorCodeEnum SendUpdateMD5Package(const char* pMD5Value);
+	DWORD SendSyncTimePackage();
+	DWORD SendSyncTimePackageNew();
+	DWORD SendLockStatePackage();
+	DWORD SendWKUpdatePackage();
+
+	DWORD SendGetTokenPackage();
+	DWORD SendExitNoticePackage(int nReason, int nWay);
+	DWORD SendTerminalStagePackage(char cNewStage, CSmallDateTime dtNewStageTime, char cOldStage, CSmallDateTime dtOldStageTime);
+	DWORD SendInitDevicePackage(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
+	DWORD SendReportStatePackage(const char*pszEventType, DWORD dwErrCode, const char *pszErrMsg);
+
+	DWORD SendCheckMD5Package(const char* pMD5Value);
+	DWORD SendUpdateMD5Package(const char* pMD5Value);
 
 private:
 	~CAccessAuthConn();
 	void OnDisconnect();
 	void OnPkgAnswer(const CSmartPointer<IPackage> &pRecvPkg);
 
-	ErrorCodeEnum HandleUpdateWKRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleReqTokenRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleTermExitRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleReportStageRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleSyncTimeRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleInitDeviceRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleReportStateRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleLockStateRet(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleCheckMD5Ret(const CSmartPointer<IPackage> &pRecvPkg);
-	ErrorCodeEnum HandleUpdateMD5Ret(const CSmartPointer<IPackage> &pRecvPkg);
+	DWORD HandleSyncTimeRet(const CSmartPointer<IPackage>& pRecvPkg);
+	DWORD HandleLockStateRet(const CSmartPointer<IPackage>& pRecvPkg);
+	DWORD HandleUpdateWKRet(const CSmartPointer<IPackage> &pRecvPkg);
+	DWORD HandleReqTokenRet(const CSmartPointer<IPackage> &pRecvPkg);
+	DWORD HandleTermExitRet(const CSmartPointer<IPackage> &pRecvPkg);
+
+	DWORD HandleReportStageRet(const CSmartPointer<IPackage> &pRecvPkg);
+
+	DWORD HandleInitDeviceRet(const CSmartPointer<IPackage> &pRecvPkg);
+
+	DWORD HandleReportStateRet(const CSmartPointer<IPackage>& pRecvPkg);
+
+	DWORD HandleCheckMD5Ret(const CSmartPointer<IPackage> &pRecvPkg);
+	DWORD HandleUpdateMD5Ret(const CSmartPointer<IPackage> &pRecvPkg);
 	
 	bool GetSpBaseSignCertHash(CSimpleStringA &strHash);
 	bool GetUKeyRootCertHash(CSimpleStringA &strHash);
@@ -241,4 +275,5 @@ private:
 private:
 	CAccessAuthFSM *m_pFSM;
 	SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer m_ctxInitDev;
-};
+};
+#endif // !__ACCESSAUTHCONN_H

+ 77 - 76
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -1,11 +1,14 @@
 #include "stdafx.h"
 #include "AccessAuthFSM.h"
 #include "mod_AccessAuth.h"
-#include "Event.h"
+
+#ifdef RVC_OS_WIN
 #include  <io.h>
+#endif
 #include  <stdio.h>
 #include  <stdlib.h>
-#include "MD5file.h"
+
+#include "comm.h"
 
 CAccessAuthFSM::CAccessAuthFSM()
 	:m_pConnection(NULL)
@@ -25,6 +28,7 @@ void CAccessAuthFSM::OnStateTrans(int iSrcState, int iDstState)
 // 初始化PinPad及KMC
 ErrorCodeEnum CAccessAuthFSM::OnInit()
 {
+	LOG_FUNCTION();
 	AddStateHooker(this);
 	m_finishAccess = 0;
 	//设置初始锁定状态,0
@@ -49,6 +53,7 @@ ErrorCodeEnum CAccessAuthFSM::OnExit()
 void CAccessAuthFSM::s1_on_entry()
 {
 	SetSysVar("I");
+	PostEventFIFO(new FSMEvent(CAccessAuthFSM::Event_StartRegist));
 }
 
 void CAccessAuthFSM::s1_on_exit()
@@ -57,6 +62,7 @@ void CAccessAuthFSM::s1_on_exit()
 
 unsigned int CAccessAuthFSM::s1_on_event(FSMEvent* pEvent)
 {
+	LOG_FUNCTION();
 	Dbg("s1_on_event: %d", pEvent->iEvt);
 	if (pEvent->iEvt == Event_ReportStage)
 	{
@@ -98,7 +104,7 @@ ErrorCodeEnum CAccessAuthFSM::SecureClientRelease()
 
 	return Error_Succeed;
 }
-std::_Mutex mut;
+std::mutex mut;
 struct TimeOutTask : public ITaskSp {
 	CAccessAuthFSM* m_fsm;
 	long m_timeOut;//毫秒级
@@ -117,6 +123,7 @@ struct TimeOutTask : public ITaskSp {
 };
 void CAccessAuthFSM::s2_on_entry()
 {
+	LOG_FUNCTION();
 	//  [6/16/2020 9:51 @Gifur]
 	//ScheduleTimer(2, 120 * 1000);		// 设定30秒准入超时
 	m_finishAccess = 0;
@@ -125,6 +132,7 @@ void CAccessAuthFSM::s2_on_entry()
 	Dbg("启动了准入超时定时器2分钟[%d]",m_finishAccess);
 
 	auto pEntity = (CAccessAuthEntity*)m_pEntity;
+	
 	auto rc = pEntity->InitKMC();
 	if (rc != Error_Succeed)
 	{
@@ -134,13 +142,12 @@ void CAccessAuthFSM::s2_on_entry()
 			GetOutPutStr("%s%08X", "InitKMC", rc).c_str());
 		return;
 	}
-
+	
 	SetSysVar("C");
 
 	if ((rc = SecureClientConnect()) != Error_Succeed)
 	{
 		// 启动定时器尝试重试
-		//LogError(Severity_Low, rc, ERROR_ACCESSAUTH_CONNECTSERVER, "connect AccessAuthorization fail, start timer(8s) to retry");
 		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_CONNECT_SERVER,
 			GetOutPutStr("%s%08X", "SecureClientConnect", rc).c_str());
 		ScheduleTimer(1, 8000);
@@ -165,6 +172,7 @@ void CAccessAuthFSM::s2_on_exit()
 // 会收到Event_UpdateWKResult和Event_ReqTokenResult和EVT_TIMER
 unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 {
+	LOG_FUNCTION();
 	if (pEvent->iEvt == EVT_TIMER)
 	{
 		if (pEvent->param1 == 2)		// access timeout
@@ -173,13 +181,12 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 			Dbg("access authorize timeout");
 			PostEventFIFO(new FSMEvent(Event_ReqTokenCancel));
 		}
-		else if (pEvent->param1 == 1)	 // reconnect
+		else if (pEvent->param1 == 1 || pEvent->param1 == 3)	 // reconnect
 		{
 			auto rc = SecureClientConnect();
 			if (rc != Error_Succeed)
 			{
 				// 启动定时器尝试重试
-				// LogError(Severity_Low, rc, ERROR_ACCESSAUTH_CONNECTSERVER, "connect to AccessAuthorization service fail, retry 8's later");
 				LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_CONNECT_SERVER,
 					GetOutPutStr("%s%08X","SecureClientConnect",rc).c_str());
 				ScheduleTimer(1, 8000);
@@ -192,56 +199,25 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 	}
 	else if (pEvent->iEvt == Event_ConnectionOK)
 	{
-		//暂时默认不校验MD5,需要校验配置CheckMD5=1
-		if (0 == m_nCheckMD5)
-		{			
-			FSMEvent *pEvent = new FSMEvent(Event_CheckMD5Succ);
-			PostEventFIFO(pEvent);		
+		Dbg("判断是否第一次准入!");
+		auto pEntity = ((CAccessAuthEntity*)m_pEntity);
+		int isFirstAccessAfterSM = pEntity->GetOrSetIsFirstSM(0);
+		if (isFirstAccessAfterSM != 1) {
+			Dbg("否则继续!");
+			FSMEvent* pEvent = new FSMEvent(Event_CheckMD5Succ);
+			PostEventFIFO(pEvent);
+			return 0;
 		}
-		else
-		{
-			//校验MD5列表的MD5值
-			//获取MD5列表路径
-			TCHAR szPath[MAX_PATH] = {0};
-			CSimpleStringA strMD5ListPath;
-			CSimpleStringA strSysDir;
-			GetModuleFileNameA(NULL, szPath, MAX_PATH);
-			*strrchr(szPath, '\\') = 0;
-			strSysDir = szPath;
-			strMD5ListPath = strSysDir.SubString(0,1);			
-			strMD5ListPath += ":\\RVC\\MD5\\MD5.txt";
-
-			//判断本地MD5列表是否存在
-			auto pEntity = (CAccessAuthEntity*)m_pEntity;
-			if(-1 == (_access(strMD5ListPath.GetData(), 0)))
-			{
-				pEntity->SetAuthErrMsg("MD5列表不存在");
-				CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
-				spFunction->SetSysVar("AuthErrMsg", "MD5列表不存在", true);
-				LogError(Severity_Middle, Error_Unexpect, ERROR_ACCESSAUTH_MD5FILE_NOTEXIST,"\\RVC\\MD5\\MD5.txt not exist");
-				PostEventFIFO(new FSMEvent(CAccessAuthFSM::Event_CheckMD5Fail));
-				return 1;
-			}
-
-			//计算本地MD5值
-			char* pMd5 = MD5_file((char*)strMD5ListPath.GetData(), 16);
-			if (NULL == pMd5)
-			{
-				pEntity->SetAuthErrMsg("计算MD5列表的MD5值失败");
-				CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
-				spFunction->SetSysVar("AuthErrMsg", "计算MD5列表的MD5值失败", true);
-				LogError(Severity_Middle, Error_Unexpect, ERROR_ACCESSAUTH_MD5FILE,"calculate \\RVC\\MD5\\MD5.txt md5 value fail");
-				PostEventFIFO(new FSMEvent(CAccessAuthFSM::Event_CheckMD5Fail));
-				return 1;
-			}
-
-			//发送MD5值校验请求
-			auto rc = m_pConnection->SendCheckMD5Package(pMd5);
-			if (rc != Error_Succeed)
-			{
-				LogError(Severity_Middle, Error_Unexpect, ERROR_ACCESSAUTH_SENDPACK,"SendCheckMD5Package fail");
-				PostEventFIFO(new FSMEvent(CAccessAuthFSM::Event_CheckMD5Fail));
-			}
+		Dbg("等待自动初始化完成!");
+		CSimpleStringA strInitState;
+		pEntity->GetFunction()->GetSysVar("InitState", strInitState);
+		if (strInitState == "1") {
+			//2020/5/29 删除了各个文件MD5检验的代码		
+			FSMEvent* pEvent = new FSMEvent(Event_CheckMD5Succ);
+			PostEventFIFO(pEvent);
+		}
+		else {
+			ScheduleTimer(3, 1500);
 		}
 	}
 	else if (pEvent->iEvt == Event_CheckMD5Fail)
@@ -253,10 +229,9 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 	else if (pEvent->iEvt == Event_CheckMD5Succ)
 	{
 		// 同步服务器时间
-		ErrorCodeEnum rc = m_pConnection->SendSyncTimePackage();
+		DWORD rc = m_pConnection->SendSyncTimePackage();
 		if (rc != Error_Succeed)
 		{
-			//LogError(Severity_Low, rc, ERROR_ACCESSAUTH_SENDPACK, "SendSyncTimePackage fail!");
 			FSMEvent *pEvent = new FSMEvent(Event_EndSyncTime);
 			PostEventFIFO(pEvent);
 			LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_SYNC_TIME,
@@ -267,8 +242,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		rc = m_pConnection->SendLockStatePackage();
 		if (rc != Error_Succeed)
 		{
-			//LogError(Severity_Low, rc, ERROR_ACCESSAUTH_SENDPACK, "SendLockStatePackage fail!");
-			LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_LOCK_STATE,
+			LogWarn(Severity_Middle, Error_Unexpect, rc,
 				GetOutPutStr("%s%08X", "SendLockStatePackage", rc).c_str());
 		}		
 	}
@@ -294,6 +268,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		//pConfig->ReadConfigValueInt("Main", "WKSyncFailCount", nWKSyncFailCount);
 		CSimpleStringA strWKSyncSuccTime = "";
 		CSimpleStringA strWKSyncFailCount = "";
+#ifdef RVC_OS_WIN
 		auto rc = pEntity->GetFunction()->GetSysVar("WKSyncSuccTime", strWKSyncSuccTime);
 		assert(rc == Error_Succeed);
 		nWKLastSyncTime = atoi(strWKSyncSuccTime);
@@ -306,12 +281,29 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		Dbg("last WK sync time: %04d-%02d-%02d %02d:%02d:%02d", 
 			stSyncTime.wYear, stSyncTime.wMonth, stSyncTime.wDay,
 			stSyncTime.wHour, stSyncTime.wMinute, stSyncTime.wSecond);
-
 		SYSTEMTIME stNow = {};
 		GetLocalTime(&stNow);
-		if (nWKLastSyncTime > 0 && stSyncTime.wYear == stNow.wYear 
-			&& stSyncTime.wMonth == stNow.wMonth && stSyncTime.wDay == stNow.wDay 
-			&& nWKSyncFailCount ==	0 )		// 最近一次同步成功,才能跳过
+		if (nWKLastSyncTime > 0 && stSyncTime.wYear == stNow.wYear
+			&& stSyncTime.wMonth == stNow.wMonth && stSyncTime.wDay == stNow.wDay
+			&& nWKSyncFailCount == 0 )		// 最近一次同步成功,才能跳过
+#else
+		auto rc = pEntity->GetFunction()->GetSysVar("WKSyncSuccTime", strWKSyncSuccTime);
+		assert(rc == Error_Succeed);
+
+		rc = pEntity->GetFunction()->GetSysVar("WKSyncFailCount", strWKSyncFailCount);
+		assert(rc == Error_Succeed);
+		nWKSyncFailCount = str2int(strWKSyncFailCount.GetData());
+		TIME* lastTime = str2time(strWKSyncSuccTime.GetData());
+		Dbg("last WK sync time: %04d-%02d-%02d %02d:%02d:%02d",
+			lastTime->year, lastTime->month, lastTime->day,
+			lastTime->hour, lastTime->minute, lastTime->second);
+		TIME *currentTime = get_system_time();
+		if (lastTime->year == currentTime->year
+			&& lastTime->month == currentTime->month && lastTime->day == currentTime->day
+			&& nWKSyncFailCount == 0)		// 最近一次同步成功,才能跳过
+#endif
+		
+		
 		{
 			Dbg("WK has been updated today, last sync time: %s", (const char*)CSmallDateTime(nWKLastSyncTime).ToTimeString());
 			FSMEvent *pEvent = new FSMEvent(Event_IgnoreUpdateWK);
@@ -322,17 +314,20 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 			Dbg("begin update WK now");
 		
 			// 请求WK
-			ErrorCodeEnum rc = m_pConnection->SendWKUpdatePackage();
+			DWORD rc = m_pConnection->SendWKUpdatePackage();
 			if (rc != Error_Succeed)
 			{
-				LogError(Severity_Low, rc, ERROR_ACCESSAUTH_SENDPACK, "SendWKUpdatePackage fail!");
 				LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_UPDATE_WK,
 					GetOutPutStr("%s%08X", "SendWKUpdatePackage", rc).c_str());
 				FSMEvent *pEvent = new FSMEvent(Event_UpdateWKFail);
 				PostEventFIFO(pEvent);	
 			}
 		}
-
+#ifdef RVC_OS_WIN
+#else
+		delete lastTime;
+		delete currentTime;
+#endif
 		return 0;
 	}
 	else if (pEvent->iEvt == Event_UpdateWKSucc)
@@ -343,8 +338,15 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		// 保存WK同步时间
 		//CSmartPointer<IConfigInfo> pConfig;
 		//m_pEntity->GetFunction()->OpenConfig(Config_Software, pConfig);
+#ifdef RVC_OS_WIN
+		DWORD rc = m_pEntity->GetFunction()->SetSysVar("WKSyncSuccTime", (const char*)CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()), true);
+#else
+		TIME* tim = get_system_time();
+		
+		DWORD rc = m_pEntity->GetFunction()->SetSysVar("WKSyncSuccTime", time2str(tim).c_str(), true);
 
-		auto rc = m_pEntity->GetFunction()->SetSysVar("WKSyncSuccTime", (const char*) CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()), true);
+		delete tim;
+#endif
 		assert(rc == Error_Succeed);
 		/*pConfig->WriteConfigValue("Main", "WKSyncSuccTime", 
 			(const char*) CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));*/
@@ -372,7 +374,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 	{
 		// 忽略同步WK,直接准入
 		Dbg("ignore update wk, get token now");
-		auto rc = SecureClientConnect();
+		DWORD rc = SecureClientConnect();
 		if (rc == Error_Succeed)
 			rc = m_pConnection->SendGetTokenPackage();
 	
@@ -501,9 +503,8 @@ void CAccessAuthFSM::s4_on_entry()
 	SetSysVar("A");
 
 	// 发送准入超时事件
-	//LogError(Severity_Middle, Error_Unexpect, EVENT_ACCESSAUTH_TIMEOUT, "准入超时");
 	LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_TIMEOUT,
-		GetOutPutStr("%s%s", "准入", "超时").c_str());
+		    GetOutPutStr("%s%s", "准入", "超时").c_str());
 	// 切换到s1
 	PostEventFIFO(new FSMEvent(Event_StateTimeout));
 }
@@ -587,7 +588,7 @@ unsigned int CAccessAuthFSM::s6_on_event(FSMEvent* pEvent)
 	else if (pEvent->iEvt == Event_ConnectionOK)
 	{
 		// 请求退出
-		ErrorCodeEnum rc = m_pConnection->SendExitNoticePackage(m_nExitReason, m_nExitWay);
+		DWORD rc = m_pConnection->SendExitNoticePackage(m_nExitReason, m_nExitWay);
 
 		// 切换到s1
 		PostEventFIFO(new FSMEvent(Event_StateTimeout));
@@ -619,9 +620,9 @@ ErrorCodeEnum CAccessAuthFSM::SetSysVar(const CSimpleStringA &newVal)
 	return spFunction->SetSysVar("EntryPermit", (const char*)newVal);
 }
 
-ErrorCodeEnum CAccessAuthFSM::InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx)
+DWORD CAccessAuthFSM::InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx)
 {
-	auto rc = SecureClientConnect();
+	DWORD rc = SecureClientConnect();
 
 	if (rc == Error_Succeed)
 		rc = m_pConnection->SendInitDevicePackage(ctx);
@@ -630,14 +631,14 @@ ErrorCodeEnum CAccessAuthFSM::InitDevice(SpReqAnsContext<AccessAuthService_InitD
 
 	if (rc != Error_Succeed)
 	{
-		ctx->Answer(rc);
+		ctx->Answer(rc? Error_Unexpect: Error_Succeed);
 		return rc;
 	}	
 
 	return Error_Succeed;
 }
 
-ErrorCodeEnum CAccessAuthFSM::SyncTime()
+DWORD CAccessAuthFSM::SyncTime()
 {
 	auto rc = SecureClientConnect();
 	if (rc == Error_Succeed)

+ 14 - 8
Module/mod_accessauth/AccessAuthFSM.h

@@ -1,10 +1,12 @@
-#pragma once
+#ifndef __ACCESSAUTHFSM_H
+#define __ACCESSAUTHFSM_H
 
 #include "SpBase.h"
 #include "SpFSM.h"
 #include "Blob.h"
 #include "AccessAuthConn.h"
 #include "AccessAuthErrorCode.h"
+#include <mutex>
 class MyMutex;
 class CAccessAuthFSM : public FSMImpl<CAccessAuthFSM>, public IFSMStateHooker
 {
@@ -48,7 +50,9 @@ public:
 		Event_StateTimeout,		// 临时状态超时
 		Event_ReportStage,
 		Event_CheckMD5Succ,
-		Event_CheckMD5Fail
+		Event_CheckMD5Fail,
+		Event_InitFinishOK,
+		Event_SyncTimeFailed  //同步时间失败
 	};
 
 	BEGIN_FSM_STATE(CAccessAuthFSM)
@@ -68,6 +72,7 @@ public:
 		FSM_RULE_ENTRY_ANY(s2, s3, Event_CheckMD5Fail)		
 		FSM_RULE_ENTRY_ANY(s2, s4, Event_ReqTokenCancel)
 		FSM_RULE_ENTRY_ANY(s2, s5, Event_ReqTokenSucc)
+		FSM_RULE_ENTRY_ANY(s2, s3, Event_SyncTimeFailed)
 		FSM_RULE_ENTRY_ANY(s3, s2, Event_StartRegist)
 		FSM_RULE_ENTRY_ANY(s4, s1, Event_StateTimeout)
 		FSM_RULE_ENTRY_ANY(s5, s6, Event_StartUnregist)			
@@ -107,8 +112,8 @@ public:
 	unsigned int s7_on_event(FSMEvent* event);
 
 public:
-	ErrorCodeEnum InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
-	ErrorCodeEnum SyncTime();
+	DWORD InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
+	DWORD SyncTime();
 	int m_finishAccess;
 
 private:
@@ -127,12 +132,13 @@ private:
 };
 class MyMutex {
 public:
-	explicit MyMutex(std::_Mutex* pm):mut(pm) {
-		mut->_Lock();
+	explicit MyMutex(std::mutex* pm):mut(pm) {
+		mut->lock();
 	}
 	~MyMutex() {
-		mut->_Unlock();
+		mut->unlock();
 	}
 private:
-	std::_Mutex* mut;
+	std::mutex* mut;
 };
+#endif // !__ACCESSAUTHFSM_H

+ 0 - 2
Module/mod_accessauth/AccessAuthorization_client_g.h

@@ -2,8 +2,6 @@
 #ifndef __ACCESSAUTHORIZATION_CLIENT_G_H
 #define __ACCESSAUTHORIZATION_CLIENT_G_H
 
-#pragma once
-
 // This code is generated by spgen tool!
 
 #include "AccessAuthorization_def_g.h"

+ 53 - 0
Module/mod_accessauth/CMakeLists.txt

@@ -0,0 +1,53 @@
+define_module("AccessAuth")
+
+#include(conan)
+#conan_cmake_run(REQUIRES boost/1.71.0@LR04.02_ThirdParty/testing
+#BASIC_SETUP CMAKE_TARGETS
+#BUILD missing)
+
+if(WIN32)
+	set(${MODULE_PREFIX}_SRCS
+	AccessAuthConn.cpp
+	AccessAuthFSM.cpp
+	mod_AccessAuth.cpp
+	WMIDeviceQuery.cpp
+	comm.cpp
+	)
+else()
+	set(${MODULE_PREFIX}_SRCS
+	comm.cpp
+	AccessAuthConn.cpp
+	AccessAuthFSM.cpp
+	mod_AccessAuth.cpp
+	)
+endif(WIN32)
+
+message(STATUS "module=${${MODULE_PREFIX}_SRCS}")
+
+set(MOD_VERSION_STRING "1.0.0-dev1")
+add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME} ${MOD_VERSION_STRING})
+
+target_include_directories(${MODULE_NAME} PRIVATE
+	${RVC_FRAMEWORK_INCLUDES_DIR}	
+	${ModuleCommonHeadPath}
+	${DevHeadPath}
+	${MODULE_BASE_DIR}/mod_accessauth
+	${MODULE_BASE_DIR}/mod_tokenmgr
+	${MODULE_BASE_DIR}/mod_pinpad
+	${MODULE_BASE_DIR}/mod_MaintainWatcher
+	${OTHER_LIB_BASE_DIR}/libpublicFun
+)
+
+target_link_directories(${MODULE_NAME} PRIVATE
+	${ThirdPartyLib}
+	#${CONAN_LIB_DIRS_BOOST}
+	#"D:/conan_data/test"
+)
+
+# 添加实体需要依赖的其他共享库(包括系统库)
+set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_ALL_LIBS})#${CONAN_PKG_LIBS_BOOST} RVCCrypt NewRVCCrypt
+target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
+
+
+
+deploy_module(${MODULE_PREFIX} ${MODULE_NAME})

+ 0 - 3
Module/mod_accessauth/Event.h

@@ -1,3 +0,0 @@
-#define EVENT_ACCESSAUTH_SUCCEED		0x50200001		// 准入成功
-#define EVENT_ACCESSAUTH_FAILED			0x50280002		// 准入失败
-#define EVENT_ACCESSAUTH_TIMEOUT		0x50280003		// 准入超时

+ 0 - 62
Module/mod_accessauth/MD5file.cpp

@@ -1,62 +0,0 @@
-#include "stdafx.h"
-#include <stdio.h>  
-#include <stdlib.h>  
-#include <string.h>  
-  
-#include "md5.h"  
-  
-char *MD5_file (char *path, int md5_len)  
-{  
-    FILE *fp = fopen (path, "rb");  
-    MD5_CTX mdContext;  
-    int bytes;  
-    unsigned char data[1024];  
-    char *file_md5;  
-    int i;  
-  
-    if (fp == NULL) 
-	{  
-        fprintf (stderr, "fopen %s failed\n", path);  
-        return NULL;  
-    }  
-  
-    MD5Init (&mdContext);  
-    while ((bytes = fread (data, 1, 1024, fp)) != 0)  
-    {  
-        MD5Update (&mdContext, data, bytes);  
-    }  
-    MD5Final (&mdContext);  
-      
-	file_md5 = new char[(md5_len + 1) * sizeof(char)];  
-    if(file_md5 == NULL)  
-    {  
-        fprintf(stderr, "malloc failed.\n");
-		fclose (fp);
-        return NULL;  
-    }  
-    memset(file_md5, 0, (md5_len + 1));  
-      
-    if(md5_len == 16)  
-    {  
-        for(i=4; i<12; i++)  
-        {  
-            sprintf(&file_md5[(i-4)*2], "%02x", mdContext.digest[i]);  
-        }  
-    }  
-    else if(md5_len == 32)  
-    {  
-        for(i=0; i<16; i++)  
-        {  
-            sprintf(&file_md5[i*2], "%02x", mdContext.digest[i]);  
-        }  
-    }  
-    else  
-    {  
-        fclose(fp);  
-		delete file_md5;
-        return NULL;  
-    }  
-      
-    fclose (fp);  
-    return file_md5;  
-}  

+ 0 - 8
Module/mod_accessauth/MD5file.h

@@ -1,8 +0,0 @@
-#ifndef MD5FILE_H
-#define MD5FILE_H
-
-#include <string>
-
-char *MD5_file (char *path, int md5_len);  
-
-#endif

+ 565 - 0
Module/mod_accessauth/comm.cpp

@@ -0,0 +1,565 @@
+#include "comm.h"
+#include <cstdarg>
+
+void GetNewForm(const char* form, char* newForm) {
+	int indexNum = 0;
+	int acount = 0;
+	newForm[0] = '{';
+	for (int i = 0; i < strlen(form); i++)
+	{
+		//if((i-1 >= 0 && form[i]=='\\') || (i-1 < 0))
+		if (form[i] == '%') {
+
+			if (acount != 0)
+			{
+				newForm[++indexNum] = '"';
+				if (acount % 2 != 0) {
+					newForm[++indexNum] = ':';
+				}
+				else {
+					newForm[++indexNum] = ',';
+				}
+			}
+			newForm[++indexNum] = '"';
+			acount++;
+		}
+		if (form[i] == ' ') continue;
+		newForm[++indexNum] = form[i];
+	}
+	newForm[++indexNum] = '"';
+	newForm[++indexNum] = '}';
+
+}
+
+string GetOutPutStr(const char* form, ...) {
+	char* newForm = new char[strlen(form) * 3 + 5];
+	memset(newForm, 0, strlen(form) * 3 + 5);
+	if (strlen(form) < 2) {
+		strcpy(newForm, "{\"\"}");
+	}
+	else {
+		GetNewForm(form, newForm);
+	}
+	va_list vaList;
+	va_start(vaList, form);
+#ifdef RVC_OS_WIN
+	int acount = _vscprintf(newForm, vaList);
+#else
+	//注意这个地方不一定对
+	int acount = vsnprintf(0,0,newForm, vaList);
+#endif
+	char* buf = new char[acount + 1];
+	memset(buf, 0, acount + 1);
+	vsprintf(buf, newForm, vaList);
+	va_end(vaList);
+
+	string ret;
+	ret.assign(buf);
+	delete buf;
+	delete newForm;
+	return ret;
+}
+
+int no_begin_with(const char strA[], const char strB[]) {
+	if (strA == NULL) return 1;
+	if (strB == NULL) return 1;
+	if (strlen(strA) == 0 || strlen(strB) == 0 || strlen(strA) < strlen(strB)) return 1;
+	const char* pA = strA;
+	const char* pB = strB;
+	while (*pA != '\0' && *pB != '\0') {
+		if (*pA != *pB) return 1;
+		pA++;
+		pB++;
+	}
+	return 0;
+}
+
+int str2int(const string str, int& ret) {
+	if (str.size() == 0) return 1;
+	ret = 0;
+	int symbol = 0;
+	for (int i = 0; i < str.size(); i++) {
+		if (i == 0 && str[i] == '-') {
+			symbol = 1;
+			continue;
+		}
+		if (i == 0 && str[i] == '+') continue;
+		if (i == 0) {
+			while (str[i] == '0' && i < str.size()) {
+				++i;
+			}
+			if (i == str.size()) return 0;
+		}
+		if (str[i] < '0' || str[i] >'9') return 2;
+
+		ret += (str[i] - '0') * pow(10, str.size() - i - 1);
+	}
+	if (symbol) ret -= 2 * ret;
+	return 0;
+}
+
+int str2int(const string str) {
+	int ret;
+	str2int(str, ret);
+	return ret;
+}
+
+vector<string> split_str(string strA, string strB) {
+	vector<string> ret;
+	//cout << "ret:" << ret.size() << endl;
+	if (strA.size() == 0 || strB.size() == 0) {
+		return ret;
+	}
+	char* chA = new char[strA.size()];
+	char* chB = new char[strB.size()];
+	memset(chA, 0, sizeof(chA));
+	memset(chB, 0, sizeof(chB));
+	strcpy(chA, strA.c_str());
+	strcpy(chB, strB.c_str());
+	char* tmp = strtok(chA, chB);
+	while (tmp) {
+		//cout << "tmp:" << tmp << endl;
+		ret.push_back(tmp);
+		tmp = strtok(NULL, chB);
+
+	}
+	delete[] chA;
+	delete[] chB;
+	return ret;
+}
+
+int ip2byte(const string str, BYTE ip[]) {
+	vector<string> ret = split_str(str, ".");
+	vector<string>::iterator it = ret.begin();
+	int index = 0;
+	while (it != ret.end()) {
+		int tmp = 0;
+		if (str2int(*it, tmp)) return 1;
+		else {
+			if (tmp > 255) return 2;
+			else {
+				ip[index] = tmp;
+				index++;
+			}
+		}
+		it++;
+	}
+	return 0;
+}
+
+unsigned char Ch2Hex(char ch)
+{
+	static const char* hex = "0123456789ABCDEF";
+	for (unsigned char i = 0; i != 16; ++i)
+		if (ch == hex[i])
+			return i;
+	return 0;
+}
+
+char* Hex2Str(const char* src, int& dstLen)
+{
+	int i = 0;
+	int cnt = 0;
+	int len = strlen(src);
+	unsigned char* d = new unsigned char[len];
+	memset(d, 0, len);
+	while (*src)
+	{
+		if (i & 1)
+		{
+			d[cnt++] |= Ch2Hex(*src);
+		}
+		else
+		{
+			d[cnt] = Ch2Hex(*src) << 4;
+		}
+		src++;
+		i++;
+	}
+	dstLen = cnt;
+	return (char*)d;
+}
+
+char* Str2Hex(const char* src, int srcLen)
+{
+	string ret;
+	static const char* hex = "0123456789ABCDEF";
+
+	for (int i = 0; i != srcLen; ++i)
+	{
+		ret.push_back(hex[(src[i] >> 4) & 0xf]);
+		ret.push_back(hex[src[i] & 0xf]);
+	}
+	char* tmp = new char[ret.length() + 1];
+	memset(tmp, 0, ret.length() + 1);
+	memcpy(tmp, ret.c_str(), ret.length());
+	return tmp;
+}
+
+#ifdef RVC_OS_LINUX
+	
+	int getIPFromLinux(char* ip) {
+		if (strlen(ip) < 15) return 1;
+		struct ifaddrs* ifAddrStruct = NULL;
+		void* tmpAddrPtr = NULL;
+		getifaddrs(&ifAddrStruct);
+
+		while (ifAddrStruct != NULL) {
+			if (ifAddrStruct->ifa_addr->sa_family == AF_INET) { // check it is IP4
+				// is a valid IP4 Address
+				tmpAddrPtr = &((struct sockaddr_in*)ifAddrStruct->ifa_addr)->sin_addr;
+				char addressBuffer[INET_ADDRSTRLEN];
+				inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
+				//printf("%s IP Address %s\n", ifAddrStruct->ifa_name, addressBuffer);
+				if (!no_begin_with(addressBuffer, "99") || !no_begin_with(addressBuffer, "10")) {
+					memset(ip, 0, sizeof(ip));
+					strcpy(ip, addressBuffer);
+				}
+				else if (strlen(ip) == 0 && no_begin_with(addressBuffer, "127.0")) {
+					memset(ip, 0, sizeof(ip));
+					strcpy(ip, addressBuffer);
+				}
+
+			}
+			/*
+			else if (ifAddrStruct->ifa_addr->sa_family==AF_INET6) { // check it is IP6
+				// is a valid IP6 Address
+				tmpAddrPtr=&((struct sockaddr_in *)ifAddrStruct->ifa_addr)->sin_addr;
+				char addressBuffer[INET6_ADDRSTRLEN];
+				inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
+				printf("%s IP Address %s\n", ifAddrStruct->ifa_name, addressBuffer);
+			}
+			*/
+			ifAddrStruct = ifAddrStruct->ifa_next;
+		}
+		//printf("ip=%s\n", ip);
+		return 0;
+	}
+
+	bool get_cpu_id_by_asm(std::string& cpu_id)
+	{
+		cpu_id.clear();
+
+		unsigned int s1 = 0;
+		unsigned int s2 = 0;
+		asm volatile
+			(
+				"movl $0x01, %%eax; \n\t"
+				"xorl %%edx, %%edx; \n\t"
+				"cpuid; \n\t"
+				"movl %%edx, %0; \n\t"
+				"movl %%eax, %1; \n\t"
+				: "=m"(s1), "=m"(s2)
+				);
+
+		if (0 == s1 && 0 == s2)
+		{
+			return(false);
+		}
+
+		char cpu[32] = { 0 };
+		snprintf(cpu, sizeof(cpu), "%08X%08X", htonl(s2), htonl(s1));
+		std::string(cpu).swap(cpu_id);
+
+		return(true);
+	}
+
+	void parse_board_serial(const char* file_name, const char* match_words, std::string& board_serial)
+	{
+		board_serial.c_str();
+
+		std::ifstream ifs(file_name, std::ios::binary);
+		if (!ifs.is_open())
+		{
+			return;
+		}
+
+		char line[4096] = { 0 };
+		while (!ifs.eof())
+		{
+			ifs.getline(line, sizeof(line));
+			if (!ifs.good())
+			{
+				break;
+			}
+
+			const char* board = strstr(line, match_words);
+			if (NULL == board)
+			{
+				continue;
+			}
+			board += strlen(match_words);
+
+			while ('\0' != board[0])
+			{
+				if (' ' != board[0])
+				{
+					board_serial.push_back(board[0]);
+				}
+				++board;
+			}
+
+			if ("None" == board_serial)
+			{
+				board_serial.clear();
+				continue;
+			}
+
+			if (!board_serial.empty())
+			{
+				break;
+			}
+		}
+
+		ifs.close();
+	}
+
+	bool get_board_serial_by_system(std::string& board_serial)
+	{
+		board_serial.c_str();
+
+		const char* dmidecode_result = ".dmidecode_result.txt";
+		char command[512] = { 0 };
+		snprintf(command, sizeof(command), "dmidecode -t 2 | grep Serial > %s", dmidecode_result);
+
+		if (0 == system(command))
+		{
+			parse_board_serial(dmidecode_result, "Serial Number:", board_serial);
+		}
+		else {
+			return false;
+		}
+		unlink(dmidecode_result);
+
+		return true;
+	}
+
+	bool parse_disk_serial(const char* line, int line_size, const char* match_words, std::string& serial_no)
+	{
+		const char* serial_s = strstr(line, match_words);
+		if (NULL == serial_s)
+		{
+			return(false);
+		}
+		serial_s += strlen(match_words);
+		while (isspace(serial_s[0]))
+		{
+			++serial_s;
+		}
+
+		const char* serial_e = line + line_size;
+		const char* comma = strchr(serial_s, ',');
+		if (NULL != comma)
+		{
+			serial_e = comma;
+		}
+
+		while (serial_e > serial_s && isspace(serial_e[-1]))
+		{
+			--serial_e;
+		}
+
+		if (serial_e <= serial_s)
+		{
+			return(false);
+		}
+
+		std::string(serial_s, serial_e).swap(serial_no);
+
+		return(true);
+	}
+
+	void get_disk_serial(const char* file_name, const char* match_words, std::vector<string>& serial_no)
+	{
+		std::ifstream ifs(file_name, std::ios::binary);
+		if (!ifs.is_open())
+		{
+			return;
+		}
+
+		char line[4096] = { 0 };
+		while (!ifs.eof())
+		{
+			ifs.getline(line, sizeof(line));
+			if (!ifs.good())
+			{
+				break;
+			}
+
+			if (0 == ifs.gcount())
+			{
+				continue;
+			}
+			string disk_serial;
+			if (parse_disk_serial(line, ifs.gcount() - 1, match_words, disk_serial))
+			{
+				//break;
+				serial_no.push_back(disk_serial);
+			}
+		}
+
+		ifs.close();
+	}
+
+	bool get_disk_serial_by_system(std::vector<string>& serial_no)
+	{
+		const char* lshw_result = ".lshw_result.txt";
+		char command[512] = { 0 };
+		snprintf(command, sizeof(command), "lshw -class disk | grep serial > %s", lshw_result);
+
+		if (0 == system(command))
+		{
+			get_disk_serial(lshw_result, "serial:", serial_no);
+		}
+		else {
+			return false;
+		}
+		unlink(lshw_result);
+
+		return(true);
+	}
+
+#include <unistd.h>
+	bool file_is_exist(string filePath) {
+		return (access(filePath.c_str(), F_OK) == 0);
+	}
+
+	bool dir_is_exist(string dirPath) {
+		return (access(dirPath.c_str(), F_OK) == 0);
+	}
+	//创建成功返回0,创建失败返回1,已经存在返回2
+	int file_create(string filePath) {
+		if (!file_is_exist(filePath)) {
+			FILE* fp;
+			if (fp = fopen(filePath.c_str(), "w")) {
+				fclose(fp);
+				return 0;
+			}
+			else {
+				return 1;
+			}
+		}
+		return 2;
+	}
+
+#include <sys/stat.h>
+	//创建成功返回0
+	int dir_create(string dirPath) {
+		if (!dir_is_exist(dirPath)) {
+			return mkdir(dirPath.c_str(), S_IRWXU);
+		}
+		return 0;
+	}
+
+	//删除成功返回0
+	int remove_file(string filePath) {
+		return remove(filePath.c_str());
+	}
+
+#include <dirent.h>
+	int remove_dir(string dirPath) {
+		DIR* dir;
+		struct dirent* ptr;
+		dir = opendir(dirPath.c_str());
+		if (dir == NULL) return 1;
+		while ((ptr = readdir(dir)) != NULL) {
+			if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) continue;
+			char path[1024] = { 0 };
+			strcpy(path, dirPath.c_str());
+			strcat(path, "/");
+			strcat(path, ptr->d_name);
+			if (ptr->d_type == DT_DIR) {
+				remove_dir(path);
+			}
+			else {
+				if (remove_file(path) != 0) return 1;
+			}
+		}
+		closedir(dir);
+		return rmdir(dirPath.c_str());
+	}
+
+	bool set_system_time(TIME* _time)
+	{
+		struct tm p;
+		p.tm_year = _time->year - 1900;
+		p.tm_mon = _time->month - 1;
+		p.tm_mday = _time->day;
+		p.tm_hour = _time->hour;
+		p.tm_min = _time->minute;
+		p.tm_sec = _time->second;
+		//cout << p.tm_year << " " << p.tm_mon << " " << p.tm_mday << " " << p.tm_hour << " " << p.tm_min << " " << p.tm_sec << endl;
+
+		time_t sec = mktime(&p);
+		//cout << sec << endl;
+
+		struct timeval tv;
+		tv.tv_sec = sec;
+		//cout << tv.tv_sec << endl;
+
+		if (settimeofday(&tv, NULL) < 0)
+		{
+			return false;
+		}
+		return true;
+	}
+
+	bool set_system_time_by_sec(int sec)
+	{
+
+		struct timeval tv;
+
+		gettimeofday(&tv, NULL);
+
+		tv.tv_sec += sec;
+		//cout << tv.tv_sec << endl;
+
+		if (settimeofday(&tv, NULL) < 0)
+		{
+			return false;
+		}
+		return true;
+	}
+
+	TIME* get_system_time()
+	{
+		TIME* t = new TIME();
+
+		time_t timep;
+		time(&timep);
+
+		struct tm* p;
+		p = localtime(&timep);
+
+		t->year = 1900 + p->tm_year;
+		t->month = 1 + p->tm_mon;
+		t->day = p->tm_mday;
+		t->hour = p->tm_hour;
+		t->minute = p->tm_min;
+		t->second = p->tm_sec;
+
+		return t;
+	}
+
+	string time2str(const TIME* tim) {
+		if (tim == NULL) return "";
+		string ret;
+		char timeStr[16] = { 0 };
+		sprintf(timeStr, "%04d%02d%02d%02d%02d%02d", tim->year,
+			tim->month, tim->day, tim->hour, tim->minute, tim->second);
+		ret = timeStr;
+		return ret;
+	}
+
+	TIME* str2time(string str) {
+		if (str.length() < 14) return NULL;
+		TIME* ret = new TIME();
+		ret->year = str2int(str.substr(0, 4));
+		ret->month = str2int(str.substr(4, 2));
+		ret->day = str2int(str.substr(6, 2));
+		ret->hour = str2int(str.substr(8, 2));
+		ret->minute = str2int(str.substr(10, 2));
+		ret->second = str2int(str.substr(12, 2));
+		return ret;
+	}
+#endif // __RVC_OS_LINUX

+ 81 - 0
Module/mod_accessauth/comm.h

@@ -0,0 +1,81 @@
+#ifndef __COMM_H
+#define __COMM_H
+
+#include <string>
+#include <sstream>
+#include <cstdio>
+#include <vector>
+#include <cstring>
+#include <cmath>
+#include<iostream>
+#include <fstream>
+
+using namespace std;
+
+#define EVENT_ACCESSAUTH_SUCCEED		0x50200001		// 准入成功
+#define EVENT_ACCESSAUTH_FAILED			0x50280002		// 准入失败
+#define EVENT_ACCESSAUTH_TIMEOUT		0x50280003		// 准入超时
+
+#define EVENT_MOD_INITIALIZER_MK_LOADED			0x50900001			// 主密钥初始化成功
+#define EVENT_MOD_INITIALIZER_MK_FAILED			0x50980002			// 主密钥初始化失败
+
+#define PUKFILENAME_RSA "RVCPubKey.ini"
+#define PUKFILENAME_SM2 "RVCSM2PubKey.ini"
+
+#define PFKEYFILENAME_DES	"CMBRVCKeys.dat"
+#define PFKEYFILENAME_SM4	"CMBRVCSm4Keys.dat"
+
+typedef unsigned char BYTE;
+
+void GetNewForm(const char* form, char* newForm);
+
+string GetOutPutStr(const char* form, ...);
+
+int no_begin_with(const char strA[], const char strB[]);
+
+int str2int(const string str, int& ret);
+
+int str2int(const string str);
+
+vector<string> split_str(string strA, string strB);
+
+int ip2byte(const string str, BYTE ip[]);
+
+char* Hex2Str(const char* src, int& dstLen);
+
+char* Str2Hex(const char* str, int strLen);
+
+#ifdef RVC_OS_LINUX
+#include <sys/types.h>
+#include <ifaddrs.h>
+#include <netinet/in.h> 
+#include <arpa/inet.h>
+#include <unistd.h>
+	int getIPFromLinux(char* ip);
+	bool get_cpu_id_by_asm(std::string& cpu_id);
+	bool get_board_serial_by_system(std::string& board_serial);
+	bool get_disk_serial_by_system(std::vector<string>& serial_no);
+	bool file_is_exist(string filePath);
+	bool dir_is_exist(string dirPath);
+	int file_create(string filePath);
+	int dir_create(string dirPath);
+	int remove_file(string filePath);
+	int remove_dir(string dirPath);
+#include<sys/time.h>
+#include <time.h>
+	typedef struct {
+		int year;
+		int month;
+		int day;
+		int hour;
+		int minute;
+		int second;
+	} TIME;
+	bool set_system_time(TIME* _time);
+	bool set_system_time_by_sec(int sec);
+	TIME* get_system_time();
+	string time2str(const TIME* tim);
+	TIME* str2time(string str);
+#endif //RVC_OS_LINUX
+
+#endif // !__COMM_H

+ 0 - 273
Module/mod_accessauth/md5.cpp

@@ -1,273 +0,0 @@
-#include "stdafx.h"
-#include "md5.h"
-
-/*
- **********************************************************************
- ** md5.c                                                            **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm             **
- ** Created: 2/17/90 RLR                                             **
- ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version                  **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- **                                                                  **
- ** License to copy and use this software is granted provided that   **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function.                                       **
- **                                                                  **
- ** License is also granted to make and use derivative works         **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
- ** material mentioning or referencing the derived work.             **
- **                                                                  **
- ** RSA Data Security, Inc. makes no representations concerning      **
- ** either the merchantability of this software or the suitability   **
- ** of this software for any particular purpose.  It is provided "as **
- ** is" without express or implied warranty of any kind.             **
- **                                                                  **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software.                                   **
- **********************************************************************
- */
-
-/* -- include the following line if the md5.h header file is separate -- */
-/* #include "md5.h" */
-
-/* forward declaration */
-static void Transform (UINT4 *buf, UINT4 *in);
-
-static unsigned char PADDING[64] = {
-  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-/* F, G and H are basic MD5 functions: selection, majority, parity */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z))) 
-
-/* ROTATE_LEFT rotates x left n bits */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s, ac) \
-  {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define GG(a, b, c, d, x, s, ac) \
-  {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define HH(a, b, c, d, x, s, ac) \
-  {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define II(a, b, c, d, x, s, ac) \
-  {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-
-void MD5Init (MD5_CTX *mdContext)
-{
-  mdContext->i[0] = mdContext->i[1] = (UINT4)0;
-
-  /* Load magic initialization constants.
-   */
-  mdContext->buf[0] = (UINT4)0x67452301;
-  mdContext->buf[1] = (UINT4)0xefcdab89;
-  mdContext->buf[2] = (UINT4)0x98badcfe;
-  mdContext->buf[3] = (UINT4)0x10325476;
-}
-
-void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
-{
-  UINT4 in[16];
-  int mdi;
-  unsigned int i, ii;
-
-  /* compute number of bytes mod 64 */
-  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
-  /* update number of bits */
-  if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
-    mdContext->i[1]++;
-  mdContext->i[0] += ((UINT4)inLen << 3);
-  mdContext->i[1] += ((UINT4)inLen >> 29);
-
-  while (inLen--) {
-    /* add new character to buffer, increment mdi */
-    mdContext->in[mdi++] = *inBuf++;
-
-    /* transform if necessary */
-    if (mdi == 0x40) {
-      for (i = 0, ii = 0; i < 16; i++, ii += 4)
-        in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
-                (((UINT4)mdContext->in[ii+2]) << 16) |
-                (((UINT4)mdContext->in[ii+1]) << 8) |
-                ((UINT4)mdContext->in[ii]);
-      Transform (mdContext->buf, in);
-      mdi = 0;
-    }
-  }
-}
-
-void MD5Final (MD5_CTX *mdContext)
-
-{
-  UINT4 in[16];
-  int mdi;
-  unsigned int i, ii;
-  unsigned int padLen;
-
-  /* save number of bits */
-  in[14] = mdContext->i[0];
-  in[15] = mdContext->i[1];
-
-  /* compute number of bytes mod 64 */
-  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
-  /* pad out to 56 mod 64 */
-  padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
-  MD5Update (mdContext, PADDING, padLen);
-
-  /* append length in bits and transform */
-  for (i = 0, ii = 0; i < 14; i++, ii += 4)
-    in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
-            (((UINT4)mdContext->in[ii+2]) << 16) |
-            (((UINT4)mdContext->in[ii+1]) << 8) |
-            ((UINT4)mdContext->in[ii]);
-  Transform (mdContext->buf, in);
-
-  /* store buffer in digest */
-  for (i = 0, ii = 0; i < 4; i++, ii += 4) {
-    mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
-    mdContext->digest[ii+1] =
-      (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
-    mdContext->digest[ii+2] =
-      (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
-    mdContext->digest[ii+3] =
-      (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
-  }
-}
-
-/* Basic MD5 step. Transform buf based on in.
- */
-static void Transform (UINT4 *buf, UINT4 *in)
-{
-  UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
-
-  /* Round 1 */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-  FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */
-  FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */
-  FF ( c, d, a, b, in[ 2], S13,  606105819); /* 3 */
-  FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */
-  FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */
-  FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */
-  FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */
-  FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */
-  FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */
-  FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */
-  FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */
-  FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */
-  FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */
-  FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */
-  FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */
-  FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */
-
-  /* Round 2 */
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-  GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */
-  GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */
-  GG ( c, d, a, b, in[11], S23,  643717713); /* 19 */
-  GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */
-  GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */
-  GG ( d, a, b, c, in[10], S22,   38016083); /* 22 */
-  GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */
-  GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */
-  GG ( a, b, c, d, in[ 9], S21,  568446438); /* 25 */
-  GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */
-  GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */
-  GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */
-  GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */
-  GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */
-  GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */
-  GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */
-
-  /* Round 3 */
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-  HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */
-  HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */
-  HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */
-  HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */
-  HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */
-  HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */
-  HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */
-  HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */
-  HH ( a, b, c, d, in[13], S31,  681279174); /* 41 */
-  HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */
-  HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */
-  HH ( b, c, d, a, in[ 6], S34,   76029189); /* 44 */
-  HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */
-  HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */
-  HH ( c, d, a, b, in[15], S33,  530742520); /* 47 */
-  HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */
-
-  /* Round 4 */
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-  II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */
-  II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */
-  II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */
-  II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */
-  II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */
-  II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */
-  II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */
-  II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */
-  II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */
-  II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */
-  II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */
-  II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */
-  II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */
-  II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */
-  II ( c, d, a, b, in[ 2], S43,  718787259); /* 63 */
-  II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */
-
-  buf[0] += a;
-  buf[1] += b;
-  buf[2] += c;
-  buf[3] += d;
-}
-
-/*
- **********************************************************************
- ** End of md5.c                                                     **
- ******************************* (cut) ********************************
- */

+ 0 - 59
Module/mod_accessauth/md5.h

@@ -1,59 +0,0 @@
-/*
- **********************************************************************
- ** md5.h -- Header file for implementation of MD5                   **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm             **
- ** Created: 2/17/90 RLR                                             **
- ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version              **
- ** Revised (for MD5): RLR 4/27/91                                   **
- **   -- G modified to have y&~z instead of y&z                      **
- **   -- FF, GG, HH modified to add in last register done            **
- **   -- Access pattern: round 2 works mod 5, round 3 works mod 3    **
- **   -- distinct additive constant for each step                    **
- **   -- round 4 added, working mod 7                                **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- **                                                                  **
- ** License to copy and use this software is granted provided that   **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function.                                       **
- **                                                                  **
- ** License is also granted to make and use derivative works         **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
- ** material mentioning or referencing the derived work.             **
- **                                                                  **
- ** RSA Data Security, Inc. makes no representations concerning      **
- ** either the merchantability of this software or the suitability   **
- ** of this software for any particular purpose.  It is provided "as **
- ** is" without express or implied warranty of any kind.             **
- **                                                                  **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software.                                   **
- **********************************************************************
- */
-
-/* typedef a 32 bit type */
-typedef unsigned long int UINT4;
-
-/* Data structure for MD5 (Message Digest) computation */
-typedef struct {
-  UINT4 i[2];                   /* number of _bits_ handled mod 2^64 */
-  UINT4 buf[4];                                    /* scratch buffer */
-  unsigned char in[64];                              /* input buffer */
-  unsigned char digest[16];     /* actual digest after MD5Final call */
-} MD5_CTX;
-
-void MD5Init (MD5_CTX *mdContext);
-void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
-void MD5Final (MD5_CTX *mdContext);
-
-/*
- **********************************************************************
- ** End of md5.h                                                     **
- ******************************* (cut) ********************************
- */

Plik diff jest za duży
+ 346 - 266
Module/mod_accessauth/mod_AccessAuth.cpp


+ 22 - 17
Module/mod_accessauth/mod_AccessAuth.h

@@ -1,14 +1,11 @@
-#pragma once
+#ifndef __MOD_ACCESSAUTH_H
+#define __MOD_ACCESSAUTH_H
 #include "SpBase.h"
-#include "RVCCrypt.h"
 #include "AccessAuthorization_server_g.h"
 using namespace AccessAuthorization;
 
-#include "..\EventCode.h"
+#include "EventCode.h"
 #include "AccessAuthFSM.h"
-//
-//#include <string>
-//using namespace std;
 
 // 准入服务 0x502
 class CAccessAuthEntity;
@@ -34,7 +31,7 @@ private:
 class CAccessAuthEntity : public CEntityBase, public ISysVarListener
 {
 public:
-	CAccessAuthEntity() :m_nAuthVersion(1) {}
+	CAccessAuthEntity() :m_nAuthVersion(1), m_bGetKMCKey(false){}
 	virtual ~CAccessAuthEntity() 
 	{
 		/*if (NULL != m_pkeys)
@@ -68,13 +65,13 @@ public:
 	ErrorCodeEnum Unregist(int nReason, int nWay);
 
 	// 时间同步
-	ErrorCodeEnum SyncTime();
+	DWORD SyncTime();
 
 	// 状态上报
 	ErrorCodeEnum PushTerminalStage(char cNewStage, DWORD dwNewStageTime, char cOldStage, DWORD dwOldStageTime);
 
 	// KMC初始化
-	ErrorCodeEnum InitKMC();
+	DWORD InitKMC();
 		
 	// 获取WK更新请求包
 	// @nAlgFlag:  1:3des only; 2: sm4 only; 3: both 3des and sm4
@@ -82,7 +79,7 @@ public:
 
 	// 解析WK
 	// @nAlgFlag:  1:3des only; 2: sm4 only; 3: both 3des and sm4
-	ErrorCodeEnum ParseWKUpdateResult(char *pBuf, int nLen, int  nAlgFlag);
+	DWORD ParseWKUpdateResult(char *pBuf, int nLen, int  nAlgFlag);
 
 	// 获取KMC错误
 	CSimpleStringA GetKMCLastErrMsg();
@@ -93,19 +90,19 @@ public:
 	//ErrorCodeEnum PrintAllKeys(bool bSM);
 
 	// 加载新WK
-	ErrorCodeEnum LoadPinPadWK(bool bSM);
+	DWORD LoadPinPadWK(bool bSM);
 	
 	bool HexStrToByteArray(const char* pHex, BYTE *pBuf, int *pBufLen);
 	string ByteArrayToHexStr(BYTE *pBuf, int nBufLen);
 
 	// 调用PinPad加密(只支持DES加密,不支持SM)
-	ErrorCodeEnum EncryptDataWithPinPad(const CBlob &raw, CBlob &enc);
+	DWORD EncryptDataWithPinPad(const CBlob &raw, CBlob &enc);
 
-	// 生成RSA密钥对
-	ErrorCodeEnum CreateRsaKeyPair(CBlob &pubKey, CBlob &priKey);
+	// 生成SM2密钥对
+	DWORD CreateSM2KeyPair(CBlob &pubKey, CBlob &priKey);
 
 	// 保存密钥对到令牌实体
-	ErrorCodeEnum SaveRsaKeyPair(const CBlob &pubKey, const CBlob &priKey);
+	DWORD SaveSM2KeyPair(const CBlob &pubKey, const CBlob &priKey);
 
 	// 保存Token和共享会话密钥到令牌实体
 	ErrorCodeEnum SaveTokenAndSharedSK(const CBlob &token, const CBlob &sharedSK);
@@ -127,7 +124,7 @@ public:
 	bool GetTerminalPublicKey(BYTE *pBuf, int &nBufLen);
 	bool GetMD5Hash(const char *pStr, BYTE md5[16]);
 	
-	ErrorCodeEnum InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
+	DWORD InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
 
 	void SetAuthErrMsg(const char *pszErrMsg) { m_strAuthErrMsg = pszErrMsg; }
 	const char *GetAuthErrMsg() { return m_strAuthErrMsg; }
@@ -143,7 +140,14 @@ public:
 	wstring ANSIToUnicode(const string& str);
 	BOOL SetLocalTimeZoneByKeyName(const TCHAR* szTimeZoneKeyName, BOOL isDaylightSavingTime);
 
+	int ConvertStr2Byte(string input, BYTE* output, int outputLen);
+	void printPasswdError();
+	int GetOrSetIsFirstSM(int type);
 
+	string m_TMK;
+	string m_TPK;
+	string m_EDK;
+	bool m_bGetKMCKey;
 protected:
 	CAccessAuthFSM m_FSM;
 
@@ -151,5 +155,6 @@ protected:
 	BYTE m_AuthSessionKey[140];
 
 	CSimpleStringA m_strAuthErrMsg;
-	EncKeys* m_pkeys;
+	//EncKeys* m_pkeys;
 };
+#endif //__MOD_ACCESSAUTH_H

+ 0 - 114
Module/mod_accessauth/mod_accessauth.vcxproj

@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{84E4854D-9D80-4F8E-A5BD-084D2B3433F3}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>mod_accessauth</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>MultiByte</CharacterSet>
-    <PlatformToolset>Windows7.1SDK</PlatformToolset>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <Import Project="..\modmake.setting" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;$(FrameworkHeadRoot)\libtoolkit;$(DevHeadPath);$(ThirdPartyHeadRoot)\KMC</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>ws2_32.lib;$(ThirdPartyLib)\RVCCrypt.lib;$(ThirdPartyLib)\NewRVCCrypt.lib;$(FrameworkLib)\libtoolkit.lib;$(FrameworkLib)\RVCComm.lib;$(FrameworkLib)\SpBase.lib;Advapi32.lib</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;$(FrameworkHeadRoot)\libtoolkit;$(DevHeadPath);$(ThirdPartyHeadRoot)\KMC</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>ws2_32.lib;$(ThirdPartyLib)\RVCCrypt.lib;$(FrameworkLib)\libtoolkit.lib;$(FrameworkLib)\RVCComm.lib;$(FrameworkLib)\SpBase.lib;Advapi32.lib</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="$(FrameworkHeadRoot)\Common\stdafx.cpp" />
-    <ClCompile Include="AccessAuthConn.cpp" />
-    <ClCompile Include="AccessAuthFSM.cpp" />
-    <ClCompile Include="md5.cpp" />
-    <ClCompile Include="MD5file.cpp" />
-    <ClCompile Include="mod_AccessAuth.cpp" />
-    <ClCompile Include="WMIDeviceQuery.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="$(FrameworkHeadRoot)\Common\stdafx.h" />
-    <ClInclude Include="AccessAuthFSM.h" />
-    <ClInclude Include="AccessAuthorization_client_g.h" />
-    <ClInclude Include="AccessAuthorization_def_g.h" />
-    <ClInclude Include="AccessAuthorization_server_g.h" />
-    <ClInclude Include="AccessAuthConn.h" />
-    <ClInclude Include="AccessAuthErrorCode.h" />
-    <ClInclude Include="Event.h" />
-    <ClInclude Include="md5.h" />
-    <ClInclude Include="MD5file.h" />
-    <ClInclude Include="mod_AccessAuth.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="AccessAuthorization.xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>

+ 0 - 83
Module/mod_accessauth/mod_accessauth.vcxproj.filters

@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="AccessAuthFSM.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="mod_AccessAuth.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="AccessAuthConn.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="$(FrameworkHeadRoot)\Common\stdafx.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="md5.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="MD5file.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="WMIDeviceQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="AccessAuthFSM.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="AccessAuthorization_client_g.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="AccessAuthorization_def_g.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="AccessAuthorization_server_g.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="AccessAuthConn.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="mod_AccessAuth.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Event.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="$(FrameworkHeadRoot)\Common\stdafx.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="md5.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="MD5file.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="AccessAuthErrorCode.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="AccessAuthorization.xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc">
-      <Filter>Resource Files</Filter>
-    </ResourceCompile>
-  </ItemGroup>
-</Project>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików