Added OPc option to UE. (needs testing.)

This commit is contained in:
Pedro Alvarez 2018-06-18 15:19:04 +01:00
parent ea5445f999
commit 75c5e476f1
6 changed files with 65 additions and 19 deletions

View File

@ -52,6 +52,17 @@
DECLARATIONS
*******************************************************************************/
/*********************************************************************
Name: compute_OPc
Description: Computes OPc from OP and K.
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
LIBLTE_ERROR_ENUM liblte_compute_opc(uint8 *k,
uint8 *op,
uint8 *op_c);
/*********************************************************************
Name: liblte_security_generate_k_asme

View File

@ -151,6 +151,9 @@ uint8_t security_128_eea2(uint8_t *key,
/******************************************************************************
* Authentication
*****************************************************************************/
uint8_t compute_opc( uint8_t *k,
uint8_t *op,
uint8_t *opc);
uint8_t security_milenage_f1( uint8_t *k,
uint8_t *op,

View File

@ -1418,24 +1418,35 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k,
}
/*********************************************************************
Name: compute_OPc
Name: liblte_compute_opc
Description: Computes OPc from OP and K.
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
void compute_OPc(uint8 *k,
LIBLTE_ERROR_ENUM liblte_compute_opc(uint8 *k,
uint8 *op,
uint8 *op_c)
{
uint32 i;
ROUND_KEY_STRUCT round_keys;
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
if(k != NULL &&
op != NULL &&
op_c != NULL)
{
rijndael_key_schedule(k, &round_keys);
rijndael_encrypt(op, &round_keys, op_c);
for(i=0; i<16; i++)
{
op_c[i] ^= op[i];
}
err = LIBLTE_SUCCESS;
}
return err;
}
/*******************************************************************************

View File

@ -229,6 +229,14 @@ uint8_t security_128_eea2(uint8_t *key,
/******************************************************************************
* Authentication
*****************************************************************************/
uint8_t compute_opc( uint8_t *k,
uint8_t *op,
uint8_t *opc)
{
return liblte_compute_opc(k,
op,
opc);
}
uint8_t security_milenage_f1( uint8_t *k,
uint8_t *op,

View File

@ -110,6 +110,7 @@ private:
auth_algo_t auth_algo;
uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H
uint8_t op[16];
uint8_t opc[16];
uint64_t imsi;
uint64_t imei;
uint8_t k[16];

View File

@ -46,12 +46,31 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_)
const char *imei_c = args->imei.c_str();
uint32_t i;
if(32 == args->k.length()) {
str_to_hex(args->k, k);
} else {
usim_log->error("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
usim_log->console("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
}
if(args->using_op)
{
if(32 == args->op.length()) {
str_to_hex(args->op, op);
compute_opc(k,op,opc);
} else {
usim_log->error("Invalid length for OP: %zu should be %d\n", args->op.length(), 32);
usim_log->console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32);
}
}
else{
if(32 == args->opc.length()) {
str_to_hex(args->opc, opc);
} else {
usim_log->error("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32);
usim_log->console("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32);
}
}
if(15 == args->imsi.length()) {
imsi = 0;
@ -77,13 +96,6 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_)
usim_log->console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15);
}
if(32 == args->k.length()) {
str_to_hex(args->k, k);
} else {
usim_log->error("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
usim_log->console("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
}
auth_algo = auth_algo_milenage;
if("xor" == args->algo) {
auth_algo = auth_algo_xor;