aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-03-21 14:16:10 +0100
committerHarald Welte <laforge@osmocom.org>2020-03-21 16:31:17 +0100
commit2954aa9b8a71108f44e5fd25401198453501e6a7 (patch)
tree3f47889d930532322894b90b72c534378a0adfd4
parente92f3628a88228b61f1b66d4fc21b16b9349328b (diff)
sim: Add HPSIM application support
-rw-r--r--src/sim/Makefile.am2
-rw-r--r--src/sim/card_fs_hpsim.c76
-rw-r--r--src/sim/core.c1
-rw-r--r--src/sim/sim_int.h1
4 files changed, 79 insertions, 1 deletions
diff --git a/src/sim/Makefile.am b/src/sim/Makefile.am
index 14bbbd84..0539dd98 100644
--- a/src/sim/Makefile.am
+++ b/src/sim/Makefile.am
@@ -14,7 +14,7 @@ lib_LTLIBRARIES = libosmosim.la
libosmosim_la_SOURCES = core.c reader.c class_tables.c \
card_fs_sim.c card_fs_usim.c card_fs_uicc.c \
- card_fs_isim.c card_fs_tetra.c
+ card_fs_isim.c card_fs_hpsim.c card_fs_tetra.c
libosmosim_la_LDFLAGS = -version-info $(LIBVERSION)
libosmosim_la_LIBADD = \
$(top_builddir)/src/libosmocore.la \
diff --git a/src/sim/card_fs_hpsim.c b/src/sim/card_fs_hpsim.c
new file mode 100644
index 00000000..4a5f7d9a
--- /dev/null
+++ b/src/sim/card_fs_hpsim.c
@@ -0,0 +1,76 @@
+/*! \file card_fs_hpsim.c
+ * 3GPP HPSIM specific structures / routines. */
+/*
+ * (C) 2020 by Harald Welte <laforge@gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <errno.h>
+#include <string.h>
+
+#include <osmocom/sim/sim.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/gsm/gsm48.h>
+
+#include "sim_int.h"
+#include "gsm_int.h"
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 7.1.3 */
+const struct osim_card_sw ts31_104_sw[] = {
+ {
+ 0x9862, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
+ .u.str = "Security management - Authentication error, incorrect MAC",
+ },
+ OSIM_CARD_SW_LAST
+};
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 4.2 */
+static const struct osim_file_desc hpsim_ef_in_adf_hpsim[] = {
+ EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
+ "Access Rule TLV data objects"),
+ EF_TRANSP_N(0x6F07, 0x07, "EF.IMST", 0, 9, 9,
+ "IMSI"),
+ EF_TRANSP_N(0x6FAD, 0x03, "EF_AD", 0, 4, 8,
+ "Administrative Data"),
+};
+
+/* Annex E - TS 101 220 */
+static const uint8_t adf_hpsim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x0A };
+
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx)
+{
+ struct osim_card_app_profile *aprof;
+ struct osim_file_desc *iadf;
+
+ aprof = talloc_zero(ctx, struct osim_card_app_profile);
+ aprof->name = "3GPP HPSIM";
+ aprof->sw = ts31_104_sw;
+ aprof->aid_len = sizeof(adf_hpsim_aid);
+ memcpy(aprof->aid, adf_hpsim_aid, aprof->aid_len);
+
+ /* ADF.HPSIM with its EF siblings */
+ iadf = alloc_adf_with_ef(aprof, adf_hpsim_aid, sizeof(adf_hpsim_aid), "ADF.HPSIM",
+ hpsim_ef_in_adf_hpsim, ARRAY_SIZE(hpsim_ef_in_adf_hpsim));
+ aprof->adf = iadf;
+
+ return aprof;
+}
diff --git a/src/sim/core.c b/src/sim/core.c
index 80a168f4..8b2d6f92 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -453,6 +453,7 @@ int osim_init(void *ctx)
{
osim_app_profile_register(osim_aprof_usim(ctx));
osim_app_profile_register(osim_aprof_isim(ctx));
+ osim_app_profile_register(osim_aprof_hpsim(ctx));
return 0;
}
diff --git a/src/sim/sim_int.h b/src/sim/sim_int.h
index 99a22428..a96a9cd2 100644
--- a/src/sim/sim_int.h
+++ b/src/sim/sim_int.h
@@ -33,5 +33,6 @@ void osim_app_profile_register(struct osim_card_app_profile *aprof);
struct osim_card_app_profile *osim_aprof_usim(void *ctx);
struct osim_card_app_profile *osim_aprof_isim(void *ctx);
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx);
#endif