From: Arran Cudbard-Bell Date: Mon, 29 Apr 2019 22:41:18 +0000 (-0400) Subject: Set vector source, and record ki/opc if we're acting as an AuC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b220eb70d9816ad0ebebfe8fa3bb239bdc7a2f34;p=thirdparty%2Ffreeradius-server.git Set vector source, and record ki/opc if we're acting as an AuC --- diff --git a/src/lib/sim/vector.c b/src/lib/sim/vector.c index 4fd93d5f454..5855618368b 100644 --- a/src/lib/sim/vector.c +++ b/src/lib/sim/vector.c @@ -94,7 +94,7 @@ static int vector_gsm_from_ki(eap_session_t *eap_session, VALUE_PAIR *vps, int i } /* - * Check to see if have a Ki for the IMSI, this allows us to generate the rest + * Check to see if we have a Ki for the IMSI, this allows us to generate the rest * of the triplets. */ version_vp = fr_pair_find_by_da(vps, attr_sim_algo_version, TAG_ANY); @@ -153,12 +153,20 @@ static int vector_gsm_from_ki(eap_session_t *eap_session, VALUE_PAIR *vps, int i RPEDEBUG2("Failed deriving GSM triplet"); return -1; } - return 0; + break; default: REDEBUG("Unknown/unsupported algorithm %i", version); return -1; } + + /* + * Store for completeness... + */ + memcpy(keys->auc.ki, ki_vp->vp_octets, sizeof(keys->auc.ki)); + memcpy(keys->auc.opc, opc_p, sizeof(keys->auc.opc)); + keys->vector_src = SIM_VECTOR_SRC_KI; + return 0; } @@ -215,6 +223,7 @@ static int vector_gsm_from_triplets(eap_session_t *eap_session, VALUE_PAIR *vps, memcpy(keys->gsm.vector[idx].kc, kc->vp_strvalue, SIM_VECTOR_GSM_KC_SIZE); memcpy(keys->gsm.vector[idx].rand, rand->vp_octets, SIM_VECTOR_GSM_RAND_SIZE); memcpy(keys->gsm.vector[idx].sres, sres->vp_octets, SIM_VECTOR_GSM_SRES_SIZE); + keys->vector_src = SIM_VECTOR_SRC_TRIPLETS; return 0; } @@ -295,6 +304,8 @@ static int vector_gsm_from_quintuplets(eap_session_t *eap_session, VALUE_PAIR *v ck->vp_octets, xres->vp_octets); + keys->vector_src = SIM_VECTOR_SRC_QUINTUPLETS; + return 0; } @@ -471,8 +482,15 @@ static int vector_umts_from_ki(REQUEST *request, VALUE_PAIR *vps, fr_sim_keys_t RPEDEBUG2("Failed deriving UMTS Quintuplet"); return -1; } - keys->umts.vector.xres_len = 8; + + /* + * Store the keys we used for possible AUTS + * validation later. + */ + memcpy(keys->auc.ki, ki_vp->vp_octets, sizeof(keys->auc.ki)); + memcpy(keys->auc.opc, opc_p, sizeof(keys->auc.opc)); + keys->vector_src = SIM_VECTOR_SRC_KI; } return 0; @@ -634,6 +652,8 @@ static int vector_umts_from_quintuplets(REQUEST *request, VALUE_PAIR *vps, fr_si memcpy(keys->umts.vector.xres, xres_vp->vp_octets, xres_vp->vp_length); keys->umts.vector.xres_len = xres_vp->vp_length; /* xres is variable length */ + keys->vector_src = SIM_VECTOR_SRC_QUINTUPLETS; + return 0; }