2021-05-31 00:56:33 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 2017 Merlok
|
|
|
|
//
|
|
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
|
|
// the license.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// ISO7816 core functionality
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef ISO7816CORE_H__
|
|
|
|
#define ISO7816CORE_H__
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include "apduinfo.h"
|
|
|
|
|
|
|
|
#define APDU_RES_LEN 260
|
|
|
|
#define APDU_AID_LEN 50
|
|
|
|
|
2021-05-31 04:31:56 +08:00
|
|
|
typedef enum {
|
|
|
|
ISODEP_INACTIVE = 0,
|
|
|
|
ISODEP_NFCA,
|
|
|
|
ISODEP_NFCB,
|
|
|
|
} isodep_state_t;
|
|
|
|
|
2021-05-31 00:56:33 +08:00
|
|
|
typedef enum {
|
|
|
|
CC_CONTACTLESS,
|
|
|
|
CC_CONTACT
|
|
|
|
} Iso7816CommandChannel;
|
|
|
|
|
|
|
|
void SetAPDULogging(bool logging);
|
|
|
|
bool GetAPDULogging(void);
|
|
|
|
|
2021-05-31 04:31:56 +08:00
|
|
|
void SetISODEPState(isodep_state_t state);
|
|
|
|
isodep_state_t GetISODEPState(void);
|
|
|
|
|
2021-05-31 15:30:44 +08:00
|
|
|
// connect
|
|
|
|
int Iso7816Connect(Iso7816CommandChannel channel);
|
|
|
|
|
2021-05-31 00:56:33 +08:00
|
|
|
// exchange
|
2021-06-20 16:32:08 +08:00
|
|
|
int Iso7816Exchange(Iso7816CommandChannel channel, bool leave_field_on, sAPDU apdu, uint8_t *result, size_t max_result_len,
|
2021-06-23 21:18:05 +08:00
|
|
|
size_t *result_len, uint16_t *sw);
|
2021-06-20 16:32:08 +08:00
|
|
|
|
|
|
|
int Iso7816ExchangeEx(Iso7816CommandChannel channel, bool activate_field, bool leave_field_on, sAPDU apdu, bool include_le,
|
2021-06-23 21:18:05 +08:00
|
|
|
uint16_t le, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
|
2021-05-31 00:56:33 +08:00
|
|
|
|
|
|
|
// search application
|
2021-06-20 16:32:08 +08:00
|
|
|
int Iso7816Select(Iso7816CommandChannel channel, bool activate_field, bool leave_field_on, uint8_t *aid, size_t aid_len,
|
2021-06-23 21:18:05 +08:00
|
|
|
uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
|
2021-06-20 16:32:08 +08:00
|
|
|
|
2021-05-31 00:56:33 +08:00
|
|
|
#endif
|