Commit 5d4921e4 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup

parent f3c47ca9
......@@ -44,8 +44,7 @@ AMF =
MYSQL_user = "root"; # Database server login
MYSQL_pass = "linux"; # Database server password
MYSQL_db = "oai_db";
OPERATOR_key = "63bfa50ee6523365ff14c1f45f88737d"; # op 0x63bfa50ee6523365ff14c1f45f88737d
#Key: 0x0C0A34601D4F07677303652C0462535B
OPERATOR_key = "63bfa50ee6523365ff14c1f45f88737d";
RANDOM = "true";
};
NAS:{
......
......@@ -186,17 +186,6 @@ public:
vector<smf_inst_t> smf_pool;
};
}
#endif
......@@ -79,16 +79,9 @@ int amf_modules::load(const std::string &config_file){
}
void amf_modules::display(){
Logger::config().info( "======= AMF Registred Modules =======");
Logger::config().info( "NGAP Message Modules Repository(SourceCode) Path( ~/oai-5g-amf/src/ngap/ngapMsgs )");
Logger::config().info( "======= AMF Registered Modules =======");
Logger::config().info( "NGAP Message Modules:");
Logger::config().info( "- %s([%d,%d])\n", msgName.c_str(), procedureCode, typeOfMsg);
}
}
......@@ -68,14 +68,6 @@ private:
// NGSetupRequestMsg *ngSetupRequest;
};
}
#endif
......@@ -160,7 +160,6 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind & nas_data_ind){
std::shared_ptr<nas_context> nc;
if(nas_data_ind.is_guti_valid){
//std::string guti = "1234567890";//need modify
std::string guti = nas_data_ind.guti;
if(is_guti_2_nas_context(guti))
nc = guti_2_nas_context(guti);
......@@ -424,10 +423,10 @@ void amf_n1::update_ue_information_statics(ue_infos &ueItem, const string connSt
}
void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_context>nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, std::string snn, bstring reg){
//1. decode registration request message from liuyu
//1. decode registration request message
RegistrationRequest *regReq = new RegistrationRequest();
regReq->decodefrombuffer(nullptr, (uint8_t*)bdata(reg), blength(reg));
//2.4 check ie 5gs mobility identity(Mondantary IE)
//2.4 check ie 5gs mobility identity(Mandatory IE)
std::string guti;
uint8_t mobility_id_type = regReq->getMobilityIdentityType();
switch(mobility_id_type){
......@@ -503,7 +502,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
nc.get()->registration_type = reg_type;
nc.get()->follow_on_req_pending_ind = is_follow_on_req_pending;
//2.3 check ie ngKSI(Mondantary IE)
//2.3 check ie ngKSI(Mandatory IE)
uint8_t ngKSI = regReq->getngKSI();
if(ngKSI == -1){
Logger::amf_n1().error("MIssing Mandontary IE ngKSI ...");
......@@ -533,11 +532,11 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
}
nc.get()->requestedNssai = requestedNssai;
nc.get()->ctx_avaliability_ind = true;
//2.9 try to get ie Last visited registred TAI(OPtional IE), if provided
//2.9 try to get ie Last visited registered TAI(OPtional IE), if provided
//2.10 try to get ie S1 Ue network capability(OPtional IE), if ue supports S1 mode
//2.11 try to get ie uplink data status(Optional IE), if UE has uplink user data to be sent
//2.11 try to get ie pdu session status(OPtional IE), associated and active pdu sessions avaliable in UE
//4. store nas informstion into nas_context
//2.11 try to get ie pdu session status(OPtional IE), associated and active pdu sessions available in UE
//4. store nas information into nas_context
//5. run different registration procedure
switch(reg_type){
case INITIAL_REGISTRATION:{
......@@ -638,14 +637,14 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value, uint32_t ran_
void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc){
Logger::amf_n1().debug("start to run registration procedure");
if(!nc.get()->ctx_avaliability_ind){
Logger::amf_n1().error("nas context is not avaliable");
Logger::amf_n1().error("nas context is not available");
return;
}
nc.get()->is_specific_procedure_for_registration_running = true;
if(nc.get()->is_imsi_present){
Logger::amf_n1().debug("suci supi format imsi is avaliable");
Logger::amf_n1().debug("suci supi format imsi is available");
if(!nc.get()->is_auth_vectors_present){
Logger::amf_n1().debug("authentication vector in nas_context is not avaliable");
Logger::amf_n1().debug("authentication vector in nas_context is not available");
if(auth_vectors_generator(nc)){// all authentication in one(AMF)
ngksi_t ngksi = 0;
if(nc.get()->security_ctx && nc.get()->ngKsi != NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE){
......@@ -658,7 +657,7 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc){
response_registration_reject_msg(_5GMM_CAUSE_ILLEGAL_UE, nc.get()->ran_ue_ngap_id, nc.get()->amf_ue_ngap_id);//cause?
}
}else{
Logger::amf_n1().debug("authentication vector in nas_context is avaliable");
Logger::amf_n1().debug("authentication vector in nas_context is available");
ngksi_t ngksi = 0;
if(nc.get()->security_ctx && nc.get()->ngKsi != NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE){
ngksi = (nc.get()->ngKsi + 1) % (NGKSI_MAX_VALUE + 1);
......@@ -725,7 +724,6 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
mysql_auth_info_t mysql_resp;
if(get_mysql_auth_info(nc.get()->imsi, mysql_resp)){
if(auts){
Logger::amf_n1().debug("auts ...");
sqn = Authentication_5gaka::sqn_ms_derive(mysql_resp.opc, mysql_resp.key, auts, mysql_resp.rand);
if(sqn){
generate_random (vector[0].rand, RAND_LENGTH);
......@@ -741,16 +739,6 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
for(int i=0; i< MAX_5GS_AUTH_VECTORS; i++){
generate_random(vector[i].rand, RAND_LENGTH);
print_buffer("amf_n1", "generated random: rand(5G HE AV)", vector[i].rand, 16);
/** for test data *******/
//uint8_t newRAND[16] = {0xc3, 0x15, 0xfb, 0x75, 0x60, 0x7c, 0xe7, 0xa1, 0x64, 0xf5, 0x68, 0xe2, 0xc6, 0xe2, 0xc7, 0x9b};
//memcpy(vector[i].rand, newRAND, 16);
//print_buffer("amf_n1", "static rand: rand(5G HE AV)", vector[i].rand, 16);
//uint8_t sqnak[6] = {0xb6, 0x22, 0xb7, 0x87, 0x4e, 0x86};
//test_generate_5g_he_av_in_udm(mysql_resp.opc, mysql_resp.key, sqnak, nc.get()->serving_network, vector[i]);
/******* end ***********/
//uint8_t rand_[16] = {0x02, 0x27, 0x40, 0x55, 0xea, 0x5a, 0x2f, 0x7e, 0x3e, 0x87, 0x16, 0x4b, 0xdf, 0x80, 0xff, 0x32};
//uint8_t sqn_[6] = {0x00, 0x00, 0x00, 0x00, 0x20, 0x9e};
//memcpy(vector[i].rand, rand_, 16);
generate_5g_he_av_in_udm(mysql_resp.opc, nc.get()->imsi, mysql_resp.key, sqn, nc.get()->serving_network, vector[i]);//serving network name
}
mysql_push_rand_sqn (nc.get()->imsi, vector[MAX_5GS_AUTH_VECTORS - 1].rand, sqn);
......@@ -765,17 +753,6 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
generate_random (vector[i].rand, RAND_LENGTH);
//print_buffer("amf_n1", "generated random: rand(5G HE AV)", vector[i].rand, 16);
sqn = mysql_resp.sqn;
/** for test data *******/
//uint8_t newRAND[16] = {0x2c, 0x6e, 0xad, 0x35, 0x82, 0x7d, 0x01, 0xca, 0x4a, 0xc0, 0xfb, 0xf0, 0xaa, 0x31, 0x98, 0x4a};
//memcpy(vector[i].rand, newRAND, 16);
//print_buffer("amf_n1", "static rand: rand(5G HE AV)", vector[i].rand, 16);
//uint8_t sqnak[6] = {0xae, 0x0e, 0x88, 0x41, 0x6f, 0xfb};
//test_generate_5g_he_av_in_udm(mysql_resp.opc, mysql_resp.key, sqnak, nc.get()->serving_network, vector[i]);
/******* end ***********/
//uint8_t rand_[16] = {0x02, 0x27, 0x40, 0x55, 0xea, 0x5a, 0x2f, 0x7e, 0x3e, 0x87, 0x16, 0x4b, 0xdf, 0x80, 0xff, 0x32};
//uint8_t sqn_[6] = {0x00, 0x00, 0x00, 0x00, 0x20, 0x9e};
//memcpy(vector[i].rand, rand_, 16);
//generate_5g_he_av_in_udm(mysql_resp.opc, nc.get()->imsi, mysql_resp.key, sqn_, nc.get()->serving_network, vector[i]);//serving network name
generate_5g_he_av_in_udm(mysql_resp.opc, nc.get()->imsi, mysql_resp.key, sqn, nc.get()->serving_network, vector[i]);//serving network name
}
mysql_push_rand_sqn (nc.get()->imsi, vector[MAX_5GS_AUTH_VECTORS - 1].rand, sqn);
......@@ -853,10 +830,6 @@ void amf_n1::generate_random(uint8_t *random_p, ssize_t length){
//Logger::amf_n1().debug("call f2345");
//f2345(key, vector.rand, vector.xres, ck, ik, ak);// to compute XRES, CK, IK, AK
Authentication_5gaka::f2345(opc, key, vector.rand, vector.xres, ck, ik, ak);// to compute XRES, CK, IK, AK
//print_buffer("amf_n1", "Result For F2345-Alg: xres", vector.xres, 8);
//print_buffer("amf_n1", "Result For F2345-Alg: ck", ck, 16);
//print_buffer("amf_n1", "Result For F2345-Alg: ik", ik, 16);
//print_buffer("amf_n1", "Result For F2345-Alg: ak", ak, 6);
annex_a_4_33501(ck, ik, vector.xres, vector.rand, serving_network, vector.xresStar);
//print_buffer("amf_n1", "Result For KDF: xres*(5G HE AV)", vector.xresStar, 16);
//Logger::amf_n1().debug("generate autn");
......
......@@ -62,7 +62,6 @@ extern void convert_string_2_hex(std::string&input, std::string&output);
extern void print_buffer(const std::string app, const std::string commit, uint8_t *buf, int len);
extern bool multipart_parser(string input, string &jsonData, string &n1sm, string &n2sm);
extern unsigned char * format_string_as_hex(std::string str);
//extern std::size_t callback(const char* in, std::size_t size, std::size_t num, std::string* out);
extern char* bstring2charString(bstring b);
std::size_t callback(
......@@ -314,7 +313,6 @@ void amf_n11::curl_http_client(string remoteUri, string jsonData, string n1SmMsg
if(n1SmMsg != ""){
Logger::amf_n11().debug("is there ok? n1");
unsigned char *n1_msg_hex = format_string_as_hex(n1SmMsg);
//Logger::amf_n11().debug("n1 msg hex: %s", n1_msg_hex);
part = curl_mime_addpart(mime);
curl_mime_data(part, reinterpret_cast<const char*>(n1_msg_hex), n1SmMsg.length()/2);
curl_mime_type(part, "application/vnd.3gpp.5gnas");
......@@ -350,7 +348,7 @@ void amf_n11::curl_http_client(string remoteUri, string jsonData, string n1SmMsg
string n1sm = "";
string n2sm = "";
bool is_response_ok = true;
Logger::amf_n11().debug("Get response with httpcode(%d)", httpCode);
Logger::amf_n11().debug("Get response with httpcode (%d)", httpCode);
if(httpCode == 0){
Logger::amf_n11().error("Cannot get response When calling %s", remoteUri.c_str());
return;
......
......@@ -138,7 +138,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request & itti_msg){
std::shared_ptr<gnb_context> gc;
if(!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("no existed gnb context with assoc_id(%d)",itti_msg.assoc_id);
Logger::amf_n2().error("no existed gNB context with assoc_id(%d)",itti_msg.assoc_id);
return;
}
gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
......@@ -153,7 +153,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request & itti_msg){
//Get IE Global RAN Node ID
uint32_t gnb_id; string gnb_mcc; string gnb_mnc;
if(!itti_msg.ngSetupReq->getGlobalGnbID(gnb_id, gnb_mcc, gnb_mnc)){
Logger::amf_n2().error("Missing Mandontary IE GlobalGnbID");
Logger::amf_n2().error("Missing Mandatory IE GlobalGnbID");
return;
}
Logger::amf_n2().debug("IE GlobalGNBID(0x%x)",gnb_id);
......@@ -270,7 +270,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg){
uint32_t ran_ue_ngap_id;
if( (ran_ue_ngap_id = init_ue_msg.initUeMsg->getRanUENgapID()) == -1){
Logger::amf_n2().error("Missing Mondontary IE(RanUeNgapId)");
Logger::amf_n2().error("Missing Mandatory IE (RanUeNgapId)");
return;
}
std::shared_ptr<ue_ngap_context> unc;
......@@ -298,7 +298,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg){
itti_msg->cgi = cgi;
itti_msg->tai = tai;
}else{
Logger::amf_n2().error("Missing Mondontary IE UserLocationInfoNR");
Logger::amf_n2().error("Missing Mandatory IE UserLocationInfoNR");
return;
}
if(init_ue_msg.initUeMsg->getRRCEstablishmentCause() == -1){
......
......@@ -65,11 +65,4 @@ void hexStr2Byte(const char* src, unsigned char *dest, int len){
}
}
#endif
......@@ -66,18 +66,4 @@ public:
};
#endif
......@@ -34,7 +34,6 @@
#include "authentication_algorithms_with_5gaka.hpp"
#include <string>
#include "nas_security_context.hpp"
//#include "ies/NSSAI.hpp"
#include "struct.hpp"
class nas_context{
......
......@@ -109,16 +109,4 @@ public:
selected_algs nas_algs;
};
#endif
......@@ -33,4 +33,3 @@ pdu_session_context::pdu_session_context(){
}
pdu_session_context::~pdu_session_context(){}
......@@ -47,17 +47,4 @@ public:
string remote_smf_addr[0];//"192.168.12.10:8080"
bool smf_avaliable;
};
#endif
......@@ -107,16 +107,4 @@ typedef struct security_context_s {
uint8_t activated;
} security_context_t;
#endif
......@@ -51,12 +51,4 @@ public:
Tai_t tai;
};
#endif
......@@ -60,14 +60,4 @@ public:
ng_ue_state_t ng_ue_state;
};
#endif
......@@ -17,7 +17,7 @@ void AMFApiServer::init(size_t thr) {
m_nonUEN2MessagesCollectionDocumentApiImpl->init();
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl->init();
m_subscriptionsCollectionDocumentApiImpl->init();
Logger::amf_server().debug("initiate amf server endpoints done!");
Logger::amf_server().debug("Initiate AMF server endpoints done!");
}
void AMFApiServer::start(){
......
......@@ -23,10 +23,10 @@ IndividualSubscriptionDocumentApiImpl::IndividualSubscriptionDocumentApiImpl(std
{ }
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_modfy(const std::string &subscriptionId, const SubscriptionData &subscriptionData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_modfy API has not been implemented yet!\n");
}
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_un_subscribe(const std::string &subscriptionId, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualSubscriptionDocumentApiImpl::a_mf_status_change_un_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -23,19 +23,19 @@ IndividualUeContextDocumentApiImpl::IndividualUeContextDocumentApiImpl(std::shar
{ }
void IndividualUeContextDocumentApiImpl::create_ue_context(const std::string &ueContextId, const Inline_object &inlineObject, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualUeContextDocumentApiImpl::create_ue_context API has not been implemented yet!\n");
}
void IndividualUeContextDocumentApiImpl::e_bi_assignment(const std::string &ueContextId, const AssignEbiData &assignEbiData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualUeContextDocumentApiImpl::e_bi_assignment API has not been implemented yet!\n");
}
void IndividualUeContextDocumentApiImpl::registration_status_update(const std::string &ueContextId, const UeRegStatusUpdateReqData &ueRegStatusUpdateReqData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualUeContextDocumentApiImpl::registration_status_update API has not been implemented yet!\n");
}
void IndividualUeContextDocumentApiImpl::release_ue_context(const std::string &ueContextId, const UEContextRelease &uEContextRelease, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualUeContextDocumentApiImpl::release_ue_context API has not been implemented yet!\n");
}
void IndividualUeContextDocumentApiImpl::u_e_context_transfer(const std::string &ueContextId, const UeContextTransferReqData &ueContextTransferReqData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "IndividualUeContextDocumentApiImpl::u_e_context_transfer API has not been implemented yet!\n");
}
}
......
......@@ -21,7 +21,7 @@ N1N2IndividualSubscriptionDocumentApiImpl::N1N2IndividualSubscriptionDocumentApi
{ }
void N1N2IndividualSubscriptionDocumentApiImpl::n1_n2_message_un_subscribe(const std::string &ueContextId, const std::string &subscriptionId, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "N1N2IndividualSubscriptionDocumentApiImpl::n1_n2_message_un_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -36,7 +36,7 @@ N1N2MessageCollectionDocumentApiImpl::N1N2MessageCollectionDocumentApiImpl(std::
void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::string &ueContextId, const N1N2MessageTransferReqData &n1N2MessageTransferReqData, Pistache::Http::ResponseWriter &response) {
Logger::amf_server().debug("response OK");
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer API has not been implemented yet!\n");
}
void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::string &ueContextId, const N1N2MessageTransferReqData &n1N2MessageTransferReqData, std::string &n1sm_str, Pistache::Http::ResponseWriter &response) {
......@@ -45,7 +45,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::str
bstring n1sm;
msg_str_2_msg_hex(n1sm_str, n1sm);
print_buffer("amf_server", "received N1 SM", (uint8_t*)bdata(n1sm), blength(n1sm));
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer API has not been implemented yet!\n");
}
void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::string &ueContextId, const N1N2MessageTransferReqData &n1N2MessageTransferReqData, std::string &n1sm_str, std::string &n2sm_str, Pistache::Http::ResponseWriter &response) {
......
......@@ -23,7 +23,7 @@ N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl::N1N2Subscript
{ }
void N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl::n1_n2_message_subscribe(const std::string &ueContextId, const UeN1N2InfoSubscriptionCreateData &ueN1N2InfoSubscriptionCreateData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl::n1_n2_message_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -21,7 +21,7 @@ NonUEN2MessageNotificationIndividualSubscriptionDocumentApiImpl::NonUEN2MessageN
{ }
void NonUEN2MessageNotificationIndividualSubscriptionDocumentApiImpl::non_ue_n2_info_un_subscribe(const std::string &n2NotifySubscriptionId, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "NonUEN2MessageNotificationIndividualSubscriptionDocumentApiImpl::non_ue_n2_info_un_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -23,7 +23,7 @@ NonUEN2MessagesCollectionDocumentApiImpl::NonUEN2MessagesCollectionDocumentApiIm
{ }
void NonUEN2MessagesCollectionDocumentApiImpl::non_ue_n2_message_transfer(const N2InformationTransferReqData &n2InformationTransferReqData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "NonUEN2MessagesCollectionDocumentApiImpl::non_ue_n2_message_transfer API has not been implemented yet!\n");
}
}
......
......@@ -23,7 +23,7 @@ NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl::NonUEN2MessagesSubscripti
{ }
void NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl::non_ue_n2_info_subscribe(const NonUeN2InfoSubscriptionCreateData &nonUeN2InfoSubscriptionCreateData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl::non_ue_n2_info_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -23,7 +23,7 @@ SubscriptionsCollectionDocumentApiImpl::SubscriptionsCollectionDocumentApiImpl(s
{ }
void SubscriptionsCollectionDocumentApiImpl::a_mf_status_change_subscribe(const SubscriptionData &subscriptionData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
response.send(Pistache::Http::Code::Ok, "SubscriptionsCollectionDocumentApiImpl::a_mf_status_change_subscribe API has not been implemented yet!\n");
}
}
......
......@@ -306,29 +306,22 @@ void Authentication_5gaka::kdf(uint8_t * key, uint16_t key_len, uint8_t * s, uin
void Authentication_5gaka::derive_kseaf(std::string serving_network, uint8_t kausf[32], uint8_t kseaf[32]){
Logger::amf_n1().debug("derive_kseaf ...");
//Logger::amf_n1().debug("inputstring: snn(%s)", serving_network.c_str());
OCTET_STRING_t netName;
OCTET_STRING_fromBuf(&netName, serving_network.c_str(), serving_network.length());
//print_buffer("amf_n1", "inputstring: snn(hex)", netName.buf, netName.size);
uint8_t S[100];
S[0] = 0x6C;//FC
memcpy(&S[1], netName.buf, netName.size);
//memcpy (&S[1+netName.size], &netName.size, 2);
S[1+netName.size] = (uint8_t)((netName.size & 0xff00) >> 8);
S[2+netName.size] = (uint8_t)(netName.size & 0x00ff);
//print_buffer("amf_n1", "inputstring S", S, 3+netName.size);
//print_buffer("amf_n1", "key KEY", kausf, 32);
kdf(kausf, 32, S, 3+netName.size, kseaf, 32);
//print_buffer("amf_n1", "KDF out: Kseaf", kseaf, 32);
//Logger::amf_n1().debug("derive kseaf finished!");
Logger::amf_n1().debug("derive kseaf finished!");
}
void Authentication_5gaka::derive_kausf(uint8_t ck[16], uint8_t ik[16], std::string serving_network, uint8_t sqn[6], uint8_t ak[6], uint8_t kausf[32]){
Logger::amf_n1().debug("derive_kausf ...");
//Logger::amf_n1().debug("inputstring: snn(%s)", serving_network.c_str());
OCTET_STRING_t netName;
OCTET_STRING_fromBuf(&netName, serving_network.c_str(), serving_network.length());
//print_buffer("amf_n1", "inputstring: snn(hex)", netName.buf, netName.size);
uint8_t S[100];
uint8_t key[32];
memcpy (&key[0], ck, 16);
......@@ -343,25 +336,15 @@ void Authentication_5gaka::derive_kausf(uint8_t ck[16], uint8_t ik[16], std::str
}
S[9+netName.size] = 0x00;
S[10+netName.size] = 0x06;
//print_buffer("amf_n1", "inputstring S", S, 11+netName.size);
//print_buffer("amf_n1", "key KEY", key, 32);
kdf(key, 32, S, 11+netName.size, kausf, 32);
//print_buffer("amf_n1", "KDF out: Kausf", kausf, 32);
//Logger::amf_n1().debug("derive kausf finished!");
}
void Authentication_5gaka::derive_kamf(std::string imsi, uint8_t *kseaf, uint8_t *kamf, uint16_t abba){
Logger::amf_n1().debug("derive_kamf ...");
std::string ueSupi = imsi;//OK
//Logger::amf_n1().debug("inputstring: supi(%s)", ueSupi.c_str());
//int supiLen = (imsi.length()*sizeof(unsigned char))/2;
//unsigned char * supi = (unsigned char*)calloc(1, supiLen);
//hexStr2Byte(imsi.c_str(), supi, imsi.length());
OCTET_STRING_t supi;
OCTET_STRING_fromBuf(&supi, ueSupi.c_str(), ueSupi.length());
//uint8_t supi[8] = {0x64, 0xf0, 0x11, 0x10, 0x32, 0x54, 0x76, 0x98};
int supiLen = supi.size;
//print_buffer("amf_n1", "inputstring: supi(hex)", supi.buf, supiLen);
uint8_t S[100];
S[0] = 0x6D;//FC = 0x6D
memcpy (&S[1], supi.buf, supiLen);
......@@ -372,11 +355,7 @@ void Authentication_5gaka::derive_kamf(std::string imsi, uint8_t *kseaf, uint8_t
S[4+supiLen] = (abba & 0xff00)>>8;
S[5+supiLen] = 0x00;
S[6+supiLen] = 0x02;
//print_buffer("amf_n1", "inputstring S", S, 7+supiLen);
//print_buffer("amf_n1", "key KEY", kseaf, 32);
kdf(kseaf, 32, S, 7+supiLen, kamf, 32);
//print_buffer("amf_n1", "KDF out: Kamf", kamf, 32);
//Logger::amf_n1().debug("derive kamf finished!");
}
void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t kamf[32], uint8_t * knas){
......@@ -390,14 +369,11 @@ void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type, uint8
S[4] = nas_alg_id;
S[5] = 0x00;
S[6] = 0x01;
//print_buffer("amf_n1", "inputstring S", S, 7);
//print_buffer("amf_n1", "key KEY", kamf, 32);
kdf (kamf, 32, S, 7, out, 32);
//memcpy (knas, &out[31 - 16 + 1], 16);
for(int i=0; i<16; i++)
knas[i] = out[16+i];
//print_buffer("amf_n1", "knas", knas, 16);
//Logger::amf_n1().debug("derive knas finished!");
Logger::amf_n1().debug("derive knas finished!");
}
void Authentication_5gaka::derive_kgnb(uint32_t uplinkCount, uint8_t accessType, uint8_t kamf[32], uint8_t * kgnb){
......@@ -410,11 +386,7 @@ void Authentication_5gaka::derive_kgnb(uint32_t uplinkCount, uint8_t accessType,
S[7] = accessType;
S[8] = 0x00;
S[9] = 0x01;
//print_buffer("amf_n1", "inputstring S", S, 10);
//print_buffer("amf_n1", "key KEY", kamf, 32);
kdf(kamf, 32, S, 10, kgnb, 32);
//print_buffer("amf_n1", "kgnb", kgnb, 32);
//Logger::amf_n1().debug("derive kgnb finished!");
}
void Authentication_5gaka::derive_kasme(uint8_t ck[16], uint8_t ik[16], uint8_t plmn[3], uint8_t sqn[6], uint8_t ak[6], uint8_t * kasme){
......@@ -470,17 +442,10 @@ int Authentication_5gaka::generate_vector(const uint8_t opc[16], uint64_t imsi,
* Compute MAC
*/
f1 (opc, key, vector->rand, sqn, amf, mac_a);
//print_buffer ("MAC_A : ", mac_a, 8);
//print_buffer ("SQN : ", sqn, 6);
//print_buffer ("RAND : ", vector->rand, 16);
/*
* Compute XRES, CK, IK, AK
*/
f2345 (opc, key, vector->rand, vector->xres, ck, ik, ak);
//print_buffer ("AK : ", ak, 6);
//print_buffer ("CK : ", ck, 16);
//print_buffer ("IK : ", ik, 16);
//print_buffer ("XRES : ", vector->xres, 8);
/*
* AUTN = SQN ^ AK || AMF || MAC
*/
......@@ -522,14 +487,7 @@ uint8_t* Authentication_5gaka::sqn_ms_derive (const uint8_t opc[16], uint8_t * k
sqn_ms[i] = ak[i] ^ conc_sqn_ms[i];
}
//print_buffer ("sqn_ms_derive() KEY : ", key, 16);
//print_buffer ("sqn_ms_derive() RAND : ", rand_p, 16);
//print_buffer ("sqn_ms_derive() AUTS : ", auts, 14);
//print_buffer ("sqn_ms_derive() AK : ", ak, 6);
//print_buffer ("sqn_ms_derive() SQN_MS : ", sqn_ms, 6);
//print_buffer ("sqn_ms_derive() MAC_S : ", mac_s, 8);
f1star (opc, key, rand_p, sqn_ms, amf, mac_s_computed);
//print_buffer ("MAC_S +: ", mac_s_computed, 8);
if (memcmp (mac_s_computed, mac_s, 8) != 0) {
//FPRINTF_ERROR ( "Failed to verify computed SQN_MS\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment