added regressiontests for cryptoRF SMA code part

This commit is contained in:
iceman1001 2023-08-21 13:08:08 +02:00
parent 5ecdd673ba
commit 0d1b86cc46
4 changed files with 18 additions and 3 deletions

View file

@ -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]
- Added cryptorf regressiontests (@iceman1001)
- 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)

View file

@ -844,7 +844,7 @@ int main(int argc, const char *argv[]) {
num_to_bytes(*itgc, 8, Gc_chk);
sm_auth(Gc_chk, Ci, Q, Ch_chk, Ci_1_chk, &ostate);
if ((memcmp(Ch_chk, Ch, 8) == 0) && (memcmp(Ci_1_chk, Ci_1, 8) == 0)) {
printf("\nFound valid key: " _GREEN_("%016" PRIx64)"\n\n", *itgc);
printf("\nValid key found [ " _GREEN_("%016" PRIx64)" ]\n\n", *itgc);
return 0;
}
}

View file

@ -1128,7 +1128,7 @@ int main(int argc, const char *argv[]) {
}
if (key_found) {
printf("\nFound valid key: " _GREEN_("%016lX")"\n\n", key.load());
printf("\nValid key found [ " _GREEN_("%016" PRIx64)" ]\n\n", key.load());
break;
}

View file

@ -14,6 +14,7 @@ TESTNONCE2KEY=false
TESTMFNONCEBRUTE=false
TESTMFDAESBRUTE=false
TESTHITAG2CRACK=false
TESTCRYPTORF=false
TESTFPGACOMPRESS=false
TESTBOOTROM=false
TESTARMSRC=false
@ -27,7 +28,7 @@ while (( "$#" )); do
case "$1" in
-h|--help)
echo """
Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|mfd_aes_brute|fpga_compress|bootrom|armsrc|client|recovery|common]
Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|mfd_aes_brute|cryptorf|fpga_compress|bootrom|armsrc|client|recovery|common]
--long: Enable slow tests
--opencl: Enable tests requiring OpenCL (preferably a Nvidia GPU)
--clientbin ...: Specify path to proxmark3 binary to test
@ -52,6 +53,11 @@ Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|
exit 1
fi
;;
cryptorf)
TESTALL=false
TESTCRYPTORF=true
shift
;;
mfkey)
TESTALL=false
TESTMFKEY=true
@ -295,6 +301,14 @@ while true; do
if ! CheckExecute "mfd_aes_brute test 1/2" "$MFDASEBRUTEBIN 1605394800 bb6aea729414a5b1eff7b16328ce37fd 82f5f498dbc29f7570102397a2e5ef2b6dc14a864f665b3c54d11765af81e95c" "key.................... .*261C07A23F2BC8262F69F10A5BDF3764"; then break; fi
if ! CheckExecute slow "mfd_aes_brute test 2/2" "$MFDASEBRUTEBIN 1546300800 3fda933e2953ca5e6cfbbf95d1b51ddf 97fe4b5de24188458d102959b888938c988e96fb98469ce7426f50f108eaa583" "key.................... .*E757178E13516A4F3171BC6EA85E165A"; then break; fi
fi
if $TESTALL || $TESTCRYPTORF; then
echo -e "\n${C_BLUE}Testing CryptoRF sma:${C_NC} ${CRYPTRFBRUTEBIN:=./tools/cryptorf/sma} ${CRYPTRF_MULTI_BRUTEBIN:=./tools/cryptorf/sma_multi}"
if ! CheckFileExist "sma exists" "$CRYPTRFBRUTEBIN"; then break; fi
if ! CheckFileExist "sma_multi exists" "$CRYPTRF_MULTI_BRUTEBIN"; then break; fi
if ! CheckExecute slow "sma test" "$CRYPTRFBRUTEBIN ffffffffffffffff 1234567812345678 88c9d4466a501a87 dec2ee1b1c9276e9" "key found \[.*4f794a463ff81d81.*\]"; then break; fi
if ! CheckExecute slow "sma_multi test" "$CRYPTRF_MULTI_BRUTEBIN ffffffffffffffff 1234567812345678 88c9d4466a501a87 dec2ee1b1c9276e9" "key found \[.*4f794a463ff81d81.*\]"; then break; fi
fi
# hitag2crack not yet part of "all"
# if $TESTALL || $TESTHITAG2CRACK; then
if $TESTHITAG2CRACK; then