feat: add conf2uedata tool for generating .*.nvram
This patch adds the conf2uedata tool for generating .ue.nvram* .ue.emm.nvram* and .usim.nvram* files from a textual configuration file. The configuration file define most usefull values like plmns, mnc, mcc, msin, K, OPc for several users. The files generated will always ends with a number corresponding to the user entry in the configuration file. This breaks oai5g because other script have not be updated for using conf2uedata. This breaks also the at_nas_ue command. Examples of configuration files are in openair3/NAS/TOOLS/
This commit is contained in:
committed by
Frédéric Leroy
parent
c4707bd8b7
commit
17d155325a
@@ -49,16 +49,14 @@
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
|
||||
u8 mac_a_pP[8], const u8 op[16])
|
||||
u8 mac_a_pP[8], const u8 op_c[16])
|
||||
{
|
||||
u8 op_c[16];
|
||||
u8 temp[16];
|
||||
u8 in1[16];
|
||||
u8 out1[16];
|
||||
u8 rijndaelInput[16];
|
||||
u8 i;
|
||||
RijndaelKeySchedule( k_pP );
|
||||
ComputeOPc(op, op_c);
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
|
||||
@@ -104,9 +102,8 @@ void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
void f2345 ( u8 k_pP[16], u8 rand_pP[16],
|
||||
u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6],const u8 op[16])
|
||||
u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6],const u8 op_c[16])
|
||||
{
|
||||
u8 op_c[16];
|
||||
u8 temp[16];
|
||||
u8 out[16];
|
||||
u8 rijndaelInput[16];
|
||||
@@ -122,7 +119,6 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
|
||||
rand_pP[8],rand_pP[9],rand_pP[10],rand_pP[11],rand_pP[12],rand_pP[13],rand_pP[14],rand_pP[15]);
|
||||
|
||||
RijndaelKeySchedule( k_pP );
|
||||
ComputeOPc(op, op_c);
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
|
||||
@@ -205,16 +201,14 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
|
||||
u8 mac_s_pP[8],const u8 op[16])
|
||||
u8 mac_s_pP[8],const u8 op_c[16])
|
||||
{
|
||||
u8 op_c[16];
|
||||
u8 temp[16];
|
||||
u8 in1[16];
|
||||
u8 out1[16];
|
||||
u8 rijndaelInput[16];
|
||||
u8 i;
|
||||
RijndaelKeySchedule( k_pP );
|
||||
ComputeOPc(op, op_c);
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
|
||||
@@ -260,15 +254,13 @@ void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
|
||||
*
|
||||
*-----------------------------------------------------------------*/
|
||||
void f5star( u8 k_pP[16], u8 rand_pP[16],
|
||||
u8 ak_pP[6], const u8 op[16])
|
||||
u8 ak_pP[6], const u8 op_c[16])
|
||||
{
|
||||
u8 op_c[16];
|
||||
u8 temp[16];
|
||||
u8 out[16];
|
||||
u8 rijndaelInput[16];
|
||||
u8 i;
|
||||
RijndaelKeySchedule( k_pP );
|
||||
ComputeOPc(op, op_c);
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
|
||||
|
||||
@@ -88,22 +88,6 @@ int usim_api_read(const char *filename, usim_data_t* data)
|
||||
LOG_FUNC_RETURN (RETURNerror);
|
||||
}
|
||||
|
||||
/* initialize the subscriber authentication security key */
|
||||
hex_string_to_hex_value(data->keys.usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE);
|
||||
|
||||
// initialize OP
|
||||
/* PFT OP used currently in HSS (OPENAIRHSS/auc/kdf.c) */
|
||||
#define OAI_LTEBOX
|
||||
|
||||
#ifdef OAI_LTEBOX
|
||||
u8 _op[16] = {0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
|
||||
0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 };
|
||||
#else
|
||||
u8 _op[16] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
|
||||
#endif
|
||||
memcpy(data->keys.op, _op, sizeof(_op));
|
||||
|
||||
LOG_FUNC_RETURN (RETURNok);
|
||||
}
|
||||
|
||||
@@ -367,7 +351,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
|
||||
|
||||
u8 ak[USIM_API_AK_SIZE];
|
||||
f2345(usim_data->keys.usim_api_k, rand_pP->value,
|
||||
res_pP->value, ck_pP->value, ik_pP->value, ak, usim_data->keys.op);
|
||||
res_pP->value, ck_pP->value, ik_pP->value, ak, usim_data->keys.opc);
|
||||
LOG_TRACE(INFO, "USIM-API - res(f2) :%s",dump_octet_string(res_pP));
|
||||
LOG_TRACE(INFO, "USIM-API - ck(f3) :%s",dump_octet_string(ck_pP));
|
||||
LOG_TRACE(INFO, "USIM-API - ik(f4) :%s",dump_octet_string(ik_pP));
|
||||
@@ -388,7 +372,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
|
||||
/* Compute XMAC = f1K (SQN || RAND || AMF) */
|
||||
#define USIM_API_XMAC_SIZE 8
|
||||
u8 xmac[USIM_API_XMAC_SIZE];
|
||||
f1(usim_data->keys.usim_api_k, rand_pP->value, sqn, &autn_pP->value[USIM_API_SQN_SIZE], xmac, usim_data->keys.op);
|
||||
f1(usim_data->keys.usim_api_k, rand_pP->value, sqn, &autn_pP->value[USIM_API_SQN_SIZE], xmac, usim_data->keys.opc);
|
||||
LOG_TRACE(DEBUG,
|
||||
"USIM-API - Computed XMAC %02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
xmac[0],xmac[1],xmac[2],xmac[3],
|
||||
@@ -416,7 +400,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
|
||||
|
||||
/* Concealed value of the counter SQNms in the USIM:
|
||||
* Conc(SQNMS) = SQNMS ⊕ f5*K(RAND) */
|
||||
f5star(usim_data->keys.usim_api_k, rand_pP->value, ak, usim_data->keys.op);
|
||||
f5star(usim_data->keys.usim_api_k, rand_pP->value, ak, usim_data->keys.opc);
|
||||
|
||||
|
||||
u8 sqn_ms[USIM_API_SQNMS_SIZE];
|
||||
@@ -445,7 +429,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
|
||||
#define USIM_API_MACS_SIZE USIM_API_XMAC_SIZE
|
||||
u8 macs[USIM_API_MACS_SIZE];
|
||||
f1star(usim_data->keys.usim_api_k, rand_pP->value, sqn_ms,
|
||||
&rand_pP->value[USIM_API_SQN_SIZE], macs, usim_data->keys.op);
|
||||
&rand_pP->value[USIM_API_SQN_SIZE], macs, usim_data->keys.opc);
|
||||
LOG_TRACE(DEBUG, "USIM-API - MACS %02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
macs[0],macs[1],macs[2],macs[3],
|
||||
macs[4],macs[5],macs[6],macs[7]);
|
||||
|
||||
@@ -124,7 +124,7 @@ typedef struct {
|
||||
#define USIM_IK_SIZE 16
|
||||
Byte_t ik[USIM_IK_SIZE];
|
||||
uint8_t usim_api_k[USIM_API_K_SIZE];
|
||||
uint8_t op[16];
|
||||
uint8_t opc[16];
|
||||
} usim_keys_t;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user