only look if no key is applied

This commit is contained in:
iceman1001 2021-02-21 11:04:15 +01:00
parent 0073fc1a71
commit fad29cb755

View file

@ -940,22 +940,27 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
}
bool verbose = arg_get_lit(clictx, 4);
CLIParserFree(clictx);
size_t keylen = 0;
uint8_t dec_data[8] = {0};
bool use_sc = IsCryptoHelperPresent(verbose);
if (have_key == false && use_sc == false) {
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(INFO, "Couldn't find any decryption methods");
return PM3_EINVARG;
bool use_sc = false;
if (have_key == false) {
use_sc = IsCryptoHelperPresent(verbose);
if (use_sc == false) {
size_t keylen = 0;
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(INFO, "Couldn't find any decryption methods");
return PM3_EINVARG;
}
if (keylen != 16) {
PrintAndLogEx(ERR, "Failed to load transport key from file");
return PM3_EINVARG;
}
memcpy(key, keyptr, sizeof(key));
free(keyptr);
}
memcpy(key, keyptr, sizeof(key));
free(keyptr);
}
// tripledes
@ -1157,18 +1162,24 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
CLIParserFree(clictx);
bool use_sc = IsCryptoHelperPresent(verbose);
bool use_sc = false;
if (have_key == false) {
use_sc = IsCryptoHelperPresent(verbose);
if (use_sc == false) {
size_t keylen = 0;
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "Failed to find any encryption methods");
return PM3_EINVARG;
}
if (have_key == false && use_sc == false) {
size_t keylen = 0;
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "Failed to find the transport key");
return PM3_EINVARG;
if (keylen != 16) {
PrintAndLogEx(ERR, "Failed to load transport key from file");
return PM3_EINVARG;
}
memcpy(key, keyptr, sizeof(key));
free(keyptr);
}
memcpy(key, keyptr, sizeof(key));
free(keyptr);
}
if (use_sc) {