lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

January 2024

  • 1 participants
  • 1559 discussions
Change in osmo-ccid-firmware[master]: add simple gangupdater for multiple octsim boards
by roh 15 Mar '25

15 Mar '25
roh has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/26896 ) Change subject: add simple gangupdater for multiple octsim boards ...................................................................... add simple gangupdater for multiple octsim boards Change-Id: Ic10572c121ac55586ec43126b63d69529757132b --- A contrib/flash_all_octsim.sh 1 file changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/96/26896/1 diff --git a/contrib/flash_all_octsim.sh b/contrib/flash_all_octsim.sh new file mode 100644 index 0000000..4f4c89b --- /dev/null +++ b/contrib/flash_all_octsim.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# this script is to scan for octsim boards, sort them by usb path and call dfu-util on each to update the board +# basic flow +# - get usb path and serialno tupel from dfu-util -l +# - reformat and sort by usbpath, drop the usbpath (grep cut tr sort cut) +# - flash the boards + +# TODO: +# - error handling +# - filter dfu-util output and generate nice summary + +dfu-util -l \ + | grep "^Found" \ + | grep "\[1d50:6141\]" \ + | cut -d ' ' -f 8,13 \ + | tr -d ',' \ + | cut -d \" -f 2,4 \ + | tr \" ' ' \ + | sort \ + | cut -d ' ' -f 2 + | xargs -n 1 dfu-util -d 1d50:6141 -D sysmoOCTSIM.bin -R -p -- To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/26896 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ccid-firmware Gerrit-Branch: master Gerrit-Change-Id: Ic10572c121ac55586ec43126b63d69529757132b Gerrit-Change-Number: 26896 Gerrit-PatchSet: 1 Gerrit-Owner: roh <jsteiger(a)sysmocom.de> Gerrit-MessageType: newchange
2 2
0 0
[L] Change in pysim[master]: Introduce GlobalPlatform SCP02 implementation
by laforge 31 Jan '24

31 Jan '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35462?usp=email ) Change subject: Introduce GlobalPlatform SCP02 implementation ...................................................................... Set Ready For Review -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35462?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I56020382b9dfe8ba0f7c1c9f71eb1a9746bc5a27 Gerrit-Change-Number: 35462 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Comment-Date: Wed, 31 Jan 2024 21:45:45 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: global_platform: implement GET STATUS command
by laforge 31 Jan '24

31 Jan '24
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/35756?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder Change subject: global_platform: implement GET STATUS command ...................................................................... global_platform: implement GET STATUS command The GlobalPlatform GET STATUS command is used to display information about ISD / Applications / ExecutabLoad Files / Modules on the card. Change-Id: Ic92f96c1c6a569aebc93a906c62a43b86fe3b811 --- M docs/shell.rst M pySim/global_platform.py 2 files changed, 107 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/56/35756/2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35756?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ic92f96c1c6a569aebc93a906c62a43b86fe3b811 Gerrit-Change-Number: 35756 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: move global_platform.py to global_platform/__init__.py
by laforge 31 Jan '24

31 Jan '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35763?usp=email ) Change subject: move global_platform.py to global_platform/__init__.py ...................................................................... move global_platform.py to global_platform/__init__.py This will allow us to have multiple different modules for different aspects of global_platform. Change-Id: Ieca0b20c26a2e41eb11455941164474b76eb3c7a --- R pySim/global_platform/__init__.py 1 file changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/35763/1 diff --git a/pySim/global_platform.py b/pySim/global_platform/__init__.py similarity index 100% rename from pySim/global_platform.py rename to pySim/global_platform/__init__.py -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35763?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ieca0b20c26a2e41eb11455941164474b76eb3c7a Gerrit-Change-Number: 35763 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: Add global_platform shell command establish_scp02 and release_scp
by laforge 31 Jan '24

