|
|
|
@ -40,7 +40,7 @@ int test_set_ksg()
|
|
|
|
|
0x9e, 0x5d, 0x28, 0xaf, 0x0e, 0x83, 0x22, 0xeb, 0x57, 0x3a, 0xda, 0x36, 0xf2, 0x1a, 0x5a, 0x89};
|
|
|
|
|
uint8_t sk_gnb_o[32];
|
|
|
|
|
uint16_t scg_counter = 0;
|
|
|
|
|
err_lte = srsran::security_generate_sk_gnb(k_enb, sk_gnb_o, scg_counter);
|
|
|
|
|
err_lte = srsran::security_generate_sk_gnb(k_enb, scg_counter, sk_gnb_o);
|
|
|
|
|
TESTASSERT(err_lte == SRSRAN_SUCCESS);
|
|
|
|
|
logger.info(&sk_gnb_o[0], sizeof(sk_gnb_o), "sk gnb o:");
|
|
|
|
|
uint8_t sk_gnb[] = {0x45, 0xcb, 0xc3, 0xf8, 0xa8, 0x11, 0x93, 0xfd, 0x5c, 0x52, 0x29, 0x30, 0x0d, 0x59, 0xed, 0xf8,
|
|
|
|
@ -298,12 +298,126 @@ int test_generate_res_star()
|
|
|
|
|
|
|
|
|
|
uint8_t res_star[] = {0xb0, 0xe3, 0x5b, 0x23, 0xdb, 0xd7, 0xa1, 0x8c, 0x84, 0x8b, 0xfa, 0xd9, 0x11, 0x35, 0xe3, 0xfd};
|
|
|
|
|
|
|
|
|
|
logger.info(res_star, 16, "RES STAR:");
|
|
|
|
|
logger.info(res_star_o, 16, "RES STAR:");
|
|
|
|
|
TESTASSERT(arrcmp(res_star_o, res_star, sizeof(res_star)) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_generate_k_ausf()
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
|
uint8_t k_ausf_o[32];
|
|
|
|
|
|
|
|
|
|
uint8_t ck[] = {0x56, 0x1e, 0x05, 0xef, 0xbd, 0xf2, 0xef, 0xeb, 0x2d, 0x55, 0x8f, 0x04, 0x1c, 0x53, 0xc4, 0x45};
|
|
|
|
|
uint8_t ik[] = {0x01, 0xe0, 0xf2, 0xf5, 0x53, 0x54, 0x31, 0x31, 0x2d, 0x57, 0x27, 0x98, 0x14, 0xcf, 0xcd, 0x89};
|
|
|
|
|
uint8_t ak_xor_sqn[] = {0x30, 0x5e, 0xb0, 0x6b, 0x73, 0x07};
|
|
|
|
|
std::string ssn = "5G:mnc070.mcc901.3gppnetwork.org";
|
|
|
|
|
|
|
|
|
|
TESTASSERT(srsran::security_generate_k_ausf(ck, ik, ak_xor_sqn, ssn.c_str(), k_ausf_o) == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
uint8_t k_ausf[] = {0xa2, 0xce, 0xb2, 0x0f, 0x79, 0x28, 0xbf, 0x15, 0x4d, 0x4b, 0x54, 0x8a, 0xee, 0x6d, 0x10, 0xa9,
|
|
|
|
|
0x76, 0x01, 0x84, 0x7f, 0xd7, 0x2d, 0x2b, 0xc9, 0x01, 0x98, 0x2c, 0x08, 0x6e, 0xa0, 0xf3, 0x46};
|
|
|
|
|
// TODO check the out put with k AMF
|
|
|
|
|
logger.info(k_ausf_o, 32, "K AUSF:");
|
|
|
|
|
TESTASSERT(arrcmp(k_ausf_o, k_ausf, sizeof(k_ausf)) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_generate_k_seaf()
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
|
uint8_t k_seaf_o[32];
|
|
|
|
|
|
|
|
|
|
uint8_t k_ausf[] = {0xd9, 0xc8, 0xff, 0x91, 0xb6, 0x9e, 0x25, 0x0e, 0x25, 0x6e, 0x92, 0x46, 0x6a, 0xcf, 0x80, 0xa1,
|
|
|
|
|
0xd8, 0x2b, 0x65, 0xf0, 0x94, 0xb7, 0xc0, 0x71, 0x19, 0x9c, 0x03, 0x12, 0xe0, 0x67, 0xff, 0x3b};
|
|
|
|
|
std::string ssn = "5G:mnc070.mcc901.3gppnetwork.org";
|
|
|
|
|
|
|
|
|
|
TESTASSERT(srsran::security_generate_k_seaf(k_ausf, ssn.c_str(), k_seaf_o) == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
uint8_t k_seaf[] = {0x6c, 0x50, 0xbf, 0xa5, 0xf3, 0x2a, 0x89, 0xad, 0xe1, 0xee, 0x6c, 0x70, 0x7d, 0xe6, 0xdc, 0xfe,
|
|
|
|
|
0xa0, 0x79, 0x0a, 0xfb, 0x6d, 0x14, 0xf9, 0xe5, 0x59, 0x43, 0xae, 0xda, 0x58, 0x33, 0x45, 0x48};
|
|
|
|
|
|
|
|
|
|
logger.info(k_seaf_o, 32, "K SEAF:");
|
|
|
|
|
TESTASSERT(arrcmp(k_seaf_o, k_seaf, sizeof(k_seaf)) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_generate_k_amf()
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
|
uint8_t k_amf_o[32];
|
|
|
|
|
|
|
|
|
|
uint8_t k_seaf[] = {0x6c, 0x50, 0xbf, 0xa5, 0xf3, 0x2a, 0x89, 0xad, 0xe1, 0xee, 0x6c, 0x70, 0x7d, 0xe6, 0xdc, 0xfe,
|
|
|
|
|
0xa0, 0x79, 0x0a, 0xfb, 0x6d, 0x14, 0xf9, 0xe5, 0x59, 0x43, 0xae, 0xda, 0x58, 0x33, 0x45, 0x48};
|
|
|
|
|
|
|
|
|
|
uint8_t abba[] = {0x00, 0x00};
|
|
|
|
|
std::string supi = "901700000021309";
|
|
|
|
|
|
|
|
|
|
TESTASSERT(srsran::security_generate_k_amf(k_seaf, supi.c_str(), abba, sizeof(abba), k_amf_o) == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
uint8_t k_amf[] = {0x46, 0x23, 0x7e, 0xf0, 0x51, 0xd6, 0xa1, 0x6a, 0x39, 0x27, 0x52, 0x5f, 0xa6, 0x5c, 0xc3, 0x95,
|
|
|
|
|
0x44, 0xcd, 0xfd, 0x79, 0x90, 0xb9, 0x46, 0xad, 0x79, 0x65, 0x30, 0xe6, 0xd7, 0x87, 0xa0, 0xda};
|
|
|
|
|
|
|
|
|
|
logger.info(k_amf_o, 32, "K AMF:");
|
|
|
|
|
TESTASSERT(arrcmp(k_amf_o, k_amf, sizeof(k_amf)) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_generate_k_amf_2()
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
|
uint8_t k_amf_o[32];
|
|
|
|
|
|
|
|
|
|
uint8_t k_seaf[] = {0x30, 0x2a, 0xb7, 0xc9, 0x4f, 0xae, 0x97, 0xe0, 0x43, 0xb3, 0x70, 0xd3, 0xeb, 0x1f, 0x54, 0x68,
|
|
|
|
|
0xf6, 0xa1, 0xd4, 0x55, 0xd6, 0x56, 0xa4, 0xca, 0xb3, 0x51, 0xea, 0xcf, 0xb9, 0xf7, 0xe1, 0x36};
|
|
|
|
|
|
|
|
|
|
uint8_t abba[] = {0x00, 0x00};
|
|
|
|
|
std::string supi = "001010123456780";
|
|
|
|
|
|
|
|
|
|
TESTASSERT(srsran::security_generate_k_amf(k_seaf, supi.c_str(), abba, sizeof(abba), k_amf_o) == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
uint8_t k_amf[] = {0x8f, 0x2a, 0x5d, 0x6c, 0x12, 0x60, 0x8d, 0x8a, 0x0a, 0x8d, 0x33, 0x0a, 0x71, 0x9d, 0xee, 0x07,
|
|
|
|
|
0x22, 0x6b, 0x47, 0x41, 0x7b, 0x66, 0x1a, 0xf5, 0x84, 0x90, 0xea, 0xb0, 0x7a, 0xa4, 0x37, 0xa4};
|
|
|
|
|
|
|
|
|
|
logger.info(k_amf_o, 32, "K AMF:");
|
|
|
|
|
TESTASSERT(arrcmp(k_amf_o, k_amf, sizeof(k_amf)) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_generate_nas_5g()
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
|
uint8_t k_nas_int_o[32];
|
|
|
|
|
uint8_t k_nas_enc_o[32];
|
|
|
|
|
|
|
|
|
|
uint8_t k_amf[] = {0x7d, 0x86, 0x18, 0x52, 0xb4, 0x2a, 0x86, 0xb5, 0x96, 0xfe, 0x22, 0xc8, 0xf5, 0x0b, 0x9b, 0x89,
|
|
|
|
|
0x5a, 0x1e, 0x21, 0x71, 0x6b, 0x61, 0xb8, 0xd1, 0x22, 0x78, 0x5e, 0x25, 0xba, 0xfc, 0x0d, 0x07};
|
|
|
|
|
|
|
|
|
|
TESTASSERT(srsran::security_generate_k_nas_5g(k_amf,
|
|
|
|
|
srsran::CIPHERING_ALGORITHM_ID_ENUM::CIPHERING_ALGORITHM_ID_EEA0,
|
|
|
|
|
srsran::INTEGRITY_ALGORITHM_ID_ENUM::INTEGRITY_ALGORITHM_ID_128_EIA2,
|
|
|
|
|
k_nas_enc_o,
|
|
|
|
|
k_nas_int_o) == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
uint8_t k_nas_enc[] = {0x83, 0x85, 0x6a, 0x01, 0x81, 0x59, 0x55, 0x21, 0xc9, 0xd3, 0x2a,
|
|
|
|
|
0x19, 0x3f, 0x59, 0xc8, 0xa8, 0xfc, 0x7e, 0x99, 0xb9, 0x8b, 0x8c,
|
|
|
|
|
0x04, 0x20, 0x1f, 0x4f, 0x9d, 0x81, 0x43, 0x3b, 0x6b, 0x38};
|
|
|
|
|
uint8_t k_nas_int[] = {0x25, 0xc5, 0x8e, 0x27, 0xe7, 0xd2, 0xc4, 0x95, 0xf3, 0xd7, 0x35,
|
|
|
|
|
0x29, 0x3a, 0x82, 0xbf, 0xfa, 0xa5, 0x3e, 0xe8, 0x84, 0xb9, 0x8d,
|
|
|
|
|
0x36, 0x6b, 0x02, 0x89, 0x23, 0x1e, 0xc4, 0x19, 0x1e, 0xd3};
|
|
|
|
|
|
|
|
|
|
logger.info(k_nas_enc_o, 32, "k_nas_enc_o:");
|
|
|
|
|
TESTASSERT(arrcmp(k_nas_enc_o, k_nas_enc, sizeof(k_nas_enc)) == 0);
|
|
|
|
|
logger.info(k_nas_int_o, 32, "k_nas_int_o:");
|
|
|
|
|
TESTASSERT(arrcmp(k_nas_int_o, k_nas_int, sizeof(k_nas_int)) == 0);
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
auto& logger = srslog::fetch_basic_logger("LOG", false);
|
|
|
|
@ -321,6 +435,11 @@ int main(int argc, char** argv)
|
|
|
|
|
TESTASSERT(test_generate_k_nh() == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(test_generate_res_star() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_generate_k_ausf() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_generate_k_seaf() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_generate_k_amf() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_generate_k_amf_2() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_generate_nas_5g() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_set_ksg() == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(test_set_nr_rrc_up() == SRSRAN_SUCCESS);
|
|
|
|
|
|
|
|
|
|