2019-03-09 15:49:41 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-06 18:24:04 +08:00
|
|
|
// Copyright (C) Gerhard de Koning Gans - May 2008
|
2022-01-06 09:19:46 +08:00
|
|
|
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
2019-03-09 15:49:41 +08:00
|
|
|
//
|
2022-01-06 09:19:46 +08:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// See LICENSE.txt for the text of the license.
|
2019-03-09 15:49:41 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef __MIFARECMD_H
|
|
|
|
#define __MIFARECMD_H
|
|
|
|
|
|
|
|
#include "common.h"
|
2019-08-08 22:57:33 +08:00
|
|
|
|
2023-07-03 22:04:57 +08:00
|
|
|
int16_t mifare_cmd_readblocks(uint8_t key_auth_cmd, uint8_t *key, uint8_t read_cmd, uint8_t block_no, uint8_t count, uint8_t *block_data);
|
|
|
|
int16_t mifare_cmd_writeblocks(uint8_t key_auth_cmd, uint8_t *key, uint8_t write_cmd, uint8_t block_no, uint8_t count, uint8_t *block_data);
|
|
|
|
void MifareReadSector(uint8_t sector_no, uint8_t key_type, uint8_t *key);
|
|
|
|
void MifareValue(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
2019-08-08 22:57:33 +08:00
|
|
|
|
|
|
|
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
|
|
|
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes);
|
|
|
|
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
|
2020-09-08 03:34:44 +08:00
|
|
|
void MifareUWriteBlockCompat(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
2019-10-03 22:15:47 +08:00
|
|
|
|
2023-07-03 22:04:57 +08:00
|
|
|
void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8_t targetKeyType, bool calibrate, uint8_t *key);
|
2020-01-14 23:00:31 +08:00
|
|
|
void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8_t targetKeyType, uint8_t *key);
|
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *datain);
|
|
|
|
void MifareAcquireNonces(uint32_t arg0, uint32_t flags);
|
2020-08-31 09:04:32 +08:00
|
|
|
void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem);
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
2020-01-22 20:11:20 +08:00
|
|
|
void MifareChkKeys_file(uint8_t *fn);
|
2019-08-08 22:57:33 +08:00
|
|
|
|
|
|
|
void MifareEMemClr(void);
|
|
|
|
void MifareEMemSet(uint8_t blockno, uint8_t blockcnt, uint8_t blockwidth, uint8_t *datain);
|
|
|
|
void MifareEMemGet(uint8_t blockno, uint8_t blockcnt);
|
2019-08-29 03:23:31 +08:00
|
|
|
int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype);
|
2019-12-31 04:31:59 +08:00
|
|
|
int MifareECardLoadExt(uint8_t sectorcnt, uint8_t keytype);
|
2019-08-08 22:57:33 +08:00
|
|
|
|
2023-03-22 02:49:52 +08:00
|
|
|
// MFC GEN1a /1b
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); // Work with "magic Chinese" card
|
|
|
|
void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain);
|
2020-09-23 18:25:30 +08:00
|
|
|
void MifareCIdent(bool is_mfc); // is "magic chinese" card?
|
2020-05-10 22:59:38 +08:00
|
|
|
void MifareHasStaticNonce(void); // Has the tag a static nonce?
|
2019-08-08 22:57:33 +08:00
|
|
|
|
2023-03-22 02:49:52 +08:00
|
|
|
// MFC GEN3
|
2020-09-06 03:32:11 +08:00
|
|
|
int DoGen3Cmd(uint8_t *cmd, uint8_t cmd_len);
|
|
|
|
void MifareGen3UID(uint8_t uidlen, uint8_t *uid); // Gen 3 magic card set UID without manufacturer block
|
|
|
|
void MifareGen3Blk(uint8_t block_len, uint8_t *block); // Gen 3 magic card overwrite manufacturer block
|
|
|
|
void MifareGen3Freez(void); // Gen 3 magic card lock further UID changes
|
|
|
|
|
2021-12-31 16:24:10 +08:00
|
|
|
// MFC GEN4 GTU
|
2022-11-09 22:49:07 +08:00
|
|
|
void MifareG4ReadBlk(uint8_t blockno, uint8_t *pwd, uint8_t workFlags);
|
|
|
|
void MifareG4WriteBlk(uint8_t blockno, uint8_t *pwd, uint8_t *data, uint8_t workFlags);
|
2021-06-24 20:59:33 +08:00
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareSetMod(uint8_t *datain);
|
2020-03-09 18:02:26 +08:00
|
|
|
void MifarePersonalizeUID(uint8_t keyType, uint8_t perso_option, uint64_t key);
|
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
void MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
2020-05-10 22:59:38 +08:00
|
|
|
void OnSuccessMagic(void);
|
2019-08-08 22:57:33 +08:00
|
|
|
void OnErrorMagic(uint8_t reason);
|
|
|
|
|
|
|
|
int32_t dist_nt(uint32_t nt1, uint32_t nt2);
|
|
|
|
//void RAMFUNC SniffMifare(uint8_t param);
|
|
|
|
|
|
|
|
void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain);
|
|
|
|
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain);
|
|
|
|
|
2019-11-08 17:28:29 +08:00
|
|
|
// Tear-off test for MFU
|
2021-05-07 18:27:13 +08:00
|
|
|
void MifareU_Otp_Tearoff(uint8_t blno, uint32_t tearoff_time, uint8_t *data_testwrite);
|
2020-11-05 19:06:12 +08:00
|
|
|
void MifareU_Counter_Tearoff(uint8_t counter, uint32_t tearoff_time, uint8_t *datain);
|
2019-03-12 07:12:26 +08:00
|
|
|
#endif
|