31 Jan '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35764?usp=email ) Change subject: Add global_platform shell command establish_scp02 and release_scp ...................................................................... Add global_platform shell command establish_scp02 and release_scp Those commands can be used to establish and release a SCP02 secure channel on the currently active logical channel. The prompt is adjusted with a 'SCP02' prefix while the secure channel is established. Change-Id: Ib2f3c8f0563f81a941dd55b97c9836e3a6856407 --- M docs/shell.rst M pySim-shell.py M pySim/global_platform/__init__.py M pySim/global_platform/scp02.py 4 files changed, 83 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/64/35764/1 diff --git a/docs/shell.rst b/docs/shell.rst index a917f8f..dff6cd1 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -959,6 +959,16 @@ :module: pySim.global_platform :func: ADF_SD.AddlShellCommands.put_key_parser +establish_scp02 +~~~~~~~~~~~~~~~ +.. argparse:: + :module: pySim.global_platform + :func: ADF_SD.AddlShellCommands.est_scp02_parser + +release_scp +~~~~~~~~~~~ +Release any previously established SCP (Secure Channel Protocol) + eUICC ISD-R commands -------------------- diff --git a/pySim-shell.py b/pySim-shell.py index 70eaee2..abe0b5f 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -205,7 +205,11 @@ def update_prompt(self): if self.lchan: path_str = self.lchan.selected_file.fully_qualified_path_str(not self.numeric_path) - self.prompt = 'pySIM-shell (%02u:%s)> ' % (self.lchan.lchan_nr, path_str) + scp = self.lchan.scc.scp + if scp: + self.prompt = 'pySIM-shell (%s:%02u:%s)> ' % (str(scp), self.lchan.lchan_nr, path_str) + else: + self.prompt = 'pySIM-shell (%02u:%s)> ' % (self.lchan.lchan_nr, path_str) else: if self.card: self.prompt = 'pySIM-shell (no card profile)> ' @@ -258,6 +262,8 @@ def do_reset(self, opts): """Reset the Card.""" atr = self.card.reset() + if self.lchan and self.lchan.scc.scp: + self.lchan.scc.scp = None self.poutput('Card ATR: %s' % i2h(atr)) self.update_prompt() diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index 385d438..44a24df 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -1,7 +1,7 @@ # coding=utf-8 """Partial Support for GlobalPLatform Card Spec (currently 2.1.1) -(C) 2022-2023 by Harald Welte <laforge(a)osmocom.org> +(C) 2022-2024 by Harald Welte <laforge(a)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 @@ -21,6 +21,8 @@ from construct import Optional as COptional from construct import * from bidict import bidict +from Cryptodome.Random import get_random_bytes +from pySim.global_platform.scp02 import SCP02 from pySim.construct import * from pySim.utils import * from pySim.filesystem import * @@ -582,6 +584,47 @@ p2 |= 0x01 return grd_list + est_scp02_parser = argparse.ArgumentParser() + est_scp02_parser.add_argument('--key-ver', type=auto_int, required=True, + help='Key Version Number (KVN)') + est_scp02_parser.add_argument('--key-enc', type=is_hexstr, required=True, + help='Secure Channel Encryption Key') + est_scp02_parser.add_argument('--key-mac', type=is_hexstr, required=True, + help='Secure Channel MAC Key') + est_scp02_parser.add_argument('--key-dek', type=is_hexstr, required=True, + help='Data Encryption Key') + est_scp02_parser.add_argument('--host-challenge', type=is_hexstr, + help='Hard-code the host challenge; default: random') + est_scp02_parser.add_argument('--security-level', type=auto_int, default=0x01, + help='Security Level. Default: 0x01 (C-MAC only)') + + @cmd2.with_argparser(est_scp02_parser) + def do_establish_scp02(self, opts): + """Establish a secure channel using the GlobalPlatform SCP02 protocol.""" + if self._cmd.lchan.scc.scp: + self._cmd.poutput("Cannot establish SCP02 as this lchan already has a SCP instance!") + return + host_challenge = h2b(opts.host_challenge) if opts.host_challenge else get_random_bytes(8) + kset = GpCardKeyset(opts.key_ver, h2b(opts.key_enc), h2b(opts.key_mac), h2b(opts.key_dek)) + scp02 = SCP02(card_keys=kset) + init_update_apdu = scp02.gen_init_update_apdu(host_challenge=host_challenge) + init_update_resp, sw = self._cmd.lchan.scc.send_apdu_checksw(b2h(init_update_apdu)) + scp02.parse_init_update_resp(h2b(init_update_resp)) + ext_auth_apdu = scp02.gen_ext_auth_apdu(opts.security_level) + ext_auth_resp, sw = self._cmd.lchan.scc.send_apdu_checksw(b2h(ext_auth_apdu)) + self._cmd.poutput("Successfully established a SCP02 secure channel") + # store a reference to the SCP instance + self._cmd.lchan.scc.scp = scp02 + self._cmd.update_prompt() + + def do_relase_scp(self, opts): + """Release a secure channel.""" + if not self._cmd.lchan.scc.scp: + self._cmd.poutput("Cannot release SCP as none is established") + return + self._cmd.lchan.scc.scp = None + self._cmd.update_prompt() + # Card Application of a Security Domain class CardApplicationSD(CardApplication): diff --git a/pySim/global_platform/scp02.py b/pySim/global_platform/scp02.py index 29c0021..a2a032e 100644 --- a/pySim/global_platform/scp02.py +++ b/pySim/global_platform/scp02.py @@ -107,6 +107,13 @@ self.card_keys = card_keys self.sk = None self.mac_on_unmodified = False + self.security_level = None + + def __str__(self) -> str: + if self.security_level: + return "%s[%02x]" % (self.__class__.__name__, self.security_level) + else: + return "%s[??]" % (self.__class__.__name__) def _cla(self, sm: bool = False, b8: bool = True) -> int: ret = 0x80 if b8 else 0x00 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35764?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ib2f3c8f0563f81a941dd55b97c9836e3a6856407 Gerrit-Change-Number: 35764 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: commands.py: Wrap the transport send_apdu* methods
by laforge 31 Jan '24

