Added TETRA cryptographic primitives (TEA1-3, TAA1 minus TA61).
If a keyfile is loaded (using -k flag), matching signalling frames
will be decrypted. No support for traffic or identity encryption
yet. Based on https://github.com/MidnightBlueLabs/TETRA_crypto
Change-Id: I0c0227cf5b747bd5032602390175b898173f6ae6
Added functions that will eventually allow for mac resource decryption,
voice/traffic decryption and identity decryption. Calls to the true TEA
keystream generator functions and TA61 identity decryption function
will need to be added in a later patch.
Change-Id: I4e6147f206ad6046f32e08015ec9721b64382ca1
Added fixups for msgb len field whenever the tail is modified
Also, added some clarifying comments
Change-Id: Ia725edbeafe26bd2ea9b5a1810d0b26bc79d84db
Added an additional command line flag -k to tetra-rx that allows for the
loading of a file containing network and key definitions.
Change-Id: I65b7ac8feb3c2a9a8cac95149f625e9ef534b66c
Added keyfile parsing code, as well as various other improvements such as definition/enum updates and freeing the tetra_crypto_context when done
Change-Id: I1c7afeeb2dcf97ece44bb4b604f44ba88882b93f
The tcs (Tetra Crypto State) struct now maintains information relevant for decryption, such as the current network, colour code, hyperframe, etcetera.
Also, the upper mac now calls a stub decryption function when receiving an encrypted resource.
Change-Id: I92d718789d6b7e84c1901d09165fce59cdf8c1ca
A crypto folder has been added containing only a single c and h file at the moment. These files contain structs and high level functionality pertaining to TETRA crypto support which can be added in future patches.
Change-Id: I63bc712630ae5dbaa049c129d456f7aef5bda863
Slot stealing is how a traffic slot can be partially or fully "stolen" by a control channel. This patch adds support for that and maintains the stealing status in the tetra_mac_state. This can be used to prevent passing a signalling half slot to the voice decoder.
Change-Id: I01a112e6e74f75401649d358b8f98c6248d2522b
We now have a list containing the lengths of the different llc pdu type minimum lengths
Before parsing the pdu, we validate the l2len is indeed sufficient to contain the pdu
This prevents out-of-bounds reads for corrupted packets.
Change-Id: I118ba2227a22afd295fffaa51aab3e45e85ff3d7
the rx_tm_sdu and rx_tl_sdu did not belong in tetra_upper_mac and are removed. Instead, we use rx_tm_sdu in tetra_llc.c, who in turn invokes rx_tl_sdu in tetra_mle.c. The llc can now also make use of the advanced link defragmentation code that was already there but unused.
Change-Id: I294c684e97c55876f1a207a7152a83dad4ebaa26
BL-ACK with and without FCS are now supported
Various improvements for advanced link parsing
tetra_llc_pdu_parse now prevents further out-of-bounds reads by setting the tl sdu length to 0 whenever the tm sdu was too short for proper parsing
Change-Id: If31858a16611ab7853e3ab840704dd2d9657a2a8
The upper mac now maintains a defragmentation buffer for each timeslot. Resources with length -1 (fragmentation start) are added to the buf for that slot, further mac/frag frames are appended. When a mac/end is encountered, the reconstructed l2 message is passed to rx_tm_sdu. The tetra_llc_pdu struct now uses a uint32_t for tl_sdu_len in order to account for the possibly longer sdus. Fill bits processing was required in order to reliably determine the end of a MAC PDU.
Change-Id: I41c9438b0b12c2fac9dff1b226eec5b33f30fbb4
According to the tetra_tdma_time struct definition, the tn should be in range 1-4. Also, tetra_burst_sync_in increments the timeslot number when in a synchronized state. The timeslot is then normalized with normalize_tn which also expects the tn to be within the 1-4 range.
Change-Id: Ib0967fdeef3bf37c612124626a74d240aa571a66
The AFC implementation by SQ5BPF as used in his fork of osmo-tetra significantly increases reception quality. A simple test yields 14545 valid CRCs as opposed to 11934 when AFC is not used.
I added the AFC to float_to_bits, the functionality can be activated with the -a flag.
Change-Id: I1c9343b83739108a1e423c4880e1dc7964656529
tp_sap_udata_ind now accepts a parameter designating from which block
(first or second) of the downlink burst the bits originate (not
applicable for all downlink burst types). In some cases, the upper mac
needs this information, see ETSI EN 300 392-7 clause 6.4.1
Change-Id: I5ff316a773906328e19c3530b09d7412f9c731ec
tetra_llc_pdu.c now parses the FCS (Frame Check Sequence) for basic link pdus
that use it. Some changes were made to the tetra_resrc_decoded struct
definition. The have_fcs field designates the FCS was present, while the FCS
field holds the extracted FCS, and FCS_invalid designates an FCS was present
but differs from the computed value.
Change-Id: I81941110801d00ca06bdafdcc0a7afaf7b7617d3
fill_bits and grant_position bits are now parsed and stored in the tetra_resrc_decoded struct
A flag is_encrypted is set to to true if resource was not encrypted or if the calling function
states that the frame has been decrypted successfully before passing it to tetra_resrc_decoded.
Lastly, the channel_alloc element is only parsed if the frame is unencrypted.
Change-Id: I6c85c93b70a34e01fd1a96a863f0e113be6424d3
gsmtap_sendmsg() may return an error, and we need to free the msg.
Likewise, if we don't even call gsmtap_sendmsg, the msgb must be free'd.
Change-Id: I9b018165982996cafb2fd17e89646177462002c6
Depends: libosmocore I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5
Related: OS#5329
Finding synchronization sequence eats several times more CPU time than the
actual decoding. This is especially pronounced on channels with lots of errors
(where synchronization is lost frequently) and channels that are most of the
time empty (such as uplink channels, support for which is coming in following
patches).
Profiling shows that all the time is spent in memcmp calls.
A complicated and efficient algorithm, e.g. Aho-Corasick, turned out to be
not necessary. Compilers can optimize even a simple bit filter into fast code.
This provides only a modest (~25 %) performance gain, more fixes are coming.
Fixes: OS#1897
Change-Id: I3b90cc70c2ec67253a0fd2f00c6957a80971c38b
When a bad frame is received, the scrambling should not be updated,
because setting scrambling to wrong values will completely break further
decoding (until another SYNC frame is received).
Change-Id: I5e88b52fcbb98532d7ab6ca85e4f956589a595ab
Running tetra-rx on a capture with lots of bit errors is not
deterministic. Investigation with Valgrind shows various errors about
uninitialised values in libosmocore's viterbi decoder.
The cause appears to lie in @lower_mac/viterbi.c@. The only function
there allocates space for 864 symbols and then fills it with the symbols
received. However, sym_count is sometimes less than 864, leaving the
rest of the array uninitialized.
Initializing it with @int8_t vit_inp[864*4] = {0};@ fixes the problem.
Change-Id: Ib745c387e21fb81afef69efcf7e46d5d49331c8f
Fixes: OS#3410
Since the gerrit build jobs no longer contain git clean workspace config (for
good reasons), it is important to use osmo-clean-workspace.sh. To make it work
best, this jenkins.sh should follow the same structure as most others do.
Change-Id: I3eca957c52b2c018e4c784b29330a0d06c4e3595
keeps some of the device specific scripts in addition to the (supposedly
generic) osmosdr-tetra_demod_fft.py
Also, update the README file to corresponding changes.
Change-Id: Icae93bb9a6a7219e14931fb6e04a4c6fffa0779d