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