Clean up duplicated picopass command definitions.

This commit is contained in:
Tiernan Messmer
2023-06-12 19:13:47 +10:00
parent 7b22576db9
commit aa747cd8bf
11 changed files with 186 additions and 181 deletions

View File

@@ -14,16 +14,19 @@
#define PICOPASS_DEV_NAME_MAX_LEN 22
#define PICOPASS_READER_DATA_MAX_SIZE 64
#define PICOPASS_BLOCK_LEN 8
#define PICOPASS_MAX_APP_LIMIT 32
#define PICOPASS_CSN_BLOCK_INDEX 0
#define PICOPASS_CONFIG_BLOCK_INDEX 1
#define PICOPASS_EPURSE_BLOCK_INDEX 2
#define PICOPASS_KD_BLOCK_INDEX 3
#define PICOPASS_KC_BLOCK_INDEX 4
#define PICOPASS_AIA_BLOCK_INDEX 5
#define PICOPASS_PACS_CFG_BLOCK_INDEX 6
// These definitions for blocks above 2 only hold for secure cards.
#define PICOPASS_SECURE_EPURSE_BLOCK_INDEX 2
#define PICOPASS_SECURE_KD_BLOCK_INDEX 3
#define PICOPASS_SECURE_KC_BLOCK_INDEX 4
#define PICOPASS_SECURE_AIA_BLOCK_INDEX 5
// Non-secure cards instead have an AIA at block 2
#define PICOPASS_NONSECURE_AIA_BLOCK_INDEX 2
// Only iClass cards
#define PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX 6
// Personalization Mode
#define PICOPASS_FUSE_PERS 0x80
@@ -35,38 +38,6 @@
// Read Access, 1 meanns anonymous read enabled, 0 means must auth to read applicaion
#define PICOPASS_FUSE_RA 0x01
// PicoPass command bytes:
// Low nibble used for command
// High nibble used for options and checksum (MSB)
// The only option we care about in 15693 mode is the key
// which is only used by READCHECK, so for simplicity we
// don't bother breaking down the command and flags into parts
// READ: ADDRESS(1) CRC16(2) -> DATA(8) CRC16(2)
// IDENTIFY: No args -> ASNB(8) CRC16(2)
#define PICOPASS_CMD_READ_OR_IDENTIFY 0x0C
// ADDRESS(1) CRC16(2) -> DATA(32) CRC16(2)
#define PICOPASS_CMD_READ4 0x06
// ADDRESS(1) DATA(8) SIGN(4)|CRC16(2) -> DATA(8) CRC16(2)
#define PICOPASS_CMD_UPDATE 0x87
// ADDRESS(1) -> DATA(8)
#define PICOPASS_CMD_READCHECK_KD 0x88
// ADDRESS(1) -> DATA(8)
#define PICOPASS_CMD_READCHECK_KC 0x18
// CHALLENGE(4) READERSIGNATURE(4) -> CHIPRESPONSE(4)
#define PICOPASS_CMD_CHECK 0x05
// No args -> SOF
#define PICOPASS_CMD_ACTALL 0x0A
// No args -> SOF
#define PICOPASS_CMD_ACT 0x8E
// ASNB(8)|SERIALNB(8) -> SERIALNB(8) CRC16(2)
#define PICOPASS_CMD_SELECT 0x81
// No args -> SERIALNB(8) CRC16(2)
#define PICOPASS_CMD_DETECT 0x0F
// No args -> SOF
#define PICOPASS_CMD_HALT 0x00
// PAGE(1) CRC16(2) -> BLOCK1(8) CRC16(2)
#define PICOPASS_CMD_PAGESEL 0x84
#define PICOPASS_APP_FOLDER ANY_PATH("picopass")
#define PICOPASS_APP_EXTENSION ".picopass"
#define PICOPASS_APP_SHADOW_EXTENSION ".pas"
@@ -122,7 +93,7 @@ typedef struct {
} PicopassPacs;
typedef struct {
uint8_t data[PICOPASS_BLOCK_LEN];
uint8_t data[RFAL_PICOPASS_BLOCK_LEN];
} PicopassBlock;
typedef struct {