make style
This commit is contained in:
@@ -174,7 +174,7 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
|
||||
PrintAndLogEx(INFO, "%s", title);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i % 16 == 0) {
|
||||
|
||||
|
||||
if (i == 0)
|
||||
cx += snprintf(output + cx, outsize - cx, "%02x| ", i);
|
||||
else
|
||||
@@ -204,9 +204,9 @@ static int testBitStream(void) {
|
||||
}
|
||||
|
||||
if (memcmp(input, output, sizeof(input)) == 0) {
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok") );
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok"));
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed") );
|
||||
PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed"));
|
||||
uint8_t i;
|
||||
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
|
||||
PrintAndLogEx(NORMAL, " IN %02x, OUT %02x", input[i], output[i]);
|
||||
@@ -234,9 +234,9 @@ static int testReversedBitstream(void) {
|
||||
}
|
||||
|
||||
if (memcmp(input, output, sizeof(input)) == 0) {
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok") );
|
||||
PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok"));
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed") );
|
||||
PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed"));
|
||||
uint8_t i;
|
||||
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
|
||||
PrintAndLogEx(NORMAL, " IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]);
|
||||
@@ -251,7 +251,7 @@ int testCipherUtils(void) {
|
||||
int retval = testBitStream();
|
||||
if (retval == PM3_SUCCESS)
|
||||
retval = testReversedBitstream();
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -481,7 +481,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) {
|
||||
if (memcmp(z_0, result, 4) != 0) {
|
||||
PrintAndLogEx(WARNING, _RED_("Failed to verify") " calculated master key (k_cus)! Something is wrong.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!"));
|
||||
return PM3_SUCCESS;
|
||||
@@ -501,9 +501,9 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
|
||||
dumpdata *attack = (dumpdata *) calloc(itemsize, sizeof(uint8_t));
|
||||
if (attack == NULL) {
|
||||
PrintAndLogEx(WARNING, "failed to allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
int res = 0;
|
||||
for (i = 0 ; i * itemsize < dumpsize ; i++) {
|
||||
memcpy(attack, dump + i * itemsize, itemsize);
|
||||
@@ -670,13 +670,13 @@ int testElite(bool slowtests) {
|
||||
int res = PM3_SUCCESS;
|
||||
PrintAndLogEx(INFO, "Testing hash1...");
|
||||
res += _testHash1();
|
||||
PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
|
||||
PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(INFO, "Testing key diversification...");
|
||||
res += _test_iclass_key_permutation();
|
||||
if (res == PM3_SUCCESS)
|
||||
PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
|
||||
|
||||
PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
|
||||
|
||||
if (slowtests)
|
||||
res += _testBruteforce();
|
||||
|
||||
|
||||
@@ -228,13 +228,13 @@ static void printState(const char *desc, uint64_t c) {
|
||||
return;
|
||||
char s[60] = {0};
|
||||
snprintf(s, sizeof(s), "%s : ", desc);
|
||||
|
||||
|
||||
uint8_t x = (c & 0xFF00000000000000) >> 56;
|
||||
uint8_t y = (c & 0x00FF000000000000) >> 48;
|
||||
|
||||
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x %02x", x, y);
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x", getSixBitByte(c, i));
|
||||
|
||||
PrintAndLogEx(DEBUG, "%s", s);
|
||||
@@ -353,7 +353,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
|
||||
* @param key
|
||||
* @param div_key
|
||||
*/
|
||||
void diversifyKey(uint8_t* csn, uint8_t* key, uint8_t* div_key) {
|
||||
void diversifyKey(uint8_t *csn, uint8_t *key, uint8_t *div_key) {
|
||||
// Prepare the DES key
|
||||
mbedtls_des_setkey_enc(&ctx_enc, key);
|
||||
|
||||
@@ -581,7 +581,7 @@ static int testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
|
||||
PrintAndLogEx(DEBUG, "");
|
||||
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypted_csn);
|
||||
PrintAndLogEx(DEBUG, " {csn-revz} %"PRIx64, crypted_csn_swapped);
|
||||
PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL") );
|
||||
PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL"));
|
||||
|
||||
if (resultbyte != expected) {
|
||||
PrintAndLogEx(DEBUG, " expected " _YELLOW_("%"PRIx64), expected);
|
||||
@@ -602,7 +602,7 @@ static int testDES2(uint64_t csn, uint64_t expected) {
|
||||
uint64_t crypt_csn = x_bytes_to_num(result, 8);
|
||||
|
||||
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypt_csn);
|
||||
PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL") );
|
||||
PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL"));
|
||||
|
||||
if (expected != crypt_csn)
|
||||
return PM3_ESOFT;
|
||||
@@ -635,7 +635,7 @@ static int doTestsWithKnownInputs(void) {
|
||||
res += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea);
|
||||
res += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3);
|
||||
|
||||
if (res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "%d res occurred (9 testcases)", res);
|
||||
res = PM3_ESOFT;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user