aboutsummaryrefslogtreecommitdiffstats
path: root/src/sim/card_fs_uicc.c
blob: 03dbad3207f73bb89e067f8a69fd01915f99a0e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <osmocom/sim/sim.h>
#include <osmocom/gsm/tlv.h>

/* TS 102 221 V10.0.0 / 10.2.1 */
const struct osim_card_sw ts102221_uicc_sw[] = {
	{
		0x9000, 0xffff, SW_TYPE_STR, SW_CLS_OK,
		.u.str = "Normal ending of the command",
	}, {
		0x9100, 0xff00, SW_TYPE_STR, SW_CLS_OK,
		.u.str = "Normal ending of the command, extra info proactive",
	}, {
		0x9200, 0xff00, SW_TYPE_STR, SW_CLS_OK,
		.u.str = "Normal ending of the command, extra info regarding transfer session",
	}, {
		0x9300, 0xff00, SW_TYPE_STR, SW_CLS_POSTP,
		.u.str = "SIM Application Toolkit is busy, command cannot be executed at present",
	}, {
		0x6200, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "No information given, state of non volatile memory unchanged",
	}, {
		0x6281, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "Part of returned data may be corrupted",
	}, {
		0x6282, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "End of file/record reached before reading Le bytes",
	}, {
		0x6283, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "Selected file invalidated",
	}, {
		0x6285, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "Selected file in termination state",
	}, {
		0x62f1, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "More data available",
	}, {
		0x62f2, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "More data available and proactive command pending",
	}, {
		0x62f3, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "Response data available",
	}, {
		0x63f1, 0xffff, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "More data expected",
	}, {
		0x63c0, 0xfff0, SW_TYPE_STR, SW_CLS_WARN,
		.u.str = "Verification falied, X retries remaining",
	}, {
		0x6400, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Execution - No information given, state of non-volatile memory unchanged",
	}, {
		0x6500, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Execution - No information given, state of non-volatile memory changed",
	}, {
		0x6581, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Execution - Memory problem",
	}, {
		0x6700, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Wrong length",
	}, {
		0x6700, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Command dependent error",
	}, {
		0x6b00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Wrong parameter(s) P1-P2",
	}, {
		0x6d00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Instruction code not supported or valid",
	}, {
		0x6e00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Class not supported",
	}, {
		0x6f00, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Technical problem, no precise diagnostics",
	}, {
		0x6f00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Checking - Command dependent error",
	}, {
		0x6800, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Function in CLA not supported - No information given",
	}, {
		0x6881, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Function in CLA not supported - Logical channel not supported",
	}, {
		0x6882, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Function in CLA not supportied - Secure messaging not supported",
	}, {
		0x6900, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - No information given",
	}, {
		0x6981, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Command incompatible with file structure",
	}, {
		0x6982, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Security status not satisfied",
	}, {
		0x6983, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Authentication/PIN method blocked",
	}, {
		0x6984, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Referenced data invalidated",
	}, {
		0x6985, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Conditions of use not satisfied",
	}, {
		0x6986, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - Noe EF selected",
	}, {
		0x6989, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Command not allowed - secure channel - security not satisfied",
	}, {
		0x6a80, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Incorrect parameters in the data field",
	}, {
		0x6a81, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Function not supported",
	}, {
		0x6a82, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - File not found",
	}, {
		0x6a83, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Record not found",
	}, {
		0x6a84, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Not enough memory space",
	}, {
		0x6a86, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Incorrect parameters P1 to P2",
	}, {
		0x6a87, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Lc inconsistent with P1 ot P2",
	}, {
		0x6a88, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Wrong parameters - Referenced data not found",
	}, {
		0x9850, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Application error - INCREASE cannot be performed, max value reached",
	}, {
		0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Application error - Authentication error, application specific",
	}, {
		0x9863, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
		.u.str = "Application error - Security session or association expired",
	},
	OSIM_CARD_SW_LAST
};

const struct value_string ts102221_fcp_vals[14] = {
	{ UICC_FCP_T_FCP,		"File control parameters" },
	{ UICC_FCP_T_FILE_SIZE,		"File size" },
	{ UICC_FCP_T_TOT_F_SIZE,	"Total size of files" },
	{ UICC_FCP_T_FILE_DESC,		"File descriptor" },
	{ UICC_FCP_T_FILE_ID,		"File identifier" },
	{ UICC_FCP_T_DF_NAME,		"DF name" },
	{ UICC_FCP_T_SFID,		"Short file identifier" },
	{ UICC_FCP_T_LIFEC_STS,		"Lifecycle status integer" },
	{ UICC_FCP_T_SEC_ATTR_REFEXP,	"Security attributes (Referenced/Expanded)" },
	{ UICC_FCP_T_SEC_ATTR_COMP,	"Security attributes (Compact)" },
	{ UICC_FCP_T_PROPRIETARY,	"Proprietary" },
	{ UICC_FCP_T_SEC_ATTR_EXP,	"Security attributes (Expanded)" },
	{ UICC_FCP_T_PIN_STS_DO,	"PIN Status DO" },
	{ 0, NULL }
};

/* FIXME: Ber-TLV ?? */
const struct tlv_definition ts102221_fcp_tlv_def = {
	.def = {
		[UICC_FCP_T_FCP]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_FILE_SIZE]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_TOT_F_SIZE]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_FILE_DESC]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_FILE_ID]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_DF_NAME]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_SFID]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_LIFEC_STS]		= { TLV_TYPE_TLV },
		[UICC_FCP_T_SEC_ATTR_REFEXP]	= { TLV_TYPE_TLV },
		[UICC_FCP_T_SEC_ATTR_COMP]	= { TLV_TYPE_TLV },
		[UICC_FCP_T_PROPRIETARY] 	= { TLV_TYPE_TLV },
		[UICC_FCP_T_SEC_ATTR_EXP]	= { TLV_TYPE_TLV },
		[UICC_FCP_T_PIN_STS_DO]		= { TLV_TYPE_TLV },
	},
};

/* Annex E - TS 101 220 */
static const uint8_t adf_uicc_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x01 };