blob: 9a52af47f2d6d8f444a9ce186282da8563b3ab29 [file] [log] [blame]
Harald Welte676e5342016-03-14 21:04:50 +01001/*
2 * (C) 2016 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
Harald Welte676e5342016-03-14 21:04:50 +010015 */
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20
21#include <osmocom/sim/sim.h>
22#include <osmocom/sim/class_tables.h>
23
24const uint8_t sim_sel_mf[] = { 0xA0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
25const uint8_t usim_sel_mf[] = { 0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
26const uint8_t uicc_tprof[] = { 0x80, 0x10, 0x00, 0x00, 0x02, 0x01, 0x02 };
27const uint8_t uicc_tprof_wrong_class[] = { 0x00, 0x10, 0x00, 0x00, 0x02, 0x01, 0x02 };
28const uint8_t uicc_read[] = { 0x00, 0xB0, 0x00, 0x00, 0x10 };
29const uint8_t uicc_upd[] = { 0x00, 0xD6, 0x00, 0x00, 0x02, 0x01, 0x02 };
Harald Welte020b3242024-04-02 14:09:47 +020030const uint8_t uicc_get_status[] = { 0x80, 0xf2, 0x00, 0x02, 0x10 };
31const uint8_t euicc_m2m_get_status[] = { 0x81, 0xf2, 0x40, 0x02, 0x02, 0x4f, 0x00 };
Harald Welte676e5342016-03-14 21:04:50 +010032
33#define APDU_CASE_ASSERT(x, y) \
34 do { \
35 printf("Testing " #x "\n"); \
36 int rc = osim_determine_apdu_case(&osim_uicc_sim_cic_profile, x); \
37 if (rc != y) \
38 printf("%d (actual) != %d (intended)\n", rc, y); \
39 OSMO_ASSERT(rc == y); \
40 } while (0)
41
42static void test_cla_ins_tbl(void)
43{
44 APDU_CASE_ASSERT(sim_sel_mf, 4);
45 APDU_CASE_ASSERT(usim_sel_mf, 4);
46 APDU_CASE_ASSERT(uicc_tprof, 3);
47 APDU_CASE_ASSERT(uicc_tprof_wrong_class, 0);
48 APDU_CASE_ASSERT(uicc_read, 2);
49 APDU_CASE_ASSERT(uicc_upd, 3);
Harald Welte020b3242024-04-02 14:09:47 +020050 APDU_CASE_ASSERT(uicc_get_status, 2);
51 APDU_CASE_ASSERT(euicc_m2m_get_status, 4);
Harald Welte676e5342016-03-14 21:04:50 +010052}
53
54int main(int argc, char **argv)
55{
56 test_cla_ins_tbl();
Holger Hans Peter Freyther92c4ec22016-03-21 11:28:59 +010057 return EXIT_SUCCESS;
Harald Welte676e5342016-03-14 21:04:50 +010058}