Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+9
+5
include/net/nfc/nfc.h
··· 53 53 typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb, 54 54 int err); 55 55 56 + typedef void (*se_io_cb_t)(void *context, u8 *apdu, size_t apdu_len, int err); 57 + 56 58 struct nfc_target; 57 59 58 60 struct nfc_ops { ··· 81 79 int (*discover_se)(struct nfc_dev *dev); 82 80 int (*enable_se)(struct nfc_dev *dev, u32 se_idx); 83 81 int (*disable_se)(struct nfc_dev *dev, u32 se_idx); 82 + int (*se_io) (struct nfc_dev *dev, u32 se_idx, 83 + u8 *apdu, size_t apdu_length, 84 + se_io_cb_t cb, void *cb_context); 84 85 }; 85 86 86 87 #define NFC_TARGET_IDX_ANY -1
+4
include/uapi/linux/nfc.h
··· 85 85 * a specific SE notifies us about the end of a transaction. The parameter 86 86 * for this event is the application ID (AID). 87 87 * @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. 88 89 */ 89 90 enum nfc_commands { 90 91 NFC_CMD_UNSPEC, ··· 115 114 NFC_EVENT_SE_CONNECTIVITY, 116 115 NFC_EVENT_SE_TRANSACTION, 117 116 NFC_CMD_GET_SE, 117 + NFC_CMD_SE_IO, 118 118 /* private: internal use only */ 119 119 __NFC_CMD_AFTER_LAST 120 120 }; ··· 149 147 * @NFC_ATTR_SE_INDEX: Secure element index 150 148 * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) 151 149 * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status 150 + * @NFC_ATTR_APDU: Secure element APDU 152 151 */ 153 152 enum nfc_attrs { 154 153 NFC_ATTR_UNSPEC, ··· 177 174 NFC_ATTR_SE_TYPE, 178 175 NFC_ATTR_SE_AID, 179 176 NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, 177 + NFC_ATTR_SE_APDU, 180 178 /* private: internal use only */ 181 179 __NFC_ATTR_AFTER_LAST 182 180 };