Commit f3d7f472 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_msin_decode' into 'develop'

Fix issue for decoding MSIN with an odd number of digits

See merge request oai/cn5g/oai-cn5g-amf!179
parents eaed3191 75cd6915
...@@ -1903,6 +1903,7 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1903,6 +1903,7 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
try { try {
ConfirmationDataResponse confirmationdataresponse; ConfirmationDataResponse confirmationdataresponse;
response.get_to(confirmationdataresponse); response.get_to(confirmationdataresponse);
if (!confirmationdataresponse.kseafIsSet()) return false;
unsigned char* kseaf_hex = unsigned char* kseaf_hex =
conv::format_string_as_hex(confirmationdataresponse.getKseaf()); conv::format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc->_5g_av[0].kseaf, kseaf_hex, 32); memcpy(nc->_5g_av[0].kseaf, kseaf_hex, 32);
......
...@@ -373,7 +373,7 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) { ...@@ -373,7 +373,7 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) {
uint8_t digit_low = 0; uint8_t digit_low = 0;
uint8_t digit_high = 0; uint8_t digit_high = 0;
int numMsin = ie_len - decoded_size; int numMsin = ie_len - decoded_size;
for (int i = 0; i < numMsin; i++) { for (int i = 0; i < (numMsin - 1); i++) {
DECODE_U8(buf + decoded_size, octet, decoded_size); DECODE_U8(buf + decoded_size, octet, decoded_size);
digit_high = (octet & 0xf0) >> 4; digit_high = (octet & 0xf0) >> 4;
digit_low = octet & 0x0f; digit_low = octet & 0x0f;
...@@ -381,6 +381,20 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) { ...@@ -381,6 +381,20 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) {
((const std::string)(std::to_string(digit_low)) + ((const std::string)(std::to_string(digit_low)) +
(const std::string)(std::to_string(digit_high))); (const std::string)(std::to_string(digit_high)));
} }
// Verify if the MSIN includes an odd number of digits,
// bits 5 to 8 of the last octet shall be coded as "1111"
DECODE_U8(buf + decoded_size, octet, decoded_size);
digit_high = (octet & 0xf0) >> 4;
digit_low = octet & 0x0f;
if (digit_high != 0x0f) {
msin +=
((const std::string)(std::to_string(digit_low)) +
(const std::string)(std::to_string(digit_high)));
} else {
msin += (const std::string)(std::to_string(digit_low));
}
supi_format_imsi_tmp.msin = msin; supi_format_imsi_tmp.msin = msin;
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded MSIN %s", supi_format_imsi_tmp.msin.c_str()); "Decoded MSIN %s", supi_format_imsi_tmp.msin.c_str());
......
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