Identity response encoding

This commit is contained in:
Laurent
2020-08-18 14:07:56 +02:00
parent 5729f15363
commit 59964b0f84
9 changed files with 204 additions and 25 deletions
+24 -4
View File
@@ -66,7 +66,7 @@ typedef enum {
} Security_header_t;
typedef enum {
SUCI=0,
SUCI=1,
SGGUTI,
IMEI,
SGSTMSI,
@@ -221,14 +221,33 @@ typedef struct {
} Identityrequest_t;
// the message continues with the identity value, depending on identity type, see TS 14.501, 9.11.3.4
typedef struct {
typedef struct __attribute__((packed)) {
Extendedprotocoldiscriminator_t epd:8;
Security_header_t sh:8;
SGSmobilitymanagementmessages_t mt:8;
identitytype_t mi:8;
uint16_t len;
} Identityresponse_t;
typedef struct __attribute__((packed)) {
Identityresponse_t common;
identitytype_t mi:8;
int supiFormat:4;
int identityType:4;
int mcc1:4;
int mcc2:4;
int mcc3:4;
int mnc3:4;
int mnc2:4;
int mnc1:4;
int routing1:4;
int routing2:4;
int routing3:4;
int routing4:4;
int protectScheme:4;
int spare:4;
uint8_t hplmnId;
} IdentityresponseIMSI_t;
typedef struct {
Extendedprotocoldiscriminator_t epd:8;
Security_header_t sh:8;
@@ -244,4 +263,5 @@ typedef struct {
SGSmobilitymanagementmessages_t mt:8;
} authenticationresponseHeader_t;
//AUTHENTICATION RESULT
+5 -1
View File
@@ -1,3 +1,7 @@
typedef struct {
#include <openair3/UICC/usim_interface.h>
typedef struct {
uicc_t * uicc;
} nr_user_nas_t;
int identityResponse(void **msg, nr_user_nas_t *UE);
+61 -12
View File
@@ -1,17 +1,25 @@
#include <openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h>
#include <openair3/NAS/NR_UE/nr_user_def.h>
void SGSabortNet(void *msg, nr_user_nas_t *UE) {
}
void nas_schedule(void) {
}
/*
*Message reception
*/
void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) {
Identityrequest_t *idmsg=(Identityrequest_t *) msg;
if (idmsg->it == SUCI ) {
LOG_I(NAS,"Received Identity request, scheduling answer\n");
nas_schedule();
} else
LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it);
}
void SGSidentityReq(void *msg, nr_user_nas_t *UE) {
@@ -28,16 +36,17 @@ void UEprocessNAS(void *msg,nr_user_nas_t *UE) {
SGSabortNet(msg, UE);
else {
switch (header->epd) {
SGSmobilitymanagementmessages:
case SGSmobilitymanagementmessages:
switch (header->mt) {
Authenticationrequest:
case Authenticationrequest:
SGSauthenticationReq(msg, UE);
break;
Identityrequest:
case Identityrequest:
SGSidentityReq(msg, UE);
break;
Securitymodecommand:
case Securitymodecommand:
SGSsecurityModeCommand(msg, UE);
break;
@@ -46,7 +55,8 @@ Securitymodecommand:
}
break;
SGSsessionmanagementmessages:
case SGSsessionmanagementmessages:
SGSabortNet(msg, UE);
break;
@@ -60,14 +70,53 @@ SGSsessionmanagementmessages:
* Messages emission
*/
void identityResponse(void *msg, nr_user_nas_t *UE) {
int identityResponse(void **msg, nr_user_nas_t *UE) {
if (UE->uicc == NULL)
// config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE
UE->uicc=init_uicc("uicc");
// TS 24.501 9.11.3.4
int imsiL=strlen(UE->uicc->imsi);
int msinL=imsiL-3-UE->uicc->nmc_size;
int respSize=sizeof(IdentityresponseIMSI_t) + (msinL+1)/2;
IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *) calloc(respSize,1);
resp->common.epd=SGSmobilitymanagementmessages;
resp->common.sh=0;
resp->common.mt=Identityresponse;
resp->common.len=htons(respSize-sizeof(Identityresponse_t));
resp->mi=SUCI;
resp->mcc1=UE->uicc->imsi[0]-'0';
resp->mcc2=UE->uicc->imsi[1]-'0';
resp->mcc3=UE->uicc->imsi[2]-'0';
resp->mnc1=UE->uicc->imsi[3]-'0';
resp->mnc2=UE->uicc->imsi[4]-'0';
resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsi[3]-'0';
// TBD: routing to fill (FF ?)
char *out=(char *)(resp+1);
char *ptr=UE->uicc->imsi + 3 + UE->uicc->nmc_size;
while ( ptr < UE->uicc->imsi+strlen(UE->uicc->imsi) ) {
*out=((*(ptr+1)-'0')<<4) | (*(ptr) -'0');
out++;
ptr+=2;
}
if (msinL%2 == 1)
*out=((*(ptr-1)-'0')) | 0xF0;
*msg=resp;
log_dump(NAS, resp, respSize, LOG_DUMP_CHAR, "\n");
return respSize;
}
void authenticationResponse(void *msg,nr_user_nas_t *UE) {
int authenticationResponse(void **msg,nr_user_nas_t *UE) {
return -1;
}
void securityModeComplete(void *msg, nr_user_nas_t *UE) {
int securityModeComplete(void **msg, nr_user_nas_t *UE) {
return -1;
}
void registrationComplete(void *msg, nr_user_nas_t *UE) {
int registrationComplete(void **msg, nr_user_nas_t *UE) {
return -1;
}
+3 -3
View File
@@ -74,11 +74,11 @@ SGSsessionmanagementmessages:
* Messages emission
*/
void identityRequest(void *msg, NRUEcontext_t *UE) {
int identityRequest(void **msg, NRUEcontext_t *UE) {
}
void authenticationRequest(void *msg, NRUEcontext_t *UE) {
int authenticationRequest(void **msg, NRUEcontext_t *UE) {
}
void securityModeCommand(void *msg, NRUEcontext_t *UE) {
int securityModeCommand(void **msg, NRUEcontext_t *UE) {
}
+50
View File
@@ -0,0 +1,50 @@
/*
* 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.1 (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
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* 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
*/
#include <openair3/UICC/usim_interface.h>
#define UICC_SECTION "uicc"
#define UICC_CONFIG_HELP_OPTIONS " list of comma separated options to interface a simulated (real UICC to be developped). Available options: \n"\
" imsi: user imsi\n"\
" key: cyphering key\n"\
" opc: cyphering OPc\n"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* configuration parameters for the rfsimulator device */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define UICC_PARAMS_DESC {\
{"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsi), defstrval:"", TYPE_STRING, 0 },\
{"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\
{"key", "USIM Ki\n", 0, strptr:&(uicc->key), defstrval:"", TYPE_STRING, 0 },\
{"opc", "USIM OPc\n", 0, strptr:&(uicc->opc), defstrval:"", TYPE_STRING, 0 },\
};
uicc_t *init_uicc(char *sectionName) {
uicc_t *uicc=(uicc_t *)calloc(sizeof(uicc_t),1);
paramdef_t uicc_params[] = UICC_PARAMS_DESC;
int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName);
AssertFatal(ret >= 0, "configuration couldn't be performed");
LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsi, uicc->key, uicc->opc);
return uicc;
}
+46
View File
@@ -0,0 +1,46 @@
/*
* 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.1 (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
*
* Author and copyright: Laurent Thomas, open-cells.comopenair3/UICC/usim_interface.h
*
* 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
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>
#include <common/utils/assertions.h>
#include <common/utils/LOG/log.h>
#include <common/utils/load_module_shlib.h>
#include <common/config/config_userapi.h>
#include "common_lib.h"
typedef struct {
char *imsi;
char *key;
char *opc;
int nmc_size;
} uicc_t;
/*
* Read the configuration file, section name variable to be able to manage several UICC
*/
uicc_t *init_uicc(char *sectionName);