Added a conversion function for USIM K parameter.
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4904 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -53,12 +53,14 @@ Description Implements the API used by the NAS layer to read/write
|
|||||||
*/
|
*/
|
||||||
#define USIM_API_K_SIZE 16
|
#define USIM_API_K_SIZE 16
|
||||||
#define USIM_API_K_VALUE "8BAF473F2F8FD09487CCCBD7097C6862"
|
#define USIM_API_K_VALUE "8BAF473F2F8FD09487CCCBD7097C6862"
|
||||||
|
|
||||||
static UInt8_t _usim_api_k[USIM_API_K_SIZE];
|
static UInt8_t _usim_api_k[USIM_API_K_SIZE];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of last used Sequence Numbers SQN
|
* List of last used Sequence Numbers SQN
|
||||||
*/
|
*/
|
||||||
static struct {
|
static struct _usim_api_data_s {
|
||||||
/* Highest sequence number the USIM has ever accepted */
|
/* Highest sequence number the USIM has ever accepted */
|
||||||
UInt32_t sqn_ms;
|
UInt32_t sqn_ms;
|
||||||
/* List of the last used sequence numbers */
|
/* List of the last used sequence numbers */
|
||||||
@@ -67,6 +69,8 @@ static struct {
|
|||||||
UInt32_t sqn[USIM_API_SQN_LIST_SIZE];
|
UInt32_t sqn[USIM_API_SQN_LIST_SIZE];
|
||||||
} _usim_api_data;
|
} _usim_api_data;
|
||||||
|
|
||||||
|
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);
|
static int _usim_api_check_sqn(UInt32_t seq, UInt8_t ind);
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@@ -108,7 +112,7 @@ int usim_api_read(usim_data_t* data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the subscriber authentication security key */
|
/* initialize the subscriber authentication security key */
|
||||||
memcpy(_usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE);
|
_usim_api_hex_string_to_hex_value(_usim_api_k, USIM_API_K_VALUE, USIM_API_K_SIZE);
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
LOG_FUNC_RETURN (RETURNok);
|
LOG_FUNC_RETURN (RETURNok);
|
||||||
@@ -176,9 +180,9 @@ int usim_api_write(const usim_data_t* data)
|
|||||||
** **
|
** **
|
||||||
** Outputs: auts: Re-synchronization token **
|
** Outputs: auts: Re-synchronization token **
|
||||||
** res: Authentication response **
|
** res: Authentication response **
|
||||||
** ck: Cipherig key **
|
** ck: Ciphering key **
|
||||||
** ik: Integrity key **
|
** ik Integrity key **
|
||||||
**
|
** **
|
||||||
** Return: RETURNerror, RETURNok **
|
** Return: RETURNerror, RETURNok **
|
||||||
** Others: None **
|
** Others: None **
|
||||||
** **
|
** **
|
||||||
@@ -265,6 +269,61 @@ int usim_api_authenticate(const OctetString* rand, const OctetString* autn,
|
|||||||
/********************* L O C A L F U N C T I O N S *********************/
|
/********************* 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() **
|
** Name: _usim_api_check_sqn() **
|
||||||
|
|||||||
Reference in New Issue
Block a user