Rename few USB -> PM3 to avoid misleading interpretations
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "standalone.h" // standalone definitions
|
||||
#include "apps.h" // debugstatements, lfops?
|
||||
#include "usb_cmd.h" // mifare1ksim flags
|
||||
#include "pm3_cmd.h" // mifare1ksim flags
|
||||
#include "mifaresim.h" // mifare1ksim
|
||||
#include "mifareutil.h"
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ void DbpStringEx(uint32_t flags, char *str) {
|
||||
#if DEBUG
|
||||
struct {
|
||||
uint16_t flag;
|
||||
uint8_t buf[USB_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||
} PACKED data;
|
||||
data.flag = flags;
|
||||
uint16_t len = MIN(strlen(str), sizeof(data.buf));
|
||||
@@ -333,8 +333,8 @@ extern struct version_information version_information;
|
||||
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
||||
extern char *_bootphase1_version_pointer, _flash_start, _flash_end, _bootrom_start, _bootrom_end, __data_src_start__;
|
||||
void SendVersion(void) {
|
||||
char temp[USB_CMD_DATA_SIZE]; /* Limited data payload in USB packets */
|
||||
char VersionString[USB_CMD_DATA_SIZE] = { '\0' };
|
||||
char temp[PM3_CMD_DATA_SIZE]; /* Limited data payload in USB packets */
|
||||
char VersionString[PM3_CMD_DATA_SIZE] = { '\0' };
|
||||
|
||||
/* Try to find the bootrom version information. Expect to find a pointer at
|
||||
* symbol _bootphase1_version_pointer, perform slight sanity checks on the
|
||||
@@ -384,9 +384,9 @@ void printUSBSpeed(void) {
|
||||
LED_B_ON();
|
||||
|
||||
while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
|
||||
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, USB_CMD_DATA_SIZE);
|
||||
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, PM3_CMD_DATA_SIZE);
|
||||
end_time = GetTickCount();
|
||||
bytes_transferred += USB_CMD_DATA_SIZE;
|
||||
bytes_transferred += PM3_CMD_DATA_SIZE;
|
||||
}
|
||||
LED_B_OFF();
|
||||
|
||||
@@ -1089,7 +1089,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
case CMD_SMART_UPLOAD: {
|
||||
// upload file from client
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
@@ -1205,8 +1205,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
// arg2 = BigBuf tracelen
|
||||
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, packet->oldarg[2]);
|
||||
|
||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
int result = reply_old(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
||||
if (result != PM3_SUCCESS)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
||||
@@ -1234,7 +1234,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
@@ -1249,8 +1249,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
// arg1 = length bytes to transfer
|
||||
// arg2 = RFU
|
||||
|
||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||
len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
int result = reply_old(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
||||
if (result != PM3_SUCCESS)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
||||
@@ -1274,7 +1274,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
|
||||
Dbprintf("FlashMem read | %d - %d | ", startidx, len);
|
||||
|
||||
size_t size = MIN(USB_CMD_DATA_SIZE, len);
|
||||
size_t size = MIN(PM3_CMD_DATA_SIZE, len);
|
||||
|
||||
if (!FlashInit()) {
|
||||
break;
|
||||
@@ -1383,7 +1383,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
case CMD_FLASHMEM_DOWNLOAD: {
|
||||
|
||||
LED_B_ON();
|
||||
uint8_t *mem = BigBuf_malloc(USB_CMD_DATA_SIZE);
|
||||
uint8_t *mem = BigBuf_malloc(PM3_CMD_DATA_SIZE);
|
||||
uint32_t startidx = packet->oldarg[0];
|
||||
uint32_t numofbytes = packet->oldarg[1];
|
||||
// arg0 = startindex
|
||||
@@ -1394,8 +1394,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
|
||||
bool isok = Flash_ReadDataCont(startidx + i, mem, len);
|
||||
if (!isok)
|
||||
|
||||
@@ -1168,7 +1168,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||
|
||||
//Use the emulator memory for SIM
|
||||
uint8_t *emulator = BigBuf_get_EM_addr();
|
||||
uint8_t mac_responses[USB_CMD_DATA_SIZE] = { 0 };
|
||||
uint8_t mac_responses[PM3_CMD_DATA_SIZE] = { 0 };
|
||||
|
||||
if (simType == 0) {
|
||||
// Use the CSN from commandline
|
||||
@@ -1188,7 +1188,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||
// in order to obtain the keys, as in the "dismantling iclass"-paper.
|
||||
#define EPURSE_MAC_SIZE 16
|
||||
int i = 0;
|
||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < USB_CMD_DATA_SIZE; i++) {
|
||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < PM3_CMD_DATA_SIZE; i++) {
|
||||
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there.
|
||||
|
||||
memcpy(emulator, datain + (i * 8), 8);
|
||||
@@ -1220,7 +1220,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||
// attack below is same as SIM 2, but we run the CSN twice to collected the mac for both keys.
|
||||
int i = 0;
|
||||
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there. iceman fork uses 9 CSNS
|
||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < USB_CMD_DATA_SIZE; i++) {
|
||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < PM3_CMD_DATA_SIZE; i++) {
|
||||
|
||||
memcpy(emulator, datain + (i * 8), 8);
|
||||
|
||||
@@ -2110,7 +2110,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||
uint8_t mem = 0;
|
||||
uint8_t check[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t read[] = { 0x0c, 0x00, 0x00, 0x00 };
|
||||
uint8_t card_data[USB_CMD_DATA_SIZE] = {0};
|
||||
uint8_t card_data[PM3_CMD_DATA_SIZE] = {0};
|
||||
uint8_t resp[ICLASS_BUFFER_SIZE] = {0};
|
||||
|
||||
static struct memory_t {
|
||||
@@ -2158,7 +2158,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||
|
||||
WDT_HIT();
|
||||
//Set card_data to all zeroes, we'll fill it with data
|
||||
memset(card_data, 0x0, USB_CMD_DATA_SIZE);
|
||||
memset(card_data, 0x0, PM3_CMD_DATA_SIZE);
|
||||
uint8_t failedRead = 0;
|
||||
uint32_t stored_data_length = 0;
|
||||
|
||||
@@ -2178,7 +2178,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||
//Fill up the buffer
|
||||
memcpy(card_data + stored_data_length, resp, 8);
|
||||
stored_data_length += 8;
|
||||
if (stored_data_length + 8 > USB_CMD_DATA_SIZE) {
|
||||
if (stored_data_length + 8 > PM3_CMD_DATA_SIZE) {
|
||||
//Time to send this off and start afresh
|
||||
reply_old(CMD_ACK,
|
||||
stored_data_length,//data length
|
||||
|
||||
@@ -2406,7 +2406,7 @@ void ReaderIso14443a(PacketCommandNG *c) {
|
||||
uint32_t timeout = c->oldarg[2];
|
||||
uint8_t *cmd = c->data.asBytes;
|
||||
uint32_t arg0;
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t par[MAX_PARITY_SIZE] = {0x00};
|
||||
|
||||
if ((param & ISO14A_CONNECT))
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "usb_cmd.h"
|
||||
#include "pm3_cmd.h"
|
||||
#include "cmd.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -1573,7 +1573,7 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||
uint8_t *cmd = c->data.asBytes;
|
||||
uint8_t status;
|
||||
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
if (MF_DBGLEVEL > 3) Dbprintf("14b raw: param, %04x", param);
|
||||
|
||||
@@ -1621,7 +1621,7 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||
CodeAndTransmit14443bAsReader(cmd, len); // raw
|
||||
GetTagSamplesFor14443bDemod(); // raw
|
||||
|
||||
sendlen = MIN(Demod.len, USB_CMD_DATA_SIZE);
|
||||
sendlen = MIN(Demod.len, PM3_CMD_DATA_SIZE);
|
||||
status = (Demod.len > 0) ? 0 : 1;
|
||||
reply_old(CMD_ACK, status, sendlen, 0, Demod.output, sendlen);
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
|
||||
uint8_t uid[10] = {0x00};
|
||||
uint8_t answer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t par[1] = {0x00};
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
uint32_t cuid = 0;
|
||||
int16_t isOK = 0;
|
||||
uint16_t num_nonces = 0;
|
||||
@@ -645,7 +645,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
|
||||
|
||||
LED_C_ON();
|
||||
|
||||
for (uint16_t i = 0; i <= USB_CMD_DATA_SIZE - 4; i += 4) {
|
||||
for (uint16_t i = 0; i <= PM3_CMD_DATA_SIZE - 4; i += 4) {
|
||||
|
||||
// Test if the action was cancelled
|
||||
if (BUTTON_PRESS()) {
|
||||
@@ -733,7 +733,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||
uint8_t uid[10] = {0x00};
|
||||
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||
uint8_t par_enc[1] = {0x00};
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
uint64_t ui64Key = bytes_to_num(datain, 6);
|
||||
uint32_t cuid = 0;
|
||||
@@ -763,7 +763,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||
|
||||
LED_C_ON();
|
||||
|
||||
for (uint16_t i = 0; i <= USB_CMD_DATA_SIZE - 9;) {
|
||||
for (uint16_t i = 0; i <= PM3_CMD_DATA_SIZE - 9;) {
|
||||
|
||||
// Test if the action was cancelled
|
||||
if (BUTTON_PRESS()) {
|
||||
@@ -1645,11 +1645,11 @@ 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);
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
|
||||
|
||||
LED_B_ON();
|
||||
reply_old(CMD_ACK, arg0, arg1, 0, buf, USB_CMD_DATA_SIZE);
|
||||
reply_old(CMD_ACK, arg0, arg1, 0, buf, PM3_CMD_DATA_SIZE);
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
@@ -1949,7 +1949,7 @@ void MifareCIdent() {
|
||||
uint8_t recpar[1] = {0x00};
|
||||
uint8_t rats[4] = { ISO14443A_CMD_RATS, 0x80, 0x31, 0x73 };
|
||||
uint8_t *par = BigBuf_malloc(MAX_PARITY_SIZE);
|
||||
uint8_t *buf = BigBuf_malloc(USB_CMD_DATA_SIZE);
|
||||
uint8_t *buf = BigBuf_malloc(PM3_CMD_DATA_SIZE);
|
||||
uint8_t *uid = BigBuf_malloc(10);
|
||||
uint32_t cuid = 0;
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ void MifareDesfireGetInformation() {
|
||||
|
||||
int len = 0;
|
||||
iso14a_card_select_t card;
|
||||
uint8_t resp[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t dataout[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t resp[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t dataout[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
/*
|
||||
1 = PCB 1
|
||||
@@ -505,7 +505,7 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout) {
|
||||
|
||||
size_t len = 0;
|
||||
size_t wrappedLen = 0;
|
||||
uint8_t wCmd[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t wCmd[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t resp[MAX_FRAME_SIZE];
|
||||
uint8_t par[MAX_PARITY_SIZE];
|
||||
|
||||
@@ -537,7 +537,7 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout) {
|
||||
// CreateAPDU
|
||||
size_t CreateAPDU(uint8_t *datain, size_t len, uint8_t *dataout) {
|
||||
|
||||
size_t cmdlen = MIN(len + 4, USB_CMD_DATA_SIZE - 1);
|
||||
size_t cmdlen = MIN(len + 4, PM3_CMD_DATA_SIZE - 1);
|
||||
|
||||
uint8_t cmd[cmdlen];
|
||||
memset(cmd, 0, cmdlen);
|
||||
|
||||
@@ -315,7 +315,7 @@ void RAMFUNC MfSniffSend() {
|
||||
|
||||
while (packlen > 0) {
|
||||
LED_B_ON();
|
||||
chunksize = MIN(USB_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||
chunksize = MIN(PM3_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||
reply_old(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||
packlen -= chunksize;
|
||||
LED_B_OFF();
|
||||
|
||||
Reference in New Issue
Block a user