Commit 4788cb79 authored by Niuhaiwen's avatar Niuhaiwen

Merge branch 'master' into test-all-handover

parents 4c132883 9e0cbaff
...@@ -375,7 +375,8 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -375,7 +375,8 @@ void amf_n1::nas_signalling_establishment_request_handle(
} break; } break;
case SERVICE_REQUEST: { case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message, handling..."); Logger::amf_n1().debug("Received service request message, handling...");
nc.get()->security_ctx->ul_count.seq_num = ulCount; if(nc != nullptr)
nc.get()->security_ctx->ul_count.seq_num = ulCount;
service_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg); service_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break; } break;
case UE_INIT_DEREGISTER: { case UE_INIT_DEREGISTER: {
...@@ -2320,7 +2321,6 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc, ...@@ -2320,7 +2321,6 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
count = 0x00000000 | ((nsc->dl_count.overflow & 0x0000ffff) << 8) | count = 0x00000000 | ((nsc->dl_count.overflow & 0x0000ffff) << 8) |
((nsc->dl_count.seq_num & 0x000000ff)); ((nsc->dl_count.seq_num & 0x000000ff));
} else { } else {
Logger::amf_n1().debug("nsc->ul_count.overflow %x", nsc->ul_count.overflow);
count = 0x00000000 | ((nsc->ul_count.overflow & 0x0000ffff) << 8) | count = 0x00000000 | ((nsc->ul_count.overflow & 0x0000ffff) << 8) |
((nsc->ul_count.seq_num & 0x000000ff)); ((nsc->ul_count.seq_num & 0x000000ff));
} }
...@@ -2331,7 +2331,6 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc, ...@@ -2331,7 +2331,6 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
AUTH_KNAS_INT_SIZE); AUTH_KNAS_INT_SIZE);
stream_cipher.key_length = AUTH_KNAS_INT_SIZE; stream_cipher.key_length = AUTH_KNAS_INT_SIZE;
stream_cipher.count = *(input_nas); stream_cipher.count = *(input_nas);
stream_cipher.bearer = 0x01;
// stream_cipher.count = count; // stream_cipher.count = count;
if (!direction) { if (!direction) {
nsc->ul_count.seq_num = stream_cipher.count; nsc->ul_count.seq_num = stream_cipher.count;
...@@ -2379,17 +2378,22 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction, ...@@ -2379,17 +2378,22 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction,
int buf_len = blength(input_nas); int buf_len = blength(input_nas);
uint32_t count = 0x00000000; uint32_t count = 0x00000000;
if (direction) if (direction)
{
count = 0x00000000 | ((nsc->dl_count.overflow & 0x0000ffff) << 8) | count = 0x00000000 | ((nsc->dl_count.overflow & 0x0000ffff) << 8) |
((nsc->dl_count.seq_num & 0x000000ff)); ((nsc->dl_count.seq_num & 0x000000ff));
}
else else
{
Logger::amf_n1().debug("nsc->ul_count.overflow %x", nsc->ul_count.overflow);
count = 0x00000000 | ((nsc->ul_count.overflow & 0x0000ffff) << 8) | count = 0x00000000 | ((nsc->ul_count.overflow & 0x0000ffff) << 8) |
((nsc->ul_count.seq_num & 0x000000ff)); ((nsc->ul_count.seq_num & 0x000000ff));
}
nas_stream_cipher_t stream_cipher = {0}; nas_stream_cipher_t stream_cipher = {0};
uint8_t mac[4]; uint8_t mac[4];
stream_cipher.key = nsc->knas_enc; stream_cipher.key = nsc->knas_enc;
stream_cipher.key_length = AUTH_KNAS_ENC_SIZE; stream_cipher.key_length = AUTH_KNAS_ENC_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
stream_cipher.bearer = 0x00; // 33.501 section 8.1.1 stream_cipher.bearer = 0x01; // 33.501 section 8.1.1
stream_cipher.direction = direction; // "1" for downlink stream_cipher.direction = direction; // "1" for downlink
stream_cipher.message = (uint8_t *)bdata(input_nas); stream_cipher.message = (uint8_t *)bdata(input_nas);
stream_cipher.blength = blength(input_nas) << 3; stream_cipher.blength = blength(input_nas) << 3;
...@@ -2412,7 +2416,6 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction, ...@@ -2412,7 +2416,6 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction,
nas_algorithms::nas_stream_encrypt_nea1(&stream_cipher, ciphered); nas_algorithms::nas_stream_encrypt_nea1(&stream_cipher, ciphered);
output_nas = blk2bstr(ciphered, ((stream_cipher.blength + 31) / 32) * 4); output_nas = blk2bstr(ciphered, ((stream_cipher.blength + 31) / 32) * 4);
// output_nas = blk2bstr(ciphered, blength(input_nas));
free(ciphered); free(ciphered);
} break; } break;
case EA2_128_5G: { case EA2_128_5G: {
......
...@@ -400,6 +400,7 @@ int ULNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, ...@@ -400,6 +400,7 @@ int ULNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
if (flag) { if (flag) {
Logger::nas_mm().debug("Unknown IEI (0x%x)", octet); Logger::nas_mm().debug("Unknown IEI (0x%x)", octet);
decoded_size++; decoded_size++;
*(buf + decoded_size) = 0x00;
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet); Logger::nas_mm().debug("Next IEI (0x%x)", octet);
} }
......
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