|
@@ -9,6 +9,7 @@
|
|
|
#include "Event.h"
|
|
|
#include "comm.h"
|
|
|
#include "CommEntityRestful.hpp"
|
|
|
+#include "CommEntityUtil.hpp"
|
|
|
#include "TokenKeeper_client_g.h"
|
|
|
using namespace TokenKeeper;
|
|
|
#include "PinPad_client_g.h"
|
|
@@ -24,10 +25,6 @@ using namespace PinPad;
|
|
|
#include "DeviceBaseClass.h"
|
|
|
#endif
|
|
|
|
|
|
-//TODO: CrossPlaform [Gifur@2025730]
|
|
|
-extern int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len);
|
|
|
-extern int StrBuf2HexBuf(LPCTSTR strBuf, PBYTE* hexBuf);
|
|
|
-
|
|
|
struct InitializerInitMKTask : ITaskSp
|
|
|
{
|
|
|
CAccessAuthFSM* m_fsm;
|
|
@@ -1216,14 +1213,13 @@ pair<string, string> CAccessAuthEntity::GenerateTmkToKMC()
|
|
|
|
|
|
pair<string, string> CAccessAuthEntity::EncryptedByPubKey(CSimpleStringA pubKey, bool bNeed04Head)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
+ //TODO: New了那么多对象,什么时候Delete?? [Gifur@202585]
|
|
|
if (pubKey.GetLength() <= 0)
|
|
|
return make_pair("", "");
|
|
|
PCHAR strRam = new CHAR[512];
|
|
|
memset(strRam, 0, 512);
|
|
|
memcpy(strRam, &(m_btRam[0]), 16);
|
|
|
- HexBuf2StrBuf((PBYTE)m_btRam, &strRam, 16);
|
|
|
+ SP::Module::Util::HexBuf2StrBuf((PBYTE)m_btRam, &strRam, 16);
|
|
|
const int MAX_KEY_SIZE = 256;
|
|
|
char random_enc_bypbk[MAX_KEY_SIZE];
|
|
|
memset(random_enc_bypbk, 0, MAX_KEY_SIZE);
|
|
@@ -1234,14 +1230,15 @@ pair<string, string> CAccessAuthEntity::EncryptedByPubKey(CSimpleStringA pubKey,
|
|
|
memset(pOldPubKey, 0, 256);
|
|
|
memset(pxxKey, 0, 256);
|
|
|
|
|
|
- int size = StrBuf2HexBuf(pubKey.GetData(), &pOldPubKey);
|
|
|
+ int size = SP::Module::Util::StrBuf2HexBuf(pubKey.GetData(), &pOldPubKey);
|
|
|
if (bNeed04Head)
|
|
|
{
|
|
|
pxxKey[0] = 0x04;
|
|
|
memcpy(pxxKey + 1, pOldPubKey, size);
|
|
|
}
|
|
|
- else
|
|
|
+ else {
|
|
|
memcpy(pxxKey, pOldPubKey, 65);
|
|
|
+ }
|
|
|
int retSM2 = EncWithSM2PubKey((unsigned char*)m_btRam, 16, (unsigned char*)random_enc_bypbk, &outMsgLen, (unsigned char*)pxxKey, 65);
|
|
|
if (!retSM2 || outMsgLen != 113)
|
|
|
{
|
|
@@ -1269,7 +1266,7 @@ pair<string, string> CAccessAuthEntity::EncryptedByPubKey(CSimpleStringA pubKey,
|
|
|
BYTE tmpRandomEnc[512];
|
|
|
memset(tmpRandomEnc, 0, 512);
|
|
|
memcpy(tmpRandomEnc, &(tmp_enc_bypbk[0]), outMsgLen - 1);
|
|
|
- size = HexBuf2StrBuf((PBYTE)tmpRandomEnc, &pBlock, 112);
|
|
|
+ size = SP::Module::Util::HexBuf2StrBuf((PBYTE)tmpRandomEnc, &pBlock, 112);
|
|
|
return make_pair(pBlock, strRam);
|
|
|
}
|
|
|
|