From e3d1cff4a332d2bb42ad9360caaf03fc25680817 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 18 Jun 2018 11:29:40 +0100 Subject: [PATCH] Revert "Adding OPc option to security functions." This reverts commit 0eeb70bede2b80a6d8d00fac5d5898132470bd34. --- lib/include/srslte/common/liblte_security.h | 11 ------- lib/include/srslte/common/security.h | 8 ++++- lib/src/common/liblte_security.cc | 4 --- lib/src/common/security.cc | 9 +----- lib/test/common/test_f12345.cc | 36 +++++++++------------ srsue/hdr/upper/usim.h | 1 - srsue/src/upper/usim.cc | 2 -- 7 files changed, 24 insertions(+), 47 deletions(-) diff --git a/lib/include/srslte/common/liblte_security.h b/lib/include/srslte/common/liblte_security.h index 528baae3d..8dc31f341 100644 --- a/lib/include/srslte/common/liblte_security.h +++ b/lib/include/srslte/common/liblte_security.h @@ -122,13 +122,6 @@ typedef enum{ static const char liblte_security_integrity_algorithm_id_text[LIBLTE_SECURITY_INTEGRITY_ALGORITHM_ID_N_ITEMS][20] = {"EIA0", "128-EIA1", "128-EIA2"}; - -typedef enum -{ - AUTH_OP, - AUTH_OPC -}AUTH_OPERATOR_CODE_TYPE; - // Structs // Functions LIBLTE_ERROR_ENUM liblte_security_generate_k_nas(uint8 *k_asme, @@ -285,7 +278,6 @@ LIBLTE_ERROR_ENUM liblte_security_decryption_eea2(uint8 *key, // Structs // Functions LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *sqn, @@ -307,7 +299,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, // Structs // Functions LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *sqn, @@ -329,7 +320,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, // Structs // Functions LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *res, @@ -351,7 +341,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, // Structs // Functions LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *ak); diff --git a/lib/include/srslte/common/security.h b/lib/include/srslte/common/security.h index a8756dc83..4881abd96 100644 --- a/lib/include/srslte/common/security.h +++ b/lib/include/srslte/common/security.h @@ -33,7 +33,7 @@ #include "srslte/common/common.h" -#include "srslte/common/liblte_security.h" + #define SECURITY_DIRECTION_UPLINK 0 #define SECURITY_DIRECTION_DOWNLINK 1 @@ -58,6 +58,12 @@ typedef enum{ static const char integrity_algorithm_id_text[INTEGRITY_ALGORITHM_ID_N_ITEMS][20] = {"EIA0", "128-EIA1", "128-EIA2"}; +typedef enum +{ + AUTH_OP, + AUTH_OPC +} AUTH_OPERATOR_CODE_TYPE; + /****************************************************************************** * Key Generation *****************************************************************************/ diff --git a/lib/src/common/liblte_security.cc b/lib/src/common/liblte_security.cc index 7debff2d5..d8f76bf2c 100644 --- a/lib/src/common/liblte_security.cc +++ b/lib/src/common/liblte_security.cc @@ -1099,7 +1099,6 @@ LIBLTE_ERROR_ENUM liblte_security_decryption_eea2(uint8 *key, Document Reference: 35.206 v10.0.0 Annex 3 *********************************************************************/ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *sqn, @@ -1189,7 +1188,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, Document Reference: 35.206 v10.0.0 Annex 3 *********************************************************************/ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *sqn, @@ -1279,7 +1277,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, Document Reference: 35.206 v10.0.0 Annex 3 *********************************************************************/ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *res, @@ -1394,7 +1391,6 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, Document Reference: 35.206 v10.0.0 Annex 3 *********************************************************************/ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8 *op, uint8 *rand, uint8 *ak) diff --git a/lib/src/common/security.cc b/lib/src/common/security.cc index 73a5e45c6..63cd478c0 100644 --- a/lib/src/common/security.cc +++ b/lib/src/common/security.cc @@ -26,6 +26,7 @@ #include "srslte/common/security.h" +#include "srslte/common/liblte_security.h" #include "srslte/common/snow_3g.h" #ifdef HAVE_MBEDTLS @@ -230,7 +231,6 @@ uint8_t security_128_eea2(uint8_t *key, *****************************************************************************/ uint8_t security_milenage_f1( uint8_t *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8_t *op, uint8_t *rand, uint8_t *sqn, @@ -238,7 +238,6 @@ uint8_t security_milenage_f1( uint8_t *k, uint8_t *mac_a) { return liblte_security_milenage_f1(k, - opc_t, op, rand, sqn, @@ -247,7 +246,6 @@ uint8_t security_milenage_f1( uint8_t *k, } uint8_t security_milenage_f1_star( uint8_t *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8_t *op, uint8_t *rand, uint8_t *sqn, @@ -255,7 +253,6 @@ uint8_t security_milenage_f1_star( uint8_t *k, uint8_t *mac_s) { return liblte_security_milenage_f1_star(k, - opc_t, op, rand, sqn, @@ -264,7 +261,6 @@ uint8_t security_milenage_f1_star( uint8_t *k, } uint8_t security_milenage_f2345( uint8_t *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8_t *op, uint8_t *rand, uint8_t *res, @@ -273,7 +269,6 @@ uint8_t security_milenage_f2345( uint8_t *k, uint8_t *ak) { return liblte_security_milenage_f2345(k, - opc_t, op, rand, res, @@ -283,13 +278,11 @@ uint8_t security_milenage_f2345( uint8_t *k, } uint8_t security_milenage_f5_star( uint8_t *k, - AUTH_OPERATOR_CODE_TYPE opc_t, uint8_t *op, uint8_t *rand, uint8_t *ak) { return liblte_security_milenage_f5_star(k, - opc_t, op, rand, ak); diff --git a/lib/test/common/test_f12345.cc b/lib/test/common/test_f12345.cc index 7a210dd9c..1c5375c43 100644 --- a/lib/test/common/test_f12345.cc +++ b/lib/test/common/test_f12345.cc @@ -49,6 +49,8 @@ void arrprint(uint8_t const * const a, uint32 len) { /* * Functions */ + + void test_set_2() { LIBLTE_ERROR_ENUM err_lte = LIBLTE_ERROR_INVALID_INPUTS; @@ -59,18 +61,17 @@ void test_set_2() uint8_t sqn[] = {0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07}; uint8_t amf[] = {0xb9, 0xb9}; uint8_t op[] = {0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6, 0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18}; - // f1 - uint8_t mac_o[8]; + + uint8_t mac_o[8]; err_lte = liblte_security_milenage_f1(k, - AUTH_OP, op, rand, sqn, amf, mac_o); - assert(err_lte == LIBLTE_SUCCESS); + arrprint(mac_o, sizeof(mac_o)); uint8_t mac_a[] = {0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3}; @@ -79,10 +80,10 @@ void test_set_2() err_cmp = arrcmp(mac_o, mac_a, sizeof(mac_a)); assert(err_cmp == 0); - // f1 star + // f1 star + uint8_t mac_so[8]; err_lte = liblte_security_milenage_f1_star(k, - AUTH_OP, op, rand, sqn, @@ -92,9 +93,9 @@ void test_set_2() assert(err_lte == LIBLTE_SUCCESS); uint8_t mac_s[] = {0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9}; - + arrprint(mac_so, sizeof(mac_so)); - + err_cmp = arrcmp(mac_so, mac_s, sizeof(mac_s)); assert(err_cmp == 0); @@ -105,7 +106,6 @@ void test_set_2() uint8_t ak_o[6]; err_lte = liblte_security_milenage_f2345(k, - AUTH_OP, op, rand, res_o, @@ -126,7 +126,7 @@ void test_set_2() err_cmp = arrcmp(res_o, res, sizeof(res)); assert(err_cmp == 0); - // CK + // CK arrprint(ck_o, sizeof(ck_o)); err_cmp = arrcmp(ck_o, ck, sizeof(ck)); @@ -142,14 +142,10 @@ void test_set_2() err_cmp = arrcmp(ak_o, ak, sizeof(ak)); assert(err_cmp == 0); - // f star + // f star uint8_t ak_star_o[6]; - - err_lte = liblte_security_milenage_f5_star(k, - AUTH_OP, - op, - rand, - ak_star_o); + + err_lte = liblte_security_milenage_f5_star(k, op, rand, ak_star_o); assert(err_lte == LIBLTE_SUCCESS); arrprint(ak_star_o, sizeof(ak_star_o)); @@ -160,12 +156,12 @@ void test_set_2() } /* - Own test sets + Own test sets */ -int main(int argc, char * argv[]) { - test_set_2(); +int main(int argc, char * argv[]) { /* + test_set_2(); test_set_3(); test_set_4(); test_set_5(); diff --git a/srsue/hdr/upper/usim.h b/srsue/hdr/upper/usim.h index b91cc599b..f36ae545f 100644 --- a/srsue/hdr/upper/usim.h +++ b/srsue/hdr/upper/usim.h @@ -109,7 +109,6 @@ private: // User data auth_algo_t auth_algo; uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H - AUTH_OPERATOR_CODE_TYPE opc_t; uint8_t op[16]; uint64_t imsi; uint64_t imei; diff --git a/srsue/src/upper/usim.cc b/srsue/src/upper/usim.cc index 7227633c6..af3cb3fbb 100644 --- a/srsue/src/upper/usim.cc +++ b/srsue/src/upper/usim.cc @@ -341,7 +341,6 @@ auth_result_t usim::gen_auth_res_milenage(uint8_t *rand, // Use RAND and K to compute RES, CK, IK and AK security_milenage_f2345( k, - opc_t, op, rand, res, @@ -364,7 +363,6 @@ auth_result_t usim::gen_auth_res_milenage(uint8_t *rand, // Generate MAC security_milenage_f1( k, - opc_t, op, rand, sqn,