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
381 stars 132 forks source link

Decoding Range256 FreqListRange is not correct #161

Open jewalt opened 2 years ago

jewalt commented 2 years ago

When decoding the following GSM SIB2: 59061A8BE7D683080000000000000000000000FF010000

I get the following ARFCNs (975 is the original ARFCN): 975, 1023, 1148 and 1152

The correct networks should be: 975, 124 ,128, 975 and 1023

This is due to a missing mod 1024 for Range256 and Range128 networks.

I am pretty sure there is also a bug in Range512 in that the result should be N, not W(0) + N mod 1024. Since Range 512, 256, 128 and BitmapVar are all decoded in https://github.com/P1sec/pycrate/blob/26c1a0a6bd26f9b0ab8f22e6efc619cbda3642b3/pycrate_mobile/TS44018_IE.py#L304

Correct?

p1-bmu commented 2 years ago

Thanks for your submission. I never checked those encodings too deeply, so you may be correct. Could you eventually provide some SIB buffers with various ARFCN range encodings, so that after patching, I can integrate specific tests ?

jewalt commented 2 years ago

I will do my best, but I'm not sure I can generate useful (and accurate) data for all ranges. I know I can generate 256 as that is the default in the tools I am using, but I will check and see if I can manipulate that to use the other ranges.