blob: 4a5f7d9aa39a6019a53f21b8e1e7bd0894a29a62 [file] [log] [blame]
Harald Welte2954aa92020-03-21 14:16:10 +01001/*! \file card_fs_hpsim.c
2 * 3GPP HPSIM specific structures / routines. */
3/*
4 * (C) 2020 by Harald Welte <laforge@gnumonks.org>
5 *
6 * All Rights Reserved
7 *
8 * SPDX-License-Identifier: GPL-2.0+
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 *
24 */
25
26
27#include <errno.h>
28#include <string.h>
29
30#include <osmocom/sim/sim.h>
31#include <osmocom/core/talloc.h>
32#include <osmocom/gsm/gsm48.h>
33
34#include "sim_int.h"
35#include "gsm_int.h"
36
37/* TS 31.104 Version 15.0.0 Release 15 / Chapter 7.1.3 */
38const struct osim_card_sw ts31_104_sw[] = {
39 {
40 0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
41 .u.str = "Security management - Authentication error, incorrect MAC",
42 },
43 OSIM_CARD_SW_LAST
44};
45
46/* TS 31.104 Version 15.0.0 Release 15 / Chapter 4.2 */
47static const struct osim_file_desc hpsim_ef_in_adf_hpsim[] = {
48 EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
49 "Access Rule TLV data objects"),
50 EF_TRANSP_N(0x6F07, 0x07, "EF.IMST", 0, 9, 9,
51 "IMSI"),
52 EF_TRANSP_N(0x6FAD, 0x03, "EF_AD", 0, 4, 8,
53 "Administrative Data"),
54};
55
56/* Annex E - TS 101 220 */
57static const uint8_t adf_hpsim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x0A };
58
59struct osim_card_app_profile *osim_aprof_hpsim(void *ctx)
60{
61 struct osim_card_app_profile *aprof;
62 struct osim_file_desc *iadf;
63
64 aprof = talloc_zero(ctx, struct osim_card_app_profile);
65 aprof->name = "3GPP HPSIM";
66 aprof->sw = ts31_104_sw;
67 aprof->aid_len = sizeof(adf_hpsim_aid);
68 memcpy(aprof->aid, adf_hpsim_aid, aprof->aid_len);
69
70 /* ADF.HPSIM with its EF siblings */
71 iadf = alloc_adf_with_ef(aprof, adf_hpsim_aid, sizeof(adf_hpsim_aid), "ADF.HPSIM",
72 hpsim_ef_in_adf_hpsim, ARRAY_SIZE(hpsim_ef_in_adf_hpsim));
73 aprof->adf = iadf;
74
75 return aprof;
76}