aboutsummaryrefslogtreecommitdiffstats
path: root/pySim/iso7816_4.py
blob: 1da58097c83d8f2a228953b5e62a71e83693ccfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# coding=utf-8
"""Utilities / Functions related to ISO 7816-4

(C) 2022 by Harald Welte <laforge@osmocom.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from construct import *
from pySim.construct import *
from pySim.utils import *
from pySim.filesystem import *
from pySim.tlv import *

# Table 91 + Section 8.2.1.2
class ApplicationId(BER_TLV_IE, tag=0x4f):
    _construct = GreedyBytes

# Table 91
class ApplicationLabel(BER_TLV_IE, tag=0x50):
    _construct = GreedyBytes

# Table 91 + Section 5.3.1.2
class FileReference(BER_TLV_IE, tag=0x51):
    _construct = GreedyBytes

# Table 91
class CommandApdu(BER_TLV_IE, tag=0x52):
    _construct = GreedyBytes

# Table 91
class DiscretionaryData(BER_TLV_IE, tag=0x53):
    _construct = GreedyBytes

# Table 91
class DiscretionaryTemplate(BER_TLV_IE, tag=0x73):
    _construct = GreedyBytes

# Table 91 + RFC1738 / RFC2396
class URL(BER_TLV_IE, tag=0x5f50):
    _construct = GreedyString('ascii')

# Table 91
class ApplicationRelatedDOSet(BER_TLV_IE, tag=0x61):
    _construct = GreedyBytes

# Section 8.2.1.3 Application Template
class ApplicationTemplate(BER_TLV_IE, tag=0x61, nested=[ApplicationId, ApplicationLabel, FileReference,
                          CommandApdu, DiscretionaryData, DiscretionaryTemplate, URL,
                          ApplicationRelatedDOSet]):
    pass