blob: 2c115b75660c14867645984c4acf3e61c0647f8a [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 *
Harald Welte2954aa92020-03-21 14:16:10 +010020 */
21
22
23#include <errno.h>
24#include <string.h>
25
26#include <osmocom/sim/sim.h>
27#include <osmocom/core/talloc.h>
28#include <osmocom/gsm/gsm48.h>
29
30#include "sim_int.h"
31#include "gsm_int.h"
32
33/* TS 31.104 Version 15.0.0 Release 15 / Chapter 7.1.3 */
34const struct osim_card_sw ts31_104_sw[] = {
35 {
36 0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
37 .u.str = "Security management - Authentication error, incorrect MAC",
38 },
39 OSIM_CARD_SW_LAST
40};
41
42/* TS 31.104 Version 15.0.0 Release 15 / Chapter 4.2 */
43static const struct osim_file_desc hpsim_ef_in_adf_hpsim[] = {
44 EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
45 "Access Rule TLV data objects"),
46 EF_TRANSP_N(0x6F07, 0x07, "EF.IMST", 0, 9, 9,
47 "IMSI"),
48 EF_TRANSP_N(0x6FAD, 0x03, "EF_AD", 0, 4, 8,
49 "Administrative Data"),
50};
51
52/* Annex E - TS 101 220 */
53static const uint8_t adf_hpsim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x0A };
54
55struct osim_card_app_profile *osim_aprof_hpsim(void *ctx)
56{
57 struct osim_card_app_profile *aprof;
58 struct osim_file_desc *iadf;
59
60 aprof = talloc_zero(ctx, struct osim_card_app_profile);
61 aprof->name = "3GPP HPSIM";
62 aprof->sw = ts31_104_sw;
63 aprof->aid_len = sizeof(adf_hpsim_aid);
64 memcpy(aprof->aid, adf_hpsim_aid, aprof->aid_len);
65
66 /* ADF.HPSIM with its EF siblings */
67 iadf = alloc_adf_with_ef(aprof, adf_hpsim_aid, sizeof(adf_hpsim_aid), "ADF.HPSIM",
68 hpsim_ef_in_adf_hpsim, ARRAY_SIZE(hpsim_ef_in_adf_hpsim));
69 aprof->adf = iadf;
70
71 return aprof;
72}