Starting to change f* to expect OPc. Making compute_OPc public function.

master
Pedro Alvarez 7 years ago
parent 02bc1c9956
commit aec0f3f5ac

@ -1099,7 +1099,7 @@ LIBLTE_ERROR_ENUM liblte_security_decryption_eea2(uint8 *key,
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k,
uint8 *op,
uint8 *op_c,
uint8 *rand,
uint8 *sqn,
uint8 *amf,
@ -1108,13 +1108,13 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k,
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
ROUND_KEY_STRUCT round_keys;
uint32 i;
uint8 op_c[16];
uint8 temp[16];
uint8 in1[16];
uint8 out1[16];
uint8 rijndael_input[16];
if(k != NULL &&
op_c != NULL &&
rand != NULL &&
sqn != NULL &&
amf != NULL &&
@ -1123,14 +1123,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k,
// Initialize the round keys
rijndael_key_schedule(k, &round_keys);
// Compute OPc
for(i=0;i<16;i++)
{
op_c[i] = op[i];
}
//compute_OPc(&round_keys, op, op_c);
// Compute temp
for(i=0; i<16; i++)
{
@ -1188,7 +1180,7 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k,
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k,
uint8 *op,
uint8 *op_c,
uint8 *rand,
uint8 *sqn,
uint8 *amf,
@ -1197,13 +1189,13 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k,
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
ROUND_KEY_STRUCT round_keys;
uint32 i;
uint8 op_c[16];
uint8 temp[16];
uint8 in1[16];
uint8 out1[16];
uint8 rijndael_input[16];
if(k != NULL &&
op_c != NULL &&
rand != NULL &&
sqn != NULL &&
amf != NULL &&
@ -1212,14 +1204,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k,
// Initialize the round keys
rijndael_key_schedule(k, &round_keys);
for(i=0;i<16;i++)
{
op_c[i] = op[i];
}
// Compute OPc
//compute_OPc(&round_keys, op, op_c);
// Compute temp
for(i=0; i<16; i++)
{
@ -1277,7 +1261,7 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k,
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k,
uint8 *op,
uint8 *op_c,
uint8 *rand,
uint8 *res,
uint8 *ck,
@ -1287,12 +1271,12 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k,
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
ROUND_KEY_STRUCT round_keys;
uint32 i;
uint8 op_c[16];
uint8 temp[16];
uint8 out[16];
uint8 rijndael_input[16];
if(k != NULL &&
op_c != NULL &&
rand != NULL &&
res != NULL &&
ck != NULL &&
@ -1302,12 +1286,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k,
// Initialize the round keys
rijndael_key_schedule(k, &round_keys);
// Compute OPc
//compute_OPc(&round_keys, op, op_c);
for(i=0;i<16;i++)
{
op_c[i] = op[i];
}
// Compute temp
for(i=0; i<16; i++)
{
@ -1391,7 +1369,7 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k,
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k,
uint8 *op,
uint8 *op_c,
uint8 *rand,
uint8 *ak)
{
@ -1404,19 +1382,13 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k,
uint8 rijndael_input[16];
if(k != NULL &&
op_c != NULL &&
rand != NULL &&
ak != NULL)
{
// Initialize the round keys
rijndael_key_schedule(k, &round_keys);
// Compute OPc
//compute_OPc(&round_keys, op, op_c);
for(i=0;i<16;i++)
{
op_c[i] = op[i];
}
// Compute temp
for(i=0; i<16; i++)
{
@ -1441,17 +1413,11 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k,
{
ak[i] = out[i];
}
err = LIBLTE_SUCCESS;
}
return(err);
}
/*******************************************************************************
LOCAL FUNCTIONS
*******************************************************************************/
/*********************************************************************
Name: compute_OPc
@ -1459,19 +1425,25 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k,
Document Reference: 35.206 v10.0.0 Annex 3
*********************************************************************/
void compute_OPc(ROUND_KEY_STRUCT *rk,
void compute_OPc(uint8 *k,
uint8 *op,
uint8 *op_c)
{
uint32 i;
rijndael_encrypt(op, rk, op_c);
for(i=0; i<16; i++)
{
op_c[i] ^= op[i];
}
uint32 i;
ROUND_KEY_STRUCT round_keys;
rijndael_key_schedule(k, &round_keys);
rijndael_encrypt(op, round_keys, op_c);
for(i=0; i<16; i++)
{
op_c[i] ^= op[i];
}
}
/*******************************************************************************
LOCAL FUNCTIONS
*******************************************************************************/
/*********************************************************************
Name: rijndael_key_schedule

Loading…
Cancel
Save