Loading...
Searching...
No Matches
slix.h
1#pragma once
2
3#include <nfc/protocols/iso15693_3/iso15693_3.h>
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#define SLIX_BLOCK_SIZE (4U)
10#define SLIX_SIGNATURE_SIZE (32U)
11
12#define SLIX_COUNTER_BLOCK_NUM (79U)
13
14#define SLIX_PP_CONDITION_RL (1U << 0)
15#define SLIX_PP_CONDITION_WL (1U << 1)
16#define SLIX_PP_CONDITION_RH (1U << 4)
17#define SLIX_PP_CONDITION_WH (1U << 5)
18
19#define SLIX_FEATURE_FLAG_UM_PP (1UL << 0)
20#define SLIX_FEATURE_FLAG_COUNTER (1UL << 1)
21#define SLIX_FEATURE_FLAG_EAS_ID (1UL << 2)
22#define SLIX_FEATURE_FLAG_EAS_PP (1UL << 3)
23#define SLIX_FEATURE_FLAG_AFI_PP (1UL << 4)
24#define SLIX_FEATURE_FLAG_INVENTORY_READ_EXT (1UL << 5)
25#define SLIX_FEATURE_FLAG_EAS_IR (1UL << 6)
26#define SLIX_FEATURE_FLAG_ORIGINALITY_SIG (1UL << 8)
27#define SLIX_FEATURE_FLAG_ORIGINALITY_SIG_PP (1UL << 9)
28#define SLIX_FEATURE_FLAG_PERSISTENT_QUIET (1UL << 10)
29#define SLIX_FEATURE_FLAG_PRIVACY (1UL << 12)
30#define SLIX_FEATURE_FLAG_DESTROY (1UL << 13)
31#define SLIX_FEATURE_EXT (1UL << 31)
32
33#define SLIX_TYPE_FEATURE_READ (1U << 0)
34#define SLIX_TYPE_FEATURE_WRITE (1U << 1)
35#define SLIX_TYPE_FEATURE_PRIVACY (1U << 2)
36#define SLIX_TYPE_FEATURE_DESTROY (1U << 3)
37#define SLIX_TYPE_FEATURE_EAS (1U << 4)
38#define SLIX_TYPE_FEATURE_SIGNATURE (1U << 5)
39#define SLIX_TYPE_FEATURE_PROTECTION (1U << 6)
40#define SLIX_TYPE_FEATURE_NFC_SYSTEM_INFO (1U << 7)
41
42typedef uint32_t SlixTypeFeatures;
43
44typedef enum {
45 SlixErrorNone,
46 SlixErrorTimeout,
47 SlixErrorFormat,
48 SlixErrorNotSupported,
49 SlixErrorInternal,
50 SlixErrorWrongPassword,
51 SlixErrorUidMismatch,
52 SlixErrorUnknown,
53} SlixError;
54
55typedef enum {
56 SlixTypeSlix,
57 SlixTypeSlixS,
58 SlixTypeSlixL,
59 SlixTypeSlix2,
60
61 SlixTypeCount,
62 SlixTypeUnknown,
63} SlixType;
64
65typedef enum {
66 SlixPasswordTypeRead,
67 SlixPasswordTypeWrite,
68 SlixPasswordTypePrivacy,
69 SlixPasswordTypeDestroy,
70 SlixPasswordTypeEasAfi,
71 SlixPasswordTypeCount,
72} SlixPasswordType;
73
74typedef uint32_t SlixPassword;
75typedef uint8_t SlixSignature[SLIX_SIGNATURE_SIZE];
76typedef bool SlixPrivacy;
77typedef uint16_t SlixRandomNumber;
78
79typedef struct {
80 uint8_t pointer;
81 uint8_t condition;
83
84typedef struct {
85 bool eas;
86 bool ppl;
88
89typedef struct {
90 SlixProtection protection;
91 SlixLockBits lock_bits;
93
94typedef enum {
95 SlixCapabilitiesDefault,
96 SlixCapabilitiesAcceptAllPasswords,
97
98 SlixCapabilitiesCount,
99} SlixCapabilities;
100
101typedef struct {
102 Iso15693_3Data* iso15693_3_data;
103 SlixSystemInfo system_info;
104 SlixSignature signature;
105 SlixPassword passwords[SlixPasswordTypeCount];
106 SlixPrivacy privacy;
107 SlixCapabilities capabilities;
108} SlixData;
109
110SlixData* slix_alloc(void);
111
112void slix_free(SlixData* data);
113
114void slix_reset(SlixData* data);
115
116void slix_copy(SlixData* data, const SlixData* other);
117
118bool slix_verify(SlixData* data, const FuriString* device_type);
119
120bool slix_load(SlixData* data, FlipperFormat* ff, uint32_t version);
121
122bool slix_save(const SlixData* data, FlipperFormat* ff);
123
124bool slix_is_equal(const SlixData* data, const SlixData* other);
125
126const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_type);
127
128const uint8_t* slix_get_uid(const SlixData* data, size_t* uid_len);
129
130bool slix_set_uid(SlixData* data, const uint8_t* uid, size_t uid_len);
131
132const Iso15693_3Data* slix_get_base_data(const SlixData* data);
133
134// Getters and tests
135
136SlixType slix_get_type(const SlixData* data);
137
138SlixPassword slix_get_password(const SlixData* data, SlixPasswordType password_type);
139
140uint16_t slix_get_counter(const SlixData* data);
141
142bool slix_is_privacy_mode(const SlixData* data);
143
144bool slix_is_block_protected(
145 const SlixData* data,
146 SlixPasswordType password_type,
147 uint8_t block_num);
148
149bool slix_is_counter_increment_protected(const SlixData* data);
150
151// Static methods
152bool slix_type_has_features(SlixType slix_type, SlixTypeFeatures features);
153
154bool slix_type_supports_password(SlixType slix_type, SlixPasswordType password_type);
155
156#ifdef __cplusplus
157}
158#endif
NfcDeviceNameType
Verbosity level of the displayed NFC device name.
Definition nfc_device_base.h:14
Definition flipper_format.c:12
Definition string.c:4
Definition iso15693_3.h:117
Definition slix.h:101
Definition slix.h:84
Definition slix.h:79
Definition slix.h:89