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
a399448c
Commit
a399448c
authored
Jul 19, 2016
by
Frédéric Leroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE/API/USIM: move OP to usim_keys_t
parent
3e61ac71
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
50 deletions
+38
-50
openair3/NAS/UE/API/USIM/aka_functions.c
openair3/NAS/UE/API/USIM/aka_functions.c
+15
-40
openair3/NAS/UE/API/USIM/aka_functions.h
openair3/NAS/UE/API/USIM/aka_functions.h
+6
-6
openair3/NAS/UE/API/USIM/usim_api.c
openair3/NAS/UE/API/USIM/usim_api.c
+16
-4
openair3/NAS/UE/API/USIM/usim_api.h
openair3/NAS/UE/API/USIM/usim_api.h
+1
-0
No files found.
openair3/NAS/UE/API/USIM/aka_functions.c
View file @
a399448c
...
...
@@ -39,26 +39,6 @@
#include "aka_functions.h"
#include "nas_log.h"
/*--------- Operator Variant Algorithm Configuration Field --------*/
/*------- Insert your value of OP here -------*/
/* PFT OP used currently in HSS (OPENAIRHSS/auc/kdf.c) */
#define OAI_LTEBOX
#ifdef OAI_LTEBOX
//1006020f0a478bf6b699f15c062e42b3
/*u8 OP[16] = {0xb3, 0x42, 0x2e, 0x06, 0x5c, 0xf1, 0x99, 0xb6,
0xf6, 0x8b, 0x47, 0x0a, 0x0f, 0x02, 0x06, 0x10
};*/
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
/*------- Insert your value of OP here -------*/
/*-------------------------------------------------------------------
* Algorithm f1
*-------------------------------------------------------------------
...
...
@@ -69,7 +49,7 @@ u8 OP[16] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
*
*-----------------------------------------------------------------*/
void
f1
(
u8
k_pP
[
16
],
u8
rand_pP
[
16
],
u8
sqn_pP
[
6
],
u8
amf_pP
[
2
],
u8
mac_a_pP
[
8
]
)
u8
mac_a_pP
[
8
]
,
const
u8
op
[
16
]
)
{
u8
op_c
[
16
];
u8
temp
[
16
];
...
...
@@ -78,7 +58,7 @@ void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8
rijndaelInput
[
16
];
u8
i
;
RijndaelKeySchedule
(
k_pP
);
ComputeOPc
(
op_c
);
ComputeOPc
(
op
,
op_c
);
for
(
i
=
0
;
i
<
16
;
i
++
)
rijndaelInput
[
i
]
=
rand_pP
[
i
]
^
op_c
[
i
];
...
...
@@ -124,7 +104,7 @@ 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
],
u8
res_pP
[
8
],
u8
ck_pP
[
16
],
u8
ik_pP
[
16
],
u8
ak_pP
[
6
]
)
u8
res_pP
[
8
],
u8
ck_pP
[
16
],
u8
ik_pP
[
16
],
u8
ak_pP
[
6
]
,
const
u8
op
[
16
]
)
{
u8
op_c
[
16
];
u8
temp
[
16
];
...
...
@@ -142,7 +122,7 @@ 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
]);
RijndaelKeySchedule
(
k_pP
);
ComputeOPc
(
op_c
);
ComputeOPc
(
op
,
op_c
);
for
(
i
=
0
;
i
<
16
;
i
++
)
rijndaelInput
[
i
]
=
rand_pP
[
i
]
^
op_c
[
i
];
...
...
@@ -225,7 +205,7 @@ 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
],
u8
mac_s_pP
[
8
]
)
u8
mac_s_pP
[
8
]
,
const
u8
op
[
16
]
)
{
u8
op_c
[
16
];
u8
temp
[
16
];
...
...
@@ -234,7 +214,7 @@ void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8
rijndaelInput
[
16
];
u8
i
;
RijndaelKeySchedule
(
k_pP
);
ComputeOPc
(
op_c
);
ComputeOPc
(
op
,
op_c
);
for
(
i
=
0
;
i
<
16
;
i
++
)
rijndaelInput
[
i
]
=
rand_pP
[
i
]
^
op_c
[
i
];
...
...
@@ -280,7 +260,7 @@ 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
],
u8
ak_pP
[
6
]
)
u8
ak_pP
[
6
]
,
const
u8
op
[
16
]
)
{
u8
op_c
[
16
];
u8
temp
[
16
];
...
...
@@ -288,7 +268,7 @@ void f5star( u8 k_pP[16], u8 rand_pP[16],
u8
rijndaelInput
[
16
];
u8
i
;
RijndaelKeySchedule
(
k_pP
);
ComputeOPc
(
op_c
);
ComputeOPc
(
op
,
op_c
);
for
(
i
=
0
;
i
<
16
;
i
++
)
rijndaelInput
[
i
]
=
rand_pP
[
i
]
^
op_c
[
i
];
...
...
@@ -316,22 +296,17 @@ void f5star( u8 k_pP[16], u8 rand_pP[16],
* Function to compute OPc from OP and K. Assumes key schedule has
already been performed.
*-----------------------------------------------------------------*/
void
ComputeOPc
(
u8
op_c_pP
[
16
]
)
void
ComputeOPc
(
const
u8
op
[
16
],
u8
op_c_pP
[
16
]
)
{
u8
i
;
LOG_TRACE
(
DEBUG
,
"USIM-API - ComputeOPc :
OP
[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
,
OP
[
0
],
OP
[
1
],
OP
[
2
],
OP
[
3
],
OP
[
4
],
OP
[
5
],
OP
[
6
],
OP
[
7
],
OP
[
8
],
OP
[
9
],
OP
[
10
],
OP
[
11
],
OP
[
12
],
OP
[
13
],
OP
[
14
],
OP
[
15
]);
RijndaelEncrypt
(
OP
,
op_c_pP
);
"USIM-API - ComputeOPc :
op
[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
,
op
[
0
],
op
[
1
],
op
[
2
],
op
[
3
],
op
[
4
],
op
[
5
],
op
[
6
],
op
[
7
],
op
[
8
],
op
[
9
],
op
[
10
],
op
[
11
],
op
[
12
],
op
[
13
],
op
[
14
],
op
[
15
]);
RijndaelEncrypt
(
op
,
op_c_pP
);
for
(
i
=
0
;
i
<
16
;
i
++
)
op_c_pP
[
i
]
^=
OP
[
i
];
LOG_TRACE
(
DEBUG
,
"USIM-API - OPc[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
,
op_c_pP
[
0
],
op_c_pP
[
1
],
op_c_pP
[
2
],
op_c_pP
[
3
],
op_c_pP
[
4
],
op_c_pP
[
5
],
op_c_pP
[
6
],
op_c_pP
[
7
],
op_c_pP
[
8
],
op_c_pP
[
9
],
op_c_pP
[
10
],
op_c_pP
[
11
],
op_c_pP
[
12
],
op_c_pP
[
13
],
op_c_pP
[
14
],
op_c_pP
[
15
]);
op_c_pP
[
i
]
^=
op
[
i
];
return
;
}
/* end of function ComputeOPc */
...
...
@@ -489,7 +464,7 @@ void MixColumn(u8 state[4][4])
* 16-byte output (using round keys already derived from 16-byte
* key).
*-----------------------------------------------------------------*/
void
RijndaelEncrypt
(
u8
input
[
16
],
u8
output
[
16
]
)
void
RijndaelEncrypt
(
const
u8
input
[
16
],
u8
output
[
16
]
)
{
u8
state
[
4
][
4
];
int
i
,
r
;
...
...
openair3/NAS/UE/API/USIM/aka_functions.h
View file @
a399448c
...
...
@@ -23,13 +23,13 @@ typedef unsigned char u8;
/*--------------------------- prototypes --------------------------*/
void
f1
(
u8
k
[
16
],
u8
rand
[
16
],
u8
sqn
[
6
],
u8
amf
[
2
],
u8
mac_a
[
8
]
);
u8
mac_a
[
8
]
,
const
u8
op
[
16
]
);
void
f2345
(
u8
k
[
16
],
u8
rand
[
16
],
u8
res
[
8
],
u8
ck
[
16
],
u8
ik
[
16
],
u8
ak
[
6
]
);
u8
res
[
8
],
u8
ck
[
16
],
u8
ik
[
16
],
u8
ak
[
6
]
,
const
u8
op
[
16
]
);
void
f1star
(
u8
k
[
16
],
u8
rand
[
16
],
u8
sqn
[
6
],
u8
amf
[
2
],
u8
mac_s
[
8
]
);
u8
mac_s
[
8
]
,
const
u8
op
[
16
]
);
void
f5star
(
u8
k
[
16
],
u8
rand
[
16
],
u8
ak
[
6
]
);
void
ComputeOPc
(
u8
op_c
[
16
]
);
u8
ak
[
6
]
,
const
u8
op
[
16
]
);
void
ComputeOPc
(
const
u8
op
[
16
],
u8
op_c_pP
[
16
]
);
void
RijndaelKeySchedule
(
u8
key
[
16
]
);
void
RijndaelEncrypt
(
u8
input
[
16
],
u8
output
[
16
]
);
void
RijndaelEncrypt
(
const
u8
input
[
16
],
u8
output
[
16
]
);
openair3/NAS/UE/API/USIM/usim_api.c
View file @
a399448c
...
...
@@ -112,6 +112,18 @@ 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
);
// 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
));
free
(
path
);
LOG_FUNC_RETURN
(
RETURNok
);
}
...
...
@@ -387,7 +399,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
u8
ak
[
USIM_API_AK_SIZE
];
f2345
(
usim_data
->
keys
.
usim_api_k
,
rand_pP
->
value
,
res_pP
->
value
,
ck_pP
->
value
,
ik_pP
->
value
,
ak
);
res_pP
->
value
,
ck_pP
->
value
,
ik_pP
->
value
,
ak
,
usim_data
->
keys
.
op
);
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 - ik(f4) :%s"
,
dump_octet_string
(
ik_pP
));
...
...
@@ -408,7 +420,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
/* Compute XMAC = f1K (SQN || RAND || AMF) */
#define USIM_API_XMAC_SIZE 8
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
);
f1
(
usim_data
->
keys
.
usim_api_k
,
rand_pP
->
value
,
sqn
,
&
autn_pP
->
value
[
USIM_API_SQN_SIZE
],
xmac
,
usim_data
->
keys
.
op
);
LOG_TRACE
(
DEBUG
,
"USIM-API - Computed XMAC %02X%02X%02X%02X%02X%02X%02X%02X"
,
xmac
[
0
],
xmac
[
1
],
xmac
[
2
],
xmac
[
3
],
...
...
@@ -436,7 +448,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
/* Concealed value of the counter SQNms in the USIM:
* Conc(SQNMS) = SQNMS ⊕ f5*K(RAND) */
f5star
(
usim_data
->
keys
.
usim_api_k
,
rand_pP
->
value
,
ak
);
f5star
(
usim_data
->
keys
.
usim_api_k
,
rand_pP
->
value
,
ak
,
usim_data
->
keys
.
op
);
u8
sqn_ms
[
USIM_API_SQNMS_SIZE
];
...
...
@@ -465,7 +477,7 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co
#define USIM_API_MACS_SIZE USIM_API_XMAC_SIZE
u8
macs
[
USIM_API_MACS_SIZE
];
f1star
(
usim_data
->
keys
.
usim_api_k
,
rand_pP
->
value
,
sqn_ms
,
&
rand_pP
->
value
[
USIM_API_SQN_SIZE
],
macs
);
&
rand_pP
->
value
[
USIM_API_SQN_SIZE
],
macs
,
usim_data
->
keys
.
op
);
LOG_TRACE
(
DEBUG
,
"USIM-API - MACS %02X%02X%02X%02X%02X%02X%02X%02X"
,
macs
[
0
],
macs
[
1
],
macs
[
2
],
macs
[
3
],
macs
[
4
],
macs
[
5
],
macs
[
6
],
macs
[
7
]);
...
...
openair3/NAS/UE/API/USIM/usim_api.h
View file @
a399448c
...
...
@@ -113,6 +113,7 @@ typedef struct {
#define USIM_IK_SIZE 16
Byte_t
ik
[
USIM_IK_SIZE
];
uint8_t
usim_api_k
[
USIM_API_K_SIZE
];
uint8_t
op
[
16
];
}
usim_keys_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