fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37690?usp=email )
Change subject: recognize ADF.PKCS15, allow selecting it ......................................................................
recognize ADF.PKCS15, allow selecting it
This is not a complete implementation of the PKCS#15 by any means. This patch simply defines AID=a000000063504b43532d3135 and allows easily selecting it. Files in this ADF do not have statically assigned FIDs, they reference each other using card/vendor specific FIDs, which need to be resolved dynamically.
AIDs on card: USIM: a0000000871002fffff00189000001ff (EF.DIR) ISIM: a0000000871004fffff00189000001ff (EF.DIR) PKCS15: a000000063504b43532d3135 (EF.DIR) pySIM-shell (00:MF)> select ADF.PKCS15
On some UICCs (e.g. sipgate), selecting this ADF may return an error:
pySIM-shell (00:MF)> select ADF.PKCS15 EXCEPTION of type 'SwMatchError' occurred with message: SW match failed! Expected 9000 and got 6999.
In this case one can read MF/EF.DIR and get the DF reference from there:
pySIM-shell (00:MF)> select MF/EF.DIR pySIM-shell (00:MF/EF.DIR)> read_records_decoded ... "application_id": "a000000063504b43532d3135" "application_label": "PKCS15" "file_reference": "3f007f80" ... pySIM-shell (00:MF/EF.DIR)> select 3f00/7f80
Change-Id: I7ea6d91805868645ae1c1a4a2c5870f7d041f74b --- M pySim/app.py A pySim/pkcs15.py 2 files changed, 78 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/90/37690/1
diff --git a/pySim/app.py b/pySim/app.py index 5525cd1..4f6e4ec 100644 --- a/pySim/app.py +++ b/pySim/app.py @@ -39,6 +39,7 @@ import pySim.ts_31_103 import pySim.ts_31_104 import pySim.ara_m +import pySim.pkcs15 import pySim.global_platform import pySim.euicc
diff --git a/pySim/pkcs15.py b/pySim/pkcs15.py new file mode 100644 index 0000000..1a34ae1 --- /dev/null +++ b/pySim/pkcs15.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +""" +Support for the PKCS#15 application inside an UICC. +""" + +# +# Copyright (C) 2024 Vadim Yanitskiy fixeria@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 pySim.filesystem import * +from pySim.utils import Hexstr + + +class ADF_ARF(CardADF): + def __init__(self, aid='a000000063504b43532d3135', name='ADF.PKCS15', fid=None, sfid=None, + desc='PKCS15 application'): + super().__init__(aid=aid, fid=fid, sfid=sfid, name=name, desc=desc) + files = [ + ] + self.add_files(files) + + +class CardApplicationARF(CardApplication): + def __init__(self): + super().__init__('PKCS15', adf=ADF_ARF())