diff options
Diffstat (limited to 'easytool/mifare_classic.c')
-rw-r--r-- | easytool/mifare_classic.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/easytool/mifare_classic.c b/easytool/mifare_classic.c new file mode 100644 index 0000000..e516631 --- /dev/null +++ b/easytool/mifare_classic.c @@ -0,0 +1,29 @@ +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "mifare_classic.h" + +void mfcl_parse_acc_bits(struct acc_bits_parsed *abp, uint8_t *acc_bits) +{ + uint8_t c1, c2, c3; + uint8_t block; + + memset(abp, 0, sizeof(*abp)); + + c1 = acc_bits[1] >> 4; + c2 = acc_bits[2] & 0xf; + c3 = acc_bits[2] >> 4; + + printf("C1 = %x, C2 = %x, C3 = %x\n", c1, c2, c3); + + for (block = 0; block < 4; block++) { + uint8_t testbit = 1 << block; + if (c1 & testbit) + abp->block[block] |= ABP_C1; + if (c2 & testbit) + abp->block[block] |= ABP_C2; + if (c3 & testbit) + abp->block[block] |= ABP_C3; + } +} |