Merge remote-tracking branch 'upstream/master' into hf_mf_sim

This commit is contained in:
vratiskol 2019-03-25 00:16:40 +01:00
commit cffb8cbca4
4 changed files with 16 additions and 9 deletions

View file

@ -876,15 +876,19 @@ int CmdAnalyseNuid(const char *Cmd) {
/* selftest1 UID 040D681AB52281 -> NUID 8F430FEF */ /* selftest1 UID 040D681AB52281 -> NUID 8F430FEF */
/* selftest2 UID 04183F09321B85 -> NUID 4F505D7D */ /* selftest2 UID 04183F09321B85 -> NUID 4F505D7D */
if (cmdp == 't') { if (cmdp == 't') {
memcpy(uid, "\x04\x0d\x68\x1a\xb5\x22\x81", 7); uint8_t uid_test1[] = {0x04, 0x0d, 0x68, 0x1a, 0xb5, 0x22, 0x81};
uint8_t nuid_test1[] = {0x8f, 0x43, 0x0f, 0xef};
uint8_t uid_test2[] = {0x04, 0x18, 0x3f, 0x09, 0x32, 0x1b, 0x85};
uint8_t nuid_test2[] = {0x4f, 0x50, 0x5d, 0x7d};
memcpy(uid, uid_test1, sizeof(uid));
generate4bNUID(uid, nuid); generate4bNUID(uid, nuid);
bool test1 = (0 == memcmp(nuid, "\x8f\x43\x0f\xef", 4)); bool test1 = (0 == memcmp(nuid, nuid_test1, sizeof(nuid)));
PrintAndLogEx(SUCCESS, "Selftest1 %s\n", test1 ? _GREEN_("OK") : _RED_("Fail")); PrintAndLogEx(SUCCESS, "Selftest1 %s\n", test1 ? _GREEN_("OK") : _RED_("Fail"));
memcpy(uid, "\x04\x18\x3f\x09\x32\x1b\x85", 7); memcpy(uid, uid_test2, sizeof(uid));
generate4bNUID(uid, nuid); generate4bNUID(uid, nuid);
bool test2 = (0 == memcmp(nuid, "\x4f\x50\x5d\x7d", 4)); bool test2 = (0 == memcmp(nuid, nuid_test2, sizeof(nuid)));
PrintAndLogEx(SUCCESS, "Selftest2 %s\n", test2 ? _GREEN_("OK") : _RED_("Fail")); PrintAndLogEx(SUCCESS, "Selftest2 %s\n", test2 ? _GREEN_("OK") : _RED_("Fail"));
return 0; return 0;
} }

View file

@ -524,7 +524,7 @@ int CmdHF14AInfo(const char *Cmd) {
(tb1 ? "" : " NOT"), (tb1 ? "" : " NOT"),
(tc1 ? "" : " NOT"), (tc1 ? "" : " NOT"),
fsci, fsci,
fsci < sizeof(atsFSC) ? atsFSC[fsci] : -1 fsci < sizeof(atsFSC)/sizeof(atsFSC[0]) ? atsFSC[fsci] : -1
); );
} }
pos = 2; pos = 2;
@ -959,7 +959,7 @@ int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
// get frame length from ATS in data field // get frame length from ATS in data field
if (resp.arg[0] > 1) { if (resp.arg[0] > 1) {
uint8_t fsci = resp.d.asBytes[1] & 0x0f; uint8_t fsci = resp.d.asBytes[1] & 0x0f;
if (fsci < sizeof(atsFSC)) if (fsci < sizeof(atsFSC)/sizeof(atsFSC[0]))
frameLength = atsFSC[fsci]; frameLength = atsFSC[fsci];
} }
} else { } else {
@ -967,7 +967,7 @@ int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.d.asBytes; iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.d.asBytes;
if (vcard->ats_len > 1) { if (vcard->ats_len > 1) {
uint8_t fsci = vcard->ats[1] & 0x0f; uint8_t fsci = vcard->ats[1] & 0x0f;
if (fsci < sizeof(atsFSC)) if (fsci < sizeof(atsFSC)/sizeof(atsFSC[0]))
frameLength = atsFSC[fsci]; frameLength = atsFSC[fsci];
} }

View file

@ -297,6 +297,8 @@ int CmdHIDClone(const char *Cmd) {
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
/*
// struct to handle wiegand // struct to handle wiegand
typedef struct { typedef struct {
uint8_t FormatLen; uint8_t FormatLen;
@ -306,6 +308,7 @@ typedef struct {
uint8_t *Wiegand; uint8_t *Wiegand;
size_t Wiegand_n; size_t Wiegand_n;
} wiegand_t; } wiegand_t;
*/
static void addHIDMarker(uint8_t fmtlen, uint8_t *out) { static void addHIDMarker(uint8_t fmtlen, uint8_t *out) {
// temp array // temp array

View file

@ -228,8 +228,8 @@ void num_to_wiegand_bits(uint64_t oem, uint64_t fc, uint64_t cn, uint8_t *dest,
break; break;
case 50 : // AWID 50 RBH case 50 : // AWID 50 RBH
fc &= 0xFFFF; // 16bits fc &= 0xFFFF; // 16bits
cn &= 0xFFFFFFFF // 32bits cn &= 0xFFFFFFFF; // 32bits
value = fc << 32 | cn; value = fc << 32 | cn;
num_to_bytebits(value, 48, temp); num_to_bytebits(value, 48, temp);
wiegand_add_parity(temp, dest, 48); // verify! wiegand_add_parity(temp, dest, 48); // verify!
break; break;