5#include <mbedtls/include/mbedtls/des.h>
11#define FELICA_IDM_SIZE (8U)
12#define FELICA_PMM_SIZE (8U)
13#define FELICA_DATA_BLOCK_SIZE (16U)
15#define FELICA_CMD_READ_WITHOUT_ENCRYPTION (0x06U)
16#define FELICA_CMD_WRITE_WITHOUT_ENCRYPTION (0x08U)
18#define FELICA_SERVICE_RW_ACCESS (0x0009U)
19#define FELICA_SERVICE_RO_ACCESS (0x000BU)
21#define FELICA_BLOCKS_TOTAL_COUNT (28U)
22#define FELICA_BLOCK_INDEX_REG (0x0EU)
23#define FELICA_BLOCK_INDEX_RC (0x80U)
24#define FELICA_BLOCK_INDEX_MAC (0x81U)
25#define FELICA_BLOCK_INDEX_ID (0x82U)
26#define FELICA_BLOCK_INDEX_D_ID (0x83U)
27#define FELICA_BLOCK_INDEX_SER_C (0x84U)
28#define FELICA_BLOCK_INDEX_SYS_C (0x85U)
29#define FELICA_BLOCK_INDEX_CKV (0x86U)
30#define FELICA_BLOCK_INDEX_CK (0x87U)
31#define FELICA_BLOCK_INDEX_MC (0x88U)
32#define FELICA_BLOCK_INDEX_WCNT (0x90U)
33#define FELICA_BLOCK_INDEX_MAC_A (0x91U)
34#define FELICA_BLOCK_INDEX_STATE (0x92U)
35#define FELICA_BLOCK_INDEX_CRC_CHECK (0xA0U)
37#define FELICA_GUARD_TIME_US (20000U)
38#define FELICA_FDT_POLL_FC (10000U)
39#define FELICA_POLL_POLL_MIN_US (1280U)
41#define FELICA_FDT_LISTEN_FC (1172)
43#define FELICA_SYSTEM_CODE_CODE (0xFFFFU)
44#define FELICA_TIME_SLOT_1 (0x00U)
45#define FELICA_TIME_SLOT_2 (0x01U)
46#define FELICA_TIME_SLOT_4 (0x03U)
47#define FELICA_TIME_SLOT_8 (0x07U)
48#define FELICA_TIME_SLOT_16 (0x0FU)
53 FelicaErrorNotPresent,
54 FelicaErrorColResFailed,
55 FelicaErrorBufferOverflow,
56 FelicaErrorCommunication,
64 uint8_t data[FELICA_DATA_BLOCK_SIZE];
69 uint8_t data[FELICA_DATA_BLOCK_SIZE];
93 uint8_t data[FELICA_DATA_BLOCK_SIZE];
107 uint8_t data[FELICA_IDM_SIZE];
112 uint8_t data[FELICA_PMM_SIZE];
120 uint8_t data[FELICA_DATA_BLOCK_SIZE];
152 uint8_t blocks_total;
162 uint16_t service_code;
169 uint8_t response_code;
176 uint8_t service_code : 4;
177 uint8_t access_mode : 3;
179 uint8_t block_number;
184 uint8_t response_code;
222const uint8_t* felica_get_uid(
const FelicaData* data,
size_t* uid_len);
224bool felica_set_uid(
FelicaData* data,
const uint8_t* uid,
size_t uid_len);
228void felica_calculate_session_key(
229 mbedtls_des3_context* ctx,
234bool felica_check_mac(
235 mbedtls_des3_context* ctx,
236 const uint8_t* session_key,
238 const uint8_t* blocks,
239 const uint8_t block_count,
242void felica_calculate_mac_read(
243 mbedtls_des3_context* ctx,
244 const uint8_t* session_key,
246 const uint8_t* blocks,
247 const uint8_t block_count,
251void felica_calculate_mac_write(
252 mbedtls_des3_context* ctx,
253 const uint8_t* session_key,
NfcDeviceNameType
Verbosity level of the displayed NFC device name.
Definition nfc_device_base.h:14
Abstract interface definitions for the NFC device system.
Struct which controls the process of authentication and can be passed as a parameter to the applicati...
Definition felica.h:82
FelicaAuthenticationStatus auth_status
Authentication status.
Definition felica.h:86
bool skip_auth
By default it is true, so auth is skipped.
Definition felica.h:83
FelicaCardKey card_key
User must fill this field with known card key in order to pass auth.
Definition felica.h:85
Structure used to hold authentication related fields.
Definition felica.h:99
mbedtls_des3_context des_context
Context for mbedtls des functions.
Definition felica.h:100
FelicaAuthenticationContext context
Public auth context provided to upper levels.
Definition felica.h:102
FelicaSessionKey session_key
Calculated session key.
Definition felica.h:101
In Felica there two types of auth.
Definition felica.h:75
Felica block with status flags indicating last operation with it.
Definition felica.h:117
uint8_t SF1
Status flag 1, equals to 0 when success.
Definition felica.h:118
uint8_t SF2
Status flag 2, equals to 0 when success.
Definition felica.h:119
Separate type for card key block.
Definition felica.h:68
Structure used to store Felica data and additional values about reading.
Definition felica.h:149
Felica filesystem structure.
Definition felica.h:124
Felica ID block.
Definition felica.h:106
Felica PMm block.
Definition felica.h:111
Stucture for holding Felica session key which is calculated from rc and ck.
Definition felica.h:92
Generic NFC device interface.
Definition nfc_device_base_i.h:142
Union which represents filesystem in junction with plain data dump.
Definition felica.h:143