Commit 598eeb79 authored by Xue Song's avatar Xue Song

Derive keys from kgnb

parent ac902811
...@@ -182,13 +182,6 @@ typedef enum nr_e_rab_satus_e { ...@@ -182,13 +182,6 @@ typedef enum nr_e_rab_satus_e {
NR_E_RAB_STATUS_FAILED, NR_E_RAB_STATUS_FAILED,
} nr_e_rab_status_t; } nr_e_rab_status_t;
typedef enum nr_pdu_session_status_e {
NR_PDU_SESSION_STATUS_NEW,
NR_PDU_SESSION_STATUS_DONE, // from the gNB perspective
NR_PDU_SESSION_STATUS_ESTABLISHED, // get the reconfigurationcomplete form UE
NR_PDU_SESSION_STATUS_FAILED,
} nr_pdu_session_status_t;
typedef struct nr_e_rab_param_s { typedef struct nr_e_rab_param_s {
e_rab_t param; e_rab_t param;
uint8_t status; uint8_t status;
...@@ -265,8 +258,10 @@ typedef struct nr_rrc_guami_s { ...@@ -265,8 +258,10 @@ typedef struct nr_rrc_guami_s {
} nr_rrc_guami_t; } nr_rrc_guami_t;
typedef enum pdu_session_satus_e { typedef enum pdu_session_satus_e {
PDU_SESSION_STATUS_NEW PDU_SESSION_STATUS_NEW,
//TODO PDU_SESSION_STATUS_DONE,
PDU_SESSION_STATUS_ESTABLISHED,
PDU_SESSION_STATUS_FAILED,
} pdu_session_status_t; } pdu_session_status_t;
typedef struct pdu_session_param_s { typedef struct pdu_session_param_s {
......
This diff is collapsed.
...@@ -55,6 +55,8 @@ typedef enum { ...@@ -55,6 +55,8 @@ typedef enum {
int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id, int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id,
const uint8_t key[32], uint8_t **out); const uint8_t key[32], uint8_t **out);
int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out);
//#define derive_key_nas_enc(aLGiD, kEY, kNAS) derive_key(NAS_ENC_ALG, aLGiD, kEY, kNAS) //#define derive_key_nas_enc(aLGiD, kEY, kNAS) derive_key(NAS_ENC_ALG, aLGiD, kEY, kNAS)
...@@ -72,6 +74,19 @@ int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id, ...@@ -72,6 +74,19 @@ int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id,
#define derive_key_up_int(aLGiD, kEY, kNAS) \ #define derive_key_up_int(aLGiD, kEY, kNAS) \
derive_key(UP_INT_ALG, aLGiD, kEY, kNAS) derive_key(UP_INT_ALG, aLGiD, kEY, kNAS)
// 5G SA
#define nr_derive_key_rrc_enc(aLGiD, kEY, kRRC) \
nr_derive_key(RRC_ENC_ALG, aLGiD, kEY, kRRC)
#define nr_derive_key_rrc_int(aLGiD, kEY, kRRC) \
nr_derive_key(RRC_INT_ALG, aLGiD, kEY, kRRC)
#define nr_derive_key_up_enc(aLGiD, kEY, kUP) \
nr_derive_key(UP_ENC_ALG, aLGiD, kEY, kUP)
#define nr_derive_key_up_int(aLGiD, kEY, kUP) \
nr_derive_key(UP_INT_ALG, aLGiD, kEY, kUP)
typedef struct { typedef struct {
uint8_t *key; uint8_t *key;
uint32_t key_length; uint32_t key_length;
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define FC_ALG_KEY_DER (0x15) #define FC_ALG_KEY_DER (0x15)
#define FC_KASME_TO_CK (0x16) #define FC_KASME_TO_CK (0x16)
#define NR_FC_ALG_KEY_DER (0x69)
#ifndef hton_int32 #ifndef hton_int32
# define hton_int32(x) \ # define hton_int32(x) \
(((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | \ (((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | \
......
...@@ -97,6 +97,34 @@ int derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, ...@@ -97,6 +97,34 @@ int derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id,
return 0; return 0;
} }
int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out)
{
uint8_t string[7];
/* FC */
string[0] = NR_FC_ALG_KEY_DER;
/* P0 = algorithm type distinguisher */
string[1] = (uint8_t)(alg_type & 0xFF);
/* L0 = length(P0) = 1 */
string[2] = 0x00;
string[3] = 0x01;
/* P1 */
string[4] = alg_id;
/* L1 = length(P1) = 1 */
string[5] = 0x00;
string[6] = 0x01;
kdf(string, 7, key, 32, out, 32);
return 0;
}
/* /*
int derive_keNB(const uint8_t key[32], const uint32_t nas_count, uint8_t **keNB) int derive_keNB(const uint8_t key[32], const uint32_t nas_count, uint8_t **keNB)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment