Commit d21f6411 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/nr_derive_key_ng_ran_star' into integration_2022_wk51

parents 599fd419 f8f1723b
...@@ -61,6 +61,8 @@ int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id, ...@@ -61,6 +61,8 @@ int derive_key(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id,
int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out); const uint8_t key[32], uint8_t **out);
int nr_derive_key_ng_ran_star(uint16_t pci, uint64_t nr_arfcn_dl, const uint8_t key[32], uint8_t *key_ng_ran_star);
//#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)
//#define derive_key_nas_int(aLGiD, kEY, kNAS) derive_key(NAS_INT_ALG, aLGiD, kEY, kNAS) //#define derive_key_nas_int(aLGiD, kEY, kNAS) derive_key(NAS_INT_ALG, aLGiD, kEY, kNAS)
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#define FC_KASME_TO_CK (0x16) #define FC_KASME_TO_CK (0x16)
#define NR_FC_ALG_KEY_DER (0x69) #define NR_FC_ALG_KEY_DER (0x69)
#define NR_FC_ALG_KEY_NG_RAN_STAR_DER (0x70)
#ifndef hton_int32 #ifndef hton_int32
# define hton_int32(x) \ # define hton_int32(x) \
......
...@@ -127,40 +127,38 @@ int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, ...@@ -127,40 +127,38 @@ int nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id,
return 0; return 0;
} }
/* int nr_derive_key_ng_ran_star(uint16_t pci, uint64_t nr_arfcn_dl, const uint8_t key[32], uint8_t *key_ng_ran_star)
int derive_keNB(const uint8_t key[32], const uint32_t nas_count, uint8_t **keNB)
{ {
uint8_t string[7]; uint8_t *out;
uint8_t s[10];
// FC /* FC */
string[0] = FC_KENB; s[0] = NR_FC_ALG_KEY_NG_RAN_STAR_DER;
// P0 = Uplink NAS count
string[1] = (nas_count & 0xff000000) >> 24;
string[2] = (nas_count & 0x00ff0000) >> 16;
string[3] = (nas_count & 0x0000ff00) >> 8;
string[4] = (nas_count & 0x000000ff);
// Length of NAS count /* P0 = PCI */
string[5] = 0x00; s[1] = (pci & 0x0000ff00) >> 8;
string[6] = 0x04; s[2] = (pci & 0x000000ff);
#if defined(SECU_DEBUG) /* L0 = length(P0) = 2 */
{ s[3] = 0x00;
int i; s[4] = 0x02;
char payload[6 * sizeof(string) + 1];
int index = 0;
for (i = 0; i < sizeof(string); i++) /* P1 = NR ARFCN */
index += sprintf(&payload[index], "0x%02x ", string[i]); s[5] = (nr_arfcn_dl & 0x00ff0000) >> 16;
LOG_D(OSA, "KeNB deriver input string: %s\n", payload); s[6] = (nr_arfcn_dl & 0x0000ff00) >> 8;
} s[7] = (nr_arfcn_dl & 0x000000ff);
#endif
/* L1 = length(P1) = 3 */
s[8] = 0x00;
s[9] = 0x03;
kdf(string, 7, key, 32, keNB, 32); kdf(s, 10, key, 32, &out, 32);
memcpy(key_ng_ran_star, out, 32);
free(out);
return 0; return 0;
} }
*/
int derive_skgNB(const uint8_t *keNB, const uint16_t sk_counter, uint8_t *skgNB) int derive_skgNB(const uint8_t *keNB, const uint16_t sk_counter, uint8_t *skgNB)
{ {
......
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