Commit b130341f authored by liuxu's avatar liuxu

add output parm kasme 230919

parent 65e9a14b
...@@ -1402,14 +1402,15 @@ int nas_stream_encrypt_eia2(nas_stream_cipher_t *stream_cipher, uint8_t out[4]) ...@@ -1402,14 +1402,15 @@ int nas_stream_encrypt_eia2(nas_stream_cipher_t *stream_cipher, uint8_t out[4])
char *KiStr = "00112233445566778899aabbccddeeff"; char *KiStr = "00112233445566778899aabbccddeeff";
int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_int) char *opcStr = "000102030405060708090a0b0c0d0e0f";
int authenticate(u8 *rand, u8 *autn, u8 *res, u8* kasme, u8 *knas_enc, u8 *knas_int)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
int rc; int rc;
int i; int i;
u8 ck[16], ik[16], Ki[16], kasme[32]; u8 ck[16], ik[16], Ki[16], opc[16];
plmn_t *plmn = (plmn_t *)malloc(sizeof(plmn_t)); plmn_t *plmn = (plmn_t *)malloc(sizeof(plmn_t));
...@@ -1431,6 +1432,7 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in ...@@ -1431,6 +1432,7 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in
plmn->MNCdigit1, plmn->MNCdigit2); plmn->MNCdigit1, plmn->MNCdigit2);
to_hex(KiStr, Ki, sizeof(Ki) ); to_hex(KiStr, Ki, sizeof(Ki) );
to_hex(opcStr, opc, sizeof(opc));
/* Compute the authentication response RES = f2K (RAND) */ /* Compute the authentication response RES = f2K (RAND) */
/* Compute the cipher key CK = f3K (RAND) */ /* Compute the cipher key CK = f3K (RAND) */
...@@ -1545,6 +1547,7 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in ...@@ -1545,6 +1547,7 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in
kasme, kasme,
32); 32);
printf("kasme:\n");
for(int i = 0; i < 32; i++) for(int i = 0; i < 32; i++)
printf("%02X ", kasme[i]); printf("%02X ", kasme[i]);
printf("\n"); printf("\n");
...@@ -1647,16 +1650,16 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in ...@@ -1647,16 +1650,16 @@ int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_in
} }
char *imsiStr = "466920000000001";
void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t nmc_size,
void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t *opc, char *imsiStr, uint8_t nmc_size,
uint8_t *xres, uint8_t *kgnb, uint8_t *knas_int) { uint8_t *xres, uint8_t *kgnb, uint8_t *knas_int) {
uint8_t kausf[32], kseaf[32], kamf[32], Ki[16]; uint8_t kausf[32], kseaf[32], kamf[32], Ki[16], opc[16];
uint8_t resTemp[16]; uint8_t resTemp[16];
uint8_t ck[16], ik[16], ak[6]; uint8_t ck[16], ik[16], ak[6];
to_hex(KiStr, Ki, sizeof(Ki) ); to_hex(KiStr, Ki, sizeof(Ki) );
to_hex(opcStr, opc, sizeof(opc));
f2345(Ki, rand, resTemp, ck, ik, ak, opc); f2345(Ki, rand, resTemp, ck, ik, ak, opc);
...@@ -1675,26 +1678,26 @@ void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t *opc, char *imsiStr, ui ...@@ -1675,26 +1678,26 @@ void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t *opc, char *imsiStr, ui
printf("kausf:"); printf("kausf:");
for(int i = 0; i < 32; i++){ for(int i = 0; i < 32; i++){
printf("%x ", kausf[i]); printf("%02x ", kausf[i]);
} }
printf("\n"); printf("\n");
printf("kseaf:"); printf("kseaf:");
for(int i = 0; i < 32; i++){ for(int i = 0; i < 32; i++){
printf("%x ", kseaf[i]); printf("%02x ", kseaf[i]);
} }
printf("\n"); printf("\n");
printf("kamf:"); printf("kamf:");
for(int i = 0; i < 32; i++){ for(int i = 0; i < 32; i++){
printf("%x ", kamf[i]); printf("%02x ", kamf[i]);
} }
printf("\n"); printf("\n");
printf("knas_int:\n"); printf("knas_int:\n");
for(int i = 0; i < 16; i++){ for(int i = 0; i < 16; i++){
printf("%x ", knas_int[i]); printf("%02x ", knas_int[i]);
} }
printf("\n"); printf("\n");
} }
...@@ -58,9 +58,9 @@ int nas_stream_encrypt_eia1(nas_stream_cipher_t *stream_cipher, uint8_t out[4]); ...@@ -58,9 +58,9 @@ int nas_stream_encrypt_eia1(nas_stream_cipher_t *stream_cipher, uint8_t out[4]);
int nas_stream_encrypt_eia2(nas_stream_cipher_t *stream_cipher, uint8_t out[4]); int nas_stream_encrypt_eia2(nas_stream_cipher_t *stream_cipher, uint8_t out[4]);
int authenticate(u8 *rand, u8 *autn, u8 *opc, u8 *res, u8 *knas_enc, u8 *knas_int); int authenticate(u8 *rand, u8 *autn, u8 *res, u8 *kasme, u8 *knas_enc, u8 *knas_int);
void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t *opc, char *imsiStr, uint8_t nmc_size, void nr_authenciate(uint8_t *rand, uint8_t *sqn, uint8_t nmc_size,
uint8_t *xres, uint8_t *kgnb, uint8_t *knas_int); uint8_t *xres, uint8_t *kgnb, uint8_t *knas_int);
#endif #endif
\ No newline at end of file
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
int main(void){ int main(void){
char *randStr, *opStr, *autnStr, *imsiStr, *sqnStr; char *randStr, *autnStr, *sqnStr;
u8 rand[16], op[16], autn[16], res[8], knas_enc[32], knas_int[32], nmc_size; u8 rand[16], autn[16], res[8], kasme[32], knas_enc[16], knas_int[16], nmc_size;
u8 nrknas_int[16], kgnb[32], sqn[6], nr_res[8]; u8 nrknas_int[16], kgnb[32], sqn[6], nr_res[8];
imsiStr = "466920000000001";
randStr = "48d918eaf3c93e26d263063c67f5b82e"; randStr = "48d918eaf3c93e26d263063c67f5b82e";
opStr = "000102030405060708090a0b0c0d0e0f";
autnStr = "45b91d3dd4a590017f8725d4320e9fe8"; autnStr = "45b91d3dd4a590017f8725d4320e9fe8";
sqnStr = "000011132760"; sqnStr = "000011132760";
nmc_size = 2; nmc_size = 2;
...@@ -37,7 +36,7 @@ int main(void){ ...@@ -37,7 +36,7 @@ int main(void){
return -1; return -1;
} }
void (*nr_authenciate)(uint8_t *, uint8_t *, uint8_t *, char *, uint8_t , void (*nr_authenciate)(uint8_t *, uint8_t *, uint8_t ,
uint8_t *, uint8_t *, uint8_t *); uint8_t *, uint8_t *, uint8_t *);
nr_authenciate = dlsym(handle, "nr_authenciate"); nr_authenciate = dlsym(handle, "nr_authenciate");
if(!nr_authenciate){ if(!nr_authenciate){
...@@ -50,14 +49,13 @@ int main(void){ ...@@ -50,14 +49,13 @@ int main(void){
to_hex(sqnStr, sqn, sizeof(sqn)); to_hex(sqnStr, sqn, sizeof(sqn));
to_hex(randStr, rand, sizeof(rand)); to_hex(randStr, rand, sizeof(rand));
to_hex(opStr, op, sizeof(op));
to_hex(autnStr, autn, sizeof(autn)); to_hex(autnStr, autn, sizeof(autn));
if(authenticate(rand, autn, op, res, knas_enc, knas_int) == RETURNok) if(authenticate(rand, autn, res, kasme, knas_enc, knas_int) == RETURNok)
printf("UE LTE authentication succeeded!\n"); printf("UE LTE authentication succeeded!\n");
else else
printf("UE LTE authentication failed!\n"); printf("UE LTE authentication failed!\n");
nr_authenciate(rand, sqn, op, imsiStr, nmc_size, nr_res, kgnb, nrknas_int); nr_authenciate(rand, sqn, nmc_size, nr_res, kgnb, nrknas_int);
return 0; return 0;
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment