Commit c7c7b99d by kevin

remove no need file, correct command shit

1 parent c994deb0
#ifndef __FUCBASE_H__
#define __FUCBASE_H__
#define UKEY_RIGHT 0
#define UKEY_WRONG -1
CString DelStr(CString strIn);
int Hex2Byte(CString strIn, BYTE *datOut);
#endif
\ No newline at end of file
......@@ -4,7 +4,6 @@
#include <iostream>
#include <WinBase.h>
#include "FucBase.h"
/*
void LK_SEETA_VERIFY::lk_seeta_establish_context()
......@@ -348,83 +347,83 @@ int Hex2Byte(std::string strIn, BYTE *datOut)
return (leth);
}
void LK_SEETA_VERIFY::contrast_authenticate()
{// not work
char* command = "8008 0000 09 03 1122334455667788";//8008 0000 09 03 1122334455667788
std::cout << "command:" << command << std::endl;
INT lenSnd, lenRcv, res, len;
BYTE cmdAPDU[0x200], outBuf[0x200];
lenSnd = Hex2Byte(command, cmdAPDU);
res = SendAPDU(lenSnd, cmdAPDU, &lenRcv, outBuf);
printf("outBuf:");
for (int i = 0; i < lenRcv; ++i)
{
//printf("%d:%x,%d ", i, outBuf[i], outBuf[i]);
printf("%d:%x ", i, outBuf[i]);
}
if (0 != res)
{
char buf[100];
sprintf(buf, "command execute error:%d\n", res);
std::string msg(buf);
std::cout << msg.c_str() << std::endl;
throw msg.c_str();
}
BYTE inoutdata[128];
BYTE keyStr[128];
memset(inoutdata, 0, 0x20);
memcpy(inoutdata, "\x08\x11\x22\x33\x44\x55\x66\x77\x88", 0x09); //注意第一个字节为加密明文长度
memcpy(keyStr, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x00\x00", 0x10);
printf("\n");
printf("inoutdata:");
for (int i = 0; i < 17; ++i)
{
printf("%d:%x ", i, inoutdata[i]);
}
printf("\n");
printf("keyStr:");
for (int i = 0; i < 16; ++i)
{
printf("%d:%x ", i, keyStr[i]);
}
printf("\n");
//xor with random inside
for (int i = 1; i < 9; ++i)
{//index 0 length of plaintext
inoutdata[i] ^= outBuf[i];
}
//3DES加密
encrypt_3des(inoutdata, keyStr);
printf("\n");
printf("des result:");
for (int i = 9; i < 17; ++i)
{
printf("%d:%x ", i, inoutdata[i]);
}
int result = compare_des_inside_outside(inoutdata + 9, outBuf + 9, 8);
if (result < 0)
{
char buf[100];
sprintf(buf, "authorize failed!\n");
std::string msg(buf);
std::cout << msg.c_str() << std::endl;
throw msg.c_str();
}
}
//void LK_SEETA_VERIFY::contrast_authenticate()
//{// not work
// char* command = "8008 0000 09 03 1122334455667788";//8008 0000 09 03 1122334455667788
// std::cout << "command:" << command << std::endl;
//
// INT lenSnd, lenRcv, res, len;
// BYTE cmdAPDU[0x200], outBuf[0x200];
//
// lenSnd = Hex2Byte(command, cmdAPDU);
//
// res = SendAPDU(lenSnd, cmdAPDU, &lenRcv, outBuf);
// printf("outBuf:");
// for (int i = 0; i < lenRcv; ++i)
// {
// //printf("%d:%x,%d ", i, outBuf[i], outBuf[i]);
// printf("%d:%x ", i, outBuf[i]);
// }
//
// if (0 != res)
// {
// char buf[100];
// sprintf(buf, "command execute error:%d\n", res);
//
// std::string msg(buf);
// std::cout << msg.c_str() << std::endl;
// throw msg.c_str();
// }
//
// BYTE inoutdata[128];
// BYTE keyStr[128];
// memset(inoutdata, 0, 0x20);
// memcpy(inoutdata, "\x08\x11\x22\x33\x44\x55\x66\x77\x88", 0x09); //注意第一个字节为加密明文长度
// memcpy(keyStr, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x00\x00", 0x10);
//
//
// printf("\n");
// printf("inoutdata:");
// for (int i = 0; i < 17; ++i)
// {
// printf("%d:%x ", i, inoutdata[i]);
// }
//
// printf("\n");
// printf("keyStr:");
// for (int i = 0; i < 16; ++i)
// {
// printf("%d:%x ", i, keyStr[i]);
// }
// printf("\n");
//
// //xor with random inside
// for (int i = 1; i < 9; ++i)
// {//index 0 length of plaintext
// inoutdata[i] ^= outBuf[i];
// }
// //3DES加密
// encrypt_3des(inoutdata, keyStr);
//
// printf("\n");
// printf("des result:");
// for (int i = 9; i < 17; ++i)
// {
// printf("%d:%x ", i, inoutdata[i]);
// }
//
// int result = compare_des_inside_outside(inoutdata + 9, outBuf + 9, 8);
//
// if (result < 0)
// {
// char buf[100];
// sprintf(buf, "authorize failed!\n");
//
// std::string msg(buf);
// std::cout << msg.c_str() << std::endl;
// throw msg.c_str();
// }
//}
void LK_SEETA_VERIFY::get_chip_id(unsigned char chip_id[], int &lenRcv)
{
......@@ -454,7 +453,7 @@ void LK_SEETA_VERIFY::write_chip_id_to_nvm()
unsigned char cmd_write_chip[300];
memset(cmd_write_chip, 0, 300);
memcpy(cmd_write_chip, "\x80\x08\x00\x00\x09\x04", 6);
memcpy(cmd_write_chip, chip_id, 8);
memcpy(cmd_write_chip + 6, chip_id, 8);
unsigned char rec[300];
int rec_len;
......
......@@ -5,7 +5,6 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "des.h"
#include <windows.h>
typedef int(__stdcall *pConnect)(int);
......
......@@ -140,13 +140,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DES.c" />
<ClCompile Include="main.cpp" />
<ClCompile Include="LK_seeta_verify.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CZ_LK_CHECKIT.h" />
<ClInclude Include="des.h" />
<ClInclude Include="LK_seeta_verify.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -21,17 +21,11 @@
<ClCompile Include="LK_seeta_verify.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DES.c">
<Filter>Header Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="LK_seeta_verify.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CZ_LK_CHECKIT.h">
<Filter>Header Files</Filter>
</ClInclude>
......
......@@ -5,10 +5,13 @@
int main()
{
LK_SEETA_VERIFY verify;
verify.write_chip_id_to_nvm();
while (true)
{
//CZ_LK_CHECKIT();
CZ_LK_CHECKIT_RANDOM();
CZ_LK_CHECKIT();
//CZ_LK_CHECKIT_time_to_time();
}
while (1);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!