[M] Change in pysim[master]: ota: CAT_TP / TCP dialect of TS 102 225 secured packet
Attention is currently required from: Hoernchen, laforge. dexter has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43717?usp=email ) Change subject: ota: CAT_TP / TCP dialect of TS 102 225 secured packet ...................................................................... Patch Set 1: Code-Review+1 (8 comments) Patchset: PS1: I have already put a lot of comments. I now carefully looked through the command packet encoder/decoder. To me it looks correct. I found no mistake, but with all those magic numbers the code is very hard to follow. I suggest to add some constants and if necessary rephrase to code so that it becomes more obvious what already happens. Other than that, I see no further problems. Even though I didn't look at the response packet/encoder I am confident that those are bug-free too. File pySim/ota.py: https://gerrit.osmocom.org/c/pysim/+/43717/comment/bb722aa8_9cf5db52?usp=ema... : PS1, Line 745: RPI = 0x02 maybe put a ``` # TS 102 225, section 6 ``` comment behind CPI and RPI for the sake of completeness? https://gerrit.osmocom.org/c/pysim/+/43717/comment/f35b515a_103987c7?usp=ema... : PS1, Line 782: padding = otak.crypt._get_padding(6 + len_sig + len(apdu), otak.crypt.blocksize) Here we have a hardcoded length of 6. As far as I understand this is the CNTR (5 octets) plus PCNTR (1 octet) https://gerrit.osmocom.org/c/pysim/+/43717/comment/ca5a6cae_7b62b79d?usp=ema... : PS1, Line 788: cnt = otak.cntr.to_bytes(5, 'big') + bytes([pad_cnt]) Here you convert the counter value (CNTR) to bytes (5). And you append the pad_cnt, which holds the number of padding bytes. I think this is a bit hard to follow. Maybe it makes sense to define a constant for the PCNTR length. Then use this constant here and above where the padding is calculated. Otherwise it may be hard to grasp from where those numbers come from. (you also have different names for CNTR and PCNTR, maybe it makes sense to rename pad_cnt to pcntr? Maybe calculate the length of otak.cntr in one line and assign the result to a variable called cntr and then do the sum. I don't know. but I think this would be easier to understand. (just ideas for possible improvements) https://gerrit.osmocom.org/c/pysim/+/43717/comment/876323d6_a28dc8db?usp=ema... : PS1, Line 790: cpl = len(bertlv_encode_len(chl)) + chl + len(apdu) # CHI (absent) .. end of data I think you should put comments and a spec ref everwhere where the CHI (RHI) is absent, people who are not familiar with this detail may think that this is a bug. (I see its mentioned in the apidoc above, but you know, people might overread this...) https://gerrit.osmocom.org/c/pysim/+/43717/comment/b326aa98_f6861fae?usp=ema... : PS1, Line 801: raise ValueError('Unexpected CPI 0x%02x' % encoded[0]) maybe extend this a bit with "..., was expecting CPI" and then you output self.CPI. I find it very helpful when programs output such hints. In particular when I debug systems I am not so familiar with. (same for the response) https://gerrit.osmocom.org/c/pysim/+/43717/comment/471dec5f_caf2fa2a?usp=ema... : PS1, Line 806: hdr_len = 7 this is SPI(2) + KIc(1) + KID(1) + and TAR(3) I think it would be good if you would define some constants for those fixed length and use those. Those magic numbers make it very difficult to follow... https://gerrit.osmocom.org/c/pysim/+/43717/comment/ed6e04ad_5d099fe8?usp=ema... : PS1, Line 816: raise ValueError('CHL %u does not match SPI' % chl) we have a lot of 6s there. But its actually 5+1 (PCNTR+CNTR), this is hard to read... -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43717?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I122a13000e622f7550468845e8560dec5a3c55a6 Gerrit-Change-Number: 43717 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Attention: Hoernchen <ewild@sysmocom.de> Gerrit-Attention: laforge <laforge@osmocom.org> Gerrit-Comment-Date: Thu, 24 Sep 2026 15:51:35 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes
participants (1)
-
dexter