diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn index 5a645bdcd..51aebd2ed 100644 --- a/bsc/MSC_ConnectionHandler.ttcn +++ b/bsc/MSC_ConnectionHandler.ttcn @@ -323,19 +323,65 @@ function f_rsl_reply(template PDU_ML3_MS_NW l3, RSL_Message orig) runs on MSC_Co f_rsl_send_l3(l3, link_id, chan_nr); } +/* Convert the chipher representation on BSSMAP to the representation used on RSL */ +function f_chipher_mode_bssmap_to_rsl(OCT1 alg_bssmap) return OCT1 +{ + /* A5 0 */ + if (alg_bssmap == '01'O) { + return '01'O; + } + /* A5 1 */ + else if (alg_bssmap == '02'O) { + return '02'O; + } + /* A5 2 */ + else if (alg_bssmap == '04'O) { + return '03'O; + } + /* A5 3 */ + else if (alg_bssmap == '08'O) { + return '04'O; + } + /* A5 4 */ + else if (alg_bssmap == '10'O) { + return '05'O; + } + /* A5 5 */ + else if (alg_bssmap == '20'O) { + return '06'O; + } + /* A5 6 */ + else if (alg_bssmap == '40'O) { + return '07'O; + } + /* A5 7 */ + else if (alg_bssmap == '80'O) { + return '08'O; + } else { + setverdict(fail, "Unexpected Encryption Algorithm"); + return '00'O; + } +} + function f_cipher_mode(OCT1 alg, OCT8 key, template OCT16 kc128 := omit, boolean exp_fail := false) runs on MSC_ConnHdlr { var PDU_BSSAP bssap; var RSL_Message rsl; + var OCT1 alg_rsl; if (isvalue(kc128)) { BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(alg, key, valueof(kc128))); } else { BSSAP.send(ts_BSSMAP_CipherModeCmd(alg, key)); } + + /* RSL uses a different representation of the encryption algorithm, + * so we need to convert first */ + alg_rsl := f_chipher_mode_bssmap_to_rsl(alg); + alt { /* RSL/UE Side */ - [] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg, key)) -> value rsl { + [] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, key)) -> value rsl { var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[3].body.l3_info.payload); log("Rx L3 from net: ", l3); if (ischosen(l3.msgs.rrm.cipheringModeCommand)) {