blob: 2c99858d4d031c13f59f2c4f94992912f3b03dad [file] [log] [blame]
Kévin Redon70a84862018-10-10 00:30:23 +02001/* apdu_dispatch - State machine to determine Rx/Tx phases of APDU
2 *
3 * (C) 2016 by Harald Welte <hwelte@hmw-consulting.de>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#pragma once
20
21#include <stdint.h>
22#include <stdbool.h>
23
24#include <osmocom/sim/sim.h>
25
26struct apdu_context {
27 struct osim_apdu_cmd_hdr hdr;
28 uint8_t dc[256];
29 uint8_t de[256];
30 uint8_t sw[2];
31 uint8_t apdu_case;
32 struct {
33 uint8_t tot;
34 uint8_t cur;
35 } lc;
36 struct {
37 uint8_t tot;
38 uint8_t cur;
39 } le;
40};
41
42enum apdu_action {
43 APDU_ACT_TX_CAPDU_TO_CARD = 0x0001,
44 APDU_ACT_RX_MORE_CAPDU_FROM_READER = 0x0002,
45};
46
47
48int apdu_segment_in(struct apdu_context *ac, const uint8_t *apdu_buf,
49 unsigned int apdu_len, bool new_apdu);