Mistake on this page?
Report an issue in GitHub or email us
iso7816.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /**
18  * \file iso7816.h
19  * \copyright Copyright (c) ARM Ltd 2014
20  * \author Donatien Garnier
21  */
22 
23 #ifndef ISO7816_H_
24 #define ISO7816_H_
25 
26 #include "stack/nfc_common.h"
27 
28 #include "transceiver/protocols.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
36  uint8_t cla;
37  uint8_t ins;
38  uint8_t p1;
39  uint8_t p2;
40  ac_buffer_t dataIn;
41  size_t maxRespLength;
42 };
43 
45  ac_buffer_t dataOut;
46  uint16_t sw;
47 };
48 
49 #define ISO7816_RX_BUFFER_SIZE 256
50 
51 typedef struct nfc_tech_iso7816_c_apdu nfc_tech_iso7816_c_apdu_t;
52 typedef struct nfc_tech_iso7816_r_apdu nfc_tech_iso7816_r_apdu_t;
53 
54 typedef struct nfc_tech_iso7816 nfc_tech_iso7816_t;
55 
56 typedef void (*nfc_tech_iso7816_disconnected_cb)(nfc_tech_iso7816_t *pIso7816, void *pUserData);
57 
59 typedef struct nfc_tech_iso7816_app nfc_tech_iso7816_app_t;
60 
62  nfc_tech_isodep_target_t isoDepTarget;
63 
64  nfc_tech_iso7816_app_t *pAppList;
65  nfc_tech_iso7816_app_t *pSelectedApp;
66 
67  bool disconnected;
68 
69  nfc_tech_iso7816_c_apdu_t cApdu;
70  nfc_tech_iso7816_r_apdu_t rApdu;
71 
72  bool responseReady;
73 
74  nfc_tech_iso7816_disconnected_cb disconnectedCb;
75  void *pUserData;
76 
77  ac_buffer_t hist; //Historical bytes
78 
79  ac_istream_t inputStream;
80  ac_ostream_t outputStream;
81 
82  //PDU buffer (tx)
83  uint8_t txBuf[2];
84  ac_buffer_builder_t txBldr;
85 
86  //Receive buffer
87  uint8_t rxBuf[ISO7816_RX_BUFFER_SIZE];
88  ac_buffer_builder_t rxBldr;
89 };
90 
91 void nfc_tech_iso7816_init(nfc_tech_iso7816_t *pIso7816, nfc_transceiver_t *pTransceiver, nfc_tech_iso7816_disconnected_cb disconnectedCb, void *pUserData);
92 void nfc_tech_iso7816_add_app(nfc_tech_iso7816_t *pIso7816, nfc_tech_iso7816_app_t *pIso7816App);
93 void nfc_tech_iso7816_connect(nfc_tech_iso7816_t *pIso7816);
94 void nfc_tech_iso7816_disconnect(nfc_tech_iso7816_t *pIso7816);
95 nfc_err_t nfc_tech_iso7816_reply(nfc_tech_iso7816_t *pIso7816);
96 
97 inline static nfc_tech_iso7816_c_apdu_t *nfc_tech_iso7816_c_apdu(nfc_tech_iso7816_t *pIso7816)
98 {
99  return &pIso7816->cApdu;
100 }
101 
102 inline static nfc_tech_iso7816_r_apdu_t *nfc_tech_iso7816_r_apdu(nfc_tech_iso7816_t *pIso7816)
103 {
104  return &pIso7816->rApdu;
105 }
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* ISO7816_H_ */
int nfc_err_t
Type for NFC errors.
Definition: nfc_errors.h:59
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.