31 Jan '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35762?usp=email ) Change subject: commands.py: Wrap the transport send_apdu* methods ...................................................................... commands.py: Wrap the transport send_apdu* methods Let's not have higher level code directly call the transports send_apdu* methods. We do this as a precursor to introducing secure channel support, where the secure channel driver would add MAC and/or encrypt APDUs before they are sent to the transport. Change-Id: I1b870140959aa8241cda2246e74576390123cb2d --- M pySim-shell.py M pySim/commands.py M pySim/euicc.py M pySim/global_platform.py M pySim/legacy/cards.py M pySim/transport/__init__.py 6 files changed, 111 insertions(+), 76 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/62/35762/1 diff --git a/pySim-shell.py b/pySim-shell.py index 5b80588..70eaee2 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -245,7 +245,7 @@ # noted that the apdu command plays an exceptional role since it is the only card accessing command that # can be executed without the presence of a runtime state (self.rs) object. However, this also means that # self.lchan is also not present (see method equip). - data, sw = self.card._scc._tp.send_apdu(opts.APDU) + data, sw = self.card._scc.send_apdu(opts.APDU) if data: self.poutput("SW: %s, RESP: %s" % (sw, data)) else: diff --git a/pySim/commands.py b/pySim/commands.py index d785251..878256b 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -5,7 +5,7 @@ # # Copyright (C) 2009-2010 Sylvain Munaut <tnt(a)246tNt.com> -# Copyright (C) 2010-2023 Harald Welte <laforge(a)gnumonks.org> +# Copyright (C) 2010-2024 Harald Welte <laforge(a)gnumonks.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 @@ -26,7 +26,7 @@ from construct import * from pySim.construct import LV -from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, i2h, str_sanitize, expand_hex +from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, i2h, str_sanitize, expand_hex, SwMatchstr from pySim.utils import Hexstr, SwHexstr, ResTuple from pySim.exceptions import SwMatchError from pySim.transport import LinkBase @@ -100,6 +100,58 @@ else: return cla_with_lchan(cla, self.lchan_nr) + def send_apdu(self, pdu: Hexstr) -> ResTuple: + """Sends an APDU and auto fetch response data + + Args: + pdu : string of hexadecimal characters (ex. "A0A40000023F00") + Returns: + tuple(data, sw), where + data : string (in hex) of returned data (ex. "074F4EFFFF") + sw : string (in hex) of status word (ex. "9000") + """ + return self._tp.send_apdu(pdu) + + def send_apdu_checksw(self, pdu: Hexstr, sw: SwMatchstr = "9000") -> ResTuple: + """Sends an APDU and check returned SW + + Args: + pdu : string of hexadecimal characters (ex. "A0A40000023F00") + sw : string of 4 hexadecimal characters (ex. "9000"). The user may mask out certain + digits using a '?' to add some ambiguity if needed. + Returns: + tuple(data, sw), where + data : string (in hex) of returned data (ex. "074F4EFFFF") + sw : string (in hex) of status word (ex. "9000") + """ + return self._tp.send_apdu_checksw(pdu, sw) + + def send_apdu_constr(self, cla: Hexstr, ins: Hexstr, p1: Hexstr, p2: Hexstr, cmd_constr: Construct, + cmd_data: Hexstr, resp_constr: Construct) -> Tuple[dict, SwHexstr]: + """Build and sends an APDU using a 'construct' definition; parses response. + + Args: + cla : string (in hex) ISO 7816 class byte + ins : string (in hex) ISO 7816 instruction byte + p1 : string (in hex) ISO 7116 Parameter 1 byte + p2 : string (in hex) ISO 7116 Parameter 2 byte + cmd_cosntr : defining how to generate binary APDU command data + cmd_data : command data passed to cmd_constr + resp_cosntr : defining how to decode binary APDU response data + Returns: + Tuple of (decoded_data, sw) + """ + cmd = cmd_constr.build(cmd_data) if cmd_data else '' + p3 = i2h([len(cmd)]) + pdu = ''.join([cla, ins, p1, p2, p3, b2h(cmd)]) + (data, sw) = self.send_apdu(pdu) + if data: + # filter the resulting dict to avoid '_io' members inside + rsp = filter_dict(resp_constr.parse(h2b(data))) + else: + rsp = None + return (rsp, sw) + # Extract a single FCP item from TLV def __parse_fcp(self, fcp: Hexstr): # see also: ETSI TS 102 221, chapter 11.1.1.3.1 Response for MF, @@ -170,8 +222,7 @@ if type(dir_list) is not list: dir_list = [dir_list] for i in dir_list: - data, sw = self._tp.send_apdu( - self.cla_byte + "a4" + self.sel_ctrl + "02" + i) + data, sw = self.send_apdu(self.cla_byte + "a4" + self.sel_ctrl + "02" + i) rv.append((data, sw)) if sw != '9000': return rv @@ -201,11 +252,11 @@ fid : file identifier as hex string """ - return self._tp.send_apdu_checksw(self.cla_byte + "a4" + self.sel_ctrl + "02" + fid) + return self.send_apdu_checksw(self.cla_byte + "a4" + self.sel_ctrl + "02" + fid) def select_parent_df(self) -> ResTuple: """Execute SELECT to switch to the parent DF """ - return self._tp.send_apdu_checksw(self.cla_byte + "a4030400") + return self.send_apdu_checksw(self.cla_byte + "a4030400") def select_adf(self, aid: Hexstr) -> ResTuple: """Execute SELECT a given Applicaiton ADF. @@ -215,7 +266,7 @@ """ aidlen = ("0" + format(len(aid) // 2, 'x'))[-2:] - return self._tp.send_apdu_checksw(self.cla_byte + "a4" + "0404" + aidlen + aid) + return self.send_apdu_checksw(self.cla_byte + "a4" + "0404" + aidlen + aid) def read_binary(self, ef: Path, length: int = None, offset: int = 0) -> ResTuple: """Execute READD BINARY. @@ -240,7 +291,7 @@ pdu = self.cla_byte + \ 'b0%04x%02x' % (offset + chunk_offset, chunk_len) try: - data, sw = self._tp.send_apdu_checksw(pdu) + data, sw = self.send_apdu_checksw(pdu) except Exception as e: raise ValueError('%s, failed to read (offset %d)' % (str_sanitize(str(e)), offset)) @@ -300,7 +351,7 @@ 'd6%04x%02x' % (offset + chunk_offset, chunk_len) + \ data[chunk_offset*2: (chunk_offset+chunk_len)*2] try: - chunk_data, chunk_sw = self._tp.send_apdu_checksw(pdu) + chunk_data, chunk_sw = self.send_apdu_checksw(pdu) except Exception as e: raise ValueError('%s, failed to write chunk (chunk_offset %d, chunk_len %d)' % (str_sanitize(str(e)), chunk_offset, chunk_len)) @@ -320,7 +371,7 @@ r = self.select_path(ef) rec_length = self.__record_len(r) pdu = self.cla_byte + 'b2%02x04%02x' % (rec_no, rec_length) - return self._tp.send_apdu_checksw(pdu) + return self.send_apdu_checksw(pdu) def __verify_record(self, ef: Path, rec_no: int, data: str): """Verify record against given data @@ -383,7 +434,7 @@ pass pdu = (self.cla_byte + 'dc%02x04%02x' % (rec_no, rec_length)) + data - res = self._tp.send_apdu_checksw(pdu) + res = self.send_apdu_checksw(pdu) if verify: self.__verify_record(ef, rec_no, data) return res @@ -421,7 +472,7 @@ pdu = self.cla4lchan('80') + 'cb008001%02x' % (tag) else: pdu = self.cla4lchan('80') + 'cb000000' - return self._tp.send_apdu_checksw(pdu) + return self.send_apdu_checksw(pdu) def retrieve_data(self, ef: Path, tag: int) -> ResTuple: """Execute RETRIEVE DATA, see also TS 102 221 Section 11.3.1. @@ -451,7 +502,7 @@ if isinstance(data, bytes) or isinstance(data, bytearray): data = b2h(data) pdu = self.cla4lchan('80') + 'db00%02x%02x%s' % (p1, len(data)//2, data) - return self._tp.send_apdu_checksw(pdu) + return self.send_apdu_checksw(pdu) def set_data(self, ef, tag: int, value: str, verify: bool = False, conserve: bool = False) -> ResTuple: """Execute SET DATA. @@ -493,7 +544,7 @@ if len(rand) != 32: raise ValueError('Invalid rand') self.select_path(['3f00', '7f20']) - return self._tp.send_apdu_checksw(self.cla4lchan('a0') + '88000010' + rand, sw='9000') + return self.send_apdu_checksw(self.cla4lchan('a0') + '88000010' + rand, sw='9000') def authenticate(self, rand: Hexstr, autn: Hexstr, context: str = '3g') -> ResTuple: """Execute AUTHENTICATE (USIM/ISIM). @@ -515,7 +566,7 @@ p2 = '81' elif context == 'gsm': p2 = '80' - (data, sw) = self._tp.send_apdu_constr_checksw( + (data, sw) = self.send_apdu_constr_checksw( self.cla_byte, '88', '00', p2, AuthCmd3G, cmd_data, AuthResp3G) if 'auts' in data: ret = {'synchronisation_failure': data} @@ -525,11 +576,11 @@ def status(self) -> ResTuple: """Execute a STATUS command as per TS 102 221 Section 11.1.2.""" - return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'F20000ff') + return self.send_apdu_checksw(self.cla4lchan('80') + 'F20000ff') def deactivate_file(self) -> ResTuple: """Execute DECATIVATE FILE command as per TS 102 221 Section 11.1.14.""" - return self._tp.send_apdu_constr_checksw(self.cla_byte, '04', '00', '00', None, None, None) + return self.send_apdu_constr_checksw(self.cla_byte, '04', '00', '00', None, None, None) def activate_file(self, fid: Hexstr) -> ResTuple: """Execute ACTIVATE FILE command as per TS 102 221 Section 11.1.15. @@ -537,31 +588,31 @@ Args: fid : file identifier as hex string """ - return self._tp.send_apdu_checksw(self.cla_byte + '44000002' + fid) + return self.send_apdu_checksw(self.cla_byte + '44000002' + fid) def create_file(self, payload: Hexstr) -> ResTuple: """Execute CREEATE FILE command as per TS 102 222 Section 6.3""" - return self._tp.send_apdu_checksw(self.cla_byte + 'e00000%02x%s' % (len(payload)//2, payload)) + return self.send_apdu_checksw(self.cla_byte + 'e00000%02x%s' % (len(payload)//2, payload)) def resize_file(self, payload: Hexstr) -> ResTuple: """Execute RESIZE FILE command as per TS 102 222 Section 6.10""" - return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'd40000%02x%s' % (len(payload)//2, payload)) + return self.send_apdu_checksw(self.cla4lchan('80') + 'd40000%02x%s' % (len(payload)//2, payload)) def delete_file(self, fid: Hexstr) -> ResTuple: """Execute DELETE FILE command as per TS 102 222 Section 6.4""" - return self._tp.send_apdu_checksw(self.cla_byte + 'e4000002' + fid) + return self.send_apdu_checksw(self.cla_byte + 'e4000002' + fid) def terminate_df(self, fid: Hexstr) -> ResTuple: """Execute TERMINATE DF command as per TS 102 222 Section 6.7""" - return self._tp.send_apdu_checksw(self.cla_byte + 'e6000002' + fid) + return self.send_apdu_checksw(self.cla_byte + 'e6000002' + fid) def terminate_ef(self, fid: Hexstr) -> ResTuple: """Execute TERMINATE EF command as per TS 102 222 Section 6.8""" - return self._tp.send_apdu_checksw(self.cla_byte + 'e8000002' + fid) + return self.send_apdu_checksw(self.cla_byte + 'e8000002' + fid) def terminate_card_usage(self) -> ResTuple: """Execute TERMINATE CARD USAGE command as per TS 102 222 Section 6.9""" - return self._tp.send_apdu_checksw(self.cla_byte + 'fe000000') + return self.send_apdu_checksw(self.cla_byte + 'fe000000') def manage_channel(self, mode: str = 'open', lchan_nr: int =0) -> ResTuple: """Execute MANAGE CHANNEL command as per TS 102 221 Section 11.1.17. @@ -575,7 +626,7 @@ else: p1 = 0x00 pdu = self.cla_byte + '70%02x%02x00' % (p1, lchan_nr) - return self._tp.send_apdu_checksw(pdu) + return self.send_apdu_checksw(pdu) def reset_card(self) -> Hexstr: """Physically reset the card""" @@ -596,8 +647,7 @@ code : chv code as hex string """ fc = rpad(b2h(code), 16) - data, sw = self._tp.send_apdu( - self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc) + data, sw = self.send_apdu(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc) self._chv_process_sw('verify', chv_no, code, sw) return (data, sw) @@ -610,8 +660,7 @@ pin_code : new chv code as hex string """ fc = rpad(b2h(puk_code), 16) + rpad(b2h(pin_code), 16) - data, sw = self._tp.send_apdu( - self.cla_byte + '2C00' + ('%02X' % chv_no) + '10' + fc) + data, sw = self.send_apdu(self.cla_byte + '2C00' + ('%02X' % chv_no) + '10' + fc) self._chv_process_sw('unblock', chv_no, pin_code, sw) return (data, sw) @@ -624,8 +673,7 @@ new_pin_code : new chv code as hex string """ fc = rpad(b2h(pin_code), 16) + rpad(b2h(new_pin_code), 16) - data, sw = self._tp.send_apdu( - self.cla_byte + '2400' + ('%02X' % chv_no) + '10' + fc) + data, sw = self.send_apdu(self.cla_byte + '2400' + ('%02X' % chv_no) + '10' + fc) self._chv_process_sw('change', chv_no, pin_code, sw) return (data, sw) @@ -638,8 +686,7 @@ new_pin_code : new chv code as hex string """ fc = rpad(b2h(pin_code), 16) - data, sw = self._tp.send_apdu( - self.cla_byte + '2600' + ('%02X' % chv_no) + '08' + fc) + data, sw = self.send_apdu(self.cla_byte + '2600' + ('%02X' % chv_no) + '08' + fc) self._chv_process_sw('disable', chv_no, pin_code, sw) return (data, sw) @@ -651,8 +698,7 @@ pin_code : chv code as hex string """ fc = rpad(b2h(pin_code), 16) - data, sw = self._tp.send_apdu( - self.cla_byte + '2800' + ('%02X' % chv_no) + '08' + fc) + data, sw = self.send_apdu(self.cla_byte + '2800' + ('%02X' % chv_no) + '08' + fc) self._chv_process_sw('enable', chv_no, pin_code, sw) return (data, sw) @@ -662,7 +708,7 @@ Args: payload : payload as hex string """ - return self._tp.send_apdu_checksw('80c20000%02x%s' % (len(payload)//2, payload)) + return self.send_apdu_checksw('80c20000%02x%s' % (len(payload)//2, payload)) def terminal_profile(self, payload: Hexstr) -> ResTuple: """Send TERMINAL PROFILE to card @@ -671,7 +717,7 @@ payload : payload as hex string """ data_length = len(payload) // 2 - data, sw = self._tp.send_apdu(('80100000%02x' % data_length) + payload) + data, sw = self.send_apdu(('80100000%02x' % data_length) + payload) return (data, sw) # ETSI TS 102 221 11.1.22 @@ -711,8 +757,7 @@ raise ValueError('Time unit must be 0x00..0x04') min_dur_enc = encode_duration(min_len_secs) max_dur_enc = encode_duration(max_len_secs) - data, sw = self._tp.send_apdu_checksw( - '8076000004' + min_dur_enc + max_dur_enc) + data, sw = self.send_apdu_checksw('8076000004' + min_dur_enc + max_dur_enc) negotiated_duration_secs = decode_duration(data[:4]) resume_token = data[4:] return (negotiated_duration_secs, resume_token, sw) @@ -722,14 +767,14 @@ """Send SUSPEND UICC (resume) to the card.""" if len(h2b(token)) != 8: raise ValueError("Token must be 8 bytes long") - data, sw = self._tp.send_apdu_checksw('8076010008' + token) + data, sw = self.send_apdu_checksw('8076010008' + token) return (data, sw) def get_data(self, tag: int, cla: int = 0x00): - data, sw = self._tp.send_apdu('%02xca%04x00' % (cla, tag)) + data, sw = self.send_apdu('%02xca%04x00' % (cla, tag)) return (data, sw) # TS 31.102 Section 7.5.2 def get_identity(self, context: int) -> Tuple[Hexstr, SwHexstr]: - data, sw = self._tp.send_apdu_checksw('807800%02x00' % (context)) + data, sw = self.send_apdu_checksw('807800%02x00' % (context)) return (data, sw) diff --git a/pySim/euicc.py b/pySim/euicc.py index e249f4f..068fb72 100644 --- a/pySim/euicc.py +++ b/pySim/euicc.py @@ -319,7 +319,7 @@ """Perform STORE DATA according to Table 47+48 in Section 5.7.2 of SGP.22. Only single-block store supported for now.""" capdu = '%sE29100%02x%s' % (scc.cla4lchan('80'), len(tx_do)//2, tx_do) - return scc._tp.send_apdu_checksw(capdu) + return scc.send_apdu_checksw(capdu) @staticmethod def store_data_tlv(scc: SimCardCommands, cmd_do, resp_cls, exp_sw='9000'): diff --git a/pySim/global_platform.py b/pySim/global_platform.py index 347399b..6793f71 100644 --- a/pySim/global_platform.py +++ b/pySim/global_platform.py @@ -495,7 +495,7 @@ {'last_block': len(remainder) == 0, 'encryption': encryption, 'structure': structure, 'response': response_permitted}) hdr = "80E2%02x%02x%02x" % (p1b[0], block_nr, len(chunk)) - data, sw = self._cmd.lchan.scc._tp.send_apdu_checksw(hdr + b2h(chunk)) + data, sw = self._cmd.lchan.scc.send_apdu_checksw(hdr + b2h(chunk)) block_nr += 1 response += data return data @@ -532,7 +532,7 @@ else: kcv = '' kdb.append({'key_type': opts.key_type[i], 'kcb': opts.key_data[i], 'kcv': kcv}) - return self.put_key(opts.old_key_version_nr, opts.key_version_nr, opts.key_id, kdb) + self.put_key(opts.old_key_version_nr, opts.key_version_nr, opts.key_id, kdb) # Table 11-68: Key Data Field - Format 1 (Basic Format) KeyDataBasic = GreedyRange(Struct('key_type'/KeyType, @@ -544,7 +544,7 @@ See GlobalPlatform CardSpecification v2.3 Section 11.8 for details.""" key_data = kvn.to_bytes(1, 'big') + build_construct(ADF_SD.AddlShellCommands.KeyDataBasic, key_dict) hdr = "80D8%02x%02x%02x" % (old_kvn, kid, len(key_data)) - data, sw = self._cmd.lchan.scc._tp.send_apdu_checksw(hdr + b2h(key_data)) + data, sw = self._cmd.lchan.scc.send_apdu_checksw(hdr + b2h(key_data)) return data get_status_parser = argparse.ArgumentParser() @@ -569,7 +569,7 @@ grd_list = [] while True: hdr = "80F2%s%02x%02x" % (subset_hex, p2, len(cmd_data)) - data, sw = self._cmd.lchan.scc._tp.send_apdu(hdr + b2h(cmd_data)) + data, sw = self._cmd.lchan.scc.send_apdu(hdr + b2h(cmd_data)) remainder = h2b(data) while len(remainder): # tlv sequence, each element is one GpRegistryRelatedData() diff --git a/pySim/legacy/cards.py b/pySim/legacy/cards.py index 9d1e2c1..5e64e95 100644 --- a/pySim/legacy/cards.py +++ b/pySim/legacy/cards.py @@ -753,7 +753,7 @@ # Set the Ki using proprietary command pdu = '80d4020010' + p['ki'] - data, sw = self._scc._tp.send_apdu(pdu) + data, sw = self._scc.send_apdu(pdu) # EF.HPLMN r = self._scc.select_path(['3f00', '7f20', '6f30']) @@ -803,7 +803,7 @@ # TODO: check if verify_chv could be used or what it needs # self._scc.verify_chv(0x0A, [0x33,0x32,0x32,0x31,0x33,0x32,0x33,0x32]) # Unlock the card.. - data, sw = self._scc._tp.send_apdu_checksw( + data, sw = self._scc.send_apdu_checksw( "0020000A083332323133323332") # TODO: move into SimCardCommands @@ -812,7 +812,7 @@ enc_iccid(p['iccid']) + # 10b ICCID enc_imsi(p['imsi']) # 9b IMSI_len + id_type(9) + IMSI ) - data, sw = self._scc._tp.send_apdu_checksw("0099000033" + par) + data, sw = self._scc.send_apdu_checksw("0099000033" + par) class SysmoSIMgr2(SimCard): @@ -851,7 +851,7 @@ pin = h2b("4444444444444444") pdu = 'A0D43A0508' + b2h(pin) - data, sw = self._scc._tp.send_apdu(pdu) + data, sw = self._scc.send_apdu(pdu) # authenticate as ADM (enough to write file, and can set PINs) diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index 59d4554..772b046 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -245,30 +245,6 @@ rsp = None return (rsp, sw) - def send_apdu_constr_checksw(self, cla: Hexstr, ins: Hexstr, p1: Hexstr, p2: Hexstr, - cmd_constr: Construct, cmd_data: Hexstr, resp_constr: Construct, - sw_exp: SwMatchstr="9000") -> Tuple[dict, SwHexstr]: - """Build and sends an APDU using a 'construct' definition; parses response. - - Args: - cla : string (in hex) ISO 7816 class byte - ins : string (in hex) ISO 7816 instruction byte - p1 : string (in hex) ISO 7116 Parameter 1 byte - p2 : string (in hex) ISO 7116 Parameter 2 byte - cmd_cosntr : defining how to generate binary APDU command data - cmd_data : command data passed to cmd_constr - resp_cosntr : defining how to decode binary APDU response data - exp_sw : string (in hex) of status word (ex. "9000") - Returns: - Tuple of (decoded_data, sw) - """ - (rsp, sw) = self.send_apdu_constr(cla, ins, - p1, p2, cmd_constr, cmd_data, resp_constr) - if not sw_match(sw, sw_exp): - raise SwMatchError(sw, sw_exp.lower(), self.sw_interpreter) - return (rsp, sw) - - def argparse_add_reader_args(arg_parser: argparse.ArgumentParser): """Add all reader related arguments to the given argparse.Argumentparser instance.""" from pySim.transport.serial import SerialSimLink -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35762?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I1b870140959aa8241cda2246e74576390123cb2d Gerrit-Change-Number: 35762 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-trx[master]: ms: do not set the blade tuning mode
by Hoernchen 31 Jan '24

