changing {} style to match majority of previous style

This commit is contained in:
Philippe Teuwen 2019-03-10 11:20:22 +01:00
commit 961d929f4d
320 changed files with 5502 additions and 10485 deletions

View file

@ -30,21 +30,18 @@ static struct {
dynamic_lock_area_t *dynamic_lock_areas; // lock area descriptors
} topaz_tag;
static void topaz_switch_on_field(void)
{
static void topaz_switch_on_field(void) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, 0, 0}};
SendCommand(&c);
}
static void topaz_switch_off_field(void)
{
static void topaz_switch_off_field(void) {
UsbCommand c = {CMD_READER_ISO_14443a, {0, 0, 0}};
SendCommand(&c);
}
// send a raw topaz command, returns the length of the response (0 in case of error)
static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response)
{
static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0}};
memcpy(c.d.asBytes, cmd, len);
SendCommand(&c);
@ -61,8 +58,7 @@ static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response)
// calculate CRC bytes and send topaz command, returns the length of the response (0 in case of error)
static int topaz_send_cmd(uint8_t *cmd, uint8_t len, uint8_t *response)
{
static int topaz_send_cmd(uint8_t *cmd, uint8_t len, uint8_t *response) {
if (len > 1) {
uint8_t b1, b2;
compute_crc(CRC_14443_B, cmd, len - 2, &b1, &b2);
@ -75,8 +71,7 @@ static int topaz_send_cmd(uint8_t *cmd, uint8_t len, uint8_t *response)
// select a topaz tag. Send WUPA and RID.
static int topaz_select(uint8_t *atqa, uint8_t *rid_response)
{
static int topaz_select(uint8_t *atqa, uint8_t *rid_response) {
// ToDo: implement anticollision
uint8_t wupa_cmd[] = {TOPAZ_WUPA};
@ -99,8 +94,7 @@ 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)
{
static int topaz_rall(uint8_t *uid, uint8_t *response) {
uint8_t rall_cmd[] = {TOPAZ_RALL, 0, 0, 0, 0, 0, 0, 0, 0};
memcpy(&rall_cmd[3], uid, 4);
@ -114,8 +108,7 @@ static int topaz_rall(uint8_t *uid, uint8_t *response)
// read a block (8 Bytes) of a selected Topaz tag.
static int topaz_read_block(uint8_t *uid, uint8_t blockno, uint8_t *block_data)
{
static int topaz_read_block(uint8_t *uid, uint8_t blockno, uint8_t *block_data) {
uint8_t read8_cmd[] = {TOPAZ_READ8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t read8_response[11];
@ -130,8 +123,7 @@ static int topaz_read_block(uint8_t *uid, uint8_t blockno, uint8_t *block_data)
}
// read a segment (16 blocks = 128 Bytes) of a selected Topaz tag. Works only for tags with dynamic memory.
static int topaz_read_segment(uint8_t *uid, uint8_t segno, uint8_t *segment_data)
{
static int topaz_read_segment(uint8_t *uid, uint8_t segno, uint8_t *segment_data) {
uint8_t rseg_cmd[] = {TOPAZ_RSEG, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t rseg_response[131];
@ -146,8 +138,7 @@ static int topaz_read_segment(uint8_t *uid, uint8_t segno, uint8_t *segment_data
}
// search for the lock area descriptor for the lockable area including byteno
static dynamic_lock_area_t *get_dynamic_lock_area(uint16_t byteno)
{
static dynamic_lock_area_t *get_dynamic_lock_area(uint16_t byteno) {
dynamic_lock_area_t *lock_area;
lock_area = topaz_tag.dynamic_lock_areas;
@ -162,8 +153,7 @@ static dynamic_lock_area_t *get_dynamic_lock_area(uint16_t byteno)
}
// check if a memory byte is locked.
static bool topaz_byte_is_locked(uint16_t byteno)
{
static bool topaz_byte_is_locked(uint16_t byteno) {
uint8_t *lockbits;
uint16_t locked_bytes_per_bit;
dynamic_lock_area_t *lock_area;
@ -192,8 +182,7 @@ static bool topaz_byte_is_locked(uint16_t byteno)
// read and print the Capability Container
static int topaz_print_CC(uint8_t *data)
{
static int topaz_print_CC(uint8_t *data) {
if (data[0] != 0xe1) {
topaz_tag.size = TOPAZ_STATIC_MEMORY;
return -1; // no NDEF message
@ -214,8 +203,7 @@ static int topaz_print_CC(uint8_t *data)
// return type, length and value of a TLV, starting at memory position *TLV_ptr
static void get_TLV(uint8_t **TLV_ptr, uint8_t *TLV_type, uint16_t *TLV_length, uint8_t **TLV_value)
{
static void get_TLV(uint8_t **TLV_ptr, uint8_t *TLV_type, uint16_t *TLV_length, uint8_t **TLV_value) {
*TLV_length = 0;
*TLV_value = NULL;
@ -249,8 +237,7 @@ static void get_TLV(uint8_t **TLV_ptr, uint8_t *TLV_type, uint16_t *TLV_length,
// lock area TLVs contain no information on the start of the respective lockable area. Lockable areas
// do not include the lock bits and reserved memory. We therefore need to adjust the start of the
// respective lockable areas accordingly
static void adjust_lock_areas(uint16_t block_start, uint16_t block_size)
{
static void adjust_lock_areas(uint16_t block_start, uint16_t block_size) {
dynamic_lock_area_t *lock_area = topaz_tag.dynamic_lock_areas;
while (lock_area != NULL) {
if (lock_area->first_locked_byte <= block_start) {
@ -262,8 +249,7 @@ static void adjust_lock_areas(uint16_t block_start, uint16_t block_size)
// read and print the lock area and reserved memory TLVs
static void topaz_print_control_TLVs(uint8_t *memory)
{
static void topaz_print_control_TLVs(uint8_t *memory) {
uint8_t *TLV_ptr = memory;
uint8_t TLV_type = 0;
uint16_t TLV_length;
@ -336,8 +322,7 @@ static void topaz_print_control_TLVs(uint8_t *memory)
}
// read all of the dynamic memory
static int topaz_read_dynamic_data(void)
{
static int topaz_read_dynamic_data(void) {
// first read the remaining block of segment 0
if (topaz_read_block(topaz_tag.uid, 0x0f, &topaz_tag.dynamic_memory[0]) == -1) {
PrintAndLogEx(WARNING, "Error while reading dynamic memory block %02x. Aborting...", 0x0f);
@ -357,8 +342,7 @@ static int topaz_read_dynamic_data(void)
// read and print the dynamic memory
static void topaz_print_dynamic_data(void)
{
static void topaz_print_dynamic_data(void) {
if (topaz_tag.size > TOPAZ_STATIC_MEMORY) {
PrintAndLogEx(NORMAL, "Dynamic Data blocks:");
if (topaz_read_dynamic_data() == 0) {
@ -378,19 +362,16 @@ static void topaz_print_dynamic_data(void)
}
}
static void topaz_print_lifecycle_state(uint8_t *data)
{
static void topaz_print_lifecycle_state(uint8_t *data) {
// to be done
}
static void topaz_print_NDEF(uint8_t *data)
{
static void topaz_print_NDEF(uint8_t *data) {
// to be done.
}
// read a Topaz tag and print some useful information
int CmdHFTopazReader(const char *Cmd)
{
int CmdHFTopazReader(const char *Cmd) {
int status;
uint8_t atqa[2];
uint8_t rid_response[8];
@ -506,20 +487,17 @@ int CmdHFTopazReader(const char *Cmd)
return 0;
}
int CmdHFTopazSim(const char *Cmd)
{
int CmdHFTopazSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "not yet implemented");
return 0;
}
int CmdHFTopazCmdRaw(const char *Cmd)
{
int CmdHFTopazCmdRaw(const char *Cmd) {
PrintAndLogEx(NORMAL, "not yet implemented. Use hf 14 raw with option -T.");
return 0;
}
int CmdHFTopazList(const char *Cmd)
{
int CmdHFTopazList(const char *Cmd) {
CmdTraceList("topaz");
return 0;
}
@ -536,15 +514,13 @@ static command_t CommandTable[] = {
{NULL, NULL, 0, NULL}
};
int CmdHFTopaz(const char *Cmd)
{
int CmdHFTopaz(const char *Cmd) {
clearCommandBuffer();
CmdsParse(CommandTable, Cmd);
return 0;
}
static int CmdHelp(const char *Cmd)
{
static int CmdHelp(const char *Cmd) {
CmdsHelp(CommandTable);
return 0;
}