P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
380 stars 130 forks source link

Parsing `RRLP_Components.LocationError` gives wrong results #249

Closed matan1008 closed 4 months ago

matan1008 commented 7 months ago

When parsing LocationError in RRLP component, the result might be wrong, for example:

from pycrate_asn1dir.RRLP import *
error = RRLP_Components.LocationError
error.from_uper(b'\x04\x99\x02@\x00')
print(error())

Gives {'locErrorReason': 'notEnoughSats'}, but according to wireshark the parsing is image

Versions:

pycrate = 0.7.0 python = 3.12

mitshell commented 4 months ago

RRLP is encoded is unaligned PER, which means the encoding is not aligned on byte-boundary. Hence, the buffer you copy from wireshark may not correspond to the exact PDU part you are looking for. Here, if you offset your buffer from 7 bits, the decoding of this RRLP object will lead to the expected value:

{'locErrorReason': 'gpsAssDataMissing', 'additionalAssistanceData': {'gpsAssistanceData': b' \x00'}}

Please note a new repository has been setup, including new fixes. This repo will keep being maintained : https://github.com/pycrate-org/pycrate.

matan1008 commented 4 months ago

Thanks a lot!