1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // Command: hf mf list. It shows data from arm buffer.
17 //-----------------------------------------------------------------------------
22 #include "mifare/mifaredefault.h" // mifare consts
26 uint32_t nt
; // tag challenge
27 uint32_t nt_enc
; // encrypted tag challenge
28 uint8_t nt_enc_par
; // encrypted tag challenge parity
29 uint32_t nr_enc
; // encrypted reader challenge
30 uint8_t nr_enc_par
; // encrypted reader challenge parity
31 uint32_t ar_enc
; // encrypted reader response
32 uint8_t ar_enc_par
; // encrypted reader response parity
33 uint32_t at_enc
; // encrypted tag response
34 uint8_t at_enc_par
; // encrypted tag response parity
35 bool first_auth
; // is first authentication
36 uint32_t ks2
; // ar ^ ar_enc
37 uint32_t ks3
; // at ^ at_enc
38 uint8_t mem
[MIFARE_4K_MAX_BYTES
];
41 void ClearAuthData(void);
43 uint8_t iso14443A_CRC_check(bool isResponse
, uint8_t *d
, uint8_t n
);
44 uint8_t iso14443B_CRC_check(uint8_t *d
, uint8_t n
);
45 uint8_t felica_CRC_check(uint8_t *d
, uint8_t n
);
46 uint8_t mifare_CRC_check(bool isResponse
, uint8_t *data
, uint8_t len
);
47 uint8_t iso15693_CRC_check(uint8_t *d
, uint8_t n
);
48 uint8_t iclass_CRC_check(bool isResponse
, uint8_t *d
, uint8_t n
);
50 int applyIso14443a(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
, bool is_response
);
52 void annotateIclass(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
, bool isResponse
);
53 void annotateIso15693(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
54 void annotateTopaz(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
55 void annotateLegic(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
56 void annotateFelica(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
57 void annotateIso7816(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
58 void annotateIso14443b(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
59 void annotateIso14443a(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
, bool is_response
);
60 void annotateMfDesfire(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
61 const char *mfpGetAnnotationForCode(uint8_t code
);
62 const char *mfpGetEncryptedForCode(uint8_t code
);
63 const char *mfpGetResponseMacedForCode(uint8_t code
);
64 const char *mfpGetCommandMacedForCode(uint8_t code
);
65 void annotateMfPlus(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
66 void annotateMifare(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
,
67 const uint8_t *parity
, uint8_t paritysize
, bool isResponse
);
68 void annotateLTO(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
69 void annotateCryptoRF(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
71 void annotateSeos(char *exp
, size_t size
, uint8_t *cmd
, uint8_t cmdsize
);
73 bool DecodeMifareData(uint8_t *cmd
, uint8_t cmdsize
, uint8_t *parity
, bool isResponse
, uint8_t *mfData
, size_t *mfDataLen
, const uint64_t *dicKeys
, uint32_t dicKeysCount
);
74 bool NTParityChk(AuthData_t
*ad
, uint32_t ntx
);
75 bool NestedCheckKey(uint64_t key
, AuthData_t
*ad
, uint8_t *cmd
, uint8_t cmdsize
, uint8_t *parity
);
76 bool CheckCrypto1Parity(const uint8_t *cmd_enc
, uint8_t cmdsize
, uint8_t *cmd
, const uint8_t *parity_enc
);
77 uint64_t GetCrypto1ProbableKey(AuthData_t
*ad
);