blob: 1da58097c83d8f2a228953b5e62a71e83693ccfc [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
27class ApplicationId(BER_TLV_IE, tag=0x4f):
28 _construct = GreedyBytes
29
30# Table 91
31class ApplicationLabel(BER_TLV_IE, tag=0x50):
32 _construct = GreedyBytes
33
34# Table 91 + Section 5.3.1.2
35class FileReference(BER_TLV_IE, tag=0x51):
36 _construct = GreedyBytes
37
38# Table 91
39class CommandApdu(BER_TLV_IE, tag=0x52):
40 _construct = GreedyBytes
41
42# Table 91
43class DiscretionaryData(BER_TLV_IE, tag=0x53):
44 _construct = GreedyBytes
45
46# Table 91
47class DiscretionaryTemplate(BER_TLV_IE, tag=0x73):
48 _construct = GreedyBytes
49
50# Table 91 + RFC1738 / RFC2396
51class URL(BER_TLV_IE, tag=0x5f50):
52 _construct = GreedyString('ascii')
53
54# Table 91
55class ApplicationRelatedDOSet(BER_TLV_IE, tag=0x61):
56 _construct = GreedyBytes
57
58# Section 8.2.1.3 Application Template
59class ApplicationTemplate(BER_TLV_IE, tag=0x61, nested=[ApplicationId, ApplicationLabel, FileReference,
Harald Weltec91085e2022-02-10 18:05:45 +010060 CommandApdu, DiscretionaryData, DiscretionaryTemplate, URL,
Harald Welte181c7c52022-02-10 14:18:32 +010061 ApplicationRelatedDOSet]):
62 pass