hf mf: add the MAD helpers parseproac needs, and register AID 0x4982
b82f60362 landed parseproac.c without them, so a clean checkout does not
build.
- mad.c / mad.h: mad_find_aid() and mad_count_aid(); DetectHID() delegates
to the first, it was already generic
- mad.json: 0x4982 PROAC, sorted in after NORALSY's 0x4980
Co-Authored-By: Claude Opus 5 (1M context)
This commit is contained in:
1 parent
b82f603622
commit
6f4643a637
3 files changed
+35
-2
No files matched your search
+20
-2
@@ -499,19 +499,37 @@ bool HasMADKey(const mad1_sector_t *s0) {
|
||||
return (memcmp(s0->trailer.key_a, g_mifare_mad_key, sizeof(g_mifare_mad_key)) == 0);
|
||||
}
|
||||
|
||||
int DetectHID(const mad1_sector_t *s0, uint16_t manufacture) {
|
||||
int mad_find_aid(const mad1_sector_t *s0, uint16_t aid) {
|
||||
if (s0 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAD1_NUM_AIDS; i++) {
|
||||
if (madGetAID(s0->mad.aid[i], false) == manufacture) {
|
||||
if (madGetAID(s0->mad.aid[i], false) == aid) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mad_count_aid(const mad1_sector_t *s0, uint16_t aid) {
|
||||
if (s0 == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
for (int i = 0; i < MAD1_NUM_AIDS; i++) {
|
||||
if (madGetAID(s0->mad.aid[i], false) == aid) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int DetectHID(const mad1_sector_t *s0, uint16_t manufacture) {
|
||||
return mad_find_aid(s0, manufacture);
|
||||
}
|
||||
|
||||
int convert_mad_to_arr(const mad1_sector_t *s0, const mad2_sector_t *s16, size_t dump_len, uint8_t *out, size_t omax, size_t *olen, bool override) {
|
||||
|
||||
if (s0 == NULL || out == NULL || olen == NULL || dump_len < sizeof(mad1_sector_t) || omax == 0) {
|
||||
|
||||
@@ -114,6 +114,14 @@ int MADDFDecodeAndPrint(uint32_t short_aid, bool verbose);
|
||||
int MADCardHolderInfoDecode(const uint8_t *data, size_t datalen, bool verbose);
|
||||
void MADPrintHeader(void);
|
||||
bool HasMADKey(const mad1_sector_t *s0);
|
||||
// First sector carrying this AID, 1..15, or -1. The MAD is how an application
|
||||
// says which sectors are its own, so every dump parser that keys off an AID
|
||||
// wants this.
|
||||
int mad_find_aid(const mad1_sector_t *s0, uint16_t aid);
|
||||
|
||||
// Count of sectors carrying this AID
|
||||
int mad_count_aid(const mad1_sector_t *s0, uint16_t aid);
|
||||
|
||||
int DetectHID(const mad1_sector_t *s0, uint16_t manufacture);
|
||||
int convert_mad_to_arr(const mad1_sector_t *s0, const mad2_sector_t *s16,
|
||||
size_t dump_len,
|
||||
|
||||
Reference in new issue
Block a user