Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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-RAN
Commits
45fccb02
Commit
45fccb02
authored
Jul 26, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE/API/USIM: move hex functions to common/utils.c
parent
9af35991
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
54 deletions
+63
-54
cmake_targets/nas_sim_tools/CMakeLists.txt
cmake_targets/nas_sim_tools/CMakeLists.txt
+4
-0
common/utils/utils.c
common/utils/utils.c
+51
-0
common/utils/utils.h
common/utils/utils.h
+6
-0
openair3/NAS/UE/API/USIM/usim_api.c
openair3/NAS/UE/API/USIM/usim_api.c
+2
-54
No files found.
cmake_targets/nas_sim_tools/CMakeLists.txt
View file @
45fccb02
...
...
@@ -27,6 +27,7 @@ set(usim_SRC
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/nas_log.c
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/OctetString.c
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/TLVEncoder.c
${
OPENAIR_DIR
}
/common/utils/utils.c
)
set
(
usim_HDR
${
OPENAIR_DIR
}
/openair3/NAS/TOOLS/network.h
...
...
@@ -36,8 +37,11 @@ set(usim_HDR
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/nas_log.h
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/OctetString.h
${
OPENAIR_DIR
}
/openair3/NAS/COMMON/UTIL/TLVEncoder.h
${
OPENAIR_DIR
}
/common/utils/utils.h
)
include_directories
(
${
OPENAIR_DIR
}
/common/utils
${
OPENAIR_DIR
}
/openair3/NAS/UE
${
OPENAIR_DIR
}
/openair3/NAS/COMMON
${
OPENAIR_DIR
}
/openair3/NAS/UE/API/USIM
${
OPENAIR_DIR
}
/openair3/NAS/UE/EMM/
...
...
common/utils/utils.c
View file @
45fccb02
...
...
@@ -21,3 +21,54 @@ void *malloc_or_fail(size_t size) {
}
return
ptr
;
}
/****************************************************************************
** **
** Name: hex_char_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded digit into its value. **
** **
** Inputs: c: A char holding the ASCII coded value **
** Others: None **
** **
** Outputs: None **
** Return: Converted value **
** Others: None **
** **
***************************************************************************/
uint8_t
hex_char_to_hex_value
(
char
c
)
{
if
(
c
>=
'A'
)
{
/* Remove case bit */
c
&=
~
(
'a'
^
'A'
);
return
(
c
-
'A'
+
10
);
}
else
{
return
(
c
-
'0'
);
}
}
/****************************************************************************
** **
** Name: hex_string_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded string into its value.**
** **
** Inputs: hex_value: A pointer to the location to store the **
** conversion result **
** size: The size of hex_value in bytes **
** Others: None **
** **
** Outputs: hex_value: Converted value **
** Return: None **
** Others: None **
** **
***************************************************************************/
void
hex_string_to_hex_value
(
uint8_t
*
hex_value
,
const
char
*
hex_string
,
int
size
)
{
int
i
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
hex_value
[
i
]
=
(
hex_char_to_hex_value
(
hex_string
[
2
*
i
])
<<
4
)
|
hex_char_to_hex_value
(
hex_string
[
2
*
i
+
1
]);
}
}
common/utils/utils.h
View file @
45fccb02
#ifndef _UTILS_H
#define _UTILS_H
#include <stdint.h>
#include <sys/types.h>
void
*
calloc_or_fail
(
size_t
size
);
void
*
malloc_or_fail
(
size_t
size
);
// Converts an hexadecimal ASCII coded digit into its value. **
uint8_t
hex_char_to_hex_value
(
char
c
);
// Converts an hexadecimal ASCII coded string into its value.**
void
hex_string_to_hex_value
(
uint8_t
*
hex_value
,
const
char
*
hex_string
,
int
size
);
#endif
openair3/NAS/UE/API/USIM/usim_api.c
View file @
45fccb02
...
...
@@ -41,6 +41,7 @@ Description Implements the API used by the NAS layer to read/write
#include "usim_api.h"
#include "nas_log.h"
#include "utils.h"
#include "memory.h"
#include <stdio.h>
#include "aka_functions.h"
...
...
@@ -66,8 +67,6 @@ Description Implements the API used by the NAS layer to read/write
*/
#define USIM_API_NVRAM_DIRNAME "USIM_DIR"
static
uint8_t
_usim_api_hex_char_to_hex_value
(
char
c
);
static
void
_usim_api_hex_string_to_hex_value
(
uint8_t
*
hex_value
,
const
char
*
hex_string
,
int
size
);
static
int
_usim_api_check_sqn
(
uint32_t
seq
,
uint8_t
ind
);
/****************************************************************************/
...
...
@@ -110,7 +109,7 @@ int usim_api_read(usim_data_t* data)
}
/* initialize the subscriber authentication security key */
_usim_api_
hex_string_to_hex_value
(
data
->
keys
.
usim_api_k
,
USIM_API_K_VALUE
,
USIM_API_K_SIZE
);
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) */
...
...
@@ -497,57 +496,6 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/****************************************************************************
** **
** Name: _usim_api_hex_char_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded digit into its value. **
** **
** Inputs: c: A char holding the ASCII coded value **
** Others: None **
** **
** Outputs: None **
** Return: Converted value **
** Others: None **
** **
***************************************************************************/
static
uint8_t
_usim_api_hex_char_to_hex_value
(
char
c
)
{
if
(
c
>=
'A'
)
{
/* Remove case bit */
c
&=
~
(
'a'
^
'A'
);
return
(
c
-
'A'
+
10
);
}
else
{
return
(
c
-
'0'
);
}
}
/****************************************************************************
** **
** Name: _usim_api_hex_string_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded string into its value.**
** **
** Inputs: hex_value: A pointer to the location to store the **
** conversion result **
** size: The size of hex_value in bytes **
** Others: None **
** **
** Outputs: hex_value: Converted value **
** Return: None **
** Others: None **
** **
***************************************************************************/
static
void
_usim_api_hex_string_to_hex_value
(
uint8_t
*
hex_value
,
const
char
*
hex_string
,
int
size
)
{
int
i
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
hex_value
[
i
]
=
(
_usim_api_hex_char_to_hex_value
(
hex_string
[
2
*
i
])
<<
4
)
|
_usim_api_hex_char_to_hex_value
(
hex_string
[
2
*
i
+
1
]);
}
}
/****************************************************************************
** **
** Name: _usim_api_check_sqn() **
...
...
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