2017-03-06 13:47:39 +00:00
|
|
|
#define TRACE_MODULE _hss_kdf
|
2017-03-03 08:33:41 +00:00
|
|
|
|
2017-12-17 15:01:07 +00:00
|
|
|
#include "core_debug.h"
|
2017-03-03 08:33:41 +00:00
|
|
|
#include "core_sha2_hmac.h"
|
2017-12-17 15:01:07 +00:00
|
|
|
#include "3gpp_types.h"
|
|
|
|
|
2018-01-21 11:46:02 +00:00
|
|
|
#include "hss_auc.h"
|
2017-12-17 15:01:07 +00:00
|
|
|
#include "milenage.h"
|
2017-03-03 08:33:41 +00:00
|
|
|
|
2017-03-06 13:47:39 +00:00
|
|
|
#define FC_VALUE 0x10
|
|
|
|
|
2018-01-21 11:46:02 +00:00
|
|
|
void hss_auc_kasme(const c_uint8_t *ck, const c_uint8_t *ik,
|
2017-03-03 14:35:17 +00:00
|
|
|
const c_uint8_t plmn_id[3], const c_uint8_t *sqn, const c_uint8_t *ak,
|
2017-03-03 08:33:41 +00:00
|
|
|
c_uint8_t *kasme)
|
|
|
|
{
|
|
|
|
c_uint8_t s[14];
|
|
|
|
c_uint8_t k[32];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memcpy(&k[0], ck, 16);
|
2017-03-03 14:35:17 +00:00
|
|
|
memcpy(&k[16], ik, 16);
|
2017-03-03 08:33:41 +00:00
|
|
|
|
2017-03-06 13:47:39 +00:00
|
|
|
s[0] = FC_VALUE;
|
2017-03-03 14:35:17 +00:00
|
|
|
memcpy(&s[1], plmn_id, 3);
|
2017-03-03 08:33:41 +00:00
|
|
|
s[4] = 0x00;
|
|
|
|
s[5] = 0x03;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
s[6+i] = sqn[i] ^ ak[i];
|
|
|
|
s[12] = 0x00;
|
|
|
|
s[13] = 0x06;
|
|
|
|
|
|
|
|
hmac_sha256(k, 32, s, 14, kasme, 32);
|
|
|
|
}
|
2017-12-17 15:01:07 +00:00
|
|
|
|
2018-01-21 11:46:02 +00:00
|
|
|
void hss_auc_sqn(
|
2017-12-18 08:28:22 +00:00
|
|
|
const c_uint8_t *opc, const c_uint8_t *k, const c_uint8_t *auts,
|
2017-12-17 15:01:07 +00:00
|
|
|
c_uint8_t *sqn_ms, c_uint8_t *mac_s)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
c_uint8_t ak[HSS_AK_LEN];
|
2017-12-18 08:28:22 +00:00
|
|
|
c_uint8_t amf[2] = { 0, 0 };
|
2017-12-17 15:01:07 +00:00
|
|
|
const c_uint8_t *rand = auts;
|
|
|
|
const c_uint8_t *conc_sqn_ms = auts + RAND_LEN;
|
|
|
|
|
|
|
|
milenage_f2345(opc, k, rand, NULL, NULL, NULL, NULL, ak);
|
|
|
|
for (i = 0; i < HSS_SQN_LEN; i++)
|
|
|
|
sqn_ms[i] = ak[i] ^ conc_sqn_ms[i];
|
|
|
|
milenage_f1(opc, k, auts, sqn_ms, amf, NULL, mac_s);
|
|
|
|
}
|