Commit 72b70b6e authored by Samuel Ortiz's avatar Samuel Ortiz

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: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent b9c0c678
...@@ -53,6 +53,8 @@ struct nfc_dev; ...@@ -53,6 +53,8 @@ struct nfc_dev;
typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb, typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
int err); int err);
typedef void (*se_io_cb_t)(void *context, u8 *apdu, size_t apdu_len, int err);
struct nfc_target; struct nfc_target;
struct nfc_ops { struct nfc_ops {
...@@ -79,6 +81,9 @@ struct nfc_ops { ...@@ -79,6 +81,9 @@ struct nfc_ops {
int (*discover_se)(struct nfc_dev *dev); int (*discover_se)(struct nfc_dev *dev);
int (*enable_se)(struct nfc_dev *dev, u32 se_idx); int (*enable_se)(struct nfc_dev *dev, u32 se_idx);
int (*disable_se)(struct nfc_dev *dev, u32 se_idx); int (*disable_se)(struct nfc_dev *dev, u32 se_idx);
int (*se_io) (struct nfc_dev *dev, u32 se_idx,
u8 *apdu, size_t apdu_length,
se_io_cb_t cb, void *cb_context);
}; };
#define NFC_TARGET_IDX_ANY -1 #define NFC_TARGET_IDX_ANY -1
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
* a specific SE notifies us about the end of a transaction. The parameter * a specific SE notifies us about the end of a transaction. The parameter
* for this event is the application ID (AID). * for this event is the application ID (AID).
* @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller. * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller.
* @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element.
*/ */
enum nfc_commands { enum nfc_commands {
NFC_CMD_UNSPEC, NFC_CMD_UNSPEC,
...@@ -114,6 +115,7 @@ enum nfc_commands { ...@@ -114,6 +115,7 @@ enum nfc_commands {
NFC_EVENT_SE_CONNECTIVITY, NFC_EVENT_SE_CONNECTIVITY,
NFC_EVENT_SE_TRANSACTION, NFC_EVENT_SE_TRANSACTION,
NFC_CMD_GET_SE, NFC_CMD_GET_SE,
NFC_CMD_SE_IO,
/* private: internal use only */ /* private: internal use only */
__NFC_CMD_AFTER_LAST __NFC_CMD_AFTER_LAST
}; };
...@@ -147,6 +149,7 @@ enum nfc_commands { ...@@ -147,6 +149,7 @@ enum nfc_commands {
* @NFC_ATTR_SE_INDEX: Secure element index * @NFC_ATTR_SE_INDEX: Secure element index
* @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
* @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
* @NFC_ATTR_APDU: Secure element APDU
*/ */
enum nfc_attrs { enum nfc_attrs {
NFC_ATTR_UNSPEC, NFC_ATTR_UNSPEC,
...@@ -174,6 +177,7 @@ enum nfc_attrs { ...@@ -174,6 +177,7 @@ enum nfc_attrs {
NFC_ATTR_SE_TYPE, NFC_ATTR_SE_TYPE,
NFC_ATTR_SE_AID, NFC_ATTR_SE_AID,
NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
NFC_ATTR_SE_APDU,
/* private: internal use only */ /* private: internal use only */
__NFC_ATTR_AFTER_LAST __NFC_ATTR_AFTER_LAST
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment