Loading ccsrc/Externals/NG_security_ext.cc +18 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "ia2_128.hh" #include "ia3_128.hh" #include "zuc.hh" namespace NG__SecurityDefinitionsAndExternalFunctions { /** Loading Loading @@ -114,6 +116,14 @@ OCTETSTRING fx__NG__NasCiphering(const OCTETSTRING& p_EncodedNasPdu,const BITST ); } else if (bit2int(p_CipheringAlgorithm) == 3) { // IA3_128/NEA3_128: ZUC based algorithm loggers::get_instance().log("fx__NG__NasCiphering: ia3_128 selected"); // loggers::get_instance().log("fx__NG__NasCiphering: %d", p_EncodedNasPdu.lengthof()); // cyphered = (unsigned char*) std::malloc(p_EncodedNasPdu.lengthof()); // zuc_eea3( // (unsigned char*)static_cast<const unsigned char*>(bit2oct(p_KNASenc)), // nas_count, (uint32_t)bit2int(p_BearerId), p_Direction, // p_EncodedNasPdu.lengthof() * 8, (unsigned char*)static_cast<const unsigned char*>(p_EncodedNasPdu), cyphered); // result = 0; // cyphered_length = p_EncodedNasPdu.lengthof(); ia3_128 enc; result = enc.encrypt( bit2int(p_CipheringAlgorithm), Loading Loading @@ -204,7 +214,13 @@ OCTETSTRING fx__NG__NasDeciphering(const OCTETSTRING& p_CipheredNasMsg, const BI &payload_length ); } else if (bit2int(p_CipheringAlgorithm) == 3) { // IA3_128/NEA3_128: ZUC based algorithm loggers::get_instance().log("fx__NG__NasDeciphering: ia1_128 selected"); // loggers::get_instance().log("fx__NG__NasDeciphering: ia1_128 selected"); // zuc_eea3( // (unsigned char*)static_cast<const unsigned char*>(bit2oct(p_KNASenc)), // nas_count, bit2int(p_BearerId), p_Direction, // p_CipheredNasMsg.lengthof() * 8, (unsigned char*)static_cast<const unsigned char*>(p_CipheredNasMsg), payload); // result = 0; // payload_length = p_CipheredNasMsg.lengthof(); ia3_128 enc; result = enc.decrypt( bit2int(p_CipheringAlgorithm), Loading Loading @@ -241,5 +257,4 @@ OCTETSTRING fx__NG__NasDeciphering(const OCTETSTRING& p_CipheredNasMsg, const BI } // namespace NG__NAS__SecurityFunctions // namespace NG__SecurityDefinitionsAndExternalFunctions } // namespace NG__SecurityDefinitionsAndExternalFunctions ccsrc/Externals/ia3_128.cc +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ void ia3_128::zuc_eea3(const uint8_t* CK, const uint32_t COUNT, const uint32_t B i--; C[i] &= 0x100 - (1<<lastbits); } loggers::get_instance().log_to_hexa(">>> ia3_128::zuc_eea3: C", C, LENGTH / 8); loggers::get_instance().log_to_hexa("ia3_128::zuc_eea3: C", C, LENGTH / 8); std::free(z); } Loading ccsrc/Externals/module.mk +4 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ sources := \ Lib_NG_NAS_Functions_ext.cc \ ia1_128.cc \ ia2_128.cc \ ia3_128.cc ia3_128.cc \ # zuc.cc includes := . ttcn/Ats_NG_NAS/NG_NAS_TestCases.ttcn +2 −2 Original line number Diff line number Diff line Loading @@ -2886,8 +2886,8 @@ module NG_NAS_TestCases { var NasCount_Type v_nas_count := '66035492'O; // NAS Count var bitstring v_nas_enc_alg := '0011'B ; // 128-NEA3 128-bit ZUC algorithm var B5_Type v_bearer_id := '01111'B; // Bearer ID (Signalling) var octetstring v_plain_text := '6cf65340735552ab0c9752fa6f9025fe0bd675d9005875b200000000'O; var octetstring v_cyphered_text := 'a6c85fc66afb8533aafc2518dfe784940ee1e4b030238cc810000000'O; // Expected cyphered text var octetstring v_plain_text := '6cf65340735552ab0c9752fa6f9025fe0bd675d9005875b200'O; var octetstring v_cyphered_text := 'a6c85fc66afb8533aafc2518dfe784940ee1e4b030238cc810'O; // Expected cyphered text var octetstring v_cyphered_text_computed := fx_NG_NasCiphering(v_plain_text, v_nas_enc_alg, oct2bit(v_k_nas_enc), v_nas_count, v_bearer_id, 0) if (not(match(v_cyphered_text_computed, v_cyphered_text))) { Loading Loading
ccsrc/Externals/NG_security_ext.cc +18 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "ia2_128.hh" #include "ia3_128.hh" #include "zuc.hh" namespace NG__SecurityDefinitionsAndExternalFunctions { /** Loading Loading @@ -114,6 +116,14 @@ OCTETSTRING fx__NG__NasCiphering(const OCTETSTRING& p_EncodedNasPdu,const BITST ); } else if (bit2int(p_CipheringAlgorithm) == 3) { // IA3_128/NEA3_128: ZUC based algorithm loggers::get_instance().log("fx__NG__NasCiphering: ia3_128 selected"); // loggers::get_instance().log("fx__NG__NasCiphering: %d", p_EncodedNasPdu.lengthof()); // cyphered = (unsigned char*) std::malloc(p_EncodedNasPdu.lengthof()); // zuc_eea3( // (unsigned char*)static_cast<const unsigned char*>(bit2oct(p_KNASenc)), // nas_count, (uint32_t)bit2int(p_BearerId), p_Direction, // p_EncodedNasPdu.lengthof() * 8, (unsigned char*)static_cast<const unsigned char*>(p_EncodedNasPdu), cyphered); // result = 0; // cyphered_length = p_EncodedNasPdu.lengthof(); ia3_128 enc; result = enc.encrypt( bit2int(p_CipheringAlgorithm), Loading Loading @@ -204,7 +214,13 @@ OCTETSTRING fx__NG__NasDeciphering(const OCTETSTRING& p_CipheredNasMsg, const BI &payload_length ); } else if (bit2int(p_CipheringAlgorithm) == 3) { // IA3_128/NEA3_128: ZUC based algorithm loggers::get_instance().log("fx__NG__NasDeciphering: ia1_128 selected"); // loggers::get_instance().log("fx__NG__NasDeciphering: ia1_128 selected"); // zuc_eea3( // (unsigned char*)static_cast<const unsigned char*>(bit2oct(p_KNASenc)), // nas_count, bit2int(p_BearerId), p_Direction, // p_CipheredNasMsg.lengthof() * 8, (unsigned char*)static_cast<const unsigned char*>(p_CipheredNasMsg), payload); // result = 0; // payload_length = p_CipheredNasMsg.lengthof(); ia3_128 enc; result = enc.decrypt( bit2int(p_CipheringAlgorithm), Loading Loading @@ -241,5 +257,4 @@ OCTETSTRING fx__NG__NasDeciphering(const OCTETSTRING& p_CipheredNasMsg, const BI } // namespace NG__NAS__SecurityFunctions // namespace NG__SecurityDefinitionsAndExternalFunctions } // namespace NG__SecurityDefinitionsAndExternalFunctions
ccsrc/Externals/ia3_128.cc +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ void ia3_128::zuc_eea3(const uint8_t* CK, const uint32_t COUNT, const uint32_t B i--; C[i] &= 0x100 - (1<<lastbits); } loggers::get_instance().log_to_hexa(">>> ia3_128::zuc_eea3: C", C, LENGTH / 8); loggers::get_instance().log_to_hexa("ia3_128::zuc_eea3: C", C, LENGTH / 8); std::free(z); } Loading
ccsrc/Externals/module.mk +4 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ sources := \ Lib_NG_NAS_Functions_ext.cc \ ia1_128.cc \ ia2_128.cc \ ia3_128.cc ia3_128.cc \ # zuc.cc includes := .
ttcn/Ats_NG_NAS/NG_NAS_TestCases.ttcn +2 −2 Original line number Diff line number Diff line Loading @@ -2886,8 +2886,8 @@ module NG_NAS_TestCases { var NasCount_Type v_nas_count := '66035492'O; // NAS Count var bitstring v_nas_enc_alg := '0011'B ; // 128-NEA3 128-bit ZUC algorithm var B5_Type v_bearer_id := '01111'B; // Bearer ID (Signalling) var octetstring v_plain_text := '6cf65340735552ab0c9752fa6f9025fe0bd675d9005875b200000000'O; var octetstring v_cyphered_text := 'a6c85fc66afb8533aafc2518dfe784940ee1e4b030238cc810000000'O; // Expected cyphered text var octetstring v_plain_text := '6cf65340735552ab0c9752fa6f9025fe0bd675d9005875b200'O; var octetstring v_cyphered_text := 'a6c85fc66afb8533aafc2518dfe784940ee1e4b030238cc810'O; // Expected cyphered text var octetstring v_cyphered_text_computed := fx_NG_NasCiphering(v_plain_text, v_nas_enc_alg, oct2bit(v_k_nas_enc), v_nas_count, v_bearer_id, 0) if (not(match(v_cyphered_text_computed, v_cyphered_text))) { Loading