Attention is currently required from: fixeria. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27507 )
Change subject: gsm48_make_ho_cmd(): optionally add Cipher Mode Setting IE ......................................................................
Patch Set 1: Code-Review+2
(1 comment)
File src/osmo-bsc/gsm_04_08_rr.c:
https://gerrit.osmocom.org/c/osmo-bsc/+/27507/comment/7dba7aeb_6fc14bf1 PS1, Line 585: (new_lchan->encr.alg_id - 2) << 1 This looked wrong at first but i figured it out. I think it would be good to explain this, maybe put it in a separate function.
Explanation:
looking at 44.018 10.5.2.9:
if n is the A5/n number, then from the spec i get to this formula:
(n - 1) << 1
However, encr.alg_id is (for historical reasons) stored as what seems to be n + 1, which makes this formula correct.
Some comments spread around osmo-msc.git explain as:
/*! alg_id is in encoded format: * alg_id == 1 means A5/0 i.e. no encryption, alg_id == 4 means A5/3. * alg_id == 0 means no such IE was present. */
The "encoded format" is in fact the Algorithm Identifier as in 3GPP TS 48.008 3.2.2.44 Chosen Encryption Algorithm.
If I were to write this from scratch, I'd have rather stored the plain A5/n number in encr.alg_id (as encr.alg_a5). Since we have alg_id around everywhere already, I think it would be nice to have a macro like ALG_A5_NR_TO_RSL() or a seprate function to explicitly show the intended conversion.
can also follow later, we'd like to get this fix out for testing.