Skip to content

Commit 72b70b6

Browse files
author
Samuel Ortiz
committed
NFC: Define secure element IO API and commands
In order to send and receive ISO7816 APDUs to and from NFC embedded secure elements, we define a specific netlink command. On a typical SE use case, host applications will send very few APDUs (Less than 10) per transaction. This is why we decided to go for a simple netlink API. Defining another NFC socket protocol for such low traffic would have been overengineered. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent b9c0c67 commit 72b70b6

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎include/net/nfc/nfc.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ struct nfc_dev;
5353
typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
5454
int err);
5555

56+
typedef void (*se_io_cb_t)(void *context, u8 *apdu, size_t apdu_len, int err);
57+
5658
struct nfc_target;
5759

5860
struct nfc_ops {
@@ -79,6 +81,9 @@ struct nfc_ops {
7981
int (*discover_se)(struct nfc_dev *dev);
8082
int (*enable_se)(struct nfc_dev *dev, u32 se_idx);
8183
int (*disable_se)(struct nfc_dev *dev, u32 se_idx);
84+
int (*se_io) (struct nfc_dev *dev, u32 se_idx,
85+
u8 *apdu, size_t apdu_length,
86+
se_io_cb_t cb, void *cb_context);
8287
};
8388

8489
#define NFC_TARGET_IDX_ANY -1

‎include/uapi/linux/nfc.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
* a specific SE notifies us about the end of a transaction. The parameter
8686
* for this event is the application ID (AID).
8787
* @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller.
88+
* @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element.
8889
*/
8990
enum nfc_commands {
9091
NFC_CMD_UNSPEC,
@@ -114,6 +115,7 @@ enum nfc_commands {
114115
NFC_EVENT_SE_CONNECTIVITY,
115116
NFC_EVENT_SE_TRANSACTION,
116117
NFC_CMD_GET_SE,
118+
NFC_CMD_SE_IO,
117119
/* private: internal use only */
118120
__NFC_CMD_AFTER_LAST
119121
};
@@ -147,6 +149,7 @@ enum nfc_commands {
147149
* @NFC_ATTR_SE_INDEX: Secure element index
148150
* @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
149151
* @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
152+
* @NFC_ATTR_APDU: Secure element APDU
150153
*/
151154
enum nfc_attrs {
152155
NFC_ATTR_UNSPEC,
@@ -174,6 +177,7 @@ enum nfc_attrs {
174177
NFC_ATTR_SE_TYPE,
175178
NFC_ATTR_SE_AID,
176179
NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
180+
NFC_ATTR_SE_APDU,
177181
/* private: internal use only */
178182
__NFC_ATTR_AFTER_LAST
179183
};

0 commit comments

Comments
 (0)