Merge branch 'chrysn/for-29033' into chrysn/ota

Change-Id: Ie0d9b0c04fe618d3809e117823c519b28d15ea05
This commit is contained in:
Christian Amsüss 2022-08-19 23:02:20 +02:00
commit 3cec0150ee
1 changed files with 13 additions and 6 deletions

View File

@ -23,6 +23,7 @@ from bidict import bidict
import zlib import zlib
import abc import abc
import struct import struct
from typing import Optional
# ETS TS 102 225 gives the general command structure and the dialects for CAT_TP, TCP/IP and HTTPS # ETS TS 102 225 gives the general command structure and the dialects for CAT_TP, TCP/IP and HTTPS
# 3GPP TS 31.115 gives the dialects for SMS-PP, SMS-CB, USSD and HTTP # 3GPP TS 31.115 gives the dialects for SMS-PP, SMS-CB, USSD and HTTP
@ -158,7 +159,12 @@ class OtaDialect(abc.ABC):
pass pass
@abc.abstractmethod @abc.abstractmethod
def decode_resp(self, otak: OtaKeyset, apdu: bytes) -> bytes: def decode_resp(self, otak: OtaKeyset, apdu: bytes) -> (object, Optional["CompactRemoteResp"]):
"""Decode a response into a response packet and, if indicted (by a
response status of `"por_ok"`) a decoded response.
The response packet's common characteristics are not fully determined,
and (so far) completely proprietary per dialect."""
pass pass
@ -401,7 +407,7 @@ class OtaDialectSms(OtaDialect):
return envelope_data return envelope_data
def decode_resp(self, otak: OtaKeyset, spi: dict, data: bytes) -> bytes: def decode_resp(self, otak: OtaKeyset, spi: dict, data: bytes) -> ("OtaDialectSms.SmsResponsePacket", Optional["CompactRemoteResp"]):
if isinstance(data, str): if isinstance(data, str):
data = h2b(data) data = h2b(data)
# plain-text POR: 027100000e0ab000110000000000000001612f # plain-text POR: 027100000e0ab000110000000000000001612f
@ -448,7 +454,8 @@ class OtaDialectSms(OtaDialect):
raise OtaCheckError('Unknown por_rc_cc_ds: %s' % spi['por_rc_cc_ds']) raise OtaCheckError('Unknown por_rc_cc_ds: %s' % spi['por_rc_cc_ds'])
# TODO: ExpandedRemoteResponse according to TS 102 226 5.2.2 # TODO: ExpandedRemoteResponse according to TS 102 226 5.2.2
dec = CompactRemoteResp.parse(res['secured_data']) if res.response_status == 'por_ok':
dec['tar'] = res['tar'] dec = CompactRemoteResp.parse(res['secured_data'])
dec['response_status'] = res['response_status'] else:
return dec dec = None
return (res, dec)