blob: c1df419b451012cfdf997f5f356e807482a838b1 [file] [log] [blame]
Harald Welte181c7c52022-02-10 14:18:32 +01001# coding=utf-8
2"""Utilities / Functions related to ISO 7816-4
3
4(C) 2022 by Harald Welte <laforge@osmocom.org>
5
6This program is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18"""
19
20from construct import *
21from pySim.construct import *
22from pySim.utils import *
23from pySim.filesystem import *
24from pySim.tlv import *
25
26# Table 91 + Section 8.2.1.2
Harald Weltec91085e2022-02-10 18:05:45 +010027
28
Harald Welte181c7c52022-02-10 14:18:32 +010029class ApplicationId(BER_TLV_IE, tag=0x4f):
30 _construct = GreedyBytes
31
32# Table 91
Harald Weltec91085e2022-02-10 18:05:45 +010033
34
Harald Welte181c7c52022-02-10 14:18:32 +010035class ApplicationLabel(BER_TLV_IE, tag=0x50):
36 _construct = GreedyBytes
37
38# Table 91 + Section 5.3.1.2
Harald Weltec91085e2022-02-10 18:05:45 +010039
40
Harald Welte181c7c52022-02-10 14:18:32 +010041class FileReference(BER_TLV_IE, tag=0x51):
42 _construct = GreedyBytes
43
44# Table 91
Harald Weltec91085e2022-02-10 18:05:45 +010045
46
Harald Welte181c7c52022-02-10 14:18:32 +010047class CommandApdu(BER_TLV_IE, tag=0x52):
48 _construct = GreedyBytes
49
50# Table 91
Harald Weltec91085e2022-02-10 18:05:45 +010051
52
Harald Welte181c7c52022-02-10 14:18:32 +010053class DiscretionaryData(BER_TLV_IE, tag=0x53):
54 _construct = GreedyBytes
55
56# Table 91
Harald Weltec91085e2022-02-10 18:05:45 +010057
58
Harald Welte181c7c52022-02-10 14:18:32 +010059class DiscretionaryTemplate(BER_TLV_IE, tag=0x73):
60 _construct = GreedyBytes
61
62# Table 91 + RFC1738 / RFC2396
Harald Weltec91085e2022-02-10 18:05:45 +010063
64
Harald Welte181c7c52022-02-10 14:18:32 +010065class URL(BER_TLV_IE, tag=0x5f50):
66 _construct = GreedyString('ascii')
67
68# Table 91
Harald Weltec91085e2022-02-10 18:05:45 +010069
70
Harald Welte181c7c52022-02-10 14:18:32 +010071class ApplicationRelatedDOSet(BER_TLV_IE, tag=0x61):
72 _construct = GreedyBytes
73
74# Section 8.2.1.3 Application Template
Harald Weltec91085e2022-02-10 18:05:45 +010075
76
Harald Welte181c7c52022-02-10 14:18:32 +010077class ApplicationTemplate(BER_TLV_IE, tag=0x61, nested=[ApplicationId, ApplicationLabel, FileReference,
Harald Weltec91085e2022-02-10 18:05:45 +010078 CommandApdu, DiscretionaryData, DiscretionaryTemplate, URL,
Harald Welte181c7c52022-02-10 14:18:32 +010079 ApplicationRelatedDOSet]):
80 pass