mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
style
This commit is contained in:
parent
faf68081b0
commit
2400418067
|
@ -85,7 +85,8 @@ static const uint8_t is_hex[] = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static inline uint64_t hex2i(const char *s) {
|
||||
uint64_t val = 0;
|
||||
|
@ -333,41 +334,41 @@ void RunMod() {
|
|||
uint64_t key64; // Defines current key
|
||||
uint8_t *keyBlock; // Where the keys will be held in memory.
|
||||
|
||||
/* VIGIK EXPIRED DUMP FOR STUDY
|
||||
Sector 0
|
||||
121C7F730208040001FA33F5CB2D021D
|
||||
44001049164916491649000000000000
|
||||
00000000000000000000000000000000
|
||||
A0A1A2A3A4A579678800010203040506
|
||||
Sector 1
|
||||
0F000000000000000000000000000000
|
||||
AA0700002102080000740C110600AF13
|
||||
000000000000000001740C1108220000
|
||||
314B4947495679678800010203040506
|
||||
Sector 2
|
||||
24E572B923A3D243B402D60CAB576956
|
||||
216D6501FC8618B6C426762511AC2DEE
|
||||
25BF4CEC3618D0BAB3A6E9210D887746
|
||||
314B4947495679678800010203040506
|
||||
Sector 3
|
||||
0FBC41A5D95398E76A1B2029E8EA9735
|
||||
088BA2CE732653D0C1147596AFCF94D7
|
||||
77B4D91F0442182273A29DEAF7A2D095
|
||||
314B4947495679678800010203040506
|
||||
Sector 4
|
||||
4CEE715866E508CDBC95C640EC9D1E58
|
||||
E800457CF8B079414E1B45DD3E6C9317
|
||||
77B4D91F0442182273A29DEAF7A2D095
|
||||
314B4947495679678800010203040506
|
||||
010203040506 0
|
||||
Sector 5-0F
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
FFFFFFFFFFFFFF078069FFFFFFFFFFFF
|
||||
KEY A : 1KGIV ;
|
||||
ACCBITS : 796788[00]+VALUE
|
||||
*/
|
||||
/* VIGIK EXPIRED DUMP FOR STUDY
|
||||
Sector 0
|
||||
121C7F730208040001FA33F5CB2D021D
|
||||
44001049164916491649000000000000
|
||||
00000000000000000000000000000000
|
||||
A0A1A2A3A4A579678800010203040506
|
||||
Sector 1
|
||||
0F000000000000000000000000000000
|
||||
AA0700002102080000740C110600AF13
|
||||
000000000000000001740C1108220000
|
||||
314B4947495679678800010203040506
|
||||
Sector 2
|
||||
24E572B923A3D243B402D60CAB576956
|
||||
216D6501FC8618B6C426762511AC2DEE
|
||||
25BF4CEC3618D0BAB3A6E9210D887746
|
||||
314B4947495679678800010203040506
|
||||
Sector 3
|
||||
0FBC41A5D95398E76A1B2029E8EA9735
|
||||
088BA2CE732653D0C1147596AFCF94D7
|
||||
77B4D91F0442182273A29DEAF7A2D095
|
||||
314B4947495679678800010203040506
|
||||
Sector 4
|
||||
4CEE715866E508CDBC95C640EC9D1E58
|
||||
E800457CF8B079414E1B45DD3E6C9317
|
||||
77B4D91F0442182273A29DEAF7A2D095
|
||||
314B4947495679678800010203040506
|
||||
010203040506 0
|
||||
Sector 5-0F
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
FFFFFFFFFFFFFF078069FFFFFFFFFFFF
|
||||
KEY A : 1KGIV ;
|
||||
ACCBITS : 796788[00]+VALUE
|
||||
*/
|
||||
|
||||
//----------------------------
|
||||
// Set of keys to be used.
|
||||
|
@ -702,18 +703,18 @@ readysim:
|
|||
|
||||
uint16_t flags;
|
||||
switch (p_card.uidlen) {
|
||||
case 10:
|
||||
flags = FLAG_10B_UID_IN_DATA;
|
||||
break;
|
||||
case 7:
|
||||
flags = FLAG_7B_UID_IN_DATA;
|
||||
break;
|
||||
case 4:
|
||||
flags = FLAG_4B_UID_IN_DATA;
|
||||
break;
|
||||
default:
|
||||
flags = FLAG_UID_IN_EMUL;
|
||||
break;
|
||||
case 10:
|
||||
flags = FLAG_10B_UID_IN_DATA;
|
||||
break;
|
||||
case 7:
|
||||
flags = FLAG_7B_UID_IN_DATA;
|
||||
break;
|
||||
case 4:
|
||||
flags = FLAG_4B_UID_IN_DATA;
|
||||
break;
|
||||
default:
|
||||
flags = FLAG_UID_IN_EMUL;
|
||||
break;
|
||||
}
|
||||
|
||||
// Use UID, SAK, ATQA from EMUL, if uid not defined
|
||||
|
@ -1031,7 +1032,7 @@ int saMifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *data
|
|||
}
|
||||
|
||||
if ((mifare_sendcmd_short(NULL, 0, 0xA0, blockNo, receivedAnswer, receivedAnswerPar, NULL) != 1) ||
|
||||
(receivedAnswer[0] != 0x0a)) {
|
||||
(receivedAnswer[0] != 0x0a)) {
|
||||
DbprintfEx(FLAG_NEWLINE, "write block send command error");
|
||||
break;
|
||||
};
|
||||
|
|
2052
armsrc/frozen.c
2052
armsrc/frozen.c
File diff suppressed because it is too large
Load diff
|
@ -36,18 +36,18 @@ enum { false = 0, true = 1 };
|
|||
|
||||
/* JSON token type */
|
||||
enum json_token_type {
|
||||
JSON_TYPE_INVALID = 0, /* memsetting to 0 should create INVALID value */
|
||||
JSON_TYPE_STRING,
|
||||
JSON_TYPE_NUMBER,
|
||||
JSON_TYPE_TRUE,
|
||||
JSON_TYPE_FALSE,
|
||||
JSON_TYPE_NULL,
|
||||
JSON_TYPE_OBJECT_START,
|
||||
JSON_TYPE_OBJECT_END,
|
||||
JSON_TYPE_ARRAY_START,
|
||||
JSON_TYPE_ARRAY_END,
|
||||
JSON_TYPE_INVALID = 0, /* memsetting to 0 should create INVALID value */
|
||||
JSON_TYPE_STRING,
|
||||
JSON_TYPE_NUMBER,
|
||||
JSON_TYPE_TRUE,
|
||||
JSON_TYPE_FALSE,
|
||||
JSON_TYPE_NULL,
|
||||
JSON_TYPE_OBJECT_START,
|
||||
JSON_TYPE_OBJECT_END,
|
||||
JSON_TYPE_ARRAY_START,
|
||||
JSON_TYPE_ARRAY_END,
|
||||
|
||||
JSON_TYPES_CNT
|
||||
JSON_TYPES_CNT
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -55,9 +55,9 @@ enum json_token_type {
|
|||
* `json_scanf()` with the format specifier `%T`.
|
||||
*/
|
||||
struct json_token {
|
||||
const char *ptr; /* Points to the beginning of the value */
|
||||
int len; /* Value length */
|
||||
enum json_token_type type; /* Type of the token, possible values are above */
|
||||
const char *ptr; /* Points to the beginning of the value */
|
||||
int len; /* Value length */
|
||||
enum json_token_type type; /* Type of the token, possible values are above */
|
||||
};
|
||||
|
||||
#define JSON_INVALID_TOKEN \
|
||||
|
@ -110,16 +110,16 @@ int json_walk(const char *json_string, int json_string_length,
|
|||
* struct json_out abstracts output, allowing alternative printing plugins.
|
||||
*/
|
||||
struct json_out {
|
||||
int (*printer)(struct json_out *, const char *str, size_t len);
|
||||
union {
|
||||
struct {
|
||||
char *buf;
|
||||
size_t size;
|
||||
size_t len;
|
||||
} buf;
|
||||
void *data;
|
||||
FILE *fp;
|
||||
} u;
|
||||
int (*printer)(struct json_out *, const char *str, size_t len);
|
||||
union {
|
||||
struct {
|
||||
char *buf;
|
||||
size_t size;
|
||||
size_t len;
|
||||
} buf;
|
||||
void *data;
|
||||
FILE *fp;
|
||||
} u;
|
||||
};
|
||||
|
||||
extern int json_printer_buf(struct json_out *, const char *, size_t);
|
||||
|
|
|
@ -464,7 +464,7 @@ RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_t
|
|||
}
|
||||
|
||||
|
||||
// Thinfilm, Kovio mangels ISO14443A in the way that they don't use start bit nor parity bits.
|
||||
// Thinfilm, Kovio mangels ISO14443A in the way that they don't use start bit nor parity bits.
|
||||
RAMFUNC int ManchesterDecoding_Thinfilm(uint8_t bit) {
|
||||
Demod.twoBits = (Demod.twoBits << 8) | bit;
|
||||
|
||||
|
@ -496,44 +496,44 @@ RAMFUNC int ManchesterDecoding_Thinfilm(uint8_t bit) {
|
|||
}
|
||||
} else {
|
||||
|
||||
if (IsManchesterModulationNibble1(Demod.twoBits >> Demod.syncBit)) { // modulation in first half
|
||||
if (IsManchesterModulationNibble2(Demod.twoBits >> Demod.syncBit)) { // ... and in second half = collision
|
||||
if (!Demod.collisionPos) {
|
||||
Demod.collisionPos = (Demod.len << 3) + Demod.bitCount;
|
||||
}
|
||||
} // modulation in first half only - Sequence D = 1
|
||||
if (IsManchesterModulationNibble1(Demod.twoBits >> Demod.syncBit)) { // modulation in first half
|
||||
if (IsManchesterModulationNibble2(Demod.twoBits >> Demod.syncBit)) { // ... and in second half = collision
|
||||
if (!Demod.collisionPos) {
|
||||
Demod.collisionPos = (Demod.len << 3) + Demod.bitCount;
|
||||
}
|
||||
} // modulation in first half only - Sequence D = 1
|
||||
Demod.bitCount++;
|
||||
Demod.shiftReg = (Demod.shiftReg << 1) | 0x1; // in both cases, add a 1 to the shiftreg
|
||||
if (Demod.bitCount == 8) { // if we decoded a full byte
|
||||
Demod.output[Demod.len++] = (Demod.shiftReg & 0xff);
|
||||
Demod.bitCount = 0;
|
||||
Demod.shiftReg = 0;
|
||||
}
|
||||
Demod.endTime = Demod.startTime + 8 * (8 * Demod.len + Demod.bitCount + 1) - 4;
|
||||
} else { // no modulation in first half
|
||||
if (IsManchesterModulationNibble2(Demod.twoBits >> Demod.syncBit)) { // and modulation in second half = Sequence E = 0
|
||||
Demod.bitCount++;
|
||||
Demod.shiftReg = (Demod.shiftReg << 1) | 0x1; // in both cases, add a 1 to the shiftreg
|
||||
if (Demod.bitCount == 8) { // if we decoded a full byte
|
||||
Demod.shiftReg = (Demod.shiftReg << 1); // add a 0 to the shiftreg
|
||||
if (Demod.bitCount >= 8) { // if we decoded a full byte
|
||||
Demod.output[Demod.len++] = (Demod.shiftReg & 0xff);
|
||||
Demod.bitCount = 0;
|
||||
Demod.shiftReg = 0;
|
||||
}
|
||||
Demod.endTime = Demod.startTime + 8 * (8 * Demod.len + Demod.bitCount + 1) - 4;
|
||||
} else { // no modulation in first half
|
||||
if (IsManchesterModulationNibble2(Demod.twoBits >> Demod.syncBit)) { // and modulation in second half = Sequence E = 0
|
||||
Demod.bitCount++;
|
||||
Demod.shiftReg = (Demod.shiftReg << 1); // add a 0 to the shiftreg
|
||||
if (Demod.bitCount >= 8) { // if we decoded a full byte
|
||||
Demod.output[Demod.len++] = (Demod.shiftReg & 0xff);
|
||||
Demod.bitCount = 0;
|
||||
Demod.shiftReg = 0;
|
||||
}
|
||||
Demod.endTime = Demod.startTime + 8 * (8 * Demod.len + Demod.bitCount + 1);
|
||||
} else { // no modulation in both halves - End of communication
|
||||
if (Demod.bitCount > 0) { // there are some remaining data bits
|
||||
Demod.shiftReg <<= (8 - Demod.bitCount); // left align the decoded bits
|
||||
Demod.output[Demod.len++] = Demod.shiftReg & 0xff; // and add them to the output
|
||||
return true;
|
||||
}
|
||||
if (Demod.len) {
|
||||
return true; // we are finished with decoding the raw data sequence
|
||||
} else { // nothing received. Start over
|
||||
DemodReset();
|
||||
}
|
||||
Demod.endTime = Demod.startTime + 8 * (8 * Demod.len + Demod.bitCount + 1);
|
||||
} else { // no modulation in both halves - End of communication
|
||||
if (Demod.bitCount > 0) { // there are some remaining data bits
|
||||
Demod.shiftReg <<= (8 - Demod.bitCount); // left align the decoded bits
|
||||
Demod.output[Demod.len++] = Demod.shiftReg & 0xff; // and add them to the output
|
||||
return true;
|
||||
}
|
||||
if (Demod.len) {
|
||||
return true; // we are finished with decoding the raw data sequence
|
||||
} else { // nothing received. Start over
|
||||
DemodReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // not finished yet, need more data
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
|||
Uart.len,
|
||||
Uart.startTime * 16 - DELAY_READER_AIR2ARM_AS_SNIFFER,
|
||||
Uart.endTime * 16 - DELAY_READER_AIR2ARM_AS_SNIFFER,
|
||||
Uart.parity,
|
||||
Uart.parity,
|
||||
true)) break;
|
||||
}
|
||||
/* ready to receive another command. */
|
||||
|
@ -2007,7 +2007,7 @@ bool EmLogTrace(uint8_t *reader_data, uint16_t reader_len, uint32_t reader_Start
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Kovio - Thinfilm barcode. TAG-TALK-FIRST -
|
||||
// Kovio - Thinfilm barcode. TAG-TALK-FIRST -
|
||||
// Wait a certain time for tag response
|
||||
// If a response is captured return TRUE
|
||||
// If it takes too long return FALSE
|
||||
|
@ -2041,7 +2041,7 @@ bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint8_t *rec
|
|||
// log
|
||||
LogTrace(receivedResponse, Demod.len, Demod.startTime * 16 - DELAY_AIR2ARM_AS_READER, Demod.endTime * 16 - DELAY_AIR2ARM_AS_READER, NULL, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// timeout already in ms + 10ms guard time
|
||||
|
|
1247
armsrc/nprintf.c
1247
armsrc/nprintf.c
File diff suppressed because it is too large
Load diff
|
@ -10,10 +10,10 @@
|
|||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -58,7 +58,7 @@ void _putchar(char character);
|
|||
* \return The number of characters that are written into the array, not counting the terminating null character
|
||||
*/
|
||||
#define printf printf_
|
||||
int printf_(const char* format, ...);
|
||||
int printf_(const char *format, ...);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ int printf_(const char* format, ...);
|
|||
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
|
||||
*/
|
||||
#define sprintf sprintf_
|
||||
int sprintf_(char* buffer, const char* format, ...);
|
||||
int sprintf_(char *buffer, const char *format, ...);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -84,8 +84,8 @@ int sprintf_(char* buffer, const char* format, ...);
|
|||
*/
|
||||
#define snprintf snprintf_
|
||||
#define vsnprintf vsnprintf_
|
||||
int snprintf_(char* buffer, size_t count, const char* format, ...);
|
||||
int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);
|
||||
int snprintf_(char *buffer, size_t count, const char *format, ...);
|
||||
int vsnprintf_(char *buffer, size_t count, const char *format, va_list va);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);
|
|||
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
|
||||
*/
|
||||
#define vprintf vprintf_
|
||||
int vprintf_(const char* format, va_list va);
|
||||
int vprintf_(const char *format, va_list va);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ int vprintf_(const char* format, va_list va);
|
|||
* \param format A string that specifies the format of the output
|
||||
* \return The number of characters that are sent to the output function, not counting the terminating null character
|
||||
*/
|
||||
int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...);
|
||||
int fctprintf(void (*out)(char character, void *arg), void *arg, const char *format, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
214
armsrc/string.c
214
armsrc/string.c
|
@ -197,56 +197,50 @@ char *strtok(char *s, const char *delim) {
|
|||
}
|
||||
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
char *strchr(const char *s, int c) {
|
||||
while (*s != (char)c)
|
||||
if (!*s++)
|
||||
return 0;
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
size_t strspn(const char *s1, const char *s2)
|
||||
{
|
||||
size_t ret=0;
|
||||
while(*s1 && strchr(s2,*s1++))
|
||||
size_t strspn(const char *s1, const char *s2) {
|
||||
size_t ret = 0;
|
||||
while (*s1 && strchr(s2, *s1++))
|
||||
ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strrchr(const char *s, int c)
|
||||
{
|
||||
const char* ret=0;
|
||||
do {
|
||||
if( *s == (char)c )
|
||||
ret=s;
|
||||
} while(*s++);
|
||||
return (char *)ret;
|
||||
}
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2)
|
||||
{
|
||||
size_t ret=0;
|
||||
while(*s1)
|
||||
if(strchr(s2,*s1))
|
||||
return ret;
|
||||
else
|
||||
s1++,ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strpbrk(const char *s1, const char *s2)
|
||||
{
|
||||
while(*s1)
|
||||
if(strchr(s2, *s1++))
|
||||
return (char*)--s1;
|
||||
char *strrchr(const char *s, int c) {
|
||||
const char *ret = 0;
|
||||
do {
|
||||
if (*s == (char)c)
|
||||
ret = s;
|
||||
} while (*s++);
|
||||
return (char *)ret;
|
||||
}
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2) {
|
||||
size_t ret = 0;
|
||||
while (*s1)
|
||||
if (strchr(s2, *s1))
|
||||
return ret;
|
||||
else
|
||||
s1++, ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *strpbrk(const char *s1, const char *s2) {
|
||||
while (*s1)
|
||||
if (strchr(s2, *s1++))
|
||||
return (char *)--s1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strncmp(const char* s1, const char* s2, size_t n)
|
||||
{
|
||||
while(n--)
|
||||
if(*s1++!=*s2++)
|
||||
return *(unsigned char*)(s1 - 1) - *(unsigned char*)(s2 - 1);
|
||||
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||
while (n--)
|
||||
if (*s1++ != *s2++)
|
||||
return *(unsigned char *)(s1 - 1) - *(unsigned char *)(s2 - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -255,97 +249,87 @@ int strncmp(const char* s1, const char* s2, size_t n)
|
|||
|
||||
#define isspace(a) __extension__ ({ unsigned char bb__isspace = (a) - 9; bb__isspace == (' ' - 9) || bb__isspace <= (13 - 9); })
|
||||
|
||||
unsigned long strtoul(const char *p, char **out_p, int base)
|
||||
{
|
||||
unsigned long v = 0;
|
||||
unsigned long strtoul(const char *p, char **out_p, int base) {
|
||||
unsigned long v = 0;
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if (((base == 16) || (base == 0)) &&
|
||||
((*p == '0') && ((p[1] == 'x') || (p[1] == 'X'))))
|
||||
{
|
||||
p += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
{
|
||||
if (*p == '0')
|
||||
base = 8;
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
char c = *p;
|
||||
if ((c >= '0') && (c <= '9') && (c - '0' < base))
|
||||
v = (v * base) + (c - '0');
|
||||
else if ((c >= 'a') && (c <= 'z') && (c - 'a' + 10 < base))
|
||||
v = (v * base) + (c - 'a' + 10);
|
||||
else if ((c >= 'A') && (c <= 'Z') && (c - 'A' + 10 < base))
|
||||
v = (v * base) + (c - 'A' + 10);
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if (((base == 16) || (base == 0)) &&
|
||||
((*p == '0') && ((p[1] == 'x') || (p[1] == 'X')))) {
|
||||
p += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
if (*p == '0')
|
||||
base = 8;
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
while (1) {
|
||||
char c = *p;
|
||||
if ((c >= '0') && (c <= '9') && (c - '0' < base))
|
||||
v = (v * base) + (c - '0');
|
||||
else if ((c >= 'a') && (c <= 'z') && (c - 'a' + 10 < base))
|
||||
v = (v * base) + (c - 'a' + 10);
|
||||
else if ((c >= 'A') && (c <= 'Z') && (c - 'A' + 10 < base))
|
||||
v = (v * base) + (c - 'A' + 10);
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
|
||||
if (out_p) *out_p = (char*)p;
|
||||
return v;
|
||||
if (out_p) *out_p = (char *)p;
|
||||
return v;
|
||||
}
|
||||
|
||||
long strtol(const char *p, char **out_p, int base)
|
||||
{
|
||||
long v = 0;
|
||||
int is_neg = 0;
|
||||
long strtol(const char *p, char **out_p, int base) {
|
||||
long v = 0;
|
||||
int is_neg = 0;
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if (*p == '-')
|
||||
is_neg = 1, p++;
|
||||
else if (*p == '+')
|
||||
is_neg = 0;
|
||||
if (((base == 16) || (base == 0)) &&
|
||||
((*p == '0') && ((p[1] == 'x') || (p[1] == 'X'))))
|
||||
{
|
||||
p += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
{
|
||||
if (*p == '0')
|
||||
base = 8;
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
char c = *p;
|
||||
if ((c >= '0') && (c <= '9') && (c - '0' < base))
|
||||
v = (v * base) + (c - '0');
|
||||
else if ((c >= 'a') && (c <= 'z') && (c - 'a' + 10 < base))
|
||||
v = (v * base) + (c - 'a' + 10);
|
||||
else if ((c >= 'A') && (c <= 'Z') && (c - 'A' + 10 < base))
|
||||
v = (v * base) + (c - 'A' + 10);
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
if (is_neg)
|
||||
v = -v;
|
||||
if (out_p) *out_p = (char*)p;
|
||||
return v;
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if (*p == '-')
|
||||
is_neg = 1, p++;
|
||||
else if (*p == '+')
|
||||
is_neg = 0;
|
||||
if (((base == 16) || (base == 0)) &&
|
||||
((*p == '0') && ((p[1] == 'x') || (p[1] == 'X')))) {
|
||||
p += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) {
|
||||
if (*p == '0')
|
||||
base = 8;
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
while (1) {
|
||||
char c = *p;
|
||||
if ((c >= '0') && (c <= '9') && (c - '0' < base))
|
||||
v = (v * base) + (c - '0');
|
||||
else if ((c >= 'a') && (c <= 'z') && (c - 'a' + 10 < base))
|
||||
v = (v * base) + (c - 'a' + 10);
|
||||
else if ((c >= 'A') && (c <= 'Z') && (c - 'A' + 10 < base))
|
||||
v = (v * base) + (c - 'A' + 10);
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
if (is_neg)
|
||||
v = -v;
|
||||
if (out_p) *out_p = (char *)p;
|
||||
return v;
|
||||
}
|
||||
|
||||
char c_tolower(int c)
|
||||
{
|
||||
char c_tolower(int c) {
|
||||
// (int)a = 97, (int)A = 65
|
||||
// (a)97 - (A)65 = 32
|
||||
// therefore 32 + 65 = a
|
||||
return c > 64 && c < 91 ? c + 32 : c;
|
||||
}
|
||||
|
||||
char c_isprint (unsigned char c)
|
||||
{
|
||||
if ( c >= 0x20 && c <= 0x7e )
|
||||
char c_isprint(unsigned char c) {
|
||||
if (c >= 0x20 && c <= 0x7e)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ size_t strspn(const char *s1, const char *s2);
|
|||
char *strrchr(const char *s, int c);
|
||||
size_t strcspn(const char *s1, const char *s2);
|
||||
char *strpbrk(const char *s1, const char *s2);
|
||||
int strncmp(const char * s1, const char * s2, size_t n);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
char c_tolower(int c);
|
||||
char c_isprint (unsigned char c);
|
||||
char c_isprint(unsigned char c);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,28 +27,28 @@ static int usage_thinfilm_info(void) {
|
|||
// https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-barcode.c
|
||||
static int print_barcode(uint8_t *barcode, const size_t barcode_len) {
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0] );
|
||||
PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0]);
|
||||
PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]);
|
||||
|
||||
uint8_t b1, b2;
|
||||
compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2);
|
||||
bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2);
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, " checksum : "_YELLOW_("%02X %02X")"- %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail"));
|
||||
PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"),
|
||||
sprint_hex(barcode, barcode_len)
|
||||
);
|
||||
sprint_hex(barcode, barcode_len)
|
||||
);
|
||||
|
||||
|
||||
char s[45];
|
||||
memset(s, 0x00, sizeof(s));
|
||||
|
||||
|
||||
switch (barcode[1]) {
|
||||
case 0:
|
||||
printf("Data Format Field: Reserved for allocation by tag manufacturer\n");
|
||||
return PM3_SUCCESS;
|
||||
case 1:
|
||||
snprintf(s, sizeof(s), "http://www." );
|
||||
snprintf(s, sizeof(s), "http://www.");
|
||||
break;
|
||||
case 2:
|
||||
snprintf(s, sizeof(s), "https://www.");
|
||||
|
@ -60,15 +60,15 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len) {
|
|||
snprintf(s, sizeof(s), "https://");
|
||||
break;
|
||||
case 5:
|
||||
PrintAndLogEx(SUCCESS, "EPC: %s", sprint_hex(barcode + 2, 12) );
|
||||
PrintAndLogEx(SUCCESS, "EPC: %s", sprint_hex(barcode + 2, 12));
|
||||
return PM3_SUCCESS;
|
||||
default:
|
||||
PrintAndLogEx(SUCCESS, "Data Format Field: unknown (%02X)", barcode[1]);
|
||||
PrintAndLogEx(SUCCESS, "Data:" _YELLOW_("%s"), sprint_hex(barcode + 2, barcode_len - 2) );
|
||||
PrintAndLogEx(SUCCESS, "Data:" _YELLOW_("%s"), sprint_hex(barcode + 2, barcode_len - 2));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
snprintf(s + strlen(s), barcode_len - 3, (const char*)&barcode[2] , barcode_len - 4);
|
||||
|
||||
snprintf(s + strlen(s), barcode_len - 3, (const char *)&barcode[2], barcode_len - 4);
|
||||
|
||||
for (uint8_t i = 0; i < strlen(s); i++) {
|
||||
|
||||
|
@ -108,8 +108,8 @@ static int CmdHfThinFilmInfo(const char *Cmd) {
|
|||
}
|
||||
|
||||
int infoThinFilm(void) {
|
||||
|
||||
clearCommandBuffer();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_THINFILM_READ, NULL, 0);
|
||||
|
||||
PacketResponseNG resp;
|
||||
|
@ -117,9 +117,9 @@ int infoThinFilm(void) {
|
|||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if ( resp.status == PM3_SUCCESS ) {
|
||||
print_barcode( resp.data.asBytes, resp.length );
|
||||
|
||||
if (resp.status == PM3_SUCCESS) {
|
||||
print_barcode(resp.data.asBytes, resp.length);
|
||||
}
|
||||
|
||||
return resp.status;
|
||||
|
|
|
@ -43,7 +43,7 @@ static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response, uint
|
|||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0, cmd, len);
|
||||
|
||||
PacketResponseNG resp;
|
||||
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
|
@ -98,10 +98,10 @@ static int topaz_select(uint8_t *atqa, uint8_t *rid_response) {
|
|||
|
||||
// read all of the static memory of a selected Topaz tag.
|
||||
static int topaz_rall(uint8_t *uid, uint8_t *response) {
|
||||
uint16_t resp_len = 0;
|
||||
uint16_t resp_len = 0;
|
||||
uint8_t rall_cmd[] = {TOPAZ_RALL, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
memcpy(&rall_cmd[3], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(rall_cmd, sizeof(rall_cmd), response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // RALL failed
|
||||
|
@ -119,7 +119,7 @@ static int topaz_read_block(uint8_t *uid, uint8_t blockno, uint8_t *block_data)
|
|||
|
||||
read8_cmd[1] = blockno;
|
||||
memcpy(&read8_cmd[10], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(read8_cmd, sizeof(read8_cmd), read8_response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // READ8 failed
|
||||
|
@ -136,7 +136,7 @@ static int topaz_read_segment(uint8_t *uid, uint8_t segno, uint8_t *segment_data
|
|||
|
||||
rseg_cmd[1] = segno << 4;
|
||||
memcpy(&rseg_cmd[10], uid, 4);
|
||||
|
||||
|
||||
if (topaz_send_cmd(rseg_cmd, sizeof(rseg_cmd), rseg_response, &resp_len) == PM3_ETIMEOUT) {
|
||||
topaz_switch_off_field();
|
||||
return PM3_ESOFT; // RSEG failed
|
||||
|
@ -420,7 +420,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
|||
(rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
|
||||
(rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
|
||||
(rid_response[0] & 0x0F) == 0x01 ? "static" : "dynamic");
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "HR1 : %02x", rid_response[1]);
|
||||
|
||||
status = topaz_rall(uid_echo, rall_response);
|
||||
|
@ -475,7 +475,7 @@ static int CmdHFTopazReader(const char *Cmd) {
|
|||
sprintf(&line[3 * j], "%02x ", topaz_tag.data_blocks[0x0e][j]);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "-------+--------+-------------------------+------------");
|
||||
PrintAndLogEx(NORMAL, " 0x%02x | 0x%02x | %s| %-3s", 0x0e, 0x0e * 8, line, "n/a");
|
||||
PrintAndLogEx(NORMAL, " 0x%02x | 0x%02x | %s| %-3s", 0x0e, 0x0e * 8, line, "n/a");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
status = topaz_print_CC(&topaz_tag.data_blocks[1][0]);
|
||||
|
|
|
@ -32,9 +32,9 @@ reg [7:0] pck_divider;
|
|||
reg clk_state;
|
||||
|
||||
// Antenna logic, depending on "lf_field" (in arm defined as FPGA_LF_READER_FIELD)
|
||||
wire tag_modulation;
|
||||
wire tag_modulation;
|
||||
assign tag_modulation = ssp_dout & !lf_field;
|
||||
wire reader_modulation;
|
||||
wire reader_modulation;
|
||||
assign reader_modulation = !ssp_dout & lf_field & clk_state;
|
||||
assign pwr_oe1 = 1'b0; // not used in LF mode
|
||||
assign pwr_oe2 = 1'b0; //tag_modulation;
|
||||
|
|
Loading…
Reference in a new issue