blob: 425ce11d711fc7b0782af3ab068d48d5a968756a [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 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include <osmocom/sim/sim.h>
26#include <osmocom/sim/class_tables.h>
27
28const uint8_t sim_sel_mf[] = { 0xA0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
29const uint8_t usim_sel_mf[] = { 0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
30const uint8_t uicc_tprof[] = { 0x80, 0x10, 0x00, 0x00, 0x02, 0x01, 0x02 };
31const uint8_t uicc_tprof_wrong_class[] = { 0x00, 0x10, 0x00, 0x00, 0x02, 0x01, 0x02 };
32const uint8_t uicc_read[] = { 0x00, 0xB0, 0x00, 0x00, 0x10 };
33const uint8_t uicc_upd[] = { 0x00, 0xD6, 0x00, 0x00, 0x02, 0x01, 0x02 };
34
35#define APDU_CASE_ASSERT(x, y) \
36 do { \
37 printf("Testing " #x "\n"); \
38 int rc = osim_determine_apdu_case(&osim_uicc_sim_cic_profile, x); \
39 if (rc != y) \
40 printf("%d (actual) != %d (intended)\n", rc, y); \
41 OSMO_ASSERT(rc == y); \
42 } while (0)
43
44static void test_cla_ins_tbl(void)
45{
46 APDU_CASE_ASSERT(sim_sel_mf, 4);
47 APDU_CASE_ASSERT(usim_sel_mf, 4);
48 APDU_CASE_ASSERT(uicc_tprof, 3);
49 APDU_CASE_ASSERT(uicc_tprof_wrong_class, 0);
50 APDU_CASE_ASSERT(uicc_read, 2);
51 APDU_CASE_ASSERT(uicc_upd, 3);
52}
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}