mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-07 16:48:15 +08:00
modified some output and made sure a local state is used for multithreaded. Also added the mod fix from Doegox in sma.cpp
This commit is contained in:
parent
e602287839
commit
b17a733bdb
3 changed files with 34 additions and 18 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Fixed `cryptorf/sma_multi` - local state used in multithread (@iceman1001)
|
||||
- Changed `fpga_compress` - better deallocation of memory and closing of file handles (@iceman1001)
|
||||
- Changed `hf search` - less swaps of fpga images on device side (@iceman1001)
|
||||
- Changed `mkversion.sh` - now regenerates version_pm3.c (and consequently the binaries) only when needed (@doegox)
|
||||
|
|
|
@ -159,6 +159,10 @@ void print_cs(const char *text, pcs s) {
|
|||
}
|
||||
|
||||
static inline uint8_t mod(uint8_t a, uint8_t m) {
|
||||
if (m == 0) {
|
||||
return 0; // Actually, divide by zero error
|
||||
}
|
||||
|
||||
// Just return the input when this is less or equal than the modular value
|
||||
if (a < m) return a;
|
||||
|
||||
|
@ -754,7 +758,7 @@ int main(int argc, const char *argv[]) {
|
|||
Q[pos] = rand();
|
||||
}
|
||||
sm_auth(Gc, Ci, Q, Ch, Ci_1, &ostate);
|
||||
printf(" Gc: ");
|
||||
printf(" Gc... ");
|
||||
print_bytes(Gc, 8);
|
||||
} else {
|
||||
sscanf(argv[1], "%016" SCNx64, &nCi);
|
||||
|
@ -765,7 +769,7 @@ int main(int argc, const char *argv[]) {
|
|||
num_to_bytes(nCh, 8, Ch);
|
||||
sscanf(argv[4], "%016" SCNx64, &nCi_1);
|
||||
num_to_bytes(nCi_1, 8, Ci_1);
|
||||
printf(" Gc: unknown\n");
|
||||
printf(" Gc... unknown\n");
|
||||
}
|
||||
|
||||
for (pos = 0; pos < 8; pos++) {
|
||||
|
@ -773,16 +777,16 @@ int main(int argc, const char *argv[]) {
|
|||
ks[(2 * pos) + 1] = Ch[pos];
|
||||
}
|
||||
|
||||
printf(" Ci: ");
|
||||
printf(" Ci... ");
|
||||
print_bytes(Ci, 8);
|
||||
printf(" Q: ");
|
||||
printf(" Q... ");
|
||||
print_bytes(Q, 8);
|
||||
printf(" Ch: ");
|
||||
printf(" Ch... ");
|
||||
print_bytes(Ch, 8);
|
||||
printf("Ci+1: ");
|
||||
printf("Ci+1... ");
|
||||
print_bytes(Ci_1, 8);
|
||||
printf("\n");
|
||||
printf(" Ks: ");
|
||||
printf(" Ks... ");
|
||||
print_bytes(ks, 16);
|
||||
printf("\n");
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ static inline uint8_t mod(uint8_t a, uint8_t m) {
|
|||
if (m == 0) {
|
||||
return 0; // Actually, divide by zero error
|
||||
}
|
||||
|
||||
// Just return the input when this is less or equal than the modular value
|
||||
if (a < m) return a;
|
||||
|
||||
|
@ -935,9 +936,19 @@ static void ice_compare(
|
|||
uint8_t *Ch,
|
||||
uint8_t *Ci_1
|
||||
) {
|
||||
uint8_t Gc_chk[8];
|
||||
uint8_t Ch_chk[ 8];
|
||||
uint8_t Ci_1_chk[ 8];
|
||||
uint8_t Gc_chk[8] = {0};
|
||||
uint8_t Ch_chk[8] = {0};
|
||||
uint8_t Ci_1_chk[8] = {0};
|
||||
|
||||
crypto_state_t ls;
|
||||
ls.b0 = ostate->b0;
|
||||
ls.b1 = ostate->b1;
|
||||
ls.b1l = ostate->b1l;
|
||||
ls.b1r = ostate->b1r;
|
||||
ls.b1s = ostate->b1s;
|
||||
ls.l = ostate->l;
|
||||
ls.m = ostate->m;
|
||||
ls.r = ostate->r;
|
||||
|
||||
for (std::size_t i = offset; i < candidates->size(); i += skips) {
|
||||
if (key_found.load(std::memory_order_relaxed))
|
||||
|
@ -946,7 +957,7 @@ static void ice_compare(
|
|||
uint64_t tkey = candidates->at(i);
|
||||
num_to_bytes(tkey, 8, Gc_chk);
|
||||
|
||||
sm_auth(Gc_chk, Ci, Q, Ch_chk, Ci_1_chk, ostate);
|
||||
sm_auth(Gc_chk, Ci, Q, Ch_chk, Ci_1_chk, &ls);
|
||||
if ((memcmp(Ch_chk, Ch, 8) == 0) && (memcmp(Ci_1_chk, Ci_1, 8) == 0)) {
|
||||
g_ice_mtx.lock();
|
||||
key_found = true;
|
||||
|
@ -1008,7 +1019,7 @@ int main(int argc, const char *argv[]) {
|
|||
Q[pos] = rand();
|
||||
}
|
||||
sm_auth(Gc, Ci, Q, Ch, Ci_1, &ostate);
|
||||
printf(" Gc: ");
|
||||
printf(" Gc... ");
|
||||
print_bytes(Gc, 8);
|
||||
} else {
|
||||
sscanf(argv[1], "%016" SCNx64, &nCi);
|
||||
|
@ -1019,7 +1030,7 @@ int main(int argc, const char *argv[]) {
|
|||
num_to_bytes(nCh, 8, Ch);
|
||||
sscanf(argv[4], "%016" SCNx64, &nCi_1);
|
||||
num_to_bytes(nCi_1, 8, Ci_1);
|
||||
printf(" Gc: unknown\n");
|
||||
printf(" Gc... unknown\n");
|
||||
}
|
||||
|
||||
for (pos = 0; pos < 8; pos++) {
|
||||
|
@ -1027,16 +1038,16 @@ int main(int argc, const char *argv[]) {
|
|||
ks[(2 * pos) + 1] = Ch[pos];
|
||||
}
|
||||
|
||||
printf(" Ci: ");
|
||||
printf(" Ci... ");
|
||||
print_bytes(Ci, 8);
|
||||
printf(" Q: ");
|
||||
printf(" Q... ");
|
||||
print_bytes(Q, 8);
|
||||
printf(" Ch: ");
|
||||
printf(" Ch... ");
|
||||
print_bytes(Ch, 8);
|
||||
printf("Ci+1: ");
|
||||
printf("Ci+1... ");
|
||||
print_bytes(Ci_1, 8);
|
||||
printf("\n");
|
||||
printf(" Ks: ");
|
||||
printf(" Ks... ");
|
||||
print_bytes(ks, 16);
|
||||
printf("\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue