blob: 339e8627745a15fa7347b60e9a54d907c023527e [file] [log] [blame]
Harald Welte171c5b12014-05-04 14:09:35 +02001/* 3GPP ISIM specific structures / routines */
2/*
3 * (C) 2014 by Harald Welte <laforge@gnumonks.org>
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23
24#include <errno.h>
25#include <string.h>
26
27#include <osmocom/sim/sim.h>
28#include <osmocom/core/talloc.h>
29#include <osmocom/gsm/gsm48.h>
30
31#include "sim_int.h"
32#include "gsm_int.h"
33
34/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 7.1.3 */
35const struct osim_card_sw ts31_103_sw[] = {
36 {
37 0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
38 .u.str = "Security management - Authentication error, incorrect MAC",
39 },
40 OSIM_CARD_SW_LAST
41};
42
43static const struct osim_card_sw *isim_card_sws[] = {
44 ts31_103_sw,
45 ts102221_uicc_sw,
46 NULL
47};
48
Harald Welte171c5b12014-05-04 14:09:35 +020049/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 4.2 */
50static const struct osim_file_desc isim_ef_in_adf_isim[] = {
51 EF_TRANSP_N(0x6F02, 0x02, "EF.IMPI", 0, 1, 256,
52 "IMS private user identity"),
53 EF_TRANSP_N(0x6F03, 0x05, "EF.DOMAIN", 0, 1, 256,
54 "Home Network Domain Name"),
55 EF_LIN_FIX_N(0x6F04, 0x04, "EF.IMPU", 0, 1, 256,
56 "IMS public user identity"),
57 EF_TRANSP_N(0x6FAD, 0x03, "EF.AD", 0, 4, 16,
58 "Administrative Data"),
59 EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
60 "Access Rule TLV data objects"),
61 EF_TRANSP_N(0x6F07, 0x07, "EF.IST", F_OPTIONAL, 1, 16,
62 "ISIM Service Table"),
63 EF_LIN_FIX_N(0x6F09, SFI_NONE, "EF.P-CSCF", F_OPTIONAL, 1, 256,
64 "P-CSCF Address"),
65 EF_TRANSP_N(0x6FD5, SFI_NONE, "EF.GBABP", F_OPTIONAL, 1, 35,
66 "GBA Bootstrapping parameters"),
67 EF_LIN_FIX_N(0x6FD7, SFI_NONE, "EF.GBANL", F_OPTIONAL, 1, 256,
68 "NAF Key Identifier TLV Objects"),
69 EF_LIN_FIX_N(0x6FDD, SFI_NONE, "EF.NAFKCA", F_OPTIONAL, 1, 256,
70 "NAF Key Centre Address"),
71 EF_LIN_FIX_N(0x6F3C, SFI_NONE, "EF.SMS", F_OPTIONAL, 176, 176,
72 "Short messages"),
73 EF_TRANSP_N(0x6F43, SFI_NONE, "EF.SMSS", F_OPTIONAL, 2, 4,
74 "SMS status"),
75 EF_LIN_FIX_N(0x6F47, SFI_NONE, "EF.SMSR", F_OPTIONAL, 30, 30,
76 "Short message status reports"),
77 EF_LIN_FIX_N(0x6F42, SFI_NONE, "EF.SMSP", F_OPTIONAL, 29, 64,
78 "Short message service parameters"),
79 EF_LIN_FIX_N(0x6FE7, SFI_NONE, "EF.UICCIARI", F_OPTIONAL, 1, 256,
80 "UICC IARI"),
81};
82
83/* Annex E - TS 101 220 */
84static const uint8_t adf_isim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x04 };
85
86struct osim_card_profile *osim_cprof_isim(void *ctx)
87{
88 struct osim_card_profile *cprof;
89 struct osim_file_desc *mf;
90
91 cprof = talloc_zero(ctx, struct osim_card_profile);
92 cprof->name = "3GPP ISIM";
93 cprof->sws = isim_card_sws;
94
95 mf = alloc_df(cprof, 0x3f00, "MF");
96
97 cprof->mf = mf;
98
99 /* ADF.USIM with its EF siblings */
100 add_adf_with_ef(mf, adf_isim_aid, sizeof(adf_isim_aid),
101 "ADF.ISIM", isim_ef_in_adf_isim,
102 ARRAY_SIZE(isim_ef_in_adf_isim));
103
104 return cprof;
105}