ciphering: Make sure to initialize lchan to no ciphering when activating
The ciphering parameters in L1 are persistent accross MPH deactivate/activate, so we need to make sure to always initialize them cleanly at RSL CHAN ACT time. This has the added benefit that we can also activate channels that have encryption enabled from the very beginning (required for encrypted handover).
This commit is contained in:
parent
bf91f06eca
commit
f5a0a439e9
|
@ -329,7 +329,7 @@ static int check_for_ciph_cmd(struct femtol1_hdl *fl1h,
|
|||
return 0;
|
||||
|
||||
lchan->ciph_state = LCHAN_CIPH_RX_REQ;
|
||||
l1if_enable_ciphering(fl1h, lchan, 0);
|
||||
l1if_set_ciphering(fl1h, lchan, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i
|
|||
* before decryption was enabled */
|
||||
if (data_ind->msgUnitParam.u8Buffer[0] == 0x01 &&
|
||||
(data_ind->msgUnitParam.u8Buffer[1] & 0x01) == 0) {
|
||||
l1if_enable_ciphering(fl1, lchan, 1);
|
||||
l1if_set_ciphering(fl1, lchan, 1);
|
||||
lchan->ciph_state = LCHAN_CIPH_TXRX_REQ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -678,11 +678,13 @@ int lchan_activate(struct gsm_lchan *lchan)
|
|||
/* send the primitive for all GsmL1_Sapi_* that match the LCHAN */
|
||||
l1if_req_compl(fl1h, msg, 0, lchan_act_compl_cb, lchan);
|
||||
|
||||
/* FIXME: check if encryption parameters are present, and issue
|
||||
* MPH-CONFIG.req */
|
||||
}
|
||||
lchan_set_state(lchan, LCHAN_S_ACT_REQ);
|
||||
|
||||
/* set the initial ciphering parameters for both directions */
|
||||
l1if_set_ciphering(fl1h, lchan, 0);
|
||||
l1if_set_ciphering(fl1h, lchan, 1);
|
||||
|
||||
lchan_init_lapdm(lchan);
|
||||
|
||||
return 0;
|
||||
|
@ -818,16 +820,13 @@ const enum GsmL1_CipherId_t rsl2l1_ciph[] = {
|
|||
[4] = GsmL1_CipherId_A53,
|
||||
};
|
||||
|
||||
int l1if_enable_ciphering(struct femtol1_hdl *fl1h,
|
||||
int l1if_set_ciphering(struct femtol1_hdl *fl1h,
|
||||
struct gsm_lchan *lchan,
|
||||
int dir_downlink)
|
||||
{
|
||||
struct msgb *msg = l1p_msgb_alloc();
|
||||
struct GsmL1_MphConfigReq_t *cfgr;
|
||||
|
||||
LOGP(DL1C, LOGL_NOTICE, "%s enable_ciphering(dir_downlink=%u)\n",
|
||||
gsm_lchan_name(lchan), dir_downlink);
|
||||
|
||||
cfgr = prim_init(msgb_l1prim(msg), GsmL1_PrimId_MphConfigReq, fl1h);
|
||||
|
||||
cfgr->cfgParamId = GsmL1_ConfigParamId_SetCipheringParams;
|
||||
|
@ -843,6 +842,12 @@ int l1if_enable_ciphering(struct femtol1_hdl *fl1h,
|
|||
return -EINVAL;
|
||||
cfgr->cfgParams.setCipheringParams.cipherId = rsl2l1_ciph[lchan->encr.alg_id];
|
||||
|
||||
LOGP(DL1C, LOGL_NOTICE, "%s SET_CIPHERING (ALG=%u %s)\n",
|
||||
gsm_lchan_name(lchan),
|
||||
cfgr->cfgParams.setCipheringParams.cipherId,
|
||||
get_value_string(femtobts_dir_names,
|
||||
cfgr->cfgParams.setCipheringParams.dir));
|
||||
|
||||
memcpy(cfgr->cfgParams.setCipheringParams.u8Kc,
|
||||
lchan->encr.key, lchan->encr.key_len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue