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

This commit is contained in:
vratiskol 2019-03-21 20:46:56 +01:00
commit 3b06c9d8ee
13 changed files with 56 additions and 56 deletions

View file

@ -807,8 +807,8 @@ void e_MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *dat
struct Crypto1State *pcs;
pcs = &mpcs;
byte_t dataoutbuf[16];
byte_t dataoutbuf2[16];
uint8_t dataoutbuf[16];
uint8_t dataoutbuf2[16];
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
@ -1006,7 +1006,7 @@ int saMifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *data
uint8_t wipeC[] = {0x41};
// variables
byte_t isOK = 0;
uint8_t isOK = 0;
uint8_t d_block[18] = {0x00};
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];

View file

@ -59,7 +59,7 @@ static int saMifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_
uint8_t wipeC[] = {0x41};
// variables
byte_t isOK = 0;
uint8_t isOK = 0;
uint8_t d_block[18] = {0x00};
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];

View file

@ -769,16 +769,16 @@ void UsbPacketReceived(uint8_t *packet, int len) {
SniffHitag(c->arg[0]);
break;
case CMD_SIMULATE_HITAG: // Simulate Hitag tag, args = memory content
SimulateHitagTag((bool)c->arg[0], (byte_t *)c->d.asBytes);
SimulateHitagTag((bool)c->arg[0], c->d.asBytes);
break;
case CMD_READER_HITAG: // Reader for Hitag tags, args = type and function
ReaderHitag((hitag_function)c->arg[0], (hitag_data *)c->d.asBytes);
break;
case CMD_SIMULATE_HITAG_S:// Simulate Hitag s tag, args = memory content
SimulateHitagSTag((bool)c->arg[0], (byte_t *)c->d.asBytes);
SimulateHitagSTag((bool)c->arg[0], c->d.asBytes);
break;
case CMD_TEST_HITAGS_TRACES:// Tests every challenge within the given file
check_challenges((bool)c->arg[0], (byte_t *)c->d.asBytes);
check_challenges((bool)c->arg[0], c->d.asBytes);
break;
case CMD_READ_HITAG_S: //Reader for only Hitag S tags, args = key or challenge
ReadHitagS((hitag_function)c->arg[0], (hitag_data *)c->d.asBytes);

View file

@ -19,7 +19,7 @@
static bool bQuiet;
static bool bSuccessful;
static struct hitagS_tag tag;
static byte_t page_to_be_written = 0;
static uint8_t page_to_be_written = 0;
static int block_data_left = 0;
typedef enum modulation {
@ -33,7 +33,7 @@ static MOD m = AC2K; // used modulation
static uint32_t temp_uid;
static int temp2 = 0;
static int sof_bits; // number of start-of-frame bits
static byte_t pwdh0, pwdl0, pwdl1; // password bytes
static uint8_t pwdh0, pwdl0, pwdl1; // password bytes
static uint32_t rnd = 0x74124485; // randomnumber
static int test = 0;
size_t blocknr;

View file

@ -2012,7 +2012,7 @@ static int GetATQA(uint8_t *resp, uint8_t *resp_par) {
// if anticollision is false, then the UID must be provided in uid_ptr[]
// and num_cascades must be set (1: 4 Byte UID, 2: 7 Byte UID, 3: 10 Byte UID)
// requests ATS unless no_rats is true
int iso14443a_select_card(byte_t *uid_ptr, iso14a_card_select_t *p_card, uint32_t *cuid_ptr, bool anticollision, uint8_t num_cascades, bool no_rats) {
int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32_t *cuid_ptr, bool anticollision, uint8_t num_cascades, bool no_rats) {
uint8_t sel_all[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x20 };
uint8_t sel_uid[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

View file

@ -46,8 +46,8 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
ui64Key = bytes_to_num(datain, 6);
// variables
byte_t isOK = 0;
byte_t dataoutbuf[16] = {0x00};
uint8_t isOK = 0;
uint8_t dataoutbuf[16] = {0x00};
uint8_t uid[10] = {0x00};
uint32_t cuid = 0;
struct Crypto1State mpcs = {0, 0};
@ -137,7 +137,7 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes) {
// datain = PWD bytes,
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
uint8_t blockNo = arg0;
byte_t dataout[16] = {0x00};
uint8_t dataout[16] = {0x00};
bool useKey = (arg1 == 1); //UL_C
bool usePwd = (arg1 == 2); //UL_EV1/NTAG
@ -206,8 +206,8 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
ui64Key = bytes_to_num(datain, 6);
// variables
byte_t isOK = 0;
byte_t dataoutbuf[16 * 16];
uint8_t isOK = 0;
uint8_t dataoutbuf[16 * 16];
uint8_t uid[10] = {0x00};
uint32_t cuid = 0;
struct Crypto1State mpcs = {0, 0};
@ -368,13 +368,13 @@ void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
uint8_t blockNo = arg0;
uint8_t keyType = arg1;
uint64_t ui64Key = 0;
byte_t blockdata[16] = {0x00};
uint8_t blockdata[16] = {0x00};
ui64Key = bytes_to_num(datain, 6);
memcpy(blockdata, datain + 10, 16);
// variables
byte_t isOK = 0;
uint8_t isOK = 0;
uint8_t uid[10] = {0x00};
uint32_t cuid = 0;
struct Crypto1State mpcs = {0, 0};
@ -430,7 +430,7 @@ void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
void MifareUWriteBlockCompat(uint8_t arg0, uint8_t *datain)
{
uint8_t blockNo = arg0;
byte_t blockdata[16] = {0x00};
uint8_t blockdata[16] = {0x00};
memcpy(blockdata, datain, 16);
@ -477,7 +477,7 @@ void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
uint8_t blockNo = arg0;
bool useKey = (arg1 == 1); //UL_C
bool usePwd = (arg1 == 2); //UL_EV1/NTAG
byte_t blockdata[4] = {0x00};
uint8_t blockdata[4] = {0x00};
memcpy(blockdata, datain, 4);
@ -539,7 +539,7 @@ void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
void MifareUSetPwd(uint8_t arg0, uint8_t *datain) {
uint8_t pwd[16] = {0x00};
byte_t blockdata[4] = {0x00};
uint8_t blockdata[4] = {0x00};
memcpy(pwd, datain, 16);
@ -1630,7 +1630,7 @@ void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain) {
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
byte_t buf[USB_CMD_DATA_SIZE] = {0x00};
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
LED_B_ON();
@ -1652,8 +1652,8 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
pcs = &mpcs;
// variables
byte_t dataoutbuf[16] = {0x00};
byte_t dataoutbuf2[16] = {0x00};
uint8_t dataoutbuf[16] = {0x00};
uint8_t dataoutbuf2[16] = {0x00};
uint8_t uid[10] = {0x00};
LED_A_ON();
@ -2053,7 +2053,7 @@ void MifareSetMod(uint8_t mod, uint8_t *key) {
// DESFIRE
//
void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain) {
byte_t dataout[12] = {0x00};
uint8_t dataout[12] = {0x00};
uint8_t uid[10] = {0x00};
uint32_t cuid = 0;
@ -2081,8 +2081,8 @@ void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain) {
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain) {
uint32_t cuid = arg0;
uint8_t key[16] = {0x00};
byte_t dataout[12] = {0x00};
byte_t isOK = 0;
uint8_t dataout[12] = {0x00};
uint8_t isOK = 0;
memcpy(key, datain, 16);

View file

@ -384,7 +384,7 @@ int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t bl
uint16_t len = 0;
uint32_t pos = 0;
uint8_t par[3] = {0x00, 0x00, 0x00}; // enough for 18 Bytes to send
byte_t res = 0;
uint8_t res = 0;
uint8_t d_block[18], d_block_enc[18];
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};

View file

@ -16,11 +16,11 @@ extern char _bootrom_start, _bootrom_end, _flash_start, _flash_end;
extern uint32_t _osimage_entry;
void DbpString(char *str) {
byte_t len = 0;
uint8_t len = 0;
while (str[len] != 0x00)
len++;
cmd_send(CMD_DEBUG_PRINT_STRING, len, 0, 0, (byte_t *)str, len);
cmd_send(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len);
}
static void ConfigClocks(void) {

View file

@ -54,12 +54,12 @@ local function parse14443a(data)
Based on this struct :
typedef struct {
byte_t uid[10];
byte_t uidlen;
byte_t atqa[2];
byte_t sak;
byte_t ats_len;
byte_t ats[256];
uint8_t uid[10];
uint8_t uidlen;
uint8_t atqa[2];
uint8_t sak;
uint8_t ats_len;
uint8_t ats[256];
} __attribute__((__packed__)) iso14a_card_select_t;
--]]

View file

@ -31,11 +31,11 @@ local function parse1443b(data)
Based on this struct :
typedef struct {
byte_t uid[10];
byte_t uidlen;
byte_t atqb[7];
byte_t chipid;
byte_t cid;
uint8_t uid[10];
uint8_t uidlen;
uint8_t atqb[7];
uint8_t chipid;
uint8_t cid;
} __attribute__((__packed__)) iso14b_card_select_t;
--]]

View file

@ -612,7 +612,7 @@ bool usb_poll_validate_length() {
//* \fn usb_read
//* \brief Read available data from Endpoint 1 OUT (host to device)
//*----------------------------------------------------------------------------
uint32_t usb_read(byte_t *data, size_t len) {
uint32_t usb_read(uint8_t *data, size_t len) {
if (len == 0) return 0;
@ -650,7 +650,7 @@ uint32_t usb_read(byte_t *data, size_t len) {
//* \fn usb_write
//* \brief Send through endpoint 2 (device to host)
//*----------------------------------------------------------------------------
uint32_t usb_write(const byte_t *data, const size_t len) {
uint32_t usb_write(const uint8_t *data, const size_t len) {
if (!len) return 0;
if (!usb_check()) return 0;
@ -773,7 +773,7 @@ void AT91F_USB_SendStall(AT91PS_UDP pUdp) {
//* 2. mixed with CDC ACM endpoint3 , interrupt, control endpoint
//*----------------------------------------------------------------------------
void AT91F_CDC_Enumerate() {
byte_t bmRequestType, bRequest;
uint8_t bmRequestType, bRequest;
uint16_t wValue, wIndex, wLength, wStatus;
if (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_RXSETUP))

View file

@ -46,8 +46,8 @@ extern void usb_enable();
extern bool usb_check();
extern bool usb_poll();
extern bool usb_poll_validate_length();
extern uint32_t usb_read(byte_t *data, size_t len);
extern uint32_t usb_write(const byte_t *data, const size_t len);
extern uint32_t usb_read(uint8_t *data, size_t len);
extern uint32_t usb_write(const uint8_t *data, const size_t len);
extern void SetUSBreconnect(int value);
extern int GetUSBreconnect(void);

View file

@ -23,12 +23,12 @@
// ISO 14443A
//-----------------------------------------------------------------------------
typedef struct {
byte_t uid[10];
byte_t uidlen;
byte_t atqa[2];
byte_t sak;
byte_t ats_len;
byte_t ats[256];
uint8_t uid[10];
uint8_t uidlen;
uint8_t atqa[2];
uint8_t sak;
uint8_t ats_len;
uint8_t ats[256];
} __attribute__((__packed__)) iso14a_card_select_t;
typedef enum ISO14A_COMMAND {
@ -57,11 +57,11 @@ typedef struct {
// ISO 14443B
//-----------------------------------------------------------------------------
typedef struct {
byte_t uid[10];
byte_t uidlen;
byte_t atqb[7];
byte_t chipid;
byte_t cid;
uint8_t uid[10];
uint8_t uidlen;
uint8_t atqb[7];
uint8_t chipid;
uint8_t cid;
} __attribute__((__packed__)) iso14b_card_select_t;
typedef enum ISO14B_COMMAND {