mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
iu_tx_sec_mode_cmd(): add send_ck flag parameter
In this way the caller can distinguish between sending an IK or an IK+CK Security Mode Command.
This commit is contained in:
@@ -37,4 +37,5 @@ int iu_tx(struct msgb *msg, uint8_t sapi);
|
||||
int iu_rab_act_cs(struct ue_conn_ctx *ue_ctx, uint32_t rtp_ip, uint16_t rtp_port);
|
||||
int iu_rab_act_ps(struct sgsn_pdp_ctx *pdp);
|
||||
int iu_rab_deact(struct ue_conn_ctx *ue_ctx, uint8_t rab_id);
|
||||
int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp);
|
||||
int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp,
|
||||
int send_ck);
|
||||
|
@@ -755,7 +755,7 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
|
||||
|
||||
/* The MS is authorized */
|
||||
if (ctx->ran_type == MM_CTX_T_UTRAN_Iu && !ctx->iu.integrity_active) {
|
||||
return iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet);
|
||||
return iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet, 0);
|
||||
}
|
||||
|
||||
switch (ctx->pending_req) {
|
||||
|
@@ -116,7 +116,8 @@ int iu_rab_deact(struct ue_conn_ctx *ue_ctx, uint8_t rab_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp)
|
||||
int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp,
|
||||
int send_ck)
|
||||
{
|
||||
struct osmo_scu_prim *prim;
|
||||
struct msgb *msg;
|
||||
@@ -124,10 +125,6 @@ int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp)
|
||||
uint8_t ck[16];
|
||||
unsigned int i;
|
||||
|
||||
/* C4 function to dervie CK from Kc */
|
||||
memcpy(ck, tp->kc, 8);
|
||||
memcpy(ck+8, tp->kc, 8);
|
||||
|
||||
/* C5 function to derive IK from Kc */
|
||||
for (i = 0; i < 4; i++)
|
||||
ik[i] = tp->kc[i] ^ tp->kc[i+4];
|
||||
@@ -135,8 +132,14 @@ int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp)
|
||||
for (i = 12; i < 16; i++)
|
||||
ik[i] = ik[i-12];
|
||||
|
||||
if (send_ck) {
|
||||
/* C4 function to derive CK from Kc */
|
||||
memcpy(ck, tp->kc, 8);
|
||||
memcpy(ck+8, tp->kc, 8);
|
||||
}
|
||||
|
||||
/* crate RANAP message */
|
||||
msg = ranap_new_msg_sec_mod_cmd(ik, NULL);
|
||||
msg = ranap_new_msg_sec_mod_cmd(ik, send_ck? ck : NULL);
|
||||
msg->l2h = msg->data;
|
||||
/* wrap RANAP message in SCCP N-DATA.req */
|
||||
prim = (struct osmo_scu_prim *) msgb_push(msg, sizeof(*prim));
|
||||
|
Reference in New Issue
Block a user