Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangbo
/
CZ_LTK_CHIP_VERIFY
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c88e8798
authored
Jul 04, 2019
by
kevin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solve verify fail bug
1 parent
d0078d4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
compare_verify/CZ_LK_CHECKIT.h
compare_verify/LK_seeta_verify.cpp
compare_verify/CZ_LK_CHECKIT.h
View file @
c88e879
...
...
@@ -42,7 +42,7 @@ void CZ_LK_CHECKIT()
else
{
//verify failed
char
buf
[
100
];
sprintf
(
buf
,
"Using unauthorized chip, please che
kc
with technicians.
\n
"
);
sprintf
(
buf
,
"Using unauthorized chip, please che
ck
with technicians.
\n
"
);
std
::
string
msg
(
buf
);
std
::
cout
<<
msg
.
c_str
()
<<
std
::
endl
;
...
...
compare_verify/LK_seeta_verify.cpp
View file @
c88e879
...
...
@@ -450,15 +450,17 @@ void LK_SEETA_VERIFY::get_chip_id(unsigned char chip_id[], int &lenRcv)
void
LK_SEETA_VERIFY
::
write_chip_id_limit_num_to_nvm
()
{
uint8_t
DES_ENCRYPT_DECRYPT_KEY
[
128
];
memcpy
(
DES_ENCRYPT_DECRYPT_KEY
,
"
\x01\x09\x09\01\x00\x07\x01\x01\x0
0\x00\x00\x00\x00\x00\x00\x00
"
,
0x10
);
memcpy
(
DES_ENCRYPT_DECRYPT_KEY
,
"
\x01\x09\x09\01\x00\x07\x01\x01\x0
1\x02\x03\x04\x05\x06\x07\x08
"
,
0x10
);
unsigned
char
chip_id
[
300
];
int
len
;
get_chip_id
(
chip_id
,
len
);
//printf("chip id from hardward:\n");
//for (int i = 0; i < len; ++i)
//{
// printf("%d:%x ", i, chip_id[i]);
//}
//printf("\n");
unsigned
char
cmd_write_chip
[
300
];
unsigned
char
chip_id_and_limit_num
[
300
];
//mingwen
...
...
@@ -473,17 +475,24 @@ void LK_SEETA_VERIFY::write_chip_id_limit_num_to_nvm()
memcpy
(
chip_id_and_limit_num
+
1
,
chip_id
,
8
);
memcpy
(
chip_id_and_limit_num
+
9
,
"
\x05\x00\x00\x01\x00\x00\x00\x00
"
,
8
);
// limit==10000
printf
(
"write into:
\n
"
);
for
(
int
i
=
0
;
i
<
17
;
++
i
)
{
printf
(
"%d:%x "
,
i
,
chip_id_and_limit_num
[
i
]);
}
//
printf("write into:\n");
//
for (int i = 0; i < 17; ++i)
//
{
//
printf("%d:%x ", i, chip_id_and_limit_num[i]);
//
}
encrypt_3des
(
chip_id_and_limit_num
,
DES_ENCRYPT_DECRYPT_KEY
);
memcpy
(
chip_id_and_limit_num_des
,
chip_id_and_limit_num
+
1
7
,
16
);
memcpy
(
chip_id_and_limit_num_des
,
chip_id_and_limit_num
+
1
,
16
);
memcpy
(
cmd_write_chip
+
6
,
chip_id_and_limit_num_des
,
16
);
//printf("write command:\n");
//for (int i = 0; i <22; ++i)
//{
// printf("%d:%x ", i, cmd_write_chip[i]);
//}
//printf("\n");
unsigned
char
rec
[
300
];
int
rec_len
;
int
res
=
SendAPDU
(
22
,
cmd_write_chip
,
&
rec_len
,
rec
);
//write to nvm
...
...
@@ -508,7 +517,7 @@ void LK_SEETA_VERIFY::write_chip_id_limit_num_to_nvm()
void
LK_SEETA_VERIFY
::
read_chip_id_limit_num_from_nvm
(
unsigned
char
chip_id_from_nvm
[],
int
&
lenRcv
)
{
uint8_t
DES_ENCRYPT_DECRYPT_KEY
[
128
];
memcpy
(
DES_ENCRYPT_DECRYPT_KEY
,
"
\x01\x09\x09\01\x00\x07\x01\x01\x0
0\x00\x00\x00\x00\x00\x00\x00
"
,
0x10
);
memcpy
(
DES_ENCRYPT_DECRYPT_KEY
,
"
\x01\x09\x09\01\x00\x07\x01\x01\x0
1\x02\x03\x04\x05\x06\x07\x08
"
,
0x10
);
unsigned
char
cmd_read_chip_id
[
300
];
unsigned
char
rec
[
300
];
...
...
@@ -518,7 +527,7 @@ void LK_SEETA_VERIFY::read_chip_id_limit_num_from_nvm(unsigned char chip_id_from
memset
(
cmd_read_chip_id
,
0
,
300
);
memcpy
(
cmd_read_chip_id
,
"
\x80\x08\x00\x00\x01\x05
"
,
6
);
int
res
=
SendAPDU
(
14
,
cmd_read_chip_id
,
&
rec_len
,
rec
);
//read from nvm
int
res
=
SendAPDU
(
6
,
cmd_read_chip_id
,
&
rec_len
,
rec
);
//read from nvm
memset
(
in_out_data
,
0
,
300
);
memcpy
(
in_out_data
,
"
\x10
"
,
1
);
...
...
@@ -526,11 +535,11 @@ void LK_SEETA_VERIFY::read_chip_id_limit_num_from_nvm(unsigned char chip_id_from
decrypt_3des
(
in_out_data
,
DES_ENCRYPT_DECRYPT_KEY
);
printf
(
"read from:
\n
"
);
for
(
int
i
=
0
;
i
<
17
;
++
i
)
{
printf
(
"%d:%x "
,
i
,
in_out_data
[
i
]);
}
//
printf("read from:\n");
//
for (int i = 0; i < 17; ++i)
//
{
//
printf("%d:%x ", i, in_out_data[i]);
//
}
if
(
0
!=
res
)
{
char
buf
[
100
];
...
...
@@ -541,13 +550,16 @@ void LK_SEETA_VERIFY::read_chip_id_limit_num_from_nvm(unsigned char chip_id_from
throw
msg
.
c_str
();
}
//for (int i = 0; i < rec_len; ++i)
//printf("read result:\n");
//for (int i = 0; i < 16; ++i)
//{
// printf("%d:%x ", i, rec[i]);
//}
//printf("\n");
lenRcv
=
8
;
memmove
(
chip_id_from_nvm
,
in_out_data
+
1
7
,
8
);
memmove
(
chip_id_from_nvm
,
in_out_data
+
1
,
8
);
return
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment