Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pespin committed Jan 8, 2024
1 parent 7d60b13 commit 119da3f
Show file tree
Hide file tree
Showing 18 changed files with 991 additions and 21 deletions.
27 changes: 27 additions & 0 deletions lib/crypt/ogs-kdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define FC_FOR_EPS_ALGORITHM_KEY_DERIVATION 0x15
#define FC_FOR_CK_IK_DERIVATION_HANDOVER 0x16
#define FC_FOR_NAS_TOKEN_DERIVATION 0x17
#define FC_FOR_KASME_DERIVATION_IDLE_MOBILITY 0x19
#define FC_FOR_CK_IK_DERIVATION_IDLE_MOBILITY 0x1B

typedef struct kdf_param_s {
Expand Down Expand Up @@ -415,6 +416,32 @@ void ogs_kdf_nas_token(
memcpy(nas_token, output, 2);
}

/* TS33.401 Annex A.11 : K’ASME from CK, IK derivation during idle mode mobility */
void ogs_kdf_kasme_idle_mobility(
const uint8_t *ck, const uint8_t *ik,
uint32_t nonce_ue, uint32_t nonce_mme,
uint8_t *kasme)
{
kdf_param_t param;
uint8_t key[OGS_KEY_LEN*2];

ogs_assert(ck);
ogs_assert(ik);
ogs_assert(kasme);

memcpy(key, ck, OGS_KEY_LEN);
memcpy(key+OGS_KEY_LEN, ik, OGS_KEY_LEN);

memset(param, 0, sizeof(param));
param[0].buf = (uint8_t *)&nonce_ue;
param[0].len = sizeof(nonce_ue);
param[1].buf = (uint8_t *)&nonce_mme;
param[1].len = sizeof(nonce_mme);

ogs_kdf_common(key, OGS_KEY_LEN*2,
FC_FOR_KASME_DERIVATION_IDLE_MOBILITY, param, kasme);
}

/* TS33.401 Annex A.13: KASME to CK', IK' derivation at idle mobility */
void ogs_kdf_ck_ik_idle_mobility(
uint32_t ul_count, const uint8_t *kasme, uint8_t *ck, uint8_t *ik)
Expand Down
4 changes: 4 additions & 0 deletions lib/crypt/ogs-kdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ void ogs_kdf_ck_ik_handover(
void ogs_kdf_nas_token(
uint32_t ul_count, const uint8_t *kasme, uint8_t *nas_token);

/* TS33.401 Annex A.11 : K’ASME from CK, IK derivation during idle mode mobility */
void ogs_kdf_kasme_idle_mobility(const uint8_t *ck, const uint8_t *ik,
uint32_t nonce_ue, uint32_t nonce_mme, uint8_t *kasme);

/* TS33.401 Annex A.13: KASME to CK', IK' derivation at idle mobility */
void ogs_kdf_ck_ik_idle_mobility(
uint32_t ul_count, const uint8_t *kasme, uint8_t *ck, uint8_t *ik);
Expand Down
Loading

0 comments on commit 119da3f

Please sign in to comment.