blob: 8ff8936460d02ce5eda6819b07ffaeacbe01f064 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file card_fs_uicc.c
2 * ETSI UICC specific structures / routines. */
Harald Weltead418632012-09-10 10:49:59 +02003/*
4 * (C) 2012 by Harald Welte <laforge@gnumonks.org>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24
Harald Welted54c2ee2012-01-17 18:25:50 +010025#include <osmocom/sim/sim.h>
26#include <osmocom/gsm/tlv.h>
27
28/* TS 102 221 V10.0.0 / 10.2.1 */
29const struct osim_card_sw ts102221_uicc_sw[] = {
30 {
31 0x9000, 0xffff, SW_TYPE_STR, SW_CLS_OK,
32 .u.str = "Normal ending of the command",
33 }, {
34 0x9100, 0xff00, SW_TYPE_STR, SW_CLS_OK,
35 .u.str = "Normal ending of the command, extra info proactive",
36 }, {
37 0x9200, 0xff00, SW_TYPE_STR, SW_CLS_OK,
38 .u.str = "Normal ending of the command, extra info regarding transfer session",
39 }, {
40 0x9300, 0xff00, SW_TYPE_STR, SW_CLS_POSTP,
41 .u.str = "SIM Application Toolkit is busy, command cannot be executed at present",
42 }, {
43 0x6200, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
44 .u.str = "No information given, state of non volatile memory unchanged",
45 }, {
46 0x6281, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
47 .u.str = "Part of returned data may be corrupted",
48 }, {
49 0x6282, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
50 .u.str = "End of file/record reached before reading Le bytes",
51 }, {
52 0x6283, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
53 .u.str = "Selected file invalidated",
54 }, {
55 0x6285, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
56 .u.str = "Selected file in termination state",
57 }, {
58 0x62f1, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
59 .u.str = "More data available",
60 }, {
61 0x62f2, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
62 .u.str = "More data available and proactive command pending",
63 }, {
64 0x62f3, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
65 .u.str = "Response data available",
66 }, {
67 0x63f1, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
68 .u.str = "More data expected",
69 }, {
70 0x63c0, 0xfff0, SW_TYPE_STR, SW_CLS_WARN,
71 .u.str = "Verification falied, X retries remaining",
72 }, {
73 0x6400, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
74 .u.str = "Execution - No information given, state of non-volatile memory unchanged",
75 }, {
76 0x6500, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
77 .u.str = "Execution - No information given, state of non-volatile memory changed",
78 }, {
79 0x6581, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
80 .u.str = "Execution - Memory problem",
81 }, {
82 0x6700, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
83 .u.str = "Checking - Wrong length",
84 }, {
85 0x6700, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
86 .u.str = "Checking - Command dependent error",
87 }, {
88 0x6b00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
89 .u.str = "Checking - Wrong parameter(s) P1-P2",
90 }, {
91 0x6d00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
92 .u.str = "Checking - Instruction code not supported or valid",
93 }, {
94 0x6e00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
95 .u.str = "Checking - Class not supported",
96 }, {
97 0x6f00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
98 .u.str = "Checking - Technical problem, no precise diagnostics",
99 }, {
100 0x6f00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
101 .u.str = "Checking - Command dependent error",
102 }, {
103 0x6800, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
104 .u.str = "Function in CLA not supported - No information given",
105 }, {
106 0x6881, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
107 .u.str = "Function in CLA not supported - Logical channel not supported",
108 }, {
109 0x6882, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
110 .u.str = "Function in CLA not supportied - Secure messaging not supported",
111 }, {
112 0x6900, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
113 .u.str = "Command not allowed - No information given",
114 }, {
115 0x6981, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
116 .u.str = "Command not allowed - Command incompatible with file structure",
117 }, {
118 0x6982, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
119 .u.str = "Command not allowed - Security status not satisfied",
120 }, {
121 0x6983, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
122 .u.str = "Command not allowed - Authentication/PIN method blocked",
123 }, {
124 0x6984, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
125 .u.str = "Command not allowed - Referenced data invalidated",
126 }, {
127 0x6985, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
128 .u.str = "Command not allowed - Conditions of use not satisfied",
129 }, {
130 0x6986, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
131 .u.str = "Command not allowed - Noe EF selected",
132 }, {
133 0x6989, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
134 .u.str = "Command not allowed - secure channel - security not satisfied",
135 }, {
136 0x6a80, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
137 .u.str = "Wrong parameters - Incorrect parameters in the data field",
138 }, {
139 0x6a81, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
140 .u.str = "Wrong parameters - Function not supported",
141 }, {
142 0x6a82, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
143 .u.str = "Wrong parameters - File not found",
144 }, {
145 0x6a83, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
146 .u.str = "Wrong parameters - Record not found",
147 }, {
148 0x6a84, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
149 .u.str = "Wrong parameters - Not enough memory space",
150 }, {
151 0x6a86, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
152 .u.str = "Wrong parameters - Incorrect parameters P1 to P2",
153 }, {
154 0x6a87, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
155 .u.str = "Wrong parameters - Lc inconsistent with P1 ot P2",
156 }, {
157 0x6a88, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
158 .u.str = "Wrong parameters - Referenced data not found",
159 }, {
160 0x9850, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
161 .u.str = "Application error - INCREASE cannot be performed, max value reached",
162 }, {
163 0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
164 .u.str = "Application error - Authentication error, application specific",
165 }, {
166 0x9863, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
167 .u.str = "Application error - Security session or association expired",
168 },
169 OSIM_CARD_SW_LAST
170};
171
172const struct value_string ts102221_fcp_vals[14] = {
173 { UICC_FCP_T_FCP, "File control parameters" },
174 { UICC_FCP_T_FILE_SIZE, "File size" },
175 { UICC_FCP_T_TOT_F_SIZE, "Total size of files" },
176 { UICC_FCP_T_FILE_DESC, "File descriptor" },
177 { UICC_FCP_T_FILE_ID, "File identifier" },
178 { UICC_FCP_T_DF_NAME, "DF name" },
179 { UICC_FCP_T_SFID, "Short file identifier" },
180 { UICC_FCP_T_LIFEC_STS, "Lifecycle status integer" },
181 { UICC_FCP_T_SEC_ATTR_REFEXP, "Security attributes (Referenced/Expanded)" },
182 { UICC_FCP_T_SEC_ATTR_COMP, "Security attributes (Compact)" },
183 { UICC_FCP_T_PROPRIETARY, "Proprietary" },
184 { UICC_FCP_T_SEC_ATTR_EXP, "Security attributes (Expanded)" },
185 { UICC_FCP_T_PIN_STS_DO, "PIN Status DO" },
186 { 0, NULL }
187};
188
189/* FIXME: Ber-TLV ?? */
190const struct tlv_definition ts102221_fcp_tlv_def = {
191 .def = {
192 [UICC_FCP_T_FCP] = { TLV_TYPE_TLV },
193 [UICC_FCP_T_FILE_SIZE] = { TLV_TYPE_TLV },
194 [UICC_FCP_T_TOT_F_SIZE] = { TLV_TYPE_TLV },
195 [UICC_FCP_T_FILE_DESC] = { TLV_TYPE_TLV },
196 [UICC_FCP_T_FILE_ID] = { TLV_TYPE_TLV },
197 [UICC_FCP_T_DF_NAME] = { TLV_TYPE_TLV },
198 [UICC_FCP_T_SFID] = { TLV_TYPE_TLV },
199 [UICC_FCP_T_LIFEC_STS] = { TLV_TYPE_TLV },
200 [UICC_FCP_T_SEC_ATTR_REFEXP] = { TLV_TYPE_TLV },
201 [UICC_FCP_T_SEC_ATTR_COMP] = { TLV_TYPE_TLV },
202 [UICC_FCP_T_PROPRIETARY] = { TLV_TYPE_TLV },
203 [UICC_FCP_T_SEC_ATTR_EXP] = { TLV_TYPE_TLV },
204 [UICC_FCP_T_PIN_STS_DO] = { TLV_TYPE_TLV },
205 },
206};
207
208/* Annex E - TS 101 220 */
Pau Espin Pedrol92274452017-06-17 23:27:47 +0200209static const uint8_t __attribute__((__unused__)) adf_uicc_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x01 };