Added OPc option to UE. (needs testing.)

master
Pedro Alvarez 7 years ago
parent ea5445f999
commit 75c5e476f1

@ -52,6 +52,17 @@
DECLARATIONS 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 Name: liblte_security_generate_k_asme

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

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

@ -229,6 +229,14 @@ uint8_t security_128_eea2(uint8_t *key,
/****************************************************************************** /******************************************************************************
* Authentication * 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 security_milenage_f1( uint8_t *k,
uint8_t *op, uint8_t *op,

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

@ -46,11 +46,30 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_)
const char *imei_c = args->imei.c_str(); const char *imei_c = args->imei.c_str();
uint32_t i; uint32_t i;
if(32 == args->op.length()) { if(32 == args->k.length()) {
str_to_hex(args->op, op); str_to_hex(args->k, k);
} else { } else {
usim_log->error("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); usim_log->error("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
usim_log->console("Invalid length for OP: %zu should be %d\n", args->op.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()) { if(15 == args->imsi.length()) {
@ -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); 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; auth_algo = auth_algo_milenage;
if("xor" == args->algo) { if("xor" == args->algo) {
auth_algo = auth_algo_xor; auth_algo = auth_algo_xor;

Loading…
Cancel
Save