Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG UE
Commits
8230f94f
Commit
8230f94f
authored
Jul 13, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE/EMM: move _authentication_data to nas_user_t
parent
c56d7c9b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
93 additions
and
77 deletions
+93
-77
openair3/NAS/UE/EMM/Authentication.c
openair3/NAS/UE/EMM/Authentication.c
+55
-73
openair3/NAS/UE/EMM/Authentication.h
openair3/NAS/UE/EMM/Authentication.h
+23
-0
openair3/NAS/UE/EMM/SAP/EmmDeregistered.c
openair3/NAS/UE/EMM/SAP/EmmDeregistered.c
+1
-1
openair3/NAS/UE/EMM/SAP/EmmNull.c
openair3/NAS/UE/EMM/SAP/EmmNull.c
+1
-1
openair3/NAS/UE/EMM/SecurityModeControl.c
openair3/NAS/UE/EMM/SecurityModeControl.c
+1
-1
openair3/NAS/UE/EMM/emmData.h
openair3/NAS/UE/EMM/emmData.h
+1
-0
openair3/NAS/UE/EMM/emm_proc.h
openair3/NAS/UE/EMM/emm_proc.h
+1
-1
openair3/NAS/UE/nas_proc.c
openair3/NAS/UE/nas_proc.c
+5
-0
openair3/NAS/UE/user_defs.h
openair3/NAS/UE/user_defs.h
+5
-0
No files found.
openair3/NAS/UE/EMM/Authentication.c
View file @
8230f94f
...
@@ -65,6 +65,7 @@ Description Defines the authentication EMM procedure executed by the
...
@@ -65,6 +65,7 @@ Description Defines the authentication EMM procedure executed by the
#include "usim_api.h"
#include "usim_api.h"
#include "secu_defs.h"
#include "secu_defs.h"
#include "Authentication.h"
/****************************************************************************/
/****************************************************************************/
...
@@ -97,25 +98,6 @@ static void *_authentication_t3416_handler(void *);
...
@@ -97,25 +98,6 @@ static void *_authentication_t3416_handler(void *);
static
void
*
_authentication_t3418_handler
(
void
*
);
static
void
*
_authentication_t3418_handler
(
void
*
);
static
void
*
_authentication_t3420_handler
(
void
*
);
static
void
*
_authentication_t3420_handler
(
void
*
);
/*
* Internal data used for authentication procedure
*/
static
struct
{
uint8_t
rand
[
AUTH_RAND_SIZE
];
/* Random challenge number */
uint8_t
res
[
AUTH_RES_SIZE
];
/* Authentication response */
uint8_t
ck
[
AUTH_CK_SIZE
];
/* Ciphering key */
uint8_t
ik
[
AUTH_IK_SIZE
];
/* Integrity key */
#define AUTHENTICATION_T3410 0x01
#define AUTHENTICATION_T3417 0x02
#define AUTHENTICATION_T3421 0x04
#define AUTHENTICATION_T3430 0x08
unsigned
char
timers
;
/* Timer restart bitmap */
#define AUTHENTICATION_COUNTER_MAX 3
unsigned
char
mac_count
:
2
;
/* MAC failure counter (#20) */
unsigned
char
umts_count
:
2
;
/* UMTS challenge failure counter (#26) */
unsigned
char
sync_count
:
2
;
/* Sync failure counter (#21) */
}
_authentication_data
;
/*
/*
* Abnormal case authentication procedure
* Abnormal case authentication procedure
*/
*/
...
@@ -123,8 +105,8 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -123,8 +105,8 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
const
OctetString
*
auts
);
const
OctetString
*
auts
);
static
int
_authentication_abnormal_case_f
(
nas_user_t
*
user
);
static
int
_authentication_abnormal_case_f
(
nas_user_t
*
user
);
static
int
_authentication_stop_timers
(
void
);
static
int
_authentication_stop_timers
(
nas_user_t
*
user
);
static
int
_authentication_start_timers
(
void
);
static
int
_authentication_start_timers
(
nas_user_t
*
user
);
static
int
_authentication_kasme
(
const
OctetString
*
autn
,
static
int
_authentication_kasme
(
const
OctetString
*
autn
,
const
OctetString
*
ck
,
const
OctetString
*
ik
,
const
plmn_t
*
plmn
,
const
OctetString
*
ck
,
const
OctetString
*
ik
,
const
plmn_t
*
plmn
,
OctetString
*
kasme
);
OctetString
*
kasme
);
...
@@ -163,11 +145,9 @@ static int _authentication_kasme(const OctetString *autn,
...
@@ -163,11 +145,9 @@ static int _authentication_kasme(const OctetString *autn,
** ksi: The NAS ket sey identifier **
** ksi: The NAS ket sey identifier **
** rand: Authentication parameter RAND **
** rand: Authentication parameter RAND **
** autn: Authentication parameter AUTN **
** autn: Authentication parameter AUTN **
** Others: user->emm_data-> _authentication_data **
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: user->emm_data-> _authentication_data, T3416, **
** T3418, T3420 **
** T3418, T3420 **
** **
** **
***************************************************************************/
***************************************************************************/
...
@@ -178,6 +158,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -178,6 +158,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
LOG_FUNC_IN
;
LOG_FUNC_IN
;
int
rc
=
RETURNerror
;
int
rc
=
RETURNerror
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
INFO
,
"EMM-PROC - Authentication requested ksi type = %s, ksi = %d"
,
native_ksi
?
"native"
:
"mapped"
,
ksi
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Authentication requested ksi type = %s, ksi = %d"
,
native_ksi
?
"native"
:
"mapped"
,
ksi
);
...
@@ -203,11 +184,11 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -203,11 +184,11 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
}
}
/* Setup security keys */
/* Setup security keys */
OctetString
ck
=
{
AUTH_CK_SIZE
,
_authentication_data
.
ck
};
OctetString
ck
=
{
AUTH_CK_SIZE
,
authentication_data
->
ck
};
OctetString
ik
=
{
AUTH_IK_SIZE
,
_authentication_data
.
ik
};
OctetString
ik
=
{
AUTH_IK_SIZE
,
authentication_data
->
ik
};
OctetString
res
=
{
AUTH_RES_SIZE
,
_authentication_data
.
res
};
OctetString
res
=
{
AUTH_RES_SIZE
,
authentication_data
->
res
};
if
(
memcmp
(
_authentication_data
.
rand
,
rand
->
value
,
AUTH_CK_SIZE
)
!=
0
)
{
if
(
memcmp
(
authentication_data
->
rand
,
rand
->
value
,
AUTH_CK_SIZE
)
!=
0
)
{
/*
/*
* There is no valid stored RAND in the ME or the stored RAND is
* There is no valid stored RAND in the ME or the stored RAND is
* different from the new received value in the AUTHENTICATION
* different from the new received value in the AUTHENTICATION
...
@@ -254,7 +235,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -254,7 +235,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
(
sbit
==
0
)
?
"Non-EPS authentication unacceptable"
:
(
sbit
==
0
)
?
"Non-EPS authentication unacceptable"
:
"MAC code failure"
);
"MAC code failure"
);
/* Delete any previously stored RAND and RES and stop timer T3416 */
/* Delete any previously stored RAND and RES and stop timer T3416 */
(
void
)
emm_proc_authentication_delete
(
);
emm_proc_authentication_delete
(
user
);
/* Proceed authentication abnormal cases procedure */
/* Proceed authentication abnormal cases procedure */
if
(
auts
.
length
>
0
)
{
if
(
auts
.
length
>
0
)
{
...
@@ -284,7 +265,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -284,7 +265,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
/* Store the new RAND in the volatile memory */
/* Store the new RAND in the volatile memory */
if
(
rand
->
length
<=
AUTH_RAND_SIZE
)
{
if
(
rand
->
length
<=
AUTH_RAND_SIZE
)
{
memcpy
(
_authentication_data
.
rand
,
rand
->
value
,
rand
->
length
);
memcpy
(
authentication_data
->
rand
,
rand
->
value
,
rand
->
length
);
}
}
/* Start, or reset and restart timer T3416 */
/* Start, or reset and restart timer T3416 */
...
@@ -304,7 +285,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -304,7 +285,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
* the authenticity of the core network
* the authenticity of the core network
*/
*/
/* Start any retransmission timers */
/* Start any retransmission timers */
rc
=
_authentication_start_timers
();
rc
=
_authentication_start_timers
(
user
);
if
(
rc
!=
RETURNok
)
{
if
(
rc
!=
RETURNok
)
{
LOG_TRACE
(
WARNING
,
"EMM-PROC - Failed to start retransmission timers"
);
LOG_TRACE
(
WARNING
,
"EMM-PROC - Failed to start retransmission timers"
);
...
@@ -339,9 +320,9 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -339,9 +320,9 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
if
(
rc
!=
RETURNerror
)
{
if
(
rc
!=
RETURNerror
)
{
/* Reset the authentication failure counters */
/* Reset the authentication failure counters */
_authentication_data
.
mac_count
=
0
;
authentication_data
->
mac_count
=
0
;
_authentication_data
.
umts_count
=
0
;
authentication_data
->
umts_count
=
0
;
_authentication_data
.
sync_count
=
0
;
authentication_data
->
sync_count
=
0
;
/* Create non-current EPS security context */
/* Create non-current EPS security context */
if
(
user
->
emm_data
->
non_current
==
NULL
)
{
if
(
user
->
emm_data
->
non_current
==
NULL
)
{
...
@@ -392,7 +373,6 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
...
@@ -392,7 +373,6 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: user->emm_data-> _authentication_data, T3410, **
** T3417, T3430 **
** T3417, T3430 **
** **
** **
***************************************************************************/
***************************************************************************/
...
@@ -402,11 +382,12 @@ int emm_proc_authentication_reject(nas_user_t *user)
...
@@ -402,11 +382,12 @@ int emm_proc_authentication_reject(nas_user_t *user)
emm_sap_t
emm_sap
;
emm_sap_t
emm_sap
;
int
rc
;
int
rc
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
WARNING
,
"EMM-PROC - Authentication not accepted by the network"
);
LOG_TRACE
(
WARNING
,
"EMM-PROC - Authentication not accepted by the network"
);
/* Delete any previously stored RAND and RES and stop timer T3416 */
/* Delete any previously stored RAND and RES and stop timer T3416 */
(
void
)
emm_proc_authentication_delete
();
(
void
)
emm_proc_authentication_delete
(
user
);
/* Set the EPS update status to EU3 ROAMING NOT ALLOWED */
/* Set the EPS update status to EU3 ROAMING NOT ALLOWED */
user
->
emm_data
->
status
=
EU3_ROAMING_NOT_ALLOWED
;
user
->
emm_data
->
status
=
EU3_ROAMING_NOT_ALLOWED
;
...
@@ -445,7 +426,7 @@ int emm_proc_authentication_reject(nas_user_t *user)
...
@@ -445,7 +426,7 @@ int emm_proc_authentication_reject(nas_user_t *user)
/* Abort any EMM signalling procedure (prevent the retransmission timers to
/* Abort any EMM signalling procedure (prevent the retransmission timers to
* be restarted) */
* be restarted) */
_authentication_data
.
timers
=
0x00
;
authentication_data
->
timers
=
0x00
;
/*
/*
* Notify EMM that authentication is not accepted by the network
* Notify EMM that authentication is not accepted by the network
...
@@ -475,12 +456,12 @@ int emm_proc_authentication_reject(nas_user_t *user)
...
@@ -475,12 +456,12 @@ int emm_proc_authentication_reject(nas_user_t *user)
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: _authentication_data, T3416 **
** **
** **
***************************************************************************/
***************************************************************************/
int
emm_proc_authentication_delete
(
void
)
int
emm_proc_authentication_delete
(
nas_user_t
*
user
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
INFO
,
"EMM-PROC - Delete authentication data RAND and RES"
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Delete authentication data RAND and RES"
);
...
@@ -491,8 +472,8 @@ int emm_proc_authentication_delete(void)
...
@@ -491,8 +472,8 @@ int emm_proc_authentication_delete(void)
}
}
/* Delete any previously stored RAND and RES */
/* Delete any previously stored RAND and RES */
memset
(
_authentication_data
.
rand
,
0
,
AUTH_RAND_SIZE
);
memset
(
authentication_data
->
rand
,
0
,
AUTH_RAND_SIZE
);
memset
(
_authentication_data
.
res
,
0
,
AUTH_RES_SIZE
);
memset
(
authentication_data
->
res
,
0
,
AUTH_RES_SIZE
);
LOG_FUNC_RETURN
(
RETURNok
);
LOG_FUNC_RETURN
(
RETURNok
);
}
}
...
@@ -529,13 +510,14 @@ int emm_proc_authentication_delete(void)
...
@@ -529,13 +510,14 @@ int emm_proc_authentication_delete(void)
static
void
*
_authentication_t3416_handler
(
void
*
args
)
static
void
*
_authentication_t3416_handler
(
void
*
args
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
nas_user_t
*
user
=
args
;
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3416 timer expired"
);
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3416 timer expired"
);
/* Stop timer T3416 */
/* Stop timer T3416 */
T3416
.
id
=
nas_timer_stop
(
T3416
.
id
);
T3416
.
id
=
nas_timer_stop
(
T3416
.
id
);
/* Delete previouly stored RAND and RES authentication data */
/* Delete previouly stored RAND and RES authentication data */
(
void
)
emm_proc_authentication_delete
();
(
void
)
emm_proc_authentication_delete
(
user
);
LOG_FUNC_RETURN
(
NULL
);
LOG_FUNC_RETURN
(
NULL
);
}
}
...
@@ -556,23 +538,23 @@ static void *_authentication_t3416_handler(void *args)
...
@@ -556,23 +538,23 @@ static void *_authentication_t3416_handler(void *args)
** **
** **
** Outputs: None **
** Outputs: None **
** Return: None **
** Return: None **
** Others: _authentication_data, T3418 **
** **
** **
***************************************************************************/
***************************************************************************/
static
void
*
_authentication_t3418_handler
(
void
*
args
)
static
void
*
_authentication_t3418_handler
(
void
*
args
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
nas_user_t
*
user
=
args
;
int
rc
;
int
rc
;
nas_user_t
*
user
=
args
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3418 timer expired"
);
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3418 timer expired"
);
/* Stop timer T3418 */
/* Stop timer T3418 */
T3418
.
id
=
nas_timer_stop
(
T3418
.
id
);
T3418
.
id
=
nas_timer_stop
(
T3418
.
id
);
/* Reset the MAC failure and UMTS challenge failure counters */
/* Reset the MAC failure and UMTS challenge failure counters */
_authentication_data
.
mac_count
=
0
;
authentication_data
->
mac_count
=
0
;
_authentication_data
.
umts_count
=
0
;
authentication_data
->
umts_count
=
0
;
/* 3GPP TS 24.301, section 5.4.2.7, case f */
/* 3GPP TS 24.301, section 5.4.2.7, case f */
rc
=
_authentication_abnormal_case_f
(
user
);
rc
=
_authentication_abnormal_case_f
(
user
);
...
@@ -598,22 +580,22 @@ static void *_authentication_t3418_handler(void *args)
...
@@ -598,22 +580,22 @@ static void *_authentication_t3418_handler(void *args)
** **
** **
** Outputs: None **
** Outputs: None **
** Return: None **
** Return: None **
** Others: _authentication_data, T3420 **
** **
** **
***************************************************************************/
***************************************************************************/
static
void
*
_authentication_t3420_handler
(
void
*
args
)
static
void
*
_authentication_t3420_handler
(
void
*
args
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
nas_user_t
*
user
=
args
;
int
rc
;
int
rc
;
nas_user_t
*
user
=
args
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3420 timer expired"
);
LOG_TRACE
(
WARNING
,
"EMM-PROC - T3420 timer expired"
);
/* Stop timer T3420 */
/* Stop timer T3420 */
T3420
.
id
=
nas_timer_stop
(
T3420
.
id
);
T3420
.
id
=
nas_timer_stop
(
T3420
.
id
);
/* Reset the sync failure counter */
/* Reset the sync failure counter */
_authentication_data
.
sync_count
=
0
;
authentication_data
->
sync_count
=
0
;
/* 3GPP TS 24.301, section 5.4.2.7, case f */
/* 3GPP TS 24.301, section 5.4.2.7, case f */
rc
=
_authentication_abnormal_case_f
(
user
);
rc
=
_authentication_abnormal_case_f
(
user
);
...
@@ -643,7 +625,6 @@ static void *_authentication_t3420_handler(void *args)
...
@@ -643,7 +625,6 @@ static void *_authentication_t3420_handler(void *args)
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: _authentication_data, T3418, T3420 **
** **
** **
***************************************************************************/
***************************************************************************/
static
int
_authentication_abnormal_cases_cde
(
nas_user_t
*
user
,
int
emm_cause
,
static
int
_authentication_abnormal_cases_cde
(
nas_user_t
*
user
,
int
emm_cause
,
...
@@ -652,11 +633,12 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -652,11 +633,12 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
LOG_FUNC_IN
;
LOG_FUNC_IN
;
int
rc
;
int
rc
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
LOG_TRACE
(
WARNING
,
"EMM-PROC - "
LOG_TRACE
(
WARNING
,
"EMM-PROC - "
"Abnormal case, authentication counters c/d/e = %d/%d/%d"
,
"Abnormal case, authentication counters c/d/e = %d/%d/%d"
,
_authentication_data
.
mac_count
,
_authentication_data
.
umts_count
,
authentication_data
->
mac_count
,
authentication_data
->
umts_count
,
_authentication_data
.
sync_count
);
authentication_data
->
sync_count
);
/*
/*
* Notify EMM-AS SAP that Authentication Failure message has to be sent
* Notify EMM-AS SAP that Authentication Failure message has to be sent
...
@@ -682,7 +664,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -682,7 +664,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
case
EMM_CAUSE_MAC_FAILURE
:
case
EMM_CAUSE_MAC_FAILURE
:
/* 3GPP TS 24.301, section 5.4.2.6, case c
/* 3GPP TS 24.301, section 5.4.2.6, case c
* Update the MAC failure counter */
* Update the MAC failure counter */
_authentication_data
.
mac_count
+=
1
;
authentication_data
->
mac_count
+=
1
;
/* Start timer T3418 */
/* Start timer T3418 */
T3418
.
id
=
nas_timer_start
(
T3418
.
sec
,
T3418
.
id
=
nas_timer_start
(
T3418
.
sec
,
_authentication_t3418_handler
,
user
);
_authentication_t3418_handler
,
user
);
...
@@ -693,7 +675,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -693,7 +675,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
case
EMM_CAUSE_NON_EPS_AUTH_UNACCEPTABLE
:
case
EMM_CAUSE_NON_EPS_AUTH_UNACCEPTABLE
:
/* 3GPP TS 24.301, section 5.4.2.6, case d
/* 3GPP TS 24.301, section 5.4.2.6, case d
* Update the UMTS challenge failure counter */
* Update the UMTS challenge failure counter */
_authentication_data
.
umts_count
+=
1
;
authentication_data
->
umts_count
+=
1
;
/* Start timer T3418 */
/* Start timer T3418 */
T3418
.
id
=
nas_timer_start
(
T3418
.
sec
,
T3418
.
id
=
nas_timer_start
(
T3418
.
sec
,
_authentication_t3418_handler
,
user
);
_authentication_t3418_handler
,
user
);
...
@@ -704,7 +686,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -704,7 +686,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
case
EMM_CAUSE_SYNCH_FAILURE
:
case
EMM_CAUSE_SYNCH_FAILURE
:
/* 3GPP TS 24.301, section 5.4.2.6, case e
/* 3GPP TS 24.301, section 5.4.2.6, case e
* Update the synch failure counter */
* Update the synch failure counter */
_authentication_data
.
sync_count
+=
1
;
authentication_data
->
sync_count
+=
1
;
/* Start timer T3420 */
/* Start timer T3420 */
T3420
.
id
=
nas_timer_start
(
T3420
.
sec
,
T3420
.
id
=
nas_timer_start
(
T3420
.
sec
,
_authentication_t3420_handler
,
user
);
_authentication_t3420_handler
,
user
);
...
@@ -721,7 +703,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -721,7 +703,7 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
/*
/*
* Stop any retransmission timers that are running
* Stop any retransmission timers that are running
*/
*/
rc
=
_authentication_stop_timers
();
rc
=
_authentication_stop_timers
(
user
);
if
(
rc
!=
RETURNok
)
{
if
(
rc
!=
RETURNok
)
{
LOG_TRACE
(
WARNING
,
"EMM-PROC - "
LOG_TRACE
(
WARNING
,
"EMM-PROC - "
...
@@ -735,12 +717,12 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
...
@@ -735,12 +717,12 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
int
failure_counter
=
0
;
int
failure_counter
=
0
;
if
(
emm_cause
==
EMM_CAUSE_MAC_FAILURE
)
{
if
(
emm_cause
==
EMM_CAUSE_MAC_FAILURE
)
{
failure_counter
=
_authentication_data
.
mac_count
failure_counter
=
authentication_data
->
mac_count
+
_authentication_data
.
sync_count
;
+
authentication_data
->
sync_count
;
}
else
if
(
emm_cause
==
EMM_CAUSE_SYNCH_FAILURE
)
{
}
else
if
(
emm_cause
==
EMM_CAUSE_SYNCH_FAILURE
)
{
failure_counter
=
_authentication_data
.
mac_count
failure_counter
=
authentication_data
->
mac_count
+
_authentication_data
.
umts_count
+
authentication_data
->
umts_count
+
_authentication_data
.
sync_count
;
+
authentication_data
->
sync_count
;
}
}
if
(
failure_counter
>=
AUTHENTICATION_COUNTER_MAX
)
{
if
(
failure_counter
>=
AUTHENTICATION_COUNTER_MAX
)
{
...
@@ -796,7 +778,7 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
...
@@ -796,7 +778,7 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
* T3430), if they were running and stopped when the UE received
* T3430), if they were running and stopped when the UE received
* the first AUTHENTICATION REQUEST message containing an invalid
* the first AUTHENTICATION REQUEST message containing an invalid
* MAC or SQN */
* MAC or SQN */
rc
=
_authentication_start_timers
();
rc
=
_authentication_start_timers
(
user
);
}
}
LOG_FUNC_RETURN
(
rc
);
LOG_FUNC_RETURN
(
rc
);
...
@@ -820,40 +802,40 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
...
@@ -820,40 +802,40 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: _authentication_data, T3410, T3417, T3421, **
** T3430 **
** T3430 **
** **
** **
***************************************************************************/
***************************************************************************/
static
int
_authentication_stop_timers
(
void
)
static
int
_authentication_stop_timers
(
nas_user_t
*
user
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
/* Stop attach timer */
/* Stop attach timer */
if
(
T3410
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
if
(
T3410
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3410 (%d)"
,
T3410
.
id
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3410 (%d)"
,
T3410
.
id
);
T3410
.
id
=
nas_timer_stop
(
T3410
.
id
);
T3410
.
id
=
nas_timer_stop
(
T3410
.
id
);
_authentication_data
.
timers
|=
AUTHENTICATION_T3410
;
authentication_data
->
timers
|=
AUTHENTICATION_T3410
;
}
}
/* Stop service request timer */
/* Stop service request timer */
if
(
T3417
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
if
(
T3417
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3417 (%d)"
,
T3417
.
id
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3417 (%d)"
,
T3417
.
id
);
T3417
.
id
=
nas_timer_stop
(
T3417
.
id
);
T3417
.
id
=
nas_timer_stop
(
T3417
.
id
);
_authentication_data
.
timers
|=
AUTHENTICATION_T3417
;
authentication_data
->
timers
|=
AUTHENTICATION_T3417
;
}
}
/* Stop detach timer */
/* Stop detach timer */
if
(
T3421
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
if
(
T3421
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3421 (%d)"
,
T3421
.
id
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3421 (%d)"
,
T3421
.
id
);
T3421
.
id
=
nas_timer_stop
(
T3421
.
id
);
T3421
.
id
=
nas_timer_stop
(
T3421
.
id
);
_authentication_data
.
timers
|=
AUTHENTICATION_T3421
;
authentication_data
->
timers
|=
AUTHENTICATION_T3421
;
}
}
/* Stop tracking area update timer */
/* Stop tracking area update timer */
if
(
T3430
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
if
(
T3430
.
id
!=
NAS_TIMER_INACTIVE_ID
)
{
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3430 (%d)"
,
T3430
.
id
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Stop timer T3430 (%d)"
,
T3430
.
id
);
T3430
.
id
=
nas_timer_stop
(
T3430
.
id
);
T3430
.
id
=
nas_timer_stop
(
T3430
.
id
);
_authentication_data
.
timers
|=
AUTHENTICATION_T3430
;
authentication_data
->
timers
|=
AUTHENTICATION_T3430
;
}
}
LOG_FUNC_RETURN
(
RETURNok
);
LOG_FUNC_RETURN
(
RETURNok
);
...
@@ -871,39 +853,39 @@ static int _authentication_stop_timers(void)
...
@@ -871,39 +853,39 @@ static int _authentication_stop_timers(void)
** 3GPP TS 24.301, section 5.4.2.7, case f **
** 3GPP TS 24.301, section 5.4.2.7, case f **
** **
** **
** Inputs: None **
** Inputs: None **
** Others: _authentication_data **
** **
** **
** Outputs: None **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Return: RETURNok, RETURNerror **
** Others: T3410, T3417, T3421, T3430 **
** Others: T3410, T3417, T3421, T3430 **
** **
** **
***************************************************************************/
***************************************************************************/
static
int
_authentication_start_timers
(
void
)
static
int
_authentication_start_timers
(
nas_user_t
*
user
)
{
{
LOG_FUNC_IN
;
LOG_FUNC_IN
;
authentication_data_t
*
authentication_data
=
user
->
authentication_data
;
if
(
_authentication_data
.
timers
&
AUTHENTICATION_T3410
)
{
if
(
authentication_data
->
timers
&
AUTHENTICATION_T3410
)
{
/* Start attach timer */
/* Start attach timer */
T3410
.
id
=
nas_timer_start
(
T3410
.
sec
,
_emm_attach_t3410_handler
,
NULL
);
T3410
.
id
=
nas_timer_start
(
T3410
.
sec
,
_emm_attach_t3410_handler
,
NULL
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3410 (%d) expires in "
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3410 (%d) expires in "
"%ld seconds"
,
T3410
.
id
,
T3410
.
sec
);
"%ld seconds"
,
T3410
.
id
,
T3410
.
sec
);
}
}
if
(
_authentication_data
.
timers
&
AUTHENTICATION_T3417
)
{
if
(
authentication_data
->
timers
&
AUTHENTICATION_T3417
)
{
/* Start service request timer */
/* Start service request timer */
T3417
.
id
=
nas_timer_start
(
T3417
.
sec
,
_emm_service_t3417_handler
,
NULL
);
T3417
.
id
=
nas_timer_start
(
T3417
.
sec
,
_emm_service_t3417_handler
,
NULL
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3417 (%d) expires in "
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3417 (%d) expires in "
"%ld seconds"
,
T3417
.
id
,
T3417
.
sec
);
"%ld seconds"
,
T3417
.
id
,
T3417
.
sec
);
}
}
if
(
_authentication_data
.
timers
&
AUTHENTICATION_T3421
)
{
if
(
authentication_data
->
timers
&
AUTHENTICATION_T3421
)
{
/* Start detach timer */
/* Start detach timer */
T3421
.
id
=
nas_timer_start
(
T3421
.
sec
,
_emm_detach_t3421_handler
,
NULL
);
T3421
.
id
=
nas_timer_start
(
T3421
.
sec
,
_emm_detach_t3421_handler
,
NULL
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3421 (%d) expires in "
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3421 (%d) expires in "
"%ld seconds"
,
T3421
.
id
,
T3421
.
sec
);
"%ld seconds"
,
T3421
.
id
,
T3421
.
sec
);
}
}
if
(
_authentication_data
.
timers
&
AUTHENTICATION_T3430
)
{
if
(
authentication_data
->
timers
&
AUTHENTICATION_T3430
)
{
/* Start tracking area update timer */
/* Start tracking area update timer */
T3430
.
id
=
nas_timer_start
(
T3430
.
sec
,
_emm_tau_t3430_handler
,
NULL
);
T3430
.
id
=
nas_timer_start
(
T3430
.
sec
,
_emm_tau_t3430_handler
,
NULL
);
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3430 (%d) expires in "
LOG_TRACE
(
INFO
,
"EMM-PROC - Timer T3430 (%d) expires in "
...
...
openair3/NAS/UE/EMM/Authentication.h
0 → 100644
View file @
8230f94f
#ifndef _AUTHENTICATION_H
#define _AUTHENTICATION_H
/*
* Internal data used for authentication procedure
*/
typedef
struct
{
uint8_t
rand
[
AUTH_RAND_SIZE
];
/* Random challenge number */
uint8_t
res
[
AUTH_RES_SIZE
];
/* Authentication response */
uint8_t
ck
[
AUTH_CK_SIZE
];
/* Ciphering key */
uint8_t
ik
[
AUTH_IK_SIZE
];
/* Integrity key */
#define AUTHENTICATION_T3410 0x01
#define AUTHENTICATION_T3417 0x02
#define AUTHENTICATION_T3421 0x04
#define AUTHENTICATION_T3430 0x08
unsigned
char
timers
;
/* Timer restart bitmap */
#define AUTHENTICATION_COUNTER_MAX 3
unsigned
char
mac_count
:
2
;
/* MAC failure counter (#20) */
unsigned
char
umts_count
:
2
;
/* UMTS challenge failure counter (#26) */
unsigned
char
sync_count
:
2
;
/* Sync failure counter (#21) */
}
authentication_data_t
;
#endif
openair3/NAS/UE/EMM/SAP/EmmDeregistered.c
View file @
8230f94f
...
@@ -98,7 +98,7 @@ int EmmDeregistered(nas_user_t *user, const emm_reg_t *evt)
...
@@ -98,7 +98,7 @@ int EmmDeregistered(nas_user_t *user, const emm_reg_t *evt)
/* Delete the authentication data RAND and RES */
/* Delete the authentication data RAND and RES */
// FIXME REVIEW
// FIXME REVIEW
rc
=
emm_proc_authentication_delete
();
rc
=
emm_proc_authentication_delete
(
user
);
if
(
rc
!=
RETURNok
)
{
if
(
rc
!=
RETURNok
)
{
LOG_FUNC_RETURN
(
rc
);
LOG_FUNC_RETURN
(
rc
);
...
...
openair3/NAS/UE/EMM/SAP/EmmNull.c
View file @
8230f94f
...
@@ -86,7 +86,7 @@ int EmmNull(nas_user_t *user, const emm_reg_t *evt)
...
@@ -86,7 +86,7 @@ int EmmNull(nas_user_t *user, const emm_reg_t *evt)
assert
(
emm_fsm_get_status
(
user
)
==
EMM_NULL
);
assert
(
emm_fsm_get_status
(
user
)
==
EMM_NULL
);
/* Delete the authentication data RAND and RES */
/* Delete the authentication data RAND and RES */
rc
=
emm_proc_authentication_delete
();
rc
=
emm_proc_authentication_delete
(
user
);
if
(
rc
!=
RETURNok
)
{
if
(
rc
!=
RETURNok
)
{
LOG_FUNC_RETURN
(
rc
);
LOG_FUNC_RETURN
(
rc
);
...
...
openair3/NAS/UE/EMM/SecurityModeControl.c
View file @
8230f94f
...
@@ -158,7 +158,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
...
@@ -158,7 +158,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
ksi
);
ksi
);
/* Delete any previously stored RAND and RES and stop timer T3416 */
/* Delete any previously stored RAND and RES and stop timer T3416 */
(
void
)
emm_proc_authentication_delete
();
(
void
)
emm_proc_authentication_delete
(
user
);
/*
/*
* Check the replayed UE security capabilities
* Check the replayed UE security capabilities
...
...
openair3/NAS/UE/EMM/emmData.h
View file @
8230f94f
...
@@ -352,6 +352,7 @@ typedef struct emm_data_s {
...
@@ -352,6 +352,7 @@ typedef struct emm_data_s {
#define T3430_DEFAULT_VALUE 15
/* 15 seconds */
#define T3430_DEFAULT_VALUE 15
/* 15 seconds */
#define T3440_DEFAULT_VALUE 10
/* 10 seconds */
#define T3440_DEFAULT_VALUE 10
/* 10 seconds */
// FIXME put in another structure
struct
nas_timer_t
T3402
;
/* attach failure timer */
struct
nas_timer_t
T3402
;
/* attach failure timer */
struct
nas_timer_t
T3410
;
/* attach timer */
struct
nas_timer_t
T3410
;
/* attach timer */
struct
nas_timer_t
T3411
;
/* attach restart timer */
struct
nas_timer_t
T3411
;
/* attach restart timer */
...
...
openair3/NAS/UE/EMM/emm_proc.h
View file @
8230f94f
...
@@ -167,7 +167,7 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
...
@@ -167,7 +167,7 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
int
emm_proc_authentication_request
(
nas_user_t
*
user
,
int
native_ksi
,
int
ksi
,
int
emm_proc_authentication_request
(
nas_user_t
*
user
,
int
native_ksi
,
int
ksi
,
const
OctetString
*
rand
,
const
OctetString
*
autn
);
const
OctetString
*
rand
,
const
OctetString
*
autn
);
int
emm_proc_authentication_reject
(
nas_user_t
*
user
);
int
emm_proc_authentication_reject
(
nas_user_t
*
user
);
int
emm_proc_authentication_delete
(
void
);
int
emm_proc_authentication_delete
(
nas_user_t
*
user
);
/*
/*
...
...
openair3/NAS/UE/nas_proc.c
View file @
8230f94f
...
@@ -97,6 +97,11 @@ void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
...
@@ -97,6 +97,11 @@ void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
user
->
proc
.
rsrq
=
NAS_PROC_RSRQ_UNKNOWN
;
user
->
proc
.
rsrq
=
NAS_PROC_RSRQ_UNKNOWN
;
user
->
proc
.
rsrp
=
NAS_PROC_RSRP_UNKNOWN
;
user
->
proc
.
rsrp
=
NAS_PROC_RSRP_UNKNOWN
;
user
->
authentication_data
=
calloc
(
1
,
sizeof
(
authentication_data_t
));
if
(
user
->
authentication_data
==
NULL
)
{
LOG_TRACE
(
ERROR
,
"NAS-PROC - Failed to alloc authentication_data"
);
// FIXME stop here
}
/* Initialize the EMM procedure manager */
/* Initialize the EMM procedure manager */
emm_main_initialize
(
user
,
emm_cb
,
imei
);
emm_main_initialize
(
user
,
emm_cb
,
imei
);
...
...
openair3/NAS/UE/user_defs.h
View file @
8230f94f
...
@@ -50,18 +50,23 @@ Description NAS type definition to manage a user equipment
...
@@ -50,18 +50,23 @@ Description NAS type definition to manage a user equipment
#include "esm_pt_defs.h"
#include "esm_pt_defs.h"
#include "EMM/emm_fsm_defs.h"
#include "EMM/emm_fsm_defs.h"
#include "EMM/emmData.h"
#include "EMM/emmData.h"
#include "EMM/Authentication.h"
#include "EMM/IdleMode_defs.h"
#include "EMM/IdleMode_defs.h"
#include "API/USIM/usim_api.h"
#include "API/USIM/usim_api.h"
typedef
struct
{
typedef
struct
{
int
fd
;
int
fd
;
proc_data_t
proc
;
proc_data_t
proc
;
// Eps Session Management
esm_data_t
*
esm_data
;
// ESM internal data (used within ESM only)
esm_data_t
*
esm_data
;
// ESM internal data (used within ESM only)
esm_pt_data_t
*
esm_pt_data
;
esm_pt_data_t
*
esm_pt_data
;
esm_ebr_data_t
*
esm_ebr_data
;
// EPS bearer contexts
esm_ebr_data_t
*
esm_ebr_data
;
// EPS bearer contexts
// Eps Mobility Management
emm_fsm_state_t
emm_fsm_status
;
// Current EPS Mobility Management status
emm_fsm_state_t
emm_fsm_status
;
// Current EPS Mobility Management status
emm_data_t
*
emm_data
;
// EPS mobility management data
emm_data_t
*
emm_data
;
// EPS mobility management data
emm_plmn_list_t
*
emm_plmn_list
;
// list of PLMN identities
emm_plmn_list_t
*
emm_plmn_list
;
// list of PLMN identities
authentication_data_t
*
authentication_data
;
// Hardware persistent storage
usim_data_t
usim_data
;
// USIM application data
usim_data_t
usim_data
;
// USIM application data
}
nas_user_t
;
}
nas_user_t
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment