Commit 791e52be authored by yangjian's avatar yangjian

Fix the authentication bug

parent 4b4ed7f5
......@@ -1394,6 +1394,7 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
try {
ConfirmationDataResponse confirmationdataresponse;
nlohmann::json::parse(Response.c_str()).get_to(confirmationdataresponse);
if(!confirmationdataresponse.getAuthResult()) return false;
unsigned char* kseaf_hex =
format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32);
......@@ -1554,13 +1555,13 @@ void amf_n1::generate_random(uint8_t* random_p, ssize_t length) {
mpz_urandomb(random_nb, random_state.state, 8 * length);
pthread_mutex_unlock(&random_state.lock);
mpz_export(random_p, NULL, 1, length, 0, 0, random_nb);
int r = 0, mask = 0, shift;
for (int i = 0; i < length; i++) {
if ((i % sizeof(i)) == 0) r = rand();
shift = 8 * (i % sizeof(i));
mask = 0xFF << shift;
random_p[i] = (r & mask) >> shift;
}
// int r = 0, mask = 0, shift;
// for (int i = 0; i < length; i++) {
// if ((i % sizeof(i)) == 0) r = rand();
// shift = 8 * (i % sizeof(i));
// mask = 0xFF << shift;
// random_p[i] = (r & mask) >> shift;
// }
} else {
Logger::amf_n1().error("AMF config random -> false");
pthread_mutex_lock(&random_state.lock);
......
......@@ -618,10 +618,12 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
item.s_nssai.sd = "None";
item.pduSessionNAS_PDU = NULL;
if (itti_msg.isn2sm_avaliable) {
bstring n2sm = itti_msg.n2sm;
// bstring n2sm = itti_msg.n2sm;
if (blength(itti_msg.n2sm) != 0) {
Logger::amf_n2().debug("*** test into itti_msg.n2sm ***");
item.pduSessionResourceSetupRequestTransfer.buf =
(uint8_t*)bdata(itti_msg.n2sm);
Logger::amf_n2().debug("*** test into item.pduSessionResourceSetupRequestTransfer.buf ***");
item.pduSessionResourceSetupRequestTransfer.size =
blength(itti_msg.n2sm);
} else {
......
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