open5gs/src/mme/mme_kdf.c

27 lines
520 B
C

#define TRACE_MODULE _mme_kdf
#include "core_sha2_hmac.h"
#define FC_VALUE 0x15
#include "core_debug.h"
void mme_kdf_nas(c_uint8_t algorithm_type_distinguishers,
c_uint8_t algorithm_identity, c_uint8_t *kasme, c_uint8_t *knas)
{
c_uint8_t s[7];
c_uint8_t out[32];
s[0] = FC_VALUE;
s[1] = algorithm_type_distinguishers;
s[2] = 0x00;
s[3] = 0x01;
s[4] = algorithm_identity;
s[5] = 0x00;
s[6] = 0x01;
hmac_sha256(kasme, 32, s, 7, out, 32);
memcpy(knas, out+16, 16);
}