Merge branch 'master' into purring-basilisk
Signed-off-by: Iceman <iceman@iuse.se>
This commit is contained in:
37 files changed
+7056
-5149
No files matched your search
@@ -263,6 +263,7 @@ set (TARGET_SOURCES
|
||||
${PM3_ROOT}/common/cardhelper.c
|
||||
${PM3_ROOT}/common/generator.c
|
||||
${PM3_ROOT}/common/bruteforce.c
|
||||
${PM3_ROOT}/common/hitag2/hitag2_crypto.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1dump.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1utils.c
|
||||
${PM3_ROOT}/client/src/crypto/libpcrypto.c
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
#
|
||||
# Mifare Default Keys
|
||||
# -- Iceman version --
|
||||
# -- contribute to this list, sharing is caring --
|
||||
#
|
||||
# Lets see how long it takes before other project takes this file
|
||||
# and claim they created it.
|
||||
#
|
||||
# factory HT2 pwd
|
||||
4D494B52
|
||||
# factory HT2 crypto key
|
||||
4F4E4D494B52
|
||||
#
|
||||
# GE HT2 reader
|
||||
#
|
||||
# TSPL
|
||||
5453504C
|
||||
05040202
|
||||
25293C2F
|
||||
# Gone in 360 seconds
|
||||
FFFF814632FF
|
||||
#
|
||||
# Paxton HT2
|
||||
BDF5E846
|
||||
#
|
||||
#
|
||||
# GE HT2 reader
|
||||
# TSPL
|
||||
5453504C
|
||||
05040202
|
||||
25293C2F
|
||||
@@ -125,4 +125,4 @@ local function main(args)
|
||||
end
|
||||
end
|
||||
|
||||
main(args)
|
||||
main(args)
|
||||
@@ -1719,12 +1719,12 @@ static int CmdSetGraphMarkers(const char *Cmd) {
|
||||
g_MarkerC.pos = arg_get_u32_def(ctx, 4, (keep ? g_MarkerC.pos : 0));
|
||||
g_MarkerD.pos = arg_get_u32_def(ctx, 5, (keep ? g_MarkerD.pos : 0));
|
||||
CLIParserFree(ctx);
|
||||
PrintAndLogEx(INFO, "Setting markers " _BRIGHT_YELLOW_("A") "=%u, "_BRIGHT_MAGENTA_("B") "=%u, "_RED_("C") "=%u, "_BLUE_("D") "=%u",
|
||||
g_MarkerA.pos,
|
||||
g_MarkerB.pos,
|
||||
g_MarkerC.pos,
|
||||
g_MarkerD.pos
|
||||
);
|
||||
PrintAndLogEx(INFO, "Setting markers " _BRIGHT_YELLOW_("A") "=%u, "_BRIGHT_MAGENTA_("B") "=%u, "_RED_("C") "=%u, "_BLUE_("D") "=%u",
|
||||
g_MarkerA.pos,
|
||||
g_MarkerB.pos,
|
||||
g_MarkerC.pos,
|
||||
g_MarkerD.pos
|
||||
);
|
||||
RepaintGraphWindow();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -3847,7 +3847,7 @@ static command_t CommandTable[] = {
|
||||
{"save", CmdSave, AlwaysAvailable, "Save signal trace data"},
|
||||
{"setdebugmode", CmdSetDebugMode, AlwaysAvailable, "Set Debugging Level on client side"},
|
||||
{"xor", CmdXor, AlwaysAvailable, "Xor a input string"},
|
||||
|
||||
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"},
|
||||
{"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"},
|
||||
{"detectclock", CmdDetectClockRate, AlwaysAvailable, "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"},
|
||||
|
||||
@@ -2737,7 +2737,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||
"Set UID for magic Chinese card (only works with such cards)\n",
|
||||
"hf 15 csetuid -u E011223344556677 -> use gen1 command\n"
|
||||
"hf 15 csetuid -u E011223344556677 --v2 -> use gen2 command"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
@@ -355,7 +355,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
if (supportVersion) {
|
||||
|
||||
int cardtype = getCardType(version[1], version[3], version[4]);
|
||||
switch(cardtype) {
|
||||
switch (cardtype) {
|
||||
case PLUS_EV1: {
|
||||
if (supportSignature) {
|
||||
PrintAndLogEx(INFO, "Tech..... " _GREEN_("MIFARE Plus EV1"));
|
||||
|
||||
+1111
-172
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,7 @@
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#define HITAG_NRAR_SIZE 8
|
||||
#define HITAG_CRYPTOKEY_SIZE 6
|
||||
#define HITAG_PASSWORD_SIZE 4
|
||||
#define HITAG_UID_SIZE 4
|
||||
@@ -37,16 +38,18 @@
|
||||
|
||||
#define HITAG2_CONFIG_BLOCK 3
|
||||
#define HITAG2_CONFIG_OFFSET (HITAG_BLOCK_SIZE * HITAG2_CONFIG_BLOCK)
|
||||
#define HITAG_DICTIONARY "ht2_default"
|
||||
|
||||
int CmdLFHitag(const char *Cmd);
|
||||
|
||||
int readHitagUid(void);
|
||||
void annotateHitag1(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response);
|
||||
void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, uint8_t bits, bool is_response);
|
||||
void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, uint8_t bits, bool is_response, const uint64_t *keys, uint32_t keycount, bool isdecrypted);
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response);
|
||||
|
||||
void annotateHitag2_init(void);
|
||||
|
||||
bool hitag2_get_plain(uint8_t *plain, uint8_t *plen);
|
||||
void hitag2_annotate_plain(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, uint8_t bits);
|
||||
|
||||
uint8_t hitag1_CRC_check(uint8_t *d, uint32_t nbit);
|
||||
#endif
|
||||
+99
-8
@@ -501,7 +501,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
uint32_t end_of_transmission_timestamp = 0;
|
||||
uint8_t topaz_reader_command[9];
|
||||
char explanation[40] = {0};
|
||||
char explanation[60] = {0};
|
||||
tracelog_hdr_t *first_hdr = (tracelog_hdr_t *)(trace);
|
||||
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
|
||||
@@ -774,10 +774,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
end_of_transmission_timestamp = hdr->timestamp + duration;
|
||||
|
||||
if (prev_eot)
|
||||
if (prev_eot) {
|
||||
*prev_eot = end_of_transmission_timestamp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Always annotate these protocols both reader/tag messages
|
||||
switch (protocol) {
|
||||
@@ -793,7 +792,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
annotateHitag1(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||
break;
|
||||
case PROTO_HITAG2:
|
||||
annotateHitag2(explanation, sizeof(explanation), frame, data_len, parityBytes[0], hdr->isResponse);
|
||||
annotateHitag2(explanation, sizeof(explanation), frame, data_len, parityBytes[0], hdr->isResponse, mfDicKeys, mfDicKeysCount, false);
|
||||
break;
|
||||
case PROTO_HITAGS:
|
||||
annotateHitagS(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||
@@ -979,6 +978,71 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
}
|
||||
}
|
||||
|
||||
if (protocol == PROTO_HITAG2) {
|
||||
|
||||
uint8_t ht2plain[9] = {0};
|
||||
uint8_t n = 0;
|
||||
if (hitag2_get_plain(ht2plain, &n)) {
|
||||
|
||||
memset(explanation, 0x00, sizeof(explanation));
|
||||
|
||||
// handle partial bytes. The parity array[0] is used to store number of left over bits from NBYTES
|
||||
// This part prints the number of bits in the trace entry for hitag.
|
||||
uint8_t nbits = parityBytes[0];
|
||||
|
||||
annotateHitag2(explanation, sizeof(explanation), ht2plain, n, nbits, hdr->isResponse, NULL, 0, true);
|
||||
|
||||
// iceman: colorise crc bytes here will need a refactor of code from above.
|
||||
for (int j = 0; j < n && (j / TRACE_MAX_HEX_BYTES) < TRACE_MAX_HEX_BYTES; j++) {
|
||||
|
||||
|
||||
if (j == 0) {
|
||||
|
||||
// only apply this to lesser than one byte
|
||||
if (n == 1) {
|
||||
|
||||
if (nbits == 5) {
|
||||
snprintf(line[0], 120, "%2u: %02X ", nbits, ht2plain[0] >> (8 - nbits));
|
||||
} else {
|
||||
snprintf(line[0], 120, "%2u: %02X ", nbits, ht2plain[0] >> (8 - nbits));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (nbits == 0) {
|
||||
snprintf(line[0], 120, "%2u: %02X ", (n * 8), ht2plain[0]);
|
||||
} else {
|
||||
snprintf(line[0], 120, "%2u: %02X ", ((n - 1) * 8) + nbits, ht2plain[0]);
|
||||
}
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
} else {
|
||||
snprintf(line[j / 18] + ((j % 18) * 4) + offset, 120, "%02X ", ht2plain[j]);
|
||||
}
|
||||
}
|
||||
|
||||
num_lines = MIN((n - 1) / TRACE_MAX_HEX_BYTES + 1, TRACE_MAX_HEX_BYTES);
|
||||
|
||||
for (int j = 0; j < num_lines ; j++) {
|
||||
if (hdr->isResponse) {
|
||||
PrintAndLogEx(NORMAL, " | | * |%-*s | %-4s| %s",
|
||||
str_padder,
|
||||
line[j],
|
||||
" ",
|
||||
explanation);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " | | * |" _YELLOW_("%-*s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"),
|
||||
str_padder,
|
||||
line[j],
|
||||
" ",
|
||||
explanation);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_last_record(tracepos, traceLen)) {
|
||||
return traceLen;
|
||||
}
|
||||
@@ -1436,6 +1500,30 @@ int CmdTraceList(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (protocol == PROTO_HITAG2) {
|
||||
|
||||
if (strlen(dictionary) == 0) {
|
||||
snprintf(dictionary, sizeof(dictionary), HITAG_DICTIONARY);
|
||||
}
|
||||
|
||||
// load keys
|
||||
uint8_t *keyBlock = NULL;
|
||||
int res = loadFileDICTIONARY_safe(dictionary, (void **) &keyBlock, HITAG_CRYPTOKEY_SIZE, &dicKeysCount);
|
||||
if (res != PM3_SUCCESS || dicKeysCount == 0 || keyBlock == NULL) {
|
||||
PrintAndLogEx(FAILED, "An error occurred while loading the dictionary!");
|
||||
} else {
|
||||
dicKeys = calloc(dicKeysCount, sizeof(uint64_t));
|
||||
for (int i = 0; i < dicKeysCount; i++) {
|
||||
uint64_t key = bytes_to_num(keyBlock + i * HITAG_CRYPTOKEY_SIZE, HITAG_CRYPTOKEY_SIZE);
|
||||
memcpy((uint8_t *) &dicKeys[i], &key, sizeof(uint64_t));
|
||||
}
|
||||
dictionaryLoad = true;
|
||||
}
|
||||
if (keyBlock != NULL) {
|
||||
free(keyBlock);
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
if (use_relative) {
|
||||
PrintAndLogEx(NORMAL, " Gap | Duration | Src | Data (! denotes parity error, ' denotes short bytes) | CRC | Annotation");
|
||||
@@ -1463,16 +1551,19 @@ int CmdTraceList(const char *Cmd) {
|
||||
while (tracepos < gs_traceLen) {
|
||||
tracepos = printTraceLine(tracepos, gs_traceLen, gs_trace, protocol, show_wait_cycles, mark_crc, prev_EOT, use_us, dicKeys, dicKeysCount);
|
||||
|
||||
if (kbd_enter_pressed())
|
||||
if (kbd_enter_pressed()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionaryLoad)
|
||||
if (dictionaryLoad) {
|
||||
free((void *) dicKeys);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_hex)
|
||||
if (show_hex) {
|
||||
PrintAndLogEx(HINT, "syntax to use: " _YELLOW_("`text2pcap -t \"%%S.\" -l 264 -n <input-text-file> <output-pcapng-file>`"));
|
||||
}
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -127,34 +127,38 @@ void des3_decrypt(void *out, const void *in, const void *key, uint8_t keycount)
|
||||
// NIST Special Publication 800-38A — Recommendation for block cipher modes of operation: methods and techniques, 2001.
|
||||
int aes_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
|
||||
uint8_t iiv[16] = {0};
|
||||
if (iv)
|
||||
if (iv) {
|
||||
memcpy(iiv, iv, 16);
|
||||
}
|
||||
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128))
|
||||
if (mbedtls_aes_setkey_enc(&aes, key, 128)) {
|
||||
return 1;
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, length, iiv, input, output))
|
||||
}
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, length, iiv, input, output)) {
|
||||
return 2;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int aes_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
|
||||
uint8_t iiv[16] = {0};
|
||||
if (iv)
|
||||
if (iv) {
|
||||
memcpy(iiv, iv, 16);
|
||||
}
|
||||
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
if (mbedtls_aes_setkey_dec(&aes, key, 128))
|
||||
if (mbedtls_aes_setkey_dec(&aes, key, 128)) {
|
||||
return 1;
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, length, iiv, input, output))
|
||||
}
|
||||
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, length, iiv, input, output)) {
|
||||
return 2;
|
||||
}
|
||||
mbedtls_aes_free(&aes);
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// NIST Special Publication 800-38B — Recommendation for block cipher modes of operation: The CMAC mode for authentication.
|
||||
@@ -171,13 +175,14 @@ int aes_cmac8(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int lengt
|
||||
memset(mac, 0x00, 8);
|
||||
|
||||
int res = aes_cmac(iv, key, input, cmac_tmp, length);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mac[i] = cmac_tmp[i * 2 + 1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t fixed_rand_value[250] = {0};
|
||||
@@ -188,21 +193,23 @@ static int fixed_rand(void *rng_state, unsigned char *output, size_t len) {
|
||||
memset(output, 0x00, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int sha1hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
if (!hash || !input)
|
||||
if (!hash || !input) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mbedtls_sha1(input, length, hash);
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int sha256hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
if (!hash || !input)
|
||||
if (!hash || !input) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mbedtls_sha256_context sctx;
|
||||
mbedtls_sha256_init(&sctx);
|
||||
@@ -211,12 +218,13 @@ int sha256hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
mbedtls_sha256_finish(&sctx, hash);
|
||||
mbedtls_sha256_free(&sctx);
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int sha512hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
if (!hash || !input)
|
||||
if (!hash || !input) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mbedtls_sha512_context sctx;
|
||||
mbedtls_sha512_init(&sctx);
|
||||
@@ -225,33 +233,35 @@ int sha512hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
mbedtls_sha512_finish(&sctx, hash);
|
||||
mbedtls_sha512_free(&sctx);
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int ecdsa_init_str(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id curveid, const char *key_d, const char *key_x, const char *key_y) {
|
||||
if (!ctx)
|
||||
if (!ctx) {
|
||||
return 1;
|
||||
|
||||
int res;
|
||||
}
|
||||
|
||||
mbedtls_ecdsa_init(ctx);
|
||||
res = mbedtls_ecp_group_load(&ctx->grp, curveid);
|
||||
if (res)
|
||||
int res = mbedtls_ecp_group_load(&ctx->grp, curveid);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (key_d) {
|
||||
res = mbedtls_mpi_read_string(&ctx->d, 16, key_d);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (key_x && key_y) {
|
||||
res = mbedtls_ecp_point_read_string(&ctx->Q, 16, key_x, key_y);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int ecdsa_init(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id curveid, uint8_t *key_d, uint8_t *key_xy) {
|
||||
@@ -278,7 +288,7 @@ static int ecdsa_init(mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id curveid,
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int ecdsa_key_create(mbedtls_ecp_group_id curveid, uint8_t *key_d, uint8_t *key_xy) {
|
||||
@@ -519,8 +529,9 @@ int ecdsa_nist_test(bool verbose) {
|
||||
size_t siglen = 0;
|
||||
|
||||
// NIST ecdsa test
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, " ECDSA NIST test: " NOLF);
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "ECDSA NIST test " NOLF);
|
||||
}
|
||||
// make signature
|
||||
res = ecdsa_signature_create_test(curveid, T_PRIVATE_KEY, T_Q_X, T_Q_Y, T_K, input, length, signature, &siglen);
|
||||
// PrintAndLogEx(INFO, "res: %x signature[%x]: %s", (res < 0)? -res : res, siglen, sprint_hex(signature, siglen));
|
||||
@@ -540,15 +551,16 @@ int ecdsa_nist_test(bool verbose) {
|
||||
uint8_t sval_s[33] = {0};
|
||||
param_gethex_to_eol(T_S, 0, sval_s, sizeof(sval_s), &slen);
|
||||
if (strncmp((char *)rval, (char *)rval_s, 32) || strncmp((char *)sval, (char *)sval_s, 32)) {
|
||||
PrintAndLogEx(INFO, "R or S check error");
|
||||
PrintAndLogEx(NORMAL, "( " _RED_("R or S check error") " )");
|
||||
res = 100;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// verify signature
|
||||
res = ecdsa_signature_verify_keystr(curveid, T_Q_X, T_Q_Y, input, length, signature, siglen, true);
|
||||
if (res)
|
||||
if (res) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// verify wrong signature
|
||||
input[0] ^= 0xFF;
|
||||
@@ -559,8 +571,8 @@ int ecdsa_nist_test(bool verbose) {
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_("passed"));
|
||||
PrintAndLogEx(INFO, " ECDSA binary signature create/check test: " NOLF);
|
||||
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
|
||||
PrintAndLogEx(INFO, "ECDSA binary signature create/check test " NOLF);
|
||||
}
|
||||
|
||||
// random ecdsa test
|
||||
@@ -587,12 +599,12 @@ int ecdsa_nist_test(bool verbose) {
|
||||
goto exit;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, _GREEN_("passed\n"));
|
||||
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
|
||||
|
||||
return PM3_SUCCESS;
|
||||
exit:
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, _RED_("failed\n"));
|
||||
PrintAndLogEx(NORMAL, "( " _RED_("fail") " )");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ size_t getFromGraphBufferEx(uint8_t *dest, size_t maxLen) {
|
||||
}
|
||||
|
||||
//TODO: In progress function to get chunks of data from the GB w/o modifying the GB
|
||||
//Currently seems like it doesn't work correctly?
|
||||
//Currently seems like it doesn't work correctly?
|
||||
size_t getGraphBufferChunk(uint8_t *dest, size_t start, size_t end) {
|
||||
if (dest == NULL) return 0;
|
||||
if (g_GraphTraceLen == 0) return 0;
|
||||
|
||||
@@ -742,7 +742,7 @@ static int DesfireExchangeISONative(bool activate_field, DesfireContext_t *ctx,
|
||||
pos += buflen;
|
||||
if (enable_chaining == false) {
|
||||
if (sw == DESFIRE_GET_ISO_STATUS(MFDES_S_OPERATION_OK) ||
|
||||
sw == DESFIRE_GET_ISO_STATUS(MFDES_ADDITIONAL_FRAME)) {
|
||||
sw == DESFIRE_GET_ISO_STATUS(MFDES_ADDITIONAL_FRAME)) {
|
||||
|
||||
if (resplen) {
|
||||
*resplen = pos;
|
||||
|
||||
@@ -626,13 +626,13 @@ static void DesfireSecureChannelDecodeEV1(DesfireContext_t *ctx, uint8_t *srcdat
|
||||
PrintAndLogEx(INFO, " calculated MAC: %s", sprint_hex(cmac, DesfireGetMACLength(ctx)));
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if (GetAPDULogging()) {
|
||||
PrintAndLogEx(INFO, "Received MAC OK");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ctx->commMode == DCMEncrypted || ctx->commMode == DCMEncryptedWithPadding) {
|
||||
} else if (ctx->commMode == DCMEncrypted || ctx->commMode == DCMEncryptedWithPadding) {
|
||||
|
||||
if (srcdatalen < desfire_get_key_block_length(ctx->keyType)) {
|
||||
memcpy(dstdata, srcdata, srcdatalen);
|
||||
|
||||
+1763
-1839
File diff suppressed because it is too large.
Load diff
+2275
-2320
File diff suppressed because it is too large.
Load diff
@@ -75,6 +75,15 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "analyse foo" },
|
||||
{ 1, "analyse units" },
|
||||
{ 1, "data help" },
|
||||
{ 1, "data clear" },
|
||||
{ 1, "data hide" },
|
||||
{ 1, "data load" },
|
||||
{ 1, "data num" },
|
||||
{ 1, "data plot" },
|
||||
{ 1, "data print" },
|
||||
{ 1, "data save" },
|
||||
{ 1, "data setdebugmode" },
|
||||
{ 1, "data xor" },
|
||||
{ 1, "data biphaserawdecode" },
|
||||
{ 1, "data detectclock" },
|
||||
{ 1, "data fsktonrz" },
|
||||
@@ -83,43 +92,32 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "data rawdemod" },
|
||||
{ 1, "data askedgedetect" },
|
||||
{ 1, "data autocorr" },
|
||||
{ 1, "data convertbitstream" },
|
||||
{ 1, "data cthreshold" },
|
||||
{ 1, "data dirthreshold" },
|
||||
{ 1, "data decimate" },
|
||||
{ 1, "data envelope" },
|
||||
{ 1, "data undecimate" },
|
||||
{ 1, "data hide" },
|
||||
{ 1, "data grid" },
|
||||
{ 1, "data getbitstream" },
|
||||
{ 1, "data hpf" },
|
||||
{ 1, "data iir" },
|
||||
{ 1, "data grid" },
|
||||
{ 1, "data ltrim" },
|
||||
{ 1, "data mtrim" },
|
||||
{ 1, "data norm" },
|
||||
{ 1, "data plot" },
|
||||
{ 1, "data cthreshold" },
|
||||
{ 1, "data rtrim" },
|
||||
{ 1, "data setgraphmarkers" },
|
||||
{ 1, "data shiftgraphzero" },
|
||||
{ 1, "data timescale" },
|
||||
{ 1, "data undecimate" },
|
||||
{ 1, "data zerocrossings" },
|
||||
{ 1, "data convertbitstream" },
|
||||
{ 1, "data getbitstream" },
|
||||
{ 1, "data asn1" },
|
||||
{ 1, "data atr" },
|
||||
{ 1, "data bin2hex" },
|
||||
{ 0, "data bitsamples" },
|
||||
{ 1, "data bmap" },
|
||||
{ 1, "data clear" },
|
||||
{ 1, "data crypto" },
|
||||
{ 1, "data diff" },
|
||||
{ 0, "data hexsamples" },
|
||||
{ 1, "data hex2bin" },
|
||||
{ 1, "data load" },
|
||||
{ 1, "data num" },
|
||||
{ 1, "data print" },
|
||||
{ 0, "data samples" },
|
||||
{ 1, "data save" },
|
||||
{ 1, "data setdebugmode" },
|
||||
{ 1, "data xor" },
|
||||
{ 1, "emv help" },
|
||||
{ 1, "emv list" },
|
||||
{ 1, "emv test" },
|
||||
@@ -558,11 +556,11 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 0, "lf sniff" },
|
||||
{ 0, "lf tune" },
|
||||
{ 1, "lf awid help" },
|
||||
{ 0, "lf awid brute" },
|
||||
{ 0, "lf awid clone" },
|
||||
{ 1, "lf awid demod" },
|
||||
{ 0, "lf awid reader" },
|
||||
{ 0, "lf awid clone" },
|
||||
{ 0, "lf awid sim" },
|
||||
{ 0, "lf awid brute" },
|
||||
{ 0, "lf awid watch" },
|
||||
{ 1, "lf cotag help" },
|
||||
{ 1, "lf cotag demod" },
|
||||
@@ -647,16 +645,19 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "lf hitag help" },
|
||||
{ 1, "lf hitag list" },
|
||||
{ 0, "lf hitag info" },
|
||||
{ 1, "lf hitag selftest" },
|
||||
{ 0, "lf hitag dump" },
|
||||
{ 0, "lf hitag read" },
|
||||
{ 0, "lf hitag sniff" },
|
||||
{ 1, "lf hitag view" },
|
||||
{ 0, "lf hitag wrbl" },
|
||||
{ 0, "lf hitag sniff" },
|
||||
{ 0, "lf hitag cc" },
|
||||
{ 0, "lf hitag ta" },
|
||||
{ 0, "lf hitag eload" },
|
||||
{ 0, "lf hitag eview" },
|
||||
{ 0, "lf hitag sim" },
|
||||
{ 0, "lf hitag cc" },
|
||||
{ 0, "lf hitag chk" },
|
||||
{ 1, "lf hitag lookup" },
|
||||
{ 0, "lf hitag ta" },
|
||||
{ 1, "lf idteck help" },
|
||||
{ 1, "lf idteck demod" },
|
||||
{ 0, "lf idteck reader" },
|
||||
|
||||
@@ -138,12 +138,12 @@ extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char
|
||||
}
|
||||
|
||||
void add_temporary_marker(uint32_t position, const char *label) {
|
||||
if(g_TempMarkerSize == 0) { //Initialize the marker array
|
||||
g_TempMarkers = (marker_t*)calloc(1, sizeof(marker_t));
|
||||
if (g_TempMarkerSize == 0) { //Initialize the marker array
|
||||
g_TempMarkers = (marker_t *)calloc(1, sizeof(marker_t));
|
||||
} else { //add more space to the marker array using realloc()
|
||||
marker_t *temp = (marker_t*)realloc(g_TempMarkers, ((g_TempMarkerSize + 1) * sizeof(marker_t)));
|
||||
marker_t *temp = (marker_t *)realloc(g_TempMarkers, ((g_TempMarkerSize + 1) * sizeof(marker_t)));
|
||||
|
||||
if(temp == NULL) { //Unable to reallocate memory for a new marker
|
||||
if (temp == NULL) { //Unable to reallocate memory for a new marker
|
||||
PrintAndLogEx(FAILED, "Unable to allocate memory for a new temporary marker!");
|
||||
free(temp);
|
||||
return;
|
||||
@@ -155,10 +155,10 @@ void add_temporary_marker(uint32_t position, const char *label) {
|
||||
|
||||
g_TempMarkers[g_TempMarkerSize].pos = position;
|
||||
|
||||
char *markerLabel = (char*)calloc(1, strlen(label) + 1);
|
||||
char *markerLabel = (char *)calloc(1, strlen(label) + 1);
|
||||
strcpy(markerLabel, label);
|
||||
|
||||
if(strlen(markerLabel) > 30) {
|
||||
if (strlen(markerLabel) > 30) {
|
||||
PrintAndLogEx(WARNING, "Label for temporary marker too long! Trunicating...");
|
||||
markerLabel[30] = '\0';
|
||||
}
|
||||
@@ -171,7 +171,7 @@ void add_temporary_marker(uint32_t position, const char *label) {
|
||||
}
|
||||
|
||||
void remove_temporary_markers(void) {
|
||||
if(g_TempMarkerSize == 0) return;
|
||||
if (g_TempMarkerSize == 0) return;
|
||||
|
||||
memset(g_TempMarkers, 0x00, (g_TempMarkerSize * sizeof(marker_t)));
|
||||
free(g_TempMarkers);
|
||||
|
||||
+89
-89
@@ -598,7 +598,7 @@ void Plot::setMaxAndStart(int *buffer, size_t len, QRect plotRect) {
|
||||
}
|
||||
|
||||
void Plot::appendMax(int *buffer, size_t len, QRect plotRect) {
|
||||
if(len == 0) {
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -750,12 +750,12 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
|
||||
painter->drawPath(penPath);
|
||||
char str[200];
|
||||
snprintf(str, sizeof(str), "max=%d min=%d mean=%" PRId64 " n=%u/%zu",
|
||||
vMax,
|
||||
vMin,
|
||||
vMean,
|
||||
g_GraphStop - g_GraphStart,
|
||||
len
|
||||
);
|
||||
vMax,
|
||||
vMin,
|
||||
vMean,
|
||||
g_GraphStop - g_GraphStart,
|
||||
len
|
||||
);
|
||||
|
||||
painter->drawText(20, annotationRect.bottom() - (48 - (12 * graphNum)), str);
|
||||
}
|
||||
@@ -781,37 +781,37 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||
|
||||
//Print the Graph Information
|
||||
char graphText[] = "@%u..%u dt=%i %s zoom=%2.3f";
|
||||
length = ((sizeof(graphText))+(sizeof(uint32_t)*3)+sizeof(scalestr)+sizeof(float_t));
|
||||
length = ((sizeof(graphText)) + (sizeof(uint32_t) * 3) + sizeof(scalestr) + sizeof(float_t));
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
|
||||
snprintf(annotation, length, graphText,
|
||||
g_GraphStart,
|
||||
g_GraphStop,
|
||||
g_MarkerB.pos - g_MarkerA.pos,
|
||||
scalestr,
|
||||
g_GraphPixelsPerPoint
|
||||
);
|
||||
g_GraphStart,
|
||||
g_GraphStop,
|
||||
g_MarkerB.pos - g_MarkerA.pos,
|
||||
scalestr,
|
||||
g_GraphPixelsPerPoint
|
||||
);
|
||||
|
||||
painter->setPen(GREEN);
|
||||
painter->drawText(82, annotationRect.bottom() - 62, annotation);
|
||||
|
||||
//Print Grid Information if the grid is enabled
|
||||
if(g_PlotGridX > 0) {
|
||||
if (g_PlotGridX > 0) {
|
||||
free(annotation);
|
||||
|
||||
const char *gridLocked = (g_GridLocked ? "Locked" : "Unlocked");
|
||||
char gridText[] = "GridX=%lf GridY=%lf (%s) GridXoffset=%lf";
|
||||
length = (sizeof(gridText) + (sizeof(double)*3) + sizeof(gridLocked));
|
||||
length = (sizeof(gridText) + (sizeof(double) * 3) + sizeof(gridLocked));
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
|
||||
snprintf(annotation, length, gridText,
|
||||
g_DefaultGridX,
|
||||
g_DefaultGridY,
|
||||
gridLocked,
|
||||
g_GridOffset
|
||||
);
|
||||
g_DefaultGridX,
|
||||
g_DefaultGridY,
|
||||
gridLocked,
|
||||
g_GridOffset
|
||||
);
|
||||
|
||||
painter->setPen(WHITE);
|
||||
painter->drawText(800, annotationRect.bottom() - 62, annotation);
|
||||
@@ -822,21 +822,21 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||
uint32_t pos = 0, loc = 375;
|
||||
painter->setPen(WHITE);
|
||||
|
||||
if(g_MarkerA.pos > 0) {
|
||||
if (g_MarkerA.pos > 0) {
|
||||
free(annotation);
|
||||
|
||||
length = (sizeof(markerText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1);
|
||||
length = (sizeof(markerText) + (sizeof(uint32_t) * 3) + sizeof(" ") + 1);
|
||||
pos = g_MarkerA.pos;
|
||||
bool flag = false;
|
||||
size_t value;
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
char *textA = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
char *textA = (char *)calloc(1, length);
|
||||
|
||||
strcat(textA, markerText);
|
||||
strcat(textA, " (%s%u)");
|
||||
|
||||
if(g_GraphBuffer[pos] <= g_OperationBuffer[pos]) {
|
||||
if (g_GraphBuffer[pos] <= g_OperationBuffer[pos]) {
|
||||
flag = true;
|
||||
value = (g_OperationBuffer[pos] - g_GraphBuffer[pos]);
|
||||
} else {
|
||||
@@ -844,65 +844,65 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||
}
|
||||
|
||||
snprintf(annotation, length, textA,
|
||||
"A",
|
||||
pos,
|
||||
g_GraphBuffer[pos],
|
||||
flag ? "+" : "-",
|
||||
value
|
||||
);
|
||||
"A",
|
||||
pos,
|
||||
g_GraphBuffer[pos],
|
||||
flag ? "+" : "-",
|
||||
value
|
||||
);
|
||||
|
||||
painter->drawText(loc, annotationRect.bottom() - 48, annotation);
|
||||
|
||||
free(textA);
|
||||
}
|
||||
|
||||
if(g_MarkerB.pos > 0) {
|
||||
if (g_MarkerB.pos > 0) {
|
||||
free(annotation);
|
||||
|
||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||
length = ((sizeof(markerText)) + (sizeof(uint32_t) * 2) + 1);
|
||||
pos = g_MarkerB.pos;
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
|
||||
snprintf(annotation, length, markerText,
|
||||
"B",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
"B",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
|
||||
painter->drawText(loc, annotationRect.bottom() - 36, annotation);
|
||||
}
|
||||
|
||||
if(g_MarkerC.pos > 0) {
|
||||
if (g_MarkerC.pos > 0) {
|
||||
free(annotation);
|
||||
|
||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||
length = ((sizeof(markerText)) + (sizeof(uint32_t) * 2) + 1);
|
||||
pos = g_MarkerC.pos;
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
|
||||
snprintf(annotation, length, markerText,
|
||||
"C",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
"C",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
|
||||
painter->drawText(loc, annotationRect.bottom() - 24, annotation);
|
||||
}
|
||||
|
||||
if(g_MarkerD.pos > 0) {
|
||||
if (g_MarkerD.pos > 0) {
|
||||
free(annotation);
|
||||
|
||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||
length = ((sizeof(markerText)) + (sizeof(uint32_t) * 2) + 1);
|
||||
pos = g_MarkerD.pos;
|
||||
|
||||
annotation = (char*)calloc(1, length);
|
||||
annotation = (char *)calloc(1, length);
|
||||
|
||||
snprintf(annotation, length, markerText,
|
||||
"D",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
"D",
|
||||
pos,
|
||||
g_GraphBuffer[pos]
|
||||
);
|
||||
|
||||
painter->drawText(loc, annotationRect.bottom() - 12, annotation);
|
||||
}
|
||||
@@ -951,7 +951,7 @@ void Plot::plotGridLines(QPainter *painter, QRect r) {
|
||||
}
|
||||
|
||||
void Plot::plotOperations(int *buffer, size_t len, QPainter *painter, QRect plotRect) {
|
||||
if(len == 0) {
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -973,10 +973,10 @@ void Plot::plotOperations(int *buffer, size_t len, QPainter *painter, QRect plot
|
||||
y = yCoordOf(current, plotRect, gs_absVMax);
|
||||
|
||||
//We only want to graph changes between the Graph Buffer and the Operation Buffer
|
||||
if(current == g_GraphBuffer[pos]) {
|
||||
if (current == g_GraphBuffer[pos]) {
|
||||
//If this point is the same, but the last point is different, we want to plot that line
|
||||
//as well
|
||||
if((pos == 0) || (prev == g_GraphBuffer[pos - 1])) {
|
||||
if ((pos == 0) || (prev == g_GraphBuffer[pos - 1])) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -1045,8 +1045,8 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||
// End graph drawing
|
||||
|
||||
//Draw the markers
|
||||
if(g_TempMarkerSize > 0) {
|
||||
for(int i = 0; i < g_TempMarkerSize; i++) {
|
||||
if (g_TempMarkerSize > 0) {
|
||||
for (int i = 0; i < g_TempMarkerSize; i++) {
|
||||
draw_marker(g_TempMarkers[i], plotRect, GRAY100, &painter);
|
||||
}
|
||||
}
|
||||
@@ -1074,15 +1074,15 @@ void Plot::draw_marker(marker_t marker, QRect plotRect, QColor color, QPainter *
|
||||
painter->setPen(color);
|
||||
|
||||
//If the marker is outside the buffer length, reset
|
||||
if(marker.pos > g_GraphTraceLen) {
|
||||
if (marker.pos > g_GraphTraceLen) {
|
||||
marker.pos = 0;
|
||||
}
|
||||
|
||||
//Make sure the marker is inside the current plot view to render
|
||||
if(marker.pos > g_GraphStart && xCoordOf(marker.pos, plotRect) < plotRect.right()) {
|
||||
if (marker.pos > g_GraphStart && xCoordOf(marker.pos, plotRect) < plotRect.right()) {
|
||||
painter->drawLine(xCoordOf(marker.pos, plotRect), plotRect.top(), xCoordOf(marker.pos, plotRect), plotRect.bottom());
|
||||
|
||||
if(strlen(marker.label) > 0) {
|
||||
if (strlen(marker.label) > 0) {
|
||||
painter->drawText(xCoordOf(marker.pos, plotRect) + 1, plotRect.top() + 12, marker.label);
|
||||
}
|
||||
}
|
||||
@@ -1295,7 +1295,7 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = int(ZOOM_LIMIT / g_GraphPixelsPerPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (event->key()) {
|
||||
@@ -1393,9 +1393,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("[ ") "/" _RED_(" ]"), "Move yellow marker left/right by 1 sample");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("{ ") "/" _RED_(" }"), "Move pink marker left/right by 1 sample");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5 samples");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 +9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point (Operation Buffer) over the yellow marker by 1");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point (Operation Buffer) over the yellow marker by 1");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 +9, _RED_("+ ") "/" _RED_(" _"), "Add/Subtract to the plot point (Graph Buffer) over the yellow marker by 1");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("+ ") "/" _RED_(" _"), "Add/Subtract to the plot point (Graph Buffer) over the yellow marker by 1");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("h"), "Show this help");
|
||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("q"), "Close plot window");
|
||||
@@ -1441,9 +1441,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
if (g_GraphStart > startMax)
|
||||
g_GraphStart = startMax;
|
||||
break;
|
||||
|
||||
|
||||
case Qt::Key_Equal:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_OperationBuffer[g_MarkerA.pos] += 5;
|
||||
} else {
|
||||
g_OperationBuffer[g_MarkerA.pos] += 1;
|
||||
@@ -1451,9 +1451,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
|
||||
RepaintGraphWindow();
|
||||
break;
|
||||
|
||||
|
||||
case Qt::Key_Minus:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_OperationBuffer[g_MarkerA.pos] -= 5;
|
||||
} else {
|
||||
g_OperationBuffer[g_MarkerA.pos] -= 1;
|
||||
@@ -1463,7 +1463,7 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
break;
|
||||
|
||||
case Qt::Key_Plus:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_GraphBuffer[g_MarkerA.pos] += 5;
|
||||
} else {
|
||||
g_GraphBuffer[g_MarkerA.pos] += 1;
|
||||
@@ -1471,9 +1471,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
|
||||
RepaintGraphWindow();
|
||||
break;
|
||||
|
||||
|
||||
case Qt::Key_Underscore:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_GraphBuffer[g_MarkerA.pos] -= 5;
|
||||
} else {
|
||||
g_GraphBuffer[g_MarkerA.pos] -= 1;
|
||||
@@ -1483,77 +1483,77 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
break;
|
||||
|
||||
case Qt::Key_BracketLeft: {
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_MarkerA.pos -= 5;
|
||||
} else {
|
||||
g_MarkerA.pos -= 1;
|
||||
}
|
||||
|
||||
if((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) {
|
||||
if ((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) {
|
||||
uint32_t halfway = PageWidth / 2;
|
||||
|
||||
if((g_MarkerA.pos - halfway) > g_GraphTraceLen) {
|
||||
if ((g_MarkerA.pos - halfway) > g_GraphTraceLen) {
|
||||
g_GraphStart = 0;
|
||||
} else {
|
||||
g_GraphStart = g_MarkerA.pos - halfway;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_MarkerA.pos < g_GraphStart) {
|
||||
if (g_MarkerA.pos < g_GraphStart) {
|
||||
g_MarkerA.pos = g_GraphStart;
|
||||
}
|
||||
|
||||
RepaintGraphWindow();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case Qt::Key_BracketRight: {
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_MarkerA.pos += 5;
|
||||
} else {
|
||||
g_MarkerA.pos += 1;
|
||||
}
|
||||
|
||||
if((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) {
|
||||
if ((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) {
|
||||
uint32_t halfway = PageWidth / 2;
|
||||
|
||||
if((g_MarkerA.pos + halfway) >= g_GraphTraceLen) {
|
||||
if ((g_MarkerA.pos + halfway) >= g_GraphTraceLen) {
|
||||
g_GraphStart = g_GraphTraceLen - halfway;
|
||||
} else {
|
||||
g_GraphStart = g_MarkerA.pos - halfway;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_MarkerA.pos >= g_GraphTraceLen) {
|
||||
if (g_MarkerA.pos >= g_GraphTraceLen) {
|
||||
g_MarkerA.pos = g_GraphTraceLen;
|
||||
}
|
||||
|
||||
RepaintGraphWindow();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case Qt::Key_BraceLeft:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_MarkerB.pos -= 5;
|
||||
} else {
|
||||
g_MarkerB.pos -= 1;
|
||||
}
|
||||
|
||||
if(g_MarkerB.pos < g_GraphStart) {
|
||||
if (g_MarkerB.pos < g_GraphStart) {
|
||||
g_MarkerB.pos = g_GraphStart;
|
||||
}
|
||||
|
||||
|
||||
RepaintGraphWindow();
|
||||
break;
|
||||
|
||||
|
||||
case Qt::Key_BraceRight:
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
g_MarkerB.pos += 5;
|
||||
} else {
|
||||
g_MarkerB.pos += 1;
|
||||
}
|
||||
|
||||
if(g_MarkerB.pos >= g_GraphTraceLen) {
|
||||
if (g_MarkerB.pos >= g_GraphTraceLen) {
|
||||
g_MarkerB.pos = g_GraphTraceLen;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user