31 Jan '24
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/35761?usp=email ) Change subject: ms: do not set the blade tuning mode ...................................................................... ms: do not set the blade tuning mode Sophisticated users can export BLADERF_DEFAULT_TUNING_MODE=fpga which reduces the startup time to 1 second, or BLADERF_DEFAULT_TUNING_MODE=fpga which always works. Defaulting to fpga mode has the unfortunate side effect that the blade can get stuck in a weird invalid mode when supplying wrong parameters that breaks sample streaming until it is power cycled or "reset" by using host tuning once. So, let's do the safe thing, and not default to fpga mode. Change-Id: I109f925f07a198d1fb33fe793e91e455fea05a96 --- M Transceiver52M/ms/bladerf_specific.h 1 file changed, 19 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/61/35761/1 diff --git a/Transceiver52M/ms/bladerf_specific.h b/Transceiver52M/ms/bladerf_specific.h index e9245d4..57aae75 100644 --- a/Transceiver52M/ms/bladerf_specific.h +++ b/Transceiver52M/ms/bladerf_specific.h @@ -255,7 +255,6 @@ bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_DEBUG); bladerf_set_usb_reset_on_open(true); - setenv("BLADERF_DEFAULT_TUNING_MODE","fpga",1); // ensure blade 2 does not spend 10 seconds initializing host control blade_check(bladerf_open, &dev, ""); if (!dev) { std::cerr << "open failed, device missing?" << std::endl; -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/35761?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I109f925f07a198d1fb33fe793e91e455fea05a96 Gerrit-Change-Number: 35761 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-trx[master]: ms: conditionally override the tuning mode
by Hoernchen 31 Jan '24

31 Jan '24
Hoernchen has abandoned this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email ) Change subject: ms: conditionally override the tuning mode ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I11f2ecc50b480d71736a7f224295e5e37745385e Gerrit-Change-Number: 35757 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: abandon
1 0
0 0
[S] Change in osmo-trx[master]: ms: conditionally override the tuning mode
by Hoernchen 31 Jan '24

31 Jan '24
Attention is currently required from: fixeria, pespin. Hoernchen has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email ) Change subject: ms: conditionally override the tuning mode ...................................................................... Patch Set 1: (1 comment) File Transceiver52M/ms/bladerf_specific.h: https://gerrit.osmocom.org/c/osmo-trx/+/35757/comment/7ec7dd40_2e6606cf PS1, Line 258: if (getenv("BLADERF_DEFAULT_TUNING_MODE") == NULL) > This probably deserves some sort of comment here explaining why one may want to set this. If running modem without parameters somehow gets the blade into a stuck state. That is only occurence so far, to be fixed by my config file patch that properly overrides the arfc/settings on the transceiver, since the whole thing is supposed to only work with ham radio frequencies anyway and should mostly ignore what the upper layer wants. -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I11f2ecc50b480d71736a7f224295e5e37745385e Gerrit-Change-Number: 35757 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Wed, 31 Jan 2024 18:46:07 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-trx[master]: ms: conditionally override the tuning mode
by pespin 31 Jan '24

31 Jan '24
Attention is currently required from: Hoernchen, fixeria. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email ) Change subject: ms: conditionally override the tuning mode ...................................................................... Patch Set 1: (1 comment) File Transceiver52M/ms/bladerf_specific.h: https://gerrit.osmocom.org/c/osmo-trx/+/35757/comment/815c3f60_4ad89b5a PS1, Line 258: if (getenv("BLADERF_DEFAULT_TUNING_MODE") == NULL) This probably deserves some sort of comment here explaining why one may want to set this. -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/35757?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I11f2ecc50b480d71736a7f224295e5e37745385e Gerrit-Change-Number: 35757 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Wed, 31 Jan 2024 18:39:39 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • ...
  • 156
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.