blob: 2e2eec58731c7be2220ee6af63501d04af3b943f [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 };
30
31#define APDU_CASE_ASSERT(x, y) \
32 do { \
33 printf("Testing " #x "\n"); \
34 int rc = osim_determine_apdu_case(&osim_uicc_sim_cic_profile, x); \
35 if (rc != y) \
36 printf("%d (actual) != %d (intended)\n", rc, y); \
37 OSMO_ASSERT(rc == y); \
38 } while (0)
39
40static void test_cla_ins_tbl(void)
41{
42 APDU_CASE_ASSERT(sim_sel_mf, 4);
43 APDU_CASE_ASSERT(usim_sel_mf, 4);
44 APDU_CASE_ASSERT(uicc_tprof, 3);
45 APDU_CASE_ASSERT(uicc_tprof_wrong_class, 0);
46 APDU_CASE_ASSERT(uicc_read, 2);
47 APDU_CASE_ASSERT(uicc_upd, 3);
48}
49
50int main(int argc, char **argv)
51{
52 test_cla_ins_tbl();
Holger Hans Peter Freyther92c4ec22016-03-21 11:28:59 +010053 return EXIT_SUCCESS;
Harald Welte676e5342016-03-14 21:04:50 +010054}