Commit 17d15532 authored by Imad ALAWE's avatar Imad ALAWE Committed by Frédéric Leroy

feat: add conf2uedata tool for generating .*.nvram

This patch adds the conf2uedata tool for generating .ue.nvram* .ue.emm.nvram*
and .usim.nvram* files from a textual configuration file.

The configuration file define most usefull values like plmns, mnc, mcc, msin, K,
OPc for several users.
The files generated will always ends with a number corresponding to the user
entry in the configuration file.

This breaks oai5g because other script have not be updated for using
conf2uedata.
This breaks also the at_nas_ue command.

Examples of configuration files are in openair3/NAS/TOOLS/
parent c4707bd8
...@@ -82,7 +82,7 @@ Options ...@@ -82,7 +82,7 @@ Options
--eNB --eNB
Makes the LTE softmodem Makes the LTE softmodem
--UE --UE
Makes the UE specific parts (ue_ip, usim, nvram) Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
--RRH --RRH
Makes the RRH Makes the RRH
-a | --agent -a | --agent
...@@ -145,6 +145,10 @@ Usage (Regular): ...@@ -145,6 +145,10 @@ Usage (Regular):
function main() { function main() {
local gen_nvram_path=$OPENAIR_DIR/targets/bin
local conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf
until [ -z "$1" ] until [ -z "$1" ]
do do
case "$1" in case "$1" in
...@@ -182,7 +186,16 @@ function main() { ...@@ -182,7 +186,16 @@ function main() {
--UE) --UE)
UE=1 UE=1
echo_info "Will compile UE" echo_info "Will compile UE"
shift;; shift
if test -n "$1"
then
[ -f "$1" ] || echo_fatal "file invalid for --UE"
conf_nvram_path=$(readlink -f "$1")
shift 1
fi;;
--UE-OUTPUT)
gen_nvram_path=$(readlink -f $2)
shift 2;;
--RRH) --RRH)
RRH=1 RRH=1
echo_info "Will compile RRH" echo_info "Will compile RRH"
...@@ -507,20 +520,12 @@ function main() { ...@@ -507,20 +520,12 @@ function main() {
cmake .. cmake ..
compilations \ compilations \
nas_sim_tools usim \ nas_sim_tools conf2uedata \
usim $dbin/usim conf2uedata $dbin/conf2uedata
compilations \
nas_sim_tools nvram \
nvram $dbin/nvram
# generate USIM data # generate USIM data
if [ -f $dbin/nvram ]; then if [ -f $dbin/conf2uedata ]; then
install_nas_tools $dbin $dconf install_nas_tools $conf_nvram_path $gen_nvram_path
echo_info "Copying UE specific part to $DIR/$lte_build_dir/build"
cp -Rvf $dbin/.ue_emm.nvram $DIR/$lte_build_dir/build
cp -Rvf $dbin/.ue.nvram $DIR/$lte_build_dir/build
cp -Rvf $dbin/.usim.nvram $DIR/$lte_build_dir/build
else else
echo_warning "not generated UE NAS files: binaries not found" echo_warning "not generated UE NAS files: binaries not found"
fi fi
...@@ -637,15 +642,12 @@ function main() { ...@@ -637,15 +642,12 @@ function main() {
cd $DIR/nas_sim_tools/build cd $DIR/nas_sim_tools/build
cmake .. cmake ..
compilations \ compilations \
nas_sim_tools usim \ nas_sim_tools conf2uedata \
usim $dbin/usim conf2uedata $dbin/conf2uedata
compilations \
nas_sim_tools nvram \
nvram $dbin/nvram
# generate USIM data # generate USIM data
if [ -f $dbin/nvram ]; then if [ -f $dbin/conf2uedata ]; then
install_nas_tools $dbin $dconf install_nas_tools $conf_nvram_path $gen_nvram_path
else else
echo_warning "not generated UE NAS files: binaries not found" echo_warning "not generated UE NAS files: binaries not found"
fi fi
......
...@@ -2,25 +2,21 @@ cmake_minimum_required(VERSION 2.8) ...@@ -2,25 +2,21 @@ cmake_minimum_required(VERSION 2.8)
project(NAS_SIM_TOOLS) project(NAS_SIM_TOOLS)
include(FindPkgConfig)
pkg_search_module(CONFIG libconfig REQUIRED)
include_directories(${CONFIG_INCLUDE_DIRS})
add_definitions(-std=gnu99)
ENABLE_LANGUAGE(C) ENABLE_LANGUAGE(C)
#Sends the -std=c99 flag to the gcc compiler
add_definitions(-std=c99) set(CMAKE_C_FLAGS
add_definitions(-DNAS_UE) "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -Werror -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat")
set(OPENAIR_DIR $ENV{OPENAIR_DIR}) set(OPENAIR_DIR $ENV{OPENAIR_DIR})
set(OPENAIR1_DIR $ENV{OPENAIR_DIR}/openair1)
set(OPENAIR2_DIR $ENV{OPENAIR_DIR}/openair2)
set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3) set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set(OPENAIR_TARGETS $ENV{OPENAIR_DIR}/targets)
#set(EXECUTABLE_OUTPUT_PATH ${OPENAIR_DIR}/targets/bin)
# Add .h files for dependancies set(conf2uedata_SRC
set(usim_SRC ${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/usim_data.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.c ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c
...@@ -29,8 +25,9 @@ set(usim_SRC ...@@ -29,8 +25,9 @@ set(usim_SRC
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.c ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.c
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
) )
set(usim_HDR
${OPENAIR_DIR}/openair3/NAS/TOOLS/network.h set(conf2uedata_HDR
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.h
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.h ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.h
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.h ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.h ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.h
...@@ -39,37 +36,18 @@ set(usim_HDR ...@@ -39,37 +36,18 @@ set(usim_HDR
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.h ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.h
${OPENAIR_DIR}/common/utils/utils.h ${OPENAIR_DIR}/common/utils/utils.h
) )
include_directories( include_directories(
${OPENAIR_DIR}/common/utils ${OPENAIR_DIR}/common/utils
${OPENAIR_DIR}/openair3/NAS/UE ${OPENAIR_DIR}/openair3/NAS/UE
${OPENAIR_DIR}/openair3/NAS/COMMON ${OPENAIR_DIR}/openair3/NAS/COMMON
${OPENAIR_DIR}/openair3/NAS/UE/API/USER
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM ${OPENAIR_DIR}/openair3/NAS/UE/API/USIM
${OPENAIR_DIR}/openair3/NAS/UE/EMM/ ${OPENAIR_DIR}/openair3/NAS/UE/EMM/
${OPENAIR_DIR}/openair3/NAS/UE/ESM/ ${OPENAIR_DIR}/openair3/NAS/UE/ESM/
${OPENAIR_DIR}/openair3/NAS/COMMON/IES/ ${OPENAIR_DIR}/openair3/NAS/COMMON/IES/
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL ${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL
) )
ADD_EXECUTABLE(usim ${usim_SRC} ${usim_HDR})
set(nvram_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/ue_data.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/nas_log.c
)
set(nvram_HDR
${OPENAIR_DIR}/openair3/NAS/UE/EMM/emmData.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.h
${OPENAIR_DIR}/openair3/NAS/COMMON/userDef.h
)
ADD_EXECUTABLE(nvram ${nvram_SRC} ${nvram_HDR})
#install (TARGETS usim DESTINATION ${EXECUTABLE_OUTPUT_PATH})
#install (TARGETS nvram DESTINATION ${EXECUTABLE_OUTPUT_PATH})
#install(CODE "EXECUTE_PROCESS (COMMAND ${OPENAIR_TARGETS}/bin/nvram --gen WORKING_DIRECTORY ${OPENAIR_TARGETS}/bin)") ADD_EXECUTABLE(conf2uedata ${conf2uedata_SRC} ${conf2uedata_HDR})
#install(CODE "EXECUTE_PROCESS (COMMAND ${OPENAIR_TARGETS}/bin/usim --gen WORKING_DIRECTORY ${OPENAIR_TARGETS}/bin)") target_link_libraries(conf2uedata ${CONFIG_LIBRARIES})
...@@ -450,24 +450,13 @@ install_asn1c_from_source(){ ...@@ -450,24 +450,13 @@ install_asn1c_from_source(){
################################################ ################################################
install_nas_tools() { install_nas_tools() {
cd $1 if [ ! -f $2/§.ue.nvram -o ! -f $2/.usim.nvram ]; then
if [ ! -f .ue.nvram ]; then cd $OPENAIR_DIR/targets/bin
echo_success "generate .ue_emm.nvram .ue.nvram" ./conf2uedata -c $1 -o $2
./nvram --gen echo_success "$1 $2"
else
[ ./nvram -nt .ue.nvram -o ./nvram -nt .ue_emm.nvram ] && ./nvram --gen
fi
if [ ! -f .usim.nvram ]; then
echo_success "generate .usim.nvram"
./usim --gen
else
[ ./usim -nt .usim.nvram ] && ./usim --gen
fi fi
} }
################################ ################################
# set_openair_env # set_openair_env
############################### ###############################
......
...@@ -103,6 +103,30 @@ char* memory_get_path(const char* dirname, const char* filename) ...@@ -103,6 +103,30 @@ char* memory_get_path(const char* dirname, const char* filename)
return data_filename; return data_filename;
} }
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid)
{
/* Get non-volatile data directory */
const char* path = getenv(dirname);
char buffer[2048];
if (path == NULL) {
path = getenv(DEFAULT_NAS_PATH);
}
if (path == NULL) {
LOG_TRACE(WARNING, "MEMORY - %s and %s environment variables are not defined trying local directory", dirname, DEFAULT_NAS_PATH);
path = ".";
}
/* Append non-volatile data file name */
if ( snprintf(buffer, sizeof(buffer), "%s/%s%d", path, filename, ueid) < 0 ) {
return NULL;
}
return strdup(buffer);
}
/**************************************************************************** /****************************************************************************
** ** ** **
** Name: memory_read() ** ** Name: memory_read() **
......
...@@ -58,6 +58,8 @@ Description Memory access utilities ...@@ -58,6 +58,8 @@ Description Memory access utilities
char* memory_get_path(const char* dirname, const char* filename); char* memory_get_path(const char* dirname, const char* filename);
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid);
int memory_read(const char* datafile, void* data, size_t size); int memory_read(const char* datafile, void* data, size_t size);
int memory_write(const char* datafile, const void* data, size_t size); int memory_write(const char* datafile, const void* data, size_t size);
......
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.0 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
export PROCESS = UE
ifndef PROJDIR
PROJDIR = $(PWD)/..
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
include $(PROJDIR)/../Makefile.tools
export LD_RUN_PATH = $(LIBDIR):$(LIBPROCESS)
LIBS = -luenas.a -lrt
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(USIMAPIDIR) -I$(EMMDIR) -I$(ESMDIR) -I$(IESDIR)
#LIBSUTIL = $(LIBDIR)/$(LIBUTIL).a $(LIBDIR)/$(LIBUTIL).so
USIM_OBJ = usim_data.o
UE_OBJ = ue_data.o
USIM_TARGET = usim_data
UE_TARGET = ue_data
TARGETS = $(USIM_TARGET) $(UE_TARGET)
all: $(TARGETS)
#-DIMSI_USA_MNC_3DIGITS
%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(USIM_TARGET): $(USIM_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
$(UE_TARGET): $(UE_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
clean:
$(RM) $(OBJS) *.bak *~
veryclean: clean
$(RM) $(TARGETS)
veryveryclean: veryclean
$(RM) -Rf *.o $(PROJDIR)
$(RM) -Rf *.a $(PROJDIR)
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
This diff is collapsed.
#ifndef _CONF2UEDATA_H
#define _CONF2UEDATA_H
#include <libconfig.h>
#include "emmData.h"
#include "usim_api.h"
#include "userDef.h"
#include "memory.h"
#include "getopt.h"
#define USER "USER"
#define UE "UE"
#define SIM "SIM"
#define PLMN "PLMN"
#define FULLNAME "FULLNAME"
#define SHORTNAME "SHORTNAME"
#define MNC "MNC"
#define MCC "MCC"
#define MSIN "MSIN"
#define USIM_API_K "USIM_API_K"
#define OPC "OPC"
#define MSISDN "MSISDN"
#define UE_IMEI "IMEI"
#define MANUFACTURER "MANUFACTURER"
#define MODEL "MODEL"
#define PINCODE "PIN"
#define HPLMN "HPLMN"
#define UCPLMN "UCPLMN_LIST"
#define OPLMN "OPLMN_LIST"
#define OCPLMN "OCPLMN_LIST"
#define FPLMN "FPLMN_LIST"
#define EHPLMN "EHPLMN_LIST"
#define KSI USIM_KSI_NOT_AVAILABLE
#define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d))
#define PRINT_PLMN(plmn) \
PRINT_PLMN_DIGIT((plmn).MCCdigit1); \
PRINT_PLMN_DIGIT((plmn).MCCdigit2); \
PRINT_PLMN_DIGIT((plmn).MCCdigit3); \
PRINT_PLMN_DIGIT((plmn).MNCdigit1); \
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3)
#define KSI_ASME USIM_KSI_NOT_AVAILABLE
#define INT_ALGO USIM_INT_EIA1
#define ENC_ALGO USIM_ENC_EEA0
#define SECURITY_ALGORITHMS (ENC_ALGO | INT_ALGO)
#define OPC_SIZE 16
#define MIN_TAC 0x0000
#define MAX_TAC 0xFFFE
#define DEFAULT_TMSI 0x0000000D
#define DEFAULT_P_TMSI 0x0000000D
#define DEFAULT_M_TMSI 0x0000000D
#define DEFAULT_LAC 0xFFFE
#define DEFAULT_RAC 0x01
#define DEFAULT_TAC 0x0001
#define DEFAULT_MME_ID 0x0102
#define DEFAULT_MME_CODE 0x0F
#define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d))
#define PRINT_PLMN(plmn) \
PRINT_PLMN_DIGIT((plmn).MCCdigit1); \
PRINT_PLMN_DIGIT((plmn).MCCdigit2); \
PRINT_PLMN_DIGIT((plmn).MCCdigit3); \
PRINT_PLMN_DIGIT((plmn).MNCdigit1); \
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3)
/*
* PLMN network operator record
*/
typedef struct {
unsigned int num;
plmn_t plmn;
char fullname[NET_FORMAT_LONG_SIZE + 1];
char shortname[NET_FORMAT_SHORT_SIZE + 1];
tac_t tac_start;
tac_t tac_end;
} network_record_t;
typedef struct {
const char* fullname;
const char* shortname;
const char* mnc;
const char* mcc;
} plmn_conf_param_t;
const char options[]="c:o:h";
unsigned char parse_data=FALSE;
unsigned char print_data=FALSE;
unsigned char output=FALSE;
const char* conf_file = NULL;
const char* output_dir = NULL;
const char* imsi=NULL;
const char* msin=NULL;
const char* usim_api_k = NULL;
const char* msisdn = NULL;
const char* opc=NULL;
const char* hplmn=NULL;
int* ucplmn=NULL;
int* oplmn=NULL;
int* ocplmn=NULL;
int* fplmn=NULL;
int* ehplmn=NULL;
int hplmn_index =0;
int plmn_nb = 0;
int ucplmn_nb=0;
int oplmn_nb=0;
int ocplmn_nb=0;
int fplmn_nb=0;
int ehplmn_nb=0;
plmn_conf_param_t* user_plmn_list=NULL;
network_record_t* user_network_record_list = NULL;
void _display_usim_data(int user_id);
void _display_usage(void);
void gen_emm_data(int user_id) ;
void gen_usim_data(int user_id);
void fill_network_record_list(void);
int _luhn(const char* cc);
void _display_ue_data(int user_id);
void _display_emm_data(int user_id);
int parse_ue_user_param(config_setting_t *ue_setting, int user_id);
int parse_ue_sim_param(config_setting_t *ue_setting, int user_id);
int parse_plmn_param(config_setting_t *plmn_setting, int index);
int parse_plmns(config_setting_t *all_plmn_setting);
int get_msin_parity(const char * msin);
int get_plmn_index(const char * mccmnc);
int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id);
int fill_ucplmn(config_setting_t* setting, int use_id);
int fill_oplmn(config_setting_t* setting, int use_id);
int fill_ocplmn(config_setting_t* setting, int use_id);
int fill_fplmn(config_setting_t* setting, int use_id);
int fill_ehplmn(config_setting_t* setting, int use_id);
#endif // _CONF2UEDATA_H
This diff is collapsed.
This diff is collapsed.
# List of known PLMNS
PLMN: {
PLMN0: {
FULLNAME="Test network";
SHORTNAME="OAI4G";
MNC="01";
MCC="001";
};
PLMN1: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="10";
MCC="208";
};
PLMN2: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="11";
MCC="208";
};
PLMN3: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="13";
MCC="208";
};
PLMN4: {
FULLNAME="OAI LTEBOX";
SHORTNAME="OAIALU";
MNC="93";
MCC="208";
};
PLMN5: {
FULLNAME="T-Mobile USA";
SHORTNAME="T-Mobile";
MNC="280";
MCC="310";
};
PLMN6: {
FULLNAME="FICTITIOUS USA";
SHORTNAME="FICTITIO";
MNC="028";
MCC="310";
};
PLMN7: {
FULLNAME="Vodafone Italia";
SHORTNAME="VODAFONE";
MNC="10";
MCC="222";
};
PLMN8: {
FULLNAME="Vodafone Spain";
SHORTNAME="VODAFONE";
MNC="01";
MCC="214";
};
PLMN9: {
FULLNAME="Vodafone Spain";
SHORTNAME="VODAFONE";
MNC="06";
MCC="214";
};
PLMN10: {
FULLNAME="Vodafone Germ";
SHORTNAME="VODAFONE";
MNC="02";
MCC="262";
};
PLMN11: {
FULLNAME="Vodafone Germ";
SHORTNAME="VODAFONE";
MNC="04";
MCC="262";
};
};
UE0:
{
USER: {
IMEI="356113022094149";
MANUFACTURER="EURECOM";
MODEL="LTE Android PC";
PIN="0000";
};
SIM: {
MSIN="0000001234";
USIM_API_K="fec86ba6eb707ed08905757b1bb44b8f";
OPC="00000000000000000000000000000000";
MSISDN="33611123456";
};
# Home PLMN Selector with Access Technology
HPLMN= "20810";
# User controlled PLMN Selector with Access Technology
UCPLMN_LIST = ();
# Operator PLMN List
OPLMN_LIST = ("00101", "20810", "20811", "20813", "310280", "310028");
# Operator controlled PLMN Selector with Access Technology
OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204");
# Forbidden plmns
FPLMN_LIST = ();
# List of Equivalent HPLMNs
EHPLMN_LIST= ("20811", "20813");
};
This diff is collapsed.
...@@ -49,16 +49,14 @@ ...@@ -49,16 +49,14 @@
* *
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2], void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8 mac_a_pP[8], const u8 op[16]) u8 mac_a_pP[8], const u8 op_c[16])
{ {
u8 op_c[16];
u8 temp[16]; u8 temp[16];
u8 in1[16]; u8 in1[16];
u8 out1[16]; u8 out1[16];
u8 rijndaelInput[16]; u8 rijndaelInput[16];
u8 i; u8 i;
RijndaelKeySchedule( k_pP ); RijndaelKeySchedule( k_pP );
ComputeOPc(op, op_c);
for (i=0; i<16; i++) for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i]; rijndaelInput[i] = rand_pP[i] ^ op_c[i];
...@@ -104,9 +102,8 @@ void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2], ...@@ -104,9 +102,8 @@ void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
* *
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
void f2345 ( u8 k_pP[16], u8 rand_pP[16], void f2345 ( u8 k_pP[16], u8 rand_pP[16],
u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6],const u8 op[16]) u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6],const u8 op_c[16])
{ {
u8 op_c[16];
u8 temp[16]; u8 temp[16];
u8 out[16]; u8 out[16];
u8 rijndaelInput[16]; u8 rijndaelInput[16];
...@@ -122,7 +119,6 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16], ...@@ -122,7 +119,6 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
rand_pP[8],rand_pP[9],rand_pP[10],rand_pP[11],rand_pP[12],rand_pP[13],rand_pP[14],rand_pP[15]); rand_pP[8],rand_pP[9],rand_pP[10],rand_pP[11],rand_pP[12],rand_pP[13],rand_pP[14],rand_pP[15]);
RijndaelKeySchedule( k_pP ); RijndaelKeySchedule( k_pP );
ComputeOPc(op, op_c);
for (i=0; i<16; i++) for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i]; rijndaelInput[i] = rand_pP[i] ^ op_c[i];
...@@ -205,16 +201,14 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16], ...@@ -205,16 +201,14 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
* *
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2], void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8 mac_s_pP[8],const u8 op[16]) u8 mac_s_pP[8],const u8 op_c[16])
{ {
u8 op_c[16];
u8 temp[16]; u8 temp[16];
u8 in1[16]; u8 in1[16];
u8 out1[16]; u8 out1[16];
u8 rijndaelInput[16]; u8 rijndaelInput[16];
u8 i; u8 i;
RijndaelKeySchedule( k_pP ); RijndaelKeySchedule( k_pP );
ComputeOPc(op, op_c);
for (i=0; i<16; i++) for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i]; rijndaelInput[i] = rand_pP[i] ^ op_c[i];
...@@ -260,15 +254,13 @@ void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2], ...@@ -260,15 +254,13 @@ void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
* *
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
void f5star( u8 k_pP[16], u8 rand_pP[16], void f5star( u8 k_pP[16], u8 rand_pP[16],
u8 ak_pP[6], const u8 op[16]) u8 ak_pP[6], const u8 op_c[16])
{ {
u8 op_c[16];
u8 temp[16]; u8 temp[16];
u8 out[16]; u8 out[16];
u8 rijndaelInput[16]; u8 rijndaelInput[16];
u8 i; u8 i;
RijndaelKeySchedule( k_pP ); RijndaelKeySchedule( k_pP );
ComputeOPc(op, op_c);
for (i=0; i<16; i++) for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i]; rijndaelInput[i] = rand_pP[i] ^ op_c[i];
......
...@@ -88,22 +88,6 @@ int usim_api_read(const char *filename, usim_data_t* data) ...@@ -88,22 +88,6 @@ int usim_api_read(const char *filename, usim_data_t* data)
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* initialize the subscriber authentication security key */
hex_string_to_hex_value(data->keys.usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE);
// initialize OP
/* PFT OP used currently in HSS (OPENAIRHSS/auc/kdf.c) */
#define OAI_LTEBOX
#ifdef OAI_LTEBOX
u8 _op[16] = {0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 };
#else
u8 _op[16] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
#endif
memcpy(data->keys.op, _op, sizeof(_op));
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -367,7 +351,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co ...@@ -367,7 +351,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
u8 ak[USIM_API_AK_SIZE]; u8 ak[USIM_API_AK_SIZE];
f2345(usim_data->keys.usim_api_k, rand_pP->value, f2345(usim_data->keys.usim_api_k, rand_pP->value,
res_pP->value, ck_pP->value, ik_pP->value, ak, usim_data->keys.op); res_pP->value, ck_pP->value, ik_pP->value, ak, usim_data->keys.opc);
LOG_TRACE(INFO, "USIM-API - res(f2) :%s",dump_octet_string(res_pP)); LOG_TRACE(INFO, "USIM-API - res(f2) :%s",dump_octet_string(res_pP));
LOG_TRACE(INFO, "USIM-API - ck(f3) :%s",dump_octet_string(ck_pP)); LOG_TRACE(INFO, "USIM-API - ck(f3) :%s",dump_octet_string(ck_pP));
LOG_TRACE(INFO, "USIM-API - ik(f4) :%s",dump_octet_string(ik_pP)); LOG_TRACE(INFO, "USIM-API - ik(f4) :%s",dump_octet_string(ik_pP));
...@@ -388,7 +372,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co ...@@ -388,7 +372,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
/* Compute XMAC = f1K (SQN || RAND || AMF) */ /* Compute XMAC = f1K (SQN || RAND || AMF) */
#define USIM_API_XMAC_SIZE 8 #define USIM_API_XMAC_SIZE 8
u8 xmac[USIM_API_XMAC_SIZE]; u8 xmac[USIM_API_XMAC_SIZE];
f1(usim_data->keys.usim_api_k, rand_pP->value, sqn, &autn_pP->value[USIM_API_SQN_SIZE], xmac, usim_data->keys.op); f1(usim_data->keys.usim_api_k, rand_pP->value, sqn, &autn_pP->value[USIM_API_SQN_SIZE], xmac, usim_data->keys.opc);
LOG_TRACE(DEBUG, LOG_TRACE(DEBUG,
"USIM-API - Computed XMAC %02X%02X%02X%02X%02X%02X%02X%02X", "USIM-API - Computed XMAC %02X%02X%02X%02X%02X%02X%02X%02X",
xmac[0],xmac[1],xmac[2],xmac[3], xmac[0],xmac[1],xmac[2],xmac[3],
...@@ -416,7 +400,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co ...@@ -416,7 +400,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
/* Concealed value of the counter SQNms in the USIM: /* Concealed value of the counter SQNms in the USIM:
* Conc(SQNMS) = SQNMS ⊕ f5*K(RAND) */ * Conc(SQNMS) = SQNMS ⊕ f5*K(RAND) */
f5star(usim_data->keys.usim_api_k, rand_pP->value, ak, usim_data->keys.op); f5star(usim_data->keys.usim_api_k, rand_pP->value, ak, usim_data->keys.opc);
u8 sqn_ms[USIM_API_SQNMS_SIZE]; u8 sqn_ms[USIM_API_SQNMS_SIZE];
...@@ -445,7 +429,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co ...@@ -445,7 +429,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
#define USIM_API_MACS_SIZE USIM_API_XMAC_SIZE #define USIM_API_MACS_SIZE USIM_API_XMAC_SIZE
u8 macs[USIM_API_MACS_SIZE]; u8 macs[USIM_API_MACS_SIZE];
f1star(usim_data->keys.usim_api_k, rand_pP->value, sqn_ms, f1star(usim_data->keys.usim_api_k, rand_pP->value, sqn_ms,
&rand_pP->value[USIM_API_SQN_SIZE], macs, usim_data->keys.op); &rand_pP->value[USIM_API_SQN_SIZE], macs, usim_data->keys.opc);
LOG_TRACE(DEBUG, "USIM-API - MACS %02X%02X%02X%02X%02X%02X%02X%02X", LOG_TRACE(DEBUG, "USIM-API - MACS %02X%02X%02X%02X%02X%02X%02X%02X",
macs[0],macs[1],macs[2],macs[3], macs[0],macs[1],macs[2],macs[3],
macs[4],macs[5],macs[6],macs[7]); macs[4],macs[5],macs[6],macs[7]);
......
...@@ -124,7 +124,7 @@ typedef struct { ...@@ -124,7 +124,7 @@ typedef struct {
#define USIM_IK_SIZE 16 #define USIM_IK_SIZE 16
Byte_t ik[USIM_IK_SIZE]; Byte_t ik[USIM_IK_SIZE];
uint8_t usim_api_k[USIM_API_K_SIZE]; uint8_t usim_api_k[USIM_API_K_SIZE];
uint8_t op[16]; uint8_t opc[16];
} usim_keys_t; } usim_keys_t;
/* /*
......
...@@ -104,21 +104,21 @@ void *nas_ue_task(void *args_p) ...@@ -104,21 +104,21 @@ void *nas_ue_task(void *args_p)
user->ueid=i; user->ueid=i;
/* Get USIM data application filename */ /* Get USIM data application filename */
user->usim_data_store = memory_get_path(USIM_API_NVRAM_DIRNAME, USIM_API_NVRAM_FILENAME); user->usim_data_store = memory_get_path_from_ueid(USIM_API_NVRAM_DIRNAME, USIM_API_NVRAM_FILENAME, user->ueid);
if ( user->usim_data_store == NULL ) { if ( user->usim_data_store == NULL ) {
LOG_E(NAS, "[UE %d] - Failed to get USIM data application filename", user->ueid); LOG_E(NAS, "[UE %d] - Failed to get USIM data application filename", user->ueid, user->ueid);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Get UE's data pathname */ /* Get UE's data pathname */
user->user_nvdata_store = memory_get_path(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME); user->user_nvdata_store = memory_get_path_from_ueid(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME, user->ueid);
if ( user->user_nvdata_store == NULL ) { if ( user->user_nvdata_store == NULL ) {
LOG_E(NAS, "[UE %d] - Failed to get USIM nvdata filename", user->ueid); LOG_E(NAS, "[UE %d] - Failed to get USIM nvdata filename", user->ueid);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Get EMM data pathname */ /* Get EMM data pathname */
user->emm_nvdata_store = memory_get_path(EMM_NVRAM_DIRNAME, EMM_NVRAM_FILENAME); user->emm_nvdata_store = memory_get_path_from_ueid(EMM_NVRAM_DIRNAME, EMM_NVRAM_FILENAME, user->ueid);
if ( user->emm_nvdata_store == NULL ) { if ( user->emm_nvdata_store == NULL ) {
LOG_E(NAS, "[UE %d] - Failed to get EMM nvdata filename", user->ueid); LOG_E(NAS, "[UE %d] - Failed to get EMM nvdata filename", user->ueid);